]> _ Git - cubeextranet.git/commitdiff
wip #5701 @0.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 2 Feb 2023 07:38:40 +0000 (07:38 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 2 Feb 2023 07:38:40 +0000 (07:38 +0000)
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Controlleur/class.ws.url.php
inc/ws/Metier/class.ws.book.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.chromeos.php
inc/ws/Util/packager/class.ws.packager.php
inc/ws/Util/packager/class.ws.packager.win.exe.html.php

index 34d5cecccbaea7bc6484f3740ae2e022e58dc150..6a31c50d5764c91203cfaa266ab7d94455ad0fa4 100644 (file)
@@ -282,58 +282,6 @@ class wsFlash extends cubeFlashGateway
         }
     }
 
-    public function testDocuments()
-    {
-        global $core;
-
-        $toload = $this->xml->addChild('toLoad');
-        $alreadyLoaded = $this->xml->addChild('alreadyLoaded');
-
-        $hash = array();
-
-        foreach ($this->args['fileName'] as $k => $name) {
-            $o = new wsDocumentLocalInfos();
-            $o->fileName = $name;
-            $o->fileSize = intval($this->args['fileSize'][$k]);
-            $o->modificationDate = intval($this->args['modificationDate'][$k]);
-            $o->creationDate = intval($this->args['creationDate'][$k]);
-
-            $hash[$k] = md5(serialize($o));
-        }
-
-        $in = array();
-        foreach ($hash as $h) {
-            $in[] = "'" . $h . "'";
-        }
-
-        $sql = 'SELECT document_id,localHash FROM documents WHERE localHash';
-        if (count($in) == 1) {
-            $sql .= ' = ' . implode(',', $in);
-        } else {
-            $sql .= ' IN (' . implode(',', $in) . ')';
-        }
-
-        $al = array();
-        $r = $core->con->select($sql);
-        while ($r->fetch()) {
-            $k = array_search($r->localHash, $hash);
-
-            if (!file_exists(WS_DOCS . '/' . $r->document_id . '/crop.pdf')) {
-                continue;
-            }
-
-            $al[$k] = true;
-            $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]);
-            $f->addAttribute('document_id', $r->document_id);
-        }
-
-        foreach ($this->args['fileName'] as $k => $name) {
-            if (!isset($al[$k])) {
-                $toload->addChild('file', $name);
-            }
-        }
-    }
-
     public function getPagesOfBook()
     {
         global $core;
index 4ea21544c3119c61e930262ad75c9bd1b9a0aba1..4dcca7ffcadc48eeeeee10a7c9276dc1b905997a 100644 (file)
@@ -20,7 +20,7 @@ class wsMaintenance
         cubePHP::neverStop();
         $r = $core->con->select('SELECT document_id FROM documents');
         while ($r->fetch()) {
-            $root = WS_DOCS . '/' . $r->document_id . '/';
+            $root = wsDocument::getDir($r->document_id);
             $original = $root . 'original.pdf';
             $crop = $root . 'crop.pdf';
             if (file_exists($original) && file_exists($crop) && filesize($original) == filesize($crop)) {
@@ -147,6 +147,8 @@ class wsMaintenance
         $limit = TIME - (2 * 3600); // 2 heures avant maintenant*
         //
         $dirs = array(
+            US_FILES . '/packager/',
+            US_FILES . '/packager/nwbuild',
             WS_FILES . '/packager/',
             WS_FILES . '/packager/nwbuild'
         );
@@ -278,7 +280,7 @@ class wsMaintenance
             self::_duplicateLines('documents', 'document_id', $doc, $newid);
 
             $f = wsDocument::getDir($doc);
-            $t = WS_DOCS . '/' . $newid;
+            $t = wsDocument::getDir($newid);
 
             `cp -r $f $t`;
 
@@ -403,7 +405,7 @@ class wsMaintenance
 
     public static function cleanDownload($args)
     {
-        $dirs = [ROOT . '/cache/download/', WS_FILES . '/packager/download'];
+        $dirs = [ROOT . '/cache/download/', WS_FILES . '/packager/download', US_FILES . '/packager/download'];
         foreach ($dirs as $dir) {
             echo `find $dir -name '*.*' -mmin +240 -delete -print`;
         }
@@ -541,7 +543,7 @@ class wsMaintenance
         $docs = array_unique($docs);
 
         foreach ($docs as $doc) {
-            $out = WS_DOCS . '/' . $doc . '/';
+            $out = wsDocument::getDir($doc);
 
             $fwstk = new cubeCommandLine('fwstk.sh');
             $fwstk->setPath(CONVERTER_PATH);
@@ -1143,7 +1145,7 @@ class wsMaintenance
         $fixed = [];
         $unfixed = [];
         while ($r->fetch()) {
-            if (file_exists(WS_DOCS . '/' . $r->document_id . '/original.pdf')) {
+            if (file_exists(wsDocument::getDir($r->document_id) . 'original.pdf')) {
                 continue;
             }
             if (!isset($fixed[$r->book_id]) && !isset($unfixed[$r->book_id])) {
index 0174412b09ee28fc5ed7c44aa2466289588f29a1..37bef8c4ee6100e6e3e51cd315af1b25a8aa5850 100644 (file)
@@ -200,7 +200,7 @@ class wsServices extends cubeFlashGateway
             }
 
             if (!isset($cover)) {
-                $cover = WS_FILES . '/social_image/' . $id . '.jpg';
+                $cover = wsBook::getRegionDir($id) . 'social_image/' . $id . '.jpg';
                 $theme = $daoTheme->selectById($book->theme);
                 $limit = max(TIME - (3600 * 24 * 30), $book->changedate, $theme->date);
                 $minsize = 20 * 1024;
@@ -239,7 +239,7 @@ class wsServices extends cubeFlashGateway
             }
         }
 
-        $sizeFile = WS_FILES . '/social_image/' . $id . '.size';
+        $sizeFile = wsBook::getRegionDir($id).'social_image/' . $id . '.size';
         if (!file_exists($sizeFile) || filemtime($sizeFile) < filemtime($cover)) {
             file_put_contents($sizeFile, json_encode(CubeIT_Image::getimagesize($cover)));
         }
index 944efeb777e275a59f6b9865850111f9723bad0b..7066b50dd6d4d32a5a2955feb6a5941c73587bd9 100644 (file)
@@ -1439,19 +1439,6 @@ html,body{height:100%;cursor: wait;font-family: "Open Sans", Arial;background-co
         $dao->updateFromObject($doc);
     }
 
-    public static function testFontExtraction($args)
-    {
-        $documentId = $args[1];
-
-        header('Content-type: text/plain');
-        ob_clean();
-
-        $extractor = new wsPDFFontExtractor(WS_DOCS . '/' . $documentId);
-        $extractor->extract();
-
-        exit;
-    }
-
     public static function getParamsHelp($args)
     {
         commonDroits::min(5);
index e8c81d429e18f24cc373cca0cfe706b0bbc266e0..322cbd775c0ec0729c915894fbe7c6dc4db2191d 100644 (file)
@@ -137,13 +137,18 @@ class wsBook extends cubeMetier
         wsMaintenance::timeoutRequest('https://workshop.fluidbook.com/maintenance/processBookPages/' . $book_id, 1);\r
     }\r
 \r
-\r
-    public static function getDir($id, $dir, $addSlash = true, $onlyroot = false)\r
+    public static function getRegionDir($id)\r
     {\r
         if (!isset(self::$_bookDirs[$id])) {\r
             self::$_bookDirs[$id] = self::_getRegion($id);\r
         }\r
-        $res = (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/';\r
+        return (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/';\r
+    }\r
+\r
+\r
+    public static function getDir($id, $dir, $addSlash = true, $onlyroot = false)\r
+    {\r
+        $res = self::getRegionDir($id);\r
         $res .= $dir . '/';\r
         if (!$onlyroot) {\r
             $res .= $id . '/';\r
@@ -170,7 +175,8 @@ class wsBook extends cubeMetier
         return $res;\r
     }\r
 \r
-    public static function getCacheDir($id){\r
+    public static function getCacheDir($id)\r
+    {\r
         return (self::$_bookDirs[$id] === 'UE' ? ROOT . '/fluidbook' : US_FILES) . '/cache/';\r
     }\r
 \r
index ef3b446eefc1df92e0f32cd9b9d03d28775b782f..f7e4cf09bdb0e485ff9566e3a8516727eb7963d5 100644 (file)
@@ -512,7 +512,7 @@ class wsDocument extends cubeMetier
         $time = round(microtime(true) - $start, 4);
         $log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t\t\t\t" . $time . "\t\t\t\t$page|$format|$resolution|$withText|$withGraphics|$version\t\t\t\t$res\t\t\t\t$output\n";
 
-        $fp = fopen(WS_DOCS . '/' . $this->document_id . '/farm.log', 'a+');
+        $fp = fopen(wsDocument::getDir($this->document_id) . 'farm.log', 'a+');
         fwrite($fp, $log);
         fclose($fp);
 
index 62384eb68b27ee8ac0cea6dc34c974e18bfebbc7..a4089f6fc883035ce4a990de92de84fccf931d9d 100644 (file)
@@ -1682,7 +1682,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             $socialDescription = html::escapeHTML($this->book->parametres->facebook_description ? $this->book->parametres->facebook_description : $this->book->parametres->seoDescription);
 
             $socialImage = 'https://workshop.fluidbook.com/services/facebook_thumbnail?cid=' . $this->book->cid;
-            $sizeFile = WS_FILES . '/social_image/' . $this->book->book_id . '.size';
+            $sizeFile = wsBook::getRegionDir($this->book->book_id).'social_image/' . $this->book->book_id . '.size';
             if (!file_exists($sizeFile)) {
                 $dim = CubeIT_Image::getimagesize($socialImage);
                 file_put_contents($sizeFile, json_encode($dim));
index 31d667ec60577ff498aea80f820ced630f82c955..eddfe4d34a9bff0c1b605b5b64633861f006fffe 100644 (file)
@@ -36,7 +36,7 @@ class wsPackagerChromeOS extends wsPackagerHTML
         $this->preparePackage();\r
 \r
         $chrome = new CubeIT_CommandLine('crx3');\r
-        $chrome->setArg('o', WS_PACKAGER . '/download/' . $this->getBaseFile() . '.crx');\r
+        $chrome->setArg('o', wsBook::getPackagerDir($this->book_id,true) . 'download/' . $this->getBaseFile() . '.crx');\r
         $chrome->setArg(null, $this->vdir . '/m/');\r
         $chrome->execute();\r
         $chrome->debug();\r
index 9d43fa7b0d072cc7be857f3b01ced08ba0897d0a..7d6667e9c81180d444caed527de1c7a1d4dec17b 100644 (file)
@@ -189,11 +189,7 @@ class wsPackager
 
     protected function getPathBase($ext = '')
     {
-        if ($this->book->region === 'UE') {
-            $base = WS_FILES;
-        } else {
-            $res = US_FILES;
-        }
+        $base=wsBook::getRegionDir($this->book_id);
         if (!file_exists($base . '/packager/download')) {
             mkdir($base . '/packager/download', 0777, true);
         }
index 5592904903bfedee4ee5e42f4aabc45ce9bffced..6ea58d1dee7119e197b4a10fc3becd0f6c303659 100644 (file)
@@ -41,7 +41,7 @@ class wsPackagerWinEXEHTML extends wsPackager
         $this->copyFluidbookFiles();\r
         $this->makeJSON();\r
 \r
-        $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id;\r
+        $this->buildPath = wsBook::getPackagerDir($this->book_id,true) . '/nwbuild/' . $this->version . '/' . $this->book_id;\r
 \r
         `umask 0000;rm -rf $this->buildPath;mkdir -p 0777 $this->buildPath;chmod -R 777 $this->vdir;mkdir -p 0777 /application/tmp;chmod -R 777 /application/tmp`;\r
 \r