]> _ Git - cubeextranet.git/commitdiff
wip #4367 @6
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Mar 2021 19:12:24 +0000 (19:12 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Mar 2021 19:12:24 +0000 (19:12 +0000)
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Util/class.ws.pdf.convert.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php

index 78a3edb4a445557ab3f2dd9fc7988c353a398dae..803cfd5a9b73e50d57dc380b793a68479bf27380 100644 (file)
@@ -512,18 +512,11 @@ class wsAjax extends cubeAjax
 
         $_POST = array_merge($defaults, $_POST);
 
-        foreach ($_POST as $k => $v) {
-            if (!is_array($v)) {
-                $_POST[$k] = htmlspecialchars($v);
-            }
-        }
-
-
         if (!self::valideDemandeDevis($x)) {
             $x->addAlert(sprintf(__("Une erreur s'est produite. Nous avons été averti de l'erreur que vous rencontrez. Vous pouvez nous contacter par e-mail à l'adresse suivante : %s"), '<a href="mailto:info@fluidbook.com">info@fluidbook.com</a>'));
             return;
         }
-        $spam = (strlen($_POST['fax']) > 0);
+        $spam = (strlen($_POST['fax']) > 0) || strpos('<', $_POST['rs']) !== false || strpos('<', $_POST['prenom']) !== false || strpos('<', $_POST['nom']) !== false;
         $_POST['spam'] = $spam ? 'Oui' : 'Non';
 
 
index 5bc8b8d3d748fa970165e9a8fec01b746128184f..f26656af1f7c24b35eddb854f78a10660db74fde 100644 (file)
@@ -835,12 +835,16 @@ class wsFlash extends cubeFlashGateway
     {
         global $core;
         $dao = new wsDAOBook($core->con);
-        $dao->setComposition($this->args['book_id'], json_decode($this->args['pages']));
+        $pages = json_decode($this->args['pages']);
+        $dao->setComposition($this->args['book_id'], $pages);
 
         // Begin to generate files async
-        $book = $dao->selectById($this->args['book_id']);
-        $url = 'https://workshop.fluidbook.com/viewerh/' . $book->book_id . '_' . $book->hash . '_' . time();
-        `wget -t 1 -T 1 $url`;
+        $url = 'https://workshop.fluidbook.com/maintenance/processPage/' . $this->args['book_id'] . '/all/0';
+        $ctx = stream_context_create(["http" => ["timeout" => 1]]);
+        $it = max(4, min(12, ceil(count($pages) / 20)));
+        for ($i = 0; $i < $it; $i++) {
+            file_get_contents($url, 0, $ctx);
+        }
     }
 
     public function getTexts()
index 7de23129763da5a649fe2c3e68125c8294d0be73..4450d3ba6152666c3cf760610f5842090f3b4f38 100644 (file)
@@ -1493,7 +1493,7 @@ class wsMaintenance
         $working = WS_BOOKS . '/working/' . $book . '/commerce/opt/';
         $res = [['EAN', 'front', 'angle', '360']];
         foreach ($eans as $ean) {
-            $res[] = [$ean." ", file_exists($working.'/'.$ean . '-front.jpg') ? 'Y' : 'N', file_exists($working.'/'.$ean . '-angle.jpg') ? 'Y' : 'N', file_exists($working.'/'.$ean . '-360.mp4') ? 'Y' : 'N'];
+            $res[] = [$ean . " ", file_exists($working . '/' . $ean . '-front.jpg') ? 'Y' : 'N', file_exists($working . '/' . $ean . '-angle.jpg') ? 'Y' : 'N', file_exists($working . '/' . $ean . '-360.mp4') ? 'Y' : 'N'];
         }
         $excel = CubeIT_Excel::simple('GrandVisionLibrary', $res);
         ob_end_clean();
@@ -1513,6 +1513,7 @@ class wsMaintenance
 
         $book_id = $args[0];
         $page = $args[1];
+        $force = !isset($args[2]) || $args[2] != '0';
 
 
         $daoBook = new wsDAOBook($core->con);
@@ -1536,9 +1537,11 @@ class wsMaintenance
             $pages = [$page];
         }
 
+        shuffle($pages);
+
         foreach ($pages as $page) {
             foreach ($files as $file) {
-                $book->getFile($page, $file[0], $file[1], $file[2], $file[3], $file[4], true);
+                $book->getFile($page, $file[0], $file[1], $file[2], $file[3], $file[4], $force);
             }
         }
     }
index 0c68767d81a8dff7bfca4305d8fa7637a710fd39..876d5368d179fcf8a80afed0c53b53798cb6086f 100644 (file)
@@ -255,8 +255,8 @@ class wsPDFConvert
             unlink($tmp);\r
         } else {\r
             $pdftoppm->debug();\r
-            echo $pdftoppm->command . ':' . $pdftoppm->output;\r
-            exit;\r
+//            echo $pdftoppm->command . ':' . $pdftoppm->output;\r
+//            exit;\r
         }\r
     }\r
 \r
index 0cbdb69b6a1e4969362a14a824cdfeafea5e0413..67c2d49772c5772ef6c0f805f3bfed0cd9928ccf 100644 (file)
@@ -1125,10 +1125,6 @@ class wsHTML5Compiler
         if ($page == 1) {
             $seo->writePage($html, $this->vdir, 'index.html');
         }
-
-        if ($page % 10 == 0) {
-            $this->log('Written page ' . $page);
-        }
     }
 
     public function getIndexVars()
@@ -2038,13 +2034,27 @@ class wsHTML5Compiler
 
     public function writeTexts()
     {
-        $this->daoBook->makeTextsIndexes($this->book, $this->pages, $index, $textes, true);
-        $this->vdir->file_put_contents('data/search.index.js', 'var INDEX=' . $index . ';' . "\r");
+        $cache = sha1($this->book->parametres->highlightResults . '/--/' . $this->book->parametres->searchWordSelectionAlgorithm . '///' . $this->book->parametres->textExtraction . '|--|' . $this->book->parametres->ignoreSearchSeparators . '|||' . max($this->book->composition_update, filemtime(WS_TOOLS . '/fwstk/out/artifacts/fwstk_jar/fwstk.jar')));
+        $cacheDir = WS_BOOKS . '/index/' . $this->book_id . '/' . $cache . '/';
+        if (!file_exists($cacheDir)) {
+            mkdir($cacheDir, 0777, true);
+
+            $this->daoBook->makeTextsIndexes($this->book, $this->pages, $index, $textes, true);
+            file_put_contents($cacheDir . '/search.index.js', 'var INDEX=' . $index . ';' . "\r");
+            if ($this->book->parametres->highlightResults) {
+                file_put_contents($cacheDir . '/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r");
+            }
+            if ($this->book->parametres->searchWordSelectionAlgorithm == 'expression') {
+                file_put_contents($cacheDir . '/search.texts.js', 'var TEXTS=' . $textes . ";\r");
+            }
+        }
+
+        $this->vdir->copy($cacheDir . '/search.index.js', 'data/search.index.js');
         if ($this->book->parametres->highlightResults) {
-            $this->vdir->file_put_contents('data/search.highlight.js', 'var HIGHLIGHTS=' . json_encode($this->daoBook->makeHighlightIndex($this->book, $this->pages)) . ";\r");
+            $this->vdir->copy($cacheDir . '/search.highlight.js', 'data/search.highlight.js');
         }
         if ($this->book->parametres->searchWordSelectionAlgorithm == 'expression') {
-            $this->vdir->file_put_contents('data/search.texts.js', 'var TEXTS=' . $textes . ";\r");
+            $this->vdir->copy($cacheDir . '/search.texts.js', 'data/search.texts.js');
         }
     }
 
@@ -2106,13 +2116,8 @@ class wsHTML5Compiler
             $imdir = 'html';
         }
 
-        $pages= array_slice($this->pages, 0);;
-        shuffle($pages);
-
         $thumbs = array();
         foreach ($this->pages as $page => $infos) {
-            $docdir = wsDocument::getDir($infos['document_id']);
-
             $thisrasterize = in_array($page, $rasterizePages);
             $thisimagesvg = !$thisrasterize && $this->svg;
             $thisbackgroundPrefix = $thisrasterize ? [true] : $this->backgroundsPrefix;
@@ -2137,11 +2142,12 @@ class wsHTML5Compiler
             }
 
             $this->vdir->copy($this->book->getThumbFile($page, $this->imageFormat), 'data/thumbnails/p' . $page . '.' . $this->imageFormat);
+            $this->log('Made image page ' . $page);
         }
 
         $this->_makeCover($this->book->getFile(1, 'jpg', 150, true, true));
 
-        $this->log('Made thumbnails');
+        $this->log('Made images');
     }
 
     protected function _makeCover($orig)
@@ -2188,6 +2194,7 @@ class wsHTML5Compiler
         $this->lessVariables['css-scale'] = $this->cssScale;
         $this->lessVariables['slider-display'] = $this->_lessBoolean($this->theme->parametres->pagesBar);
         $this->lessVariables['slider-thumb-background'] = wsHTML5::colorToCSS($this->theme->parametres->pageBarThumbBack);
+        $this->lessVariables['pages-background'] = $this->book->parametres->forceWhiteBackground ? '#ffffff' : 'transparent';
 
         // General theme
         $cssWidth = $this->cssWidth;
@@ -3013,3 +3020,18 @@ if (!function_exists('is_countable')) {
     }
 
 }
+
+function shuffle_assoc(&$array)
+{
+    $keys = array_keys($array);
+
+    shuffle($keys);
+
+    foreach ($keys as $key) {
+        $new[$key] = $array[$key];
+    }
+
+    $array = $new;
+
+    return true;
+}