From: vincent@cubedesigners.com Date: Thu, 2 Feb 2023 07:38:40 +0000 (+0000) Subject: wip #5701 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=0d2a48ad7767ad3db737620fffa50302538df1a3;p=cubeextranet.git wip #5701 @0.5 --- diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 34d5ceccc..6a31c50d5 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -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; diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 4ea21544c..4dcca7ffc 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -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])) { diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 0174412b0..37bef8c4e 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -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))); } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 944efeb77..7066b50dd 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -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); diff --git a/inc/ws/Metier/class.ws.book.php b/inc/ws/Metier/class.ws.book.php index e8c81d429..322cbd775 100644 --- a/inc/ws/Metier/class.ws.book.php +++ b/inc/ws/Metier/class.ws.book.php @@ -137,13 +137,18 @@ class wsBook extends cubeMetier wsMaintenance::timeoutRequest('https://workshop.fluidbook.com/maintenance/processBookPages/' . $book_id, 1); } - - public static function getDir($id, $dir, $addSlash = true, $onlyroot = false) + public static function getRegionDir($id) { if (!isset(self::$_bookDirs[$id])) { self::$_bookDirs[$id] = self::_getRegion($id); } - $res = (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/'; + return (self::$_bookDirs[$id] === 'UE' ? WS_BOOKS : US_BOOKS) . '/'; + } + + + public static function getDir($id, $dir, $addSlash = true, $onlyroot = false) + { + $res = self::getRegionDir($id); $res .= $dir . '/'; if (!$onlyroot) { $res .= $id . '/'; @@ -170,7 +175,8 @@ class wsBook extends cubeMetier return $res; } - public static function getCacheDir($id){ + public static function getCacheDir($id) + { return (self::$_bookDirs[$id] === 'UE' ? ROOT . '/fluidbook' : US_FILES) . '/cache/'; } diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index ef3b446ee..f7e4cf09b 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -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); diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 62384eb68..a4089f6fc 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -1682,7 +1682,7 @@ height="0" width="0" style="display:none;visibility:hidden"> $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)); diff --git a/inc/ws/Util/packager/class.ws.packager.chromeos.php b/inc/ws/Util/packager/class.ws.packager.chromeos.php index 31d667ec6..eddfe4d34 100644 --- a/inc/ws/Util/packager/class.ws.packager.chromeos.php +++ b/inc/ws/Util/packager/class.ws.packager.chromeos.php @@ -36,7 +36,7 @@ class wsPackagerChromeOS extends wsPackagerHTML $this->preparePackage(); $chrome = new CubeIT_CommandLine('crx3'); - $chrome->setArg('o', WS_PACKAGER . '/download/' . $this->getBaseFile() . '.crx'); + $chrome->setArg('o', wsBook::getPackagerDir($this->book_id,true) . 'download/' . $this->getBaseFile() . '.crx'); $chrome->setArg(null, $this->vdir . '/m/'); $chrome->execute(); $chrome->debug(); diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index 9d43fa7b0..7d6667e9c 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -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); } diff --git a/inc/ws/Util/packager/class.ws.packager.win.exe.html.php b/inc/ws/Util/packager/class.ws.packager.win.exe.html.php index 559290490..6ea58d1de 100644 --- a/inc/ws/Util/packager/class.ws.packager.win.exe.html.php +++ b/inc/ws/Util/packager/class.ws.packager.win.exe.html.php @@ -41,7 +41,7 @@ class wsPackagerWinEXEHTML extends wsPackager $this->copyFluidbookFiles(); $this->makeJSON(); - $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id; + $this->buildPath = wsBook::getPackagerDir($this->book_id,true) . '/nwbuild/' . $this->version . '/' . $this->book_id; `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`;