}
}
- 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;
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)) {
$limit = TIME - (2 * 3600); // 2 heures avant maintenant*
//
$dirs = array(
+ US_FILES . '/packager/',
+ US_FILES . '/packager/nwbuild',
WS_FILES . '/packager/',
WS_FILES . '/packager/nwbuild'
);
self::_duplicateLines('documents', 'document_id', $doc, $newid);
$f = wsDocument::getDir($doc);
- $t = WS_DOCS . '/' . $newid;
+ $t = wsDocument::getDir($newid);
`cp -r $f $t`;
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`;
}
$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);
$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])) {
}
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;
}
}
- $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)));
}
$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);
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
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
$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);
$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));
$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
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);
}
$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