]> _ Git - cubeextranet.git/commitdiff
wait #4554 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 24 Jun 2021 15:34:42 +0000 (15:34 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 24 Jun 2021 15:34:42 +0000 (15:34 +0000)
inc/ws/Controlleur/class.ws.services.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/DAO/class.ws.dao.book.php

index 6515221b4b9711adec3ec38fad495d9312caf06c..6ef003a92644b506d203123db296afafb9bd60df 100644 (file)
@@ -183,13 +183,13 @@ class wsServices extends cubeFlashGateway
         }
 
         $id = $book->book_id;
-        $wid=$book->getAssetDir();
+        $wid = $book->getAssetDir();
 
         if (isset($this->args['image'])) {
             $cover = $wid . $this->args['image'];
         } else {
             if (isset($book->parametres->facebook_image) && $book->parametres->facebook_image != '') {
-                $c =$wid. $book->parametres->facebook_image;
+                $c = $wid . $book->parametres->facebook_image;
                 if (file_exists($c)) {
                     $cover = $c;
                 }
@@ -197,19 +197,24 @@ class wsServices extends cubeFlashGateway
 
             if (!isset($cover)) {
                 $cover = WS_FILES . '/social_image/' . $id . '.jpg';
-                $limit = TIME - (3600 * 24 * 5);
+                $limit = TIME - (3600 * 24 * 30);
                 $minsize = 20 * 1024;
 
                 if (isset($_GET['force']) || !file_exists($cover) || filemtime($cover) < $limit || filesize($cover) < $minsize) {
-                    $url = 'https://workshop.fluidbook.com/viewerh/' . $id . '_' . $book->hash . '_' . TIME . '/?nointerface=1';
-                    if (isset($_GET['forcecompile'])) {
-                        $url .= '&force=1';
-                    }
-                    $url .= '#/page/0';
 
+                    $lock = WS_BOOKS . '/locks/' . $id . '.social_screenshot';
+                    if (!file_exists($lock) || filemtime($lock) < time() - 3600) {
+                        touch($lock);
+
+                        $url = 'https://workshop.fluidbook.com/viewerh/' . $id . '_' . $book->hash . '_' . TIME . '/?nointerface=1';
+                        if (isset($_GET['forcecompile'])) {
+                            $url .= '&force=1';
+                        }
+                        $url .= '#/page/0';
 
-                    $w = 1200;
-                    $h = 628;
+
+                        $w = 1200;
+                        $h = 628;
 //                    $tmp = CubeIT_Files::tempnam() . '.svg';
 //                    $cl = new CubeIT_CommandLine('xvfb-run');
 //                    $cl->setArg('a');
@@ -228,16 +233,19 @@ class wsServices extends cubeFlashGateway
 //                    `convert $tmp -crop $geo+0+0 +repage -resize $geo -flatten  $cover`;
 //                    unlink($tmp);
 
-                    $cl = new CubeIT_CommandLine('node');
-                    $cl->setArg(null, WS_TOOLS . '/social_screenshot/social_screenshot.js');
-                    $cl->setArg('width', $w);
-                    $cl->setArg('height', $h);
-                    $cl->setArg('delay', 10);
-                    $cl->setArg('scale', 0.5);
-                    $cl->setArg('dest', $cover);
-                    $cl->setArg('url', $url);
-                    $cl->execute();
-                    $cl->debug();
+                        $cl = new CubeIT_CommandLine('node');
+                        $cl->setArg(null, WS_TOOLS . '/social_screenshot/social_screenshot.js');
+                        $cl->setArg('width', $w);
+                        $cl->setArg('height', $h);
+                        $cl->setArg('delay', 10);
+                        $cl->setArg('scale', 0.5);
+                        $cl->setArg('dest', $cover);
+                        $cl->setArg('url', $url);
+                        $cl->execute();
+                        $cl->debug();
+
+                        unlink($lock);
+                    }
                 }
             }
         }
@@ -448,7 +456,7 @@ class wsServices extends cubeFlashGateway
     {
         global $core;
         $mode = $force ? $force : $book->parametres->bookmarkUsePDF;
-        $wid=$book->getAssetDir();
+        $wid = $book->getAssetDir();
         switch ($mode) {
             case 'download':
                 $res = $wid . $book->parametres->pdfReplace;
index d3b2ea8c0e7f24df43147fb50e7ce37c221e35a3..c70675b220c4db1af036627375d26fcb2ea36c50 100644 (file)
@@ -1250,8 +1250,6 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
             $r = $_SERVER['HTTP_REFERER'];
         }
 
-        fb($r, $id);
-
         global $core;
         $rr = $core->con->select('SELECT * FROM books_referer WHERE book_id=\'' . $core->con->escape($id) . '\' AND referer=\'' . $core->con->escape($r) . '\'');
         $c = $core->con->openCursor('books_referer');
index 5cbc585064b4fc8f2b2513b64c5bd8017f9cca83..76849c3c4d9dfddf660ed7a3b381369debdcc3e4 100644 (file)
@@ -1195,6 +1195,14 @@ class wsDAOBook extends commonDAO
             return;
         }
 
+        $compileLock = WS_BOOKS . '/locks/' . $book_id . '.lock';
+
+        while (file_exists($compileLock) && filemtime($compileLock) > time() - 3600) {
+            sleep(10);
+        }
+
+        touch($compileLock);
+
         if (null === $book) {
             $book = $this->selectById($book_id);
         }
@@ -1205,6 +1213,8 @@ class wsDAOBook extends commonDAO
         $res .= $this->compileHTML5($book_id, $book, $dev, $delete);
         $this->touchCompile($book_id, 'html5');
 
+        unlink($compileLock);
+
         return $res;
     }