- '/data/extranet/www/fluidbook/cover:/application/fluidbook/cover'\r
- '/mnt/sshfs/fluidbook:/mnt/sshfs/fluidbook'\r
- '/mnt/sshfs/macparis:/mnt/sshfs/macparis'\r
- - '/mnt/sshfs/codesign:/mnt/sshfs/codesign'\r
- '/data/extranet/www/fluidbook/cache/nwbuild:/usr/lib/node_modules/nw-builder/cache'\r
- '/home/toolbox/www:/home/toolbox/www'\r
- '/home/stats/www:/home/stats/www'\r
- '/data/extranet/www/fluidbook/cover:/application/fluidbook/cover'\r
- '/mnt/sshfs/fluidbook:/mnt/sshfs/fluidbook'\r
- '/mnt/sshfs/macparis:/mnt/sshfs/macparis'\r
- - '/mnt/sshfs/codesign:/mnt/sshfs/codesign'\r
- '/data/extranet/www/fluidbook/cache/nwbuild:/usr/lib/node_modules/nw-builder/cache'\r
- '/home/toolbox/www:/home/toolbox/www'\r
- '/home/stats/www:/home/stats/www'\r
- '/data/extranet/www/fluidbook/cover:/application/fluidbook/cover'\r
- '/mnt/sshfs/fluidbook:/mnt/sshfs/fluidbook'\r
- '/mnt/sshfs/macparis:/mnt/sshfs/macparis'\r
- - '/mnt/sshfs/codesign:/mnt/sshfs/codesign'\r
- '/data/extranet/www/fluidbook/cache/nwbuild:/usr/lib/node_modules/nw-builder/cache'\r
- '/home/toolbox/www:/home/toolbox/www'\r
- '/home/stats/www:/home/stats/www'\r
RUN echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
-RUN apt-get update && apt-get -y --no-install-recommends install \
+RUN apt update && apt -y --no-install-recommends install \
git \
php7.2-fpm \
php7.2-apcu \
STOPSIGNAL SIGQUIT
# Toolbox
-RUN apt-get -y --no-install-recommends install nodejs google-chrome-stable
-RUN apt-get -y --no-install-recommends install sudo
-RUN apt-get -y --no-install-recommends install supervisor ssh rsync
-RUN apt-get -y --no-install-recommends install default-jre pdftk poppler-utils inkscape mupdf-tools ghostscript imagemagick netpbm libjpeg-turbo8 libjpeg-turbo-progs
-RUN apt-get -y --no-install-recommends install zip unzip gzip 7zip
-RUN apt-get -y --no-install-recommends install icoutils fontforge icnsutils
-RUN apt-get -y --no-install-recommends install ffmpeg lame x264 vorbis-tools
-RUN apt-get -y --no-install-recommends install inkscape mupdf-tools librsvg2-bin
-RUN apt-get -y --no-install-recommends install cron monit locate
-RUN apt-get -y --no-install-recommends install build-essential chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
-RUN apt-get -y --no-install-recommends install libreoffice
-RUN apt-get -y --no-install-recommends install sshfs lftp
-RUN apt-get -y --no-install-recommends install sshfs python3 python3-pip
-RUN apt-get -y --no-install-recommends install openssh-server rsyslog
-RUN apt-get -y --no-install-recommends install mariadb-client
+RUN apt -y --no-install-recommends install nodejs google-chrome-stable
+RUN apt -y --no-install-recommends install sudo
+RUN apt -y --no-install-recommends install supervisor ssh rsync
+RUN apt -y --no-install-recommends install default-jre pdftk poppler-utils inkscape mupdf-tools ghostscript imagemagick netpbm libjpeg-turbo8 libjpeg-turbo-progs
+RUN apt -y --no-install-recommends install zip unzip gzip 7zip
+RUN apt -y --no-install-recommends install icoutils fontforge icnsutils
+RUN apt -y --no-install-recommends install ffmpeg lame x264 vorbis-tools
+RUN apt -y --no-install-recommends install inkscape mupdf-tools librsvg2-bin
+RUN apt -y --no-install-recommends install cron monit locate
+RUN apt -y --no-install-recommends install build-essential chrpath libssl-dev libxft-dev libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
+RUN apt -y --no-install-recommends install libreoffice
+RUN apt -y --no-install-recommends install sshfs lftp
+RUN apt -y --no-install-recommends install sshfs python3 python3-pip
+RUN apt -y --no-install-recommends install openssh-server rsyslog
+RUN apt -y --no-install-recommends install mariadb-client
RUN cd /root;wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2;tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2;mv phantomjs-2.1.1-linux-x86_64 /usr/local/share;ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin
RUN cd /root;wget https://github.com/nwutils/Web2Executable/releases/download/v0.7.1b/Web2ExeLinux-CMD.zip;unzip Web2ExeLinux-CMD.zip;mv Web2ExeLinux-CMD /usr/local/web2exe
RUN npm install --unsafe-perm --global uglify-js less sass puppeteer favicons nw-builder@3.5.7
RUN pip3 install font-line
-RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
+RUN apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
RUN groupadd fluidbook;groupadd sudo;useradd -d /application -g 33 -G sudo -s /bin/bash -u 1002 extranet
$f = $file->getRealPath();
$f = addcslashes($f, "$ #!\"\'&)(*,;<>?[]\^`{}|~");
$n = CubeIT_Text::str2URL($base) . '.xlsx';
- $dest = WS_BOOKS . '/working/' . $id . '/';
+ $dest = wsBook::getDir($id,'working');
$cmd = "mv $f $dest/$n";
`$cmd`;
$settings = [];
// .\r
// Table documents\r
$db->documents->document_id('integer', 0, false);\r
+ $db->documents->region('varchar', 2, false,'"UE"');\r
$db->documents->file('varchar', 256, false);\r
$db->documents->proprietaire('integer', 0, false);\r
$db->documents->pages('integer', 0, false);\r
define('WS_TOOLS', WS_FILES . '/tools');
define('WS_PACKAGER', WS_FILES . '/packager');
-define('UUS_FILES', '/application/usstorage/');
+define('US_FILES', '/application/usstorage/');
define('US_BOOKS', US_FILES . '/books');
define('US_COLLECTIONS', US_FILES . '/collections');
define('US_DOCS', US_FILES . '/docs');
$exporter = new wsExporter();
- file_put_contents(WS_CACHE . '/' . $_POST['book_id'] . '.post.options', print_r($_POST, true));
$exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $dest['dir'], $dest['file'], $_POST['options'] ?? []);
$x->addClosePopup();
if (!$id) {
$c = __('Entrez le numéro du fluidbook source pour sélectionner les fichiers à transférer');
} else {
- $dr = opendir(WS_BOOKS . '/working/' . $id);
+ $dr = opendir(wsBook::getDir($id,'working'));
$files = array();
while ($f = readdir($dr)) {
if ($f == '.' || $f == '..') {
return;
}
- $d = WS_BOOKS . '/working/' . $_POST['dest'];
+ $d = wsBook::getDir($_POST['dest'],'working');
if (!file_exists($d)) {
mkdir($d, 0777, true);
}
- $s = WS_BOOKS . '/working/' . $_POST['source'];
+ $s = wsBook::getDir($_POST['source'],'working');
foreach ($_POST['files'] as $f) {
copy($s . '/' . $f, $d . '/' . $f);
$torulers = $fromrulers;
}
- $wt = WS_BOOKS . '/working/' . $to;
- $wf = WS_BOOKS . '/working/' . $from;
+ $wt = wsBook::getDir($to, 'working');
+ $wf = wsBook::getDir($from, 'working');
if (file_exists($wf)) {
$wf1 = $wf . '/*';
$book_id = $args[0];
- $dir = WS_BOOKS . '/working/' . $book_id;
+ $dir = wsBook::getDir($book_id, 'working');
wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
foreach ($links as $link) {
$book_id = $args[0];
$format = $args[1];
- $dir = WS_BOOKS . '/working/' . $book_id;
+ $dir = wsBook::getDir($book_id, 'working');
wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers);
$res .= $fwstk->output;
}
- $dir = WS_BOOKS . '/index/' . $book->book_id;
+ $dir = wsBook::getDir($book->book_id, 'index');
if ($book->parametres->ignoreSearchSeparators != '') {
$dir .= '/' . sha1($book->parametres->ignoreSearchSeparators);
}
}
}
- $i = WS_BOOKS . '/index/' . $book_id . '/*';
+ $i = wsBook::getDir($book_id, 'index') . '*';
`rm -rf $i`;
ob_end_clean();
die('<pre>' . $res . '</pre>');
$book_id = $args[0];
+ $pdf = wsBook::getDir($book_id, 'pdf');
+
$places = [
- WS_BOOKS . '/pdf/' . $book_id . '/original.pdf',
- WS_BOOKS . '/pdf/' . $book_id . '/normal.pdf',
- WS_BOOKS . '/final/' . $book_id . '/data/document.pdf',
- WS_BOOKS . '/html5/' . $book_id . '/data/document.pdf',
+ wsBook::getDir($book_id, 'pdf') . 'original.pdf',
+ wsBook::getDir($book_id, 'pdf') . 'normal.pdf',
+ wsBook::getDir($book_id, 'final') . 'data/document.pdf',
+ wsBook::getDir($book_id, 'html5') . 'data/document.pdf',
];
$ok = false;
}
$tmp = CubeIT_Files::tempnam() . ".zip";
- CubeIT_Util_Zip::archive(WS_BOOKS . '/working/' . $book_id, $tmp);
+ CubeIT_Util_Zip::archive(wsBook::getDir($book_id, 'working'), $tmp);
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="working_' . $book_id . '.zip"');
header('Content-Length: ' . filesize($tmp));
public static function clearLocks()
{
- $dir = WS_BOOKS . '/locks/*';
- `rm $dir`;
+ $dirs = [WS_BOOKS . '/locks/*', US_BOOKS . '/locks/*'];
+ foreach ($dirs as $dir) {
+ `rm $dir`;
+ }
}
public static function processPage($args)
//die($limit . ':' . $book->changedate . '//' . filemtime($cover));
if (isset($_GET['force']) || !file_exists($cover) || filemtime($cover) < $limit || filesize($cover) < $minsize) {
- $lock = WS_BOOKS . '/locks/' . $id . '.social_screenshot';
+ $lock = wsBook::getDir($id, 'locks', false) . '.social_screenshot';
if (!file_exists($lock) || filemtime($lock) < time() - 3600) {
touch($lock);
exit;
}
- public function searchHints()
- {
- $index = Zend_Search_Lucene::open(WS_BOOKS . '/search/' . $this->args['id']);
-
- $charsLimit = 2;
-
- $terms = $this->getTerms($this->args['term']);
- $term = array_pop($terms);
-
- if (strlen($term) < $charsLimit) {
- $this->xml->addChild('hints', '{}');
- return;
- }
-
- $term = new Zend_Search_Lucene_Index_Term($term . '*', 'contents');
- $query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
- $query->setMinPrefixLength($charsLimit);
-
- $index->find($query);
- $terms = $query->getQueryTerms();
- $res = array();
- foreach ($terms as $t) {
- $res[$t->text] = array_sum($index->termFreqs($t));
- }
- arsort($res);
- $res = array_slice($res, 0, 10, true);
- $this->xml->addChild('hints', json_encode($res));
- }
-
- public function searchResults()
- {
- $index = Zend_Search_Lucene::open(WS_BOOKS . '/search/' . $this->args['id']);
-
- $terms = $this->getTerms($this->args['term']);
-
- $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
- foreach ($terms as $term) {
- $query->addTerm(new Zend_Search_Lucene_Index_Term($term, 'contents'), null);
- }
-
- $hits = $index->find($query);
- $res = array();
- $terms = array();
- foreach ($query->getQueryTerms() as $t) {
- $terms[] = $t->text;
- foreach ($index->termFreqs($t) as $doc_id => $f) {
- $page = trim($index->getDocument($doc_id)->getField('url')->getUtf8Value(), "#");
- if (!isset($res[$page])) {
- $res[$page] = 0;
- }
- $res[$page] += $f;
- }
- }
- $this->xml->addChild('results', json_encode($res));
- $this->xml->addChild('terms', implode(',', $terms));
- }
-
protected function getTerms($term)
{
$term = trim($term, '*? ');
if (is_null($book)) {
$book = $this->callArgs[0];
- $range = $this->callArgs[1]??'';
+ $range = $this->callArgs[1] ?? '';
}
$daoBook = new wsDAOBook($core->con);
return false;
}
- $destDir = WS_CACHE . '/exportpdf/' . $book->cid;
+
+ $destDir = wsBook::getCacheDir($book->book_id) . '/exportpdf/' . $book->cid;
if (!file_exists($destDir)) {
mkdir($destDir, 0777, true);
}
break;
case 'pages':
default:
- $normal = WS_BOOKS . '/pdf/' . $book->book_id . '/original.pdf';
+ $normal = wsBook::getDir($book->book_id, 'pdf') . 'original.pdf';
if (!file_exists($normal)) {
$daoBook = new wsDAOBook($core->con);
$pages = $daoBook->getPagesOfBook($book->book_id);
$book_id = $args[1];
$time = $args[2];
- $file = WS_BOOKS . '/links/' . $book_id . '/' . $time . '.xlsx';
+ $file = wsBook::getDir($book_id, 'links') . $time . '.xlsx';
if (!file_exists($file) || filesize($file) === 0) {
wsLinks::getLinksAndRulersFromFile($book_id, $links, $rulers, $time);
if (!$forceTheme) {
self::logReferer($book_id);
}
- $htmlFile = WS_BOOKS . '/html5' . $dir . '/' . $id . '/index.html';
+ $htmlFile = wsBook::getDir($id, 'html5') . 'index.html';
$html = '';
if (file_exists($htmlFile)) {
$html = file_get_contents($htmlFile);
protected $_compileLock = null;
+
/**
* wsDAOBook::singleton()
*
return $this->factory($r);
}
+
public function selectById($book_id = null, $simple = false)
{
if (is_null($book_id)) {
return $this->selectById($book_id);
}
- public function initUSStorage($book_id){
+ public function initUSStorage($book_id)
+ {
}
$c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
}
- /**
- * @param $book wsBook
- * @param $version
- * @return bool
- */
- public function isUpToDate($book, $version)
- {
- $version = (string)$version;
- if ($version == '2') {
- if (!file_exists(WS_BOOKS . '/final/' . $book->book_id)) {
- return false;
- }
- if ($book->compiledate < $book->changedate) {
- return false;
- }
- } else if ($version == '1') {
- // V1
- if (!file_exists(WS_BOOKS . '/finalv1/' . $book->book_id . '/index.swf')) {
- return false;
- }
- if ($book->compile1date < $book->changedate) {
- return false;
- }
- } else if ($version == 'html5') {
- return false;
- // HTML5
- $checks = array($book->changedate, cubeFiles::filemtimeRecursive($book->getAssetDir()), cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'), cubeFiles::filemtimeRecursive(ROOT . '/inc/ws/Util/html5'));
- foreach ($checks as $check) {
- if ($check > $book->compilehtml5date) {
- return false;
- }
- }
- }
- return true;
- }
-
public function setComposition($book_id, $pages, $setNumerotation = true)
{
$numerotation = array();
$prefix = 'f';
}
- $dir = WS_BOOKS . '/index/' . $book->book_id;
+ $dir = wsBook::getDir($book->book_id, 'index');
if ($book->parametres->ignoreSearchSeparators !== '') {
$dir .= '/' . sha1($book->parametres->ignoreSearchSeparators);
}
$lockId .= '-' . wsTheme::hashThemeArray($forceTheme);
}
- $this->_compileLock = WS_BOOKS . '/locks/' . $lockId . '.lock';
+ $this->_compileLock = wsBook::getDir($lockId, 'locks', false) . '.lock';
while (file_exists($this->_compileLock) && filemtime($this->_compileLock) > (time() - 900)) {
public function compilePDF($book, $pages)
{
- $res = wsUtil::compilePDF($book, $pages);
-
- $finalPDF = WS_BOOKS . '/final/' . $book->book_id . '/data/' . $book->parametres->pdfName;
- if ($res) {
- $this->copy($res, $finalPDF);
- }
+ return wsUtil::compilePDF($book, $pages);
}
public function generateCID()
+++ /dev/null
-<?php
-
-class wsDAOBook3 extends wsDAOBook
-{
-
- public static $pagesOfBookCache = array();
-
- /** @var wsHTML5Compiler */
- public static $lastHTML5Compiler = null;
-
- protected $_compileLock = null;
-
- /**
- * wsDAOBook::singleton()
- *
- * @param mixed $r
- * @return
- */
-
- protected static function _toTimestamp($date)
- {
- return strtotime($date);
- }
-
- protected function singleton($r)
- {
-
- $book = new wsBook();
- $book->book_id = $r->id;
- $book->cid = $r->cid;
- $book->nom = $r->name;
- $book->lang = $r->locale;
- $book->theme = $r->theme;
- $book->proprietaire = $r->proprietaire_nom;
- $book->proprietaire_id = $r->owner;
- $book->proprietaire_utilisateur = $r->proprietaire_utilisateur;
- $book->hash = $r->hash;
- $book->demo_counter = $book->compteur_visites = $r->visits_counter;
- $book->status = $r->status;
- $book->date_status = self::_toTimestamp($r->status_date);
- $book->date = self::_toTimestamp($r->created_at);
- $book->pages = array();
- $book->chapters = $r->chapters;
- $book->traductions = $r->translations;
- $book->parametres = new wsBookParametres($this);
- $book->parametres->importFromJson($r->settings);
- $book->numerotation = $r->page_numbers;
- $book->changedate = self::_toTimestamp($r->updated_at);
- $book->compilehtml5date = $book->compile1date = $book->compiledate = self::_toTimestamp($r->compilation_date);
- if (isset($r->facturable)) {
- $book->facturable = $r->facturable;
- }
- if (isset($r->facturable_id)) {
- $book->facturable_id = $r->facturable_id;
- }
- $book->tache = $r->extranet_task;
- if (isset($r->projet)) {
- $book->projet = $r->projet;
- }
- $book->version = 2;
- $book->composition_update = self::_toTimestamp($r->composition_updated_at);
- $book->exportdatas = $r->export_data;
-
- return $book;
- }
-
- protected function cree($r)
- {
- $book = new wsBook();
- $book->book_id = 'new';
- $book->nom = '';
- $book->cid = null;
- $book->lang = 'fr';
- $book->theme = 1;
- $book->proprietaire = '';
- $book->proprietaire_id = 0;
- $book->hash = '';
- $book->compteur_visites = 20;
- $book->status = 0;
- $book->date_status = TIME;
- $book->date = TIME;
- $book->composition_update = TIME;
- $book->chapters = json_encode(array());
- $book->parametres = new wsBookParametres();
- $book->tache = 0;
- $book->pages = array();
- $book->version = 2;
- return $book;
- }
-
- protected function getNextId()
- {
- $r = $this->con->select('SELECT MAX(book_id) AS book_id FROM books');
- if ($r->book_id < 10000) {
- return 10000;
- }
- return $r->book_id + 1;
- }
-
- public function saveExportDatas($book_id, $datas)
- {
- $c = $this->con->openCursor('books');
- $c->exportdatas = json_encode($datas);
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function addDemoCount($book_id)
- {
-
- $r = $this->con->select('SELECT demo_counter,nom FROM books WHERE book_id=\'' . $book_id . '\'');
- $m = 20;
- if ($r->demo_counter > 0 && $r->demo_counter % $m == 0) {
- $mail = new cubeMail();
- $mail->charset = 'UTF-8';
- $mail->from = 'contact@fluidbook.com';
- $mail->to = 'tech@fluidbook.com';
- $mail->subject = '[Fluidbook Workshop] Fluidbook consulté via l\'url publique';
- $mail->body = 'Le fluidbook suivant a été consulté ' . $m . ' fois (et ' . $r->demo_counter . ' au total) via l\'url publique : ' . "\r\n" .
- 'Fluidbook # ' . $book_id . ' - ' . $r->nom;
- $mail->send();
- }
-
- $this->con->select('UPDATE books SET demo_counter=demo_counter+1 WHERE book_id=\'' . $book_id . '\'');
- }
-
- public function selectByIds($book_ids = array(), $simple = false)
- {
- if ($simple) {
- $table = 'books';
- } else {
- $table = 'books_vue';
- }
-
- $ids = array();
- foreach ($book_ids as $bid) {
-
- if (intval($bid) > 0) {
- $ids[] = $bid;
- }
- }
-
- $sql = 'SELECT * FROM ' . $table . ' WHERE book_id IN (' . implode(',', $ids) . ')';
- $books = $this->factory($this->con->select($sql));
- $res = array();
- foreach ($books as $book) {
- $res[$book->book_id] = $book;
- }
- return $res;
- }
-
- public function selectAll()
- {
- $table = 'books_vue';
- $sql = 'SELECT * FROM ' . $table;
- $r = $this->con->select($sql);
- return $this->factory($r);
- }
-
- public function selectById($book_id = null, $simple = false)
- {
- if (is_null($book_id)) {
- return $this->cree();
- }
- if ($simple) {
- $table = 'books';
- } else {
- $table = 'books_vue';
- }
- $sql = 'SELECT * FROM ' . $table . ' WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1';
- $r = $this->con->select($sql);
- return $this->singleton($r);
- }
-
- public function selectByCid($cid = null, $simple = false)
- {
- if ($simple) {
- $table = 'books';
- } else {
- $table = 'books_vue';
- }
-
- $sql = 'SELECT * FROM ' . $table . ' WHERE cid LIKE BINARY \'' . $this->con->escape($cid) . '\' LIMIT 1';
- $r = $this->con->select($sql);
- return $this->singleton($r);
- }
-
-
- /**
- * wsDAOBook::sauve()
- *
- * @param mixed $createur
- * @param mixed $data
- * @return
- */
- public function sauve($createur, $data)
- {
- $c = $this->con->openCursor('books');
- if (isset($data['nom'])) {
- $c->nom = $data['nom'];
- }
- if (isset($data['lang'])) {
- $c->lang = $data['lang'];
- }
- if (isset($data['theme'])) {
- $c->theme = $data['theme'];
- }
- if (isset($data['proprietaire'])) {
- $c->proprietaire = $data['proprietaire'];
- }
-
- if ($data['book_id'] == 'new' || $data['book_id'] == '') {
- $c->date = TIME;
- $c->hash = md5(rand(0, 123456789365469));
- $c->compteur_visites = 20;
- $c->parametres = serialize(new wsParametres());
- $c->changedate = TIME;
- $book_id = $c->book_id = $this->getNextId();
-
- $c->insert();
- } else {
- $c->changedate = TIME;
- $book_id = $data['book_id'];
- $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\'');
- }
-
- if (isset(self::$pagesOfBookCache[$book_id])) {
- unset(self::$pagesOfBookCache[$book_id]);
- }
-
- return $this->selectById($book_id);
- }
-
- public function duplicate($book_id, $createur, $nom = null, $pages = false, $complete = false)
- {
- $r = $this->con->select('SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
-
- $old_id = $book_id;
-
-
- $parametres = unserialize($r->parametres);
- $parametres->setParent($this);
- if (null === $nom) {
- $nom = $parametres->title;
- }
- $parametres->title = $nom;
-
- if (!$complete) {
- $parametres->pdfReplace = '';
- }
-
- $c = $this->con->openCursor('books');
- $c->proprietaire = $createur;
- $c->date = TIME;
- $c->hash = md5(rand(0, 1234567893));
- $c->cid = $this->generateCID();
- $c->compteur_visites = 20;
- $c->status = -1;
- $c->date_status = TIME;
- $c->lang = $r->lang;
- $c->parametres = serialize($parametres);
- $c->nom = $nom;
- $c->theme = $r->theme;
- $c->changedate = TIME;
- $c->compiledate = 0;
- $c->version = 2;
- $c->traductions = $r->traductions;
- $c->specialLinks = $r->specialLinks;
- $c->specialRulers = $r->specialRulers;
- $c->composition_update = TIME;
- $book_id = $c->book_id = $this->getNextId();
- if ($pages) {
- $c->numerotation = $r->numerotation;
- $c->chapters = $r->chapters;
- $this->con->execute('INSERT INTO book_pages SELECT ' . $book_id . ' AS book_id,book_page,document_id,document_page FROM book_pages WHERE book_id=' . $old_id);
- }
- if ($complete) {
- $c->numerotation = $r->numerotation;
- $c->chapters = $r->chapters;
- }
- $c->insert();
-
- $this->saveCompositionVersion($book_id);
-
- return $this->selectById($book_id);
- }
-
- public function creeEmpty($createur, $lang, $nom)
- {
- $c = $this->con->openCursor('books');
-
- $parametres = new wsBookParametres($this);
- $parametres->title = $nom;
-
- $c->proprietaire = $createur;
- $c->cid = $this->generateCID();
- $c->nom = $nom;
- $c->date = TIME;
- $c->hash = md5(rand(0, 1234567893));
- $c->compteur_visites = 20;
- $c->status = -1;
- $c->date_status = TIME;
- $c->parametres = serialize($parametres);
-
- $c->theme = 1;
- $c->lang = $lang;
- $c->changedate = TIME;
- $c->compiledate = 0;
- $c->version = 2;
- $c->composition_update = TIME;
- $book_id = $c->book_id = $this->getNextId();
- $c->insert();
- return $this->selectById($book_id);
- }
-
- public function supprime($book_id)
- {
- $this->con->execute('DELETE FROM book_pages_versions WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- $this->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- return $this->con->execute('DELETE FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function count($limitedToUserRights = false)
- {
- $filters = $this->makeWhereFromFiltres();
- if ($filters == '1=1') {
- $table = 'books';
- } else {
- $table = 'books_vue';
- }
-
- $where = '(' . $filters . ')';
- $where .= $this->limitToUserRights($limitedToUserRights);
- $r = $this->con->select('SELECT COUNT(*) AS nb FROM ' . $table . ' WHERE ' . $where);
- return $r->nb;
- }
-
-
- public function insertDocument($book_id, $after_page, $document_id)
- {
- // Obtiens le book
- $book = $this->selectById($book_id);
- $num = explode(',', $book->numerotation);
- // Obtiens le nombre de pages
- $r = $this->con->select('SELECT pages,numberSections FROM documents WHERE document_id=\'' . $this->con->escape($document_id) . '\'');
- // Décale les pages vers le bas
- if ($after_page > 0) {
- $this->decalePages($book_id, $after_page, $r->pages);
- }
- // Insère les pages
- $c = $this->con->openCursor('book_pages');
- $c->book_id = $book_id;
- $c->document_id = $document_id;
- for ($i = 1; $i <= $r->pages; $i++) {
- $c->document_page = $i;
- $c->book_page = $after_page + $i;
- $c->insert();
- }
- // Mets à jour la liste des numéros des pages
- $before = array_slice($num, 0, $after_page);
- $after = array_slice($num, $after_page, count($num) - $after_page);
-
- $newnum = $r->numberSections;
- if (trim($newnum, ',') == '') {
- // If no number detected, we create a numeric list from 1
- $between = range(1, $r->pages);
- } else {
- // Else, we use numbers detected at conversion
- $between = explode(',', $r->numberSections);
- }
- $num = array_merge($before, $between, $after);
- // Mets à jour la numerotation de la publication
- $c = $this->con->openCursor('books');
- $c->numerotation = implode(',', $num);
- $c->composition_update = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
-
- $this->saveCompositionVersion($book_id);
- }
-
-
- public function getListe($orderby = null, $sens = null, $limit = null, $limitedToUserRights = false)
- {
- if (!is_null($this->q)) {
- $where = '(';
- if ($this->search_id) {
- $where .= ' book_id=\'' . $this->con->escape($this->q) . '\' OR ';
- }
-
- if (!cubeMath::is_int($this->q)) {
- $where .= 'nom LIKE \'%' . $this->con->escape($this->q) . '%\'';
- $daoClient = new commonDAOClient($this->con);
- $where .= ' OR proprietaire_id IN(' . $daoClient->querySearchByName($this->q) . ') OR ';
- }
- $limit = null;
- $where .= '1=2)';
- } else {
- $where = '(' . $this->makeWhereFromFiltres() . ')';
- }
- $where .= $this->limitToUserRights($limitedToUserRights);
-
- $orderby = is_null($orderby) ? 'book_id' : $orderby;
- $sens = is_null($sens) ? 'DESC' : $sens;
- $limit = is_null($limit) ? '' : $this->con->limit($limit);
-
- $sql = 'SELECT * FROM books_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit;
- $r = $this->con->select($sql);
- return $this->factory($r);
- }
-
- protected function limitToUserRights($utilisateur)
- {
- if ($utilisateur) {
- if (wsDroits::admin()) {
- return '';
- }
- return ' AND proprietaire IN (' . $utilisateur->ws_rights . ')';
- }
- return '';
- }
-
- protected function makeWhereFromFiltres()
- {
- if (!is_null($this->filtres)) {
- $w = array('1=1');
- if (commonFiltre::test('admin_book', $this->filtres)) {
- $w[] = 'super_admin IN (' . implode(',', array_keys($this->filtres['admin_book'])) . ')';
- }
- if (commonFiltre::test('status_book', $this->filtres)) {
- $w[] = 'status IN(' . implode(',', array_keys($this->filtres['status_book'])) . ')';
- }
- if (commonFiltre::test('revendeur_book', $this->filtres)) {
- $v = array_keys($this->filtres['revendeur_book']);
- $values = array();
- foreach ($v as $r) {
- $values[] = $this->con->escape($r);
- }
-
-
- $w[] = 'facturable IN(\'' . implode('\',\'', $values) . '\')';
- }
- return implode(' AND ', $w);
- } else {
- return '1=1';
- }
- }
-
- public function setChapters($book_id, $json)
- {
- $chapters = json_decode($json, true);
- $res = array();
-
- foreach ($chapters as $c) {
- $c['label'] = trim($c['label']);
- $n = (string)$c['page'];
- $c['label'] = trim(preg_replace('|\s+' . $n . '$|iu', '', $c['label']));
- $res[] = $c;
- }
-
- $json_chapters = json_encode($res);
-
- $c = $this->con->openCursor('books');
- $c->chapters = $json_chapters;
- $c->changedate = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
-
- if ($json_chapters && $json_chapters != '[]') {
- if (count($res) == 1) {
- if ($res[0]['label'] == '' && $res[0]['page'] == '') {
- return;
- }
- }
- $c = $this->con->openCursor('books_chapters_versions');
- $c->book_id = $book_id;
- $c->chapters = $json_chapters;
- $c->time = TIME;
- $c->insert();
- }
- }
-
- public function setTheme($book_id, $theme)
- {
- $c = $this->con->openCursor('books');
- $c->theme = $theme;
- $c->changedate = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function setStatus($book_id, $status)
- {
- $c = $this->con->openCursor('books');
- if ($status < 2) {
- $c->tache = 0;
- }
- $c->status = $status;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- return $this->selectById($book_id);
- }
-
- public function setLang($book_id, $base, $traductions)
- {
- // Cleanup user translations
- $traductions = json_decode($traductions, true);
- foreach ($traductions as $k => $v) {
- $traductions[$k] = $v;
- }
-
- $daoLang = new wsDAOLang($this->con);
- $lang = $daoLang->selectById($base);
- // Cleanup base translations
- $baseTraductions = $lang->traductions;
- foreach ($baseTraductions as $k => $v) {
- $baseTraductions[$k] = $v;
- }
- // Then compare them. If there is no differences, we don't save translations in the book
- if ($traductions == $baseTraductions) {
- $t = '';
- } else {
- $t = json_encode($traductions);
- }
-
- $c = $this->con->openCursor('books');
- $c->lang = $base;
- $c->traductions = $t;
- $c->changedate = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function setSettings($book_id, $settings)
- {
- $book = $this->selectById($book_id);
- $parametres = $book->parametres;
- $new = $settings;
- $root = ['lang', 'proprietaire_id', 'status'];
- $rootSettings = [];
- foreach ($new as $k => $v) {
- if ($k == '_empty_') {
- continue;
- }
- if (in_array($k, $root)) {
- $rootSettings[$k] = $v;
- } else {
- try {
- $parametres->$k = $v;
- } catch (Exception $e) {
-
- }
- }
- }
-
-
- $ip = array();
- if (isset($parametres->stats_exclude_ip) && trim($parametres->stats_exclude_ip) != '') {
- $list = $parametres->stats_exclude_ip;
- $list = str_replace("\r", "\n", $list);
- $e = explode("\n", $list);
- foreach ($e as $i) {
- $i = trim($i);
- if ($i == '') {
- continue;
- }
- $long = ip2long($i);
- if ($long !== false) {
- $ip[] = $long;
- }
- }
- }
-
- $file = '/home/stats/www/exclude/' . $book_id;
-
- if (count($ip)) {
- file_put_contents($file, implode(',', $ip));
- chmod($file, 0777);
- chown($file, 'stats');
- } else if (file_exists($file)) {
- unlink($file);
- }
-
- $c = $this->con->openCursor('books');
- $c->nom = $parametres->title;
- $c->parametres = serialize($parametres);
- $c->changedate = TIME;
- foreach ($rootSettings as $k => $v) {
- $c->$k = $v;
- }
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function setProprietaire($book_id, $proprietaire_id)
- {
- $c = $this->con->openCursor('books');
- $c->proprietaire = $proprietaire_id;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function setTache($book_id, $tache)
- {
- $c = $this->con->openCursor('books');
- $c->tache = $tache;
- $c->status = 2;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function setVersion($book_id, $version)
- {
- $c = $this->con->openCursor('books');
- $c->version = $version;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function touch($book_id)
- {
- $c = $this->con->openCursor('books');
- $c->changedate = TIME;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function touchCompile($book_id, $version = 'all')
- {
- $c = $this->con->openCursor('books');
- if ($version == '2') {
- $c->compiledate = TIME;
- } elseif ($version == '1') {
- $c->compile1date = TIME;
- } elseif ($version == 'html5') {
- $c->compilehtml5date = TIME;
- } else {
- $c->compiledate = TIME;
- $c->compile1date = TIME;
- $c->compilehtml5date = TIME;
- }
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- /**
- * @param $book wsBook
- * @param $version
- * @return bool
- */
- public function isUpToDate($book, $version)
- {
- $version = (string)$version;
- if ($version == '2') {
- if (!file_exists(WS_BOOKS . '/final/' . $book->book_id)) {
- return false;
- }
- if ($book->compiledate < $book->changedate) {
- return false;
- }
- } else if ($version == '1') {
- // V1
- if (!file_exists(WS_BOOKS . '/finalv1/' . $book->book_id . '/index.swf')) {
- return false;
- }
- if ($book->compile1date < $book->changedate) {
- return false;
- }
- } else if ($version == 'html5') {
- return false;
- // HTML5
- $checks = array($book->changedate, cubeFiles::filemtimeRecursive($book->getAssetDir()), cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'), cubeFiles::filemtimeRecursive(ROOT . '/inc/ws/Util/html5'));
- foreach ($checks as $check) {
- if ($check > $book->compilehtml5date) {
- return false;
- }
- }
- }
- return true;
- }
-
- public function setComposition($book_id, $pages, $setNumerotation = true)
- {
- $numerotation = array();
- $nb_pages = 0;
- foreach ($pages as $p) {
- if ($setNumerotation) {
- $numerotation[] = $p->virtual;
- }
- $nb_pages++;
- }
-
- $book = $this->selectById($book_id);
- $parametres = $book->parametres;
- $parametres->pages = $nb_pages;
-
- $c = $this->con->openCursor('books');
- $c->parametres = serialize($parametres);
- if ($setNumerotation) {
- $c->numerotation = implode(',', $numerotation);
- }
- $c->changedate = TIME;
-
- // Check if composition need to be updated
- $r = $this->con->select('SELECT * FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- $tab = array();
- $now = array();
- $ref = array();
- while ($r->fetch()) {
- $ref[$r->book_page] = array((int)$r->document_id, (int)$r->document_page);
- }
- $i = 1;
- foreach ($pages as $p) {
- $now[$i] = array((int)$p->document_id, (int)$p->document_page);
- $i++;
- }
- if ($now != $ref) {
- $this->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
-
- $c1 = $this->con->openCursor('book_pages');
- $c1->book_id = $book_id;
- $i = 1;
- foreach ($pages as $p) {
- $c1->document_id = $p->document_id;
- $c1->document_page = $p->document_page;
- $c1->book_page = $i;
- $c1->insert();
- $i++;
- }
- $c->composition_update = TIME;
- $this->saveCompositionVersion($book_id);
- }
-
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-
- public function setInstallDir($book_id, $dir, $server)
- {
- $col = 'dir_' . $server;
-
- $c = $this->con->openCursor('books');
- $c->$col = $dir;
- $c->update('WHERE book_id=\'' . $this->con->escape($book_id) . '\'');
- }
-}
class wsDAODocument extends commonDAO
{
- public static $normal = array('document_id', 'file', 'proprietaire', 'pages', 'date', 'numberSections', 'version');
+ public static $normal = array('document_id', 'file', 'proprietaire', 'pages', 'date', 'numberSections', 'version', 'region');
public static $complex = array('localInfos', 'bookmarks', 'generalInfos', 'conversionInfos', 'trim');
- public function singleton($r)
+ public function singleton($r, $init = true)
{
set_time_limit(0);
$document = new wsDocument();
$document->$k = unserialize($r->$k);
}
}
- $document->init();
+ if ($init) {
+ $document->init();
+ }
return $document;
}
return $r->document_id + 1;
}
- public function selectById($document_id)
+ public function selectById($document_id, $init = true)
{
$r = $this->con->select('SELECT * FROM documents WHERE document_id=\'' . $this->con->escape($document_id) . '\'');
- return $this->singleton($r);
+ return $this->singleton($r, $init);
}
public function selectByBookId($book_id)
\r
protected $_docs = [];\r
\r
+\r
+ protected static $_bookDirs = [];\r
+\r
public function __get($varname)\r
{\r
if (!property_exists($this, $varname)) {\r
\r
public function getAssetDir($sub = '')\r
{\r
- if($this->region==='US'){\r
- return rtrim(US_BOOKS . '/working/' . $this->getAssetDirId() . '/' . trim($sub, '/'), '/') . '/';\r
- }\r
- return rtrim(WS_BOOKS . '/working/' . $this->getAssetDirId() . '/' . trim($sub, '/'), '/') . '/';\r
+ return rtrim(wsBook::getDir($this->getAssetDirId(), 'working') . '/' . trim($sub, '/'), '/') . '/';\r
}\r
\r
public function getAssetDirId()\r
// Begin to generate files async\r
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
+ {\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
+ $res .= $dir . '/';\r
+ if (!$onlyroot) {\r
+ $res .= $id . '/';\r
+ }\r
+ if (!$addSlash) {\r
+ $res = rtrim($res, '/');\r
+ } else {\r
+ if (!file_exists($res)) {\r
+ mkdir($res, 0777, true);\r
+ }\r
+ }\r
+ return $res;\r
+ }\r
+\r
+ public static function getPackagerDir($id, $onlyroot = false)\r
+ {\r
+ if (!isset(self::$_bookDirs[$id])) {\r
+ self::$_bookDirs[$id] = self::_getRegion($id);\r
+ }\r
+ $res = (self::$_bookDirs[$id] === 'UE' ? ROOT . '/fluidbook' : US_FILES) . '/packager/';\r
+ if (!$onlyroot) {\r
+ $res .= $id . '/';\r
+ }\r
+ return $res;\r
+ }\r
+\r
+ public static function getCacheDir($id){\r
+ return (self::$_bookDirs[$id] === 'UE' ? ROOT . '/fluidbook' : US_FILES) . '/cache/';\r
+ }\r
+\r
+ protected static function _getRegion($id)\r
+ {\r
+ global $core;\r
+\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($id, true);\r
+ return $book->region;\r
+ }\r
}
\ No newline at end of file
protected $cropped;
protected $rgb;
protected $filesdata = null;
+ protected $region = 'UE';
- protected static $_docsDir;
+ protected static $_docsDir = [];
const NORMAL = 0;
const FLATTEN = 1;
}
}
- public static function getDir($id)
+ public static function _getDir($id)
{
+ global $core;
- $res = WS_DOCS . '/' . $id . '/';
+ $dao = new wsDAODocument($core->con);
+ $doc = $dao->selectById($id, false);
+ if ($doc->region === 'UE') {
+ $res = WS_DOCS . '/' . $id . '/';
+ } else {
+ $res = US_DOCS . '/' . $id . '/';
+ }
if (!file_exists($res)) {
mkdir($res, 0777, true);
}
return $res;
}
+ public static function getDir($id)
+ {
+ if (!isset(self::$_docsDir[$id])) {
+ self::$_docsDir[$id] = self::_getDir($id);
+ }
+ return self::$_docsDir[$id];
+ }
+
// public static function makeHTML5FilesIfNotExists($document_id, $document_page, $format = 'jpg')
// {
// global $core;
public static function getLinksDir($book_id)
{
- $dir = WS_BOOKS . '/links/' . $book_id;
+ $dir = wsBook::getDir($book_id,'links');
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
return false;\r
}\r
\r
- $cacheDir = WS_BOOKS . '/pdf/' . $book->book_id;\r
+ $cacheDir = wsBook::getDir($book->book_id, 'pdf');\r
if (!file_exists($cacheDir)) {\r
mkdir($cacheDir, 0777, true);\r
}\r
\r
- $normalPDF = $cacheDir . '/normal.pdf';\r
- $originalPDF = $cacheDir . '/original.pdf';\r
- $compressedPDF = $cacheDir . '/compressed.pdf';\r
+ $normalPDF = $cacheDir . 'normal.pdf';\r
+ $originalPDF = $cacheDir . 'original.pdf';\r
+ $compressedPDF = $cacheDir . 'compressed.pdf';\r
\r
$files = [$normalPDF, $originalPDF, $compressedPDF];\r
\r
if ($invalid) {\r
\r
if (file_exists($originalPDF)) {\r
- self::copy($originalPDF, $cacheDir . '/original.' . TIME . '.pdf', false);\r
+ self::copy($originalPDF, $cacheDir . 'original.' . TIME . '.pdf', false);\r
}\r
\r
$pdfList = array();\r
\r
$args .= ' output ' . $originalPDF;\r
\r
- $cached = WS_BOOKS . '/pdf/' . $hash . '.pdf';\r
+ $cached = wsBook::getDir($book->book_id, 'pdf', true, true) . $hash . '.pdf';\r
\r
if (file_exists($cached) && filesize($cached) > 0) {\r
self::copy($cached, $originalPDF, false);\r
if ($forceThemeId) {
$id .= '-' . $forceThemeId;
}
- $this->dir = WS_BOOKS . '/html5/' . $id . '/';
+ $this->dir = wsBook::getDir($id, 'html5');
} else {
$this->dir = $dir;
}
if ($voiceInfos) {
$hash = hash('sha256', $voiceInfos . '_^_' . $text);
$fname = $hash . '.mp3';
- $dir = WS_BOOKS . '/audiodescription/';
- if (!file_exists($dir)) {
- mkdir($dir, 0777, true);
- }
+ $dir = wsBook::getDir($this->book_id, 'audiodescription', true, true);
$file = $dir . $fname;
public function writeTexts()
{
$cache = sha1($this->book->parametres->highlightResults . '/--/' . $this->book->parametres->searchWordSelectionAlgorithm . '///' . $this->book->parametres->textExtraction . '|--|' . $this->book->parametres->ignoreSearchSeparators . '|||' . $this->book->composition_update . '()()()' . filemtime(WS_TOOLS . '/fwstk/out/artifacts/fwstk_jar/fwstk.jar'));
- $cacheDir = WS_BOOKS . '/index/' . $this->book_id . '/' . $cache . '/';
+ $cacheDir = wsBook::getDir( $this->book_id,'index').'cache/';
if (!file_exists($cacheDir)) {
mkdir($cacheDir, 0777, true);
$init = wsLinks::decryptLink($init);
$init = CubeIT_Util_Array::asArray($init);
- $wdir = WS_BOOKS . '/' . $id . '/working/';
+ $wdir = wsBook::getDir($id, 'working');
$init['scorm'] = self::isScorm($init);
$init['to'] = self::replaceCustomURL($init['to']);
$leftfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
$extractPage,
array('x' => $x, 'y' => $y, 'width' => $w, 'height' => $h),
- $left, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
+ $left, $extractOptions, wsBook::getCacheDir($compiler->book_id) . $cachedir . '/' . $compiler->book_id . '/');
if (!file_exists($leftfile)) {
die('Error generating left part ' . $leftfile);
$rightfile = CubeIT_CommandLine_Poppler::extractArea($pdfpath,
$extractPage,
array('x' => 0, 'y' => $y, 'width' => $diff, 'height' => $h),
- $right, $extractOptions, WS_CACHE . '/' . $cachedir . '/' . $compiler->book_id . '/');
+ $right, $extractOptions, wsBook::getCacheDir($compiler->book_id) . $cachedir . '/' . $compiler->book_id . '/');
if (!file_exists($rightfile)) {
die('Error generating right part ' . $rightfile);
}\r
$html = str_replace('<!-- $base -->', $base, $html);\r
\r
- $dir = WS_BOOKS . '/seo/' . $this->_container->compiler->book_id . '/';\r
+ $dir = wsBook::getDir( $this->_container->compiler->book_id,'seo');\r
if (!file_exists($dir)) {\r
mkdir($dir, 0777, true);\r
}\r
$cp->setPath(CONVERTER_PATH);
$cp->setArg('r');
$cp->setArg('p');
- $cp->setArg(null, WS_BOOKS . '/html5/' . $bookId . '/*');
+ $cp->setArg(null, wsBook::getDir($bookId, 'html5') . '*');
$cp->setArg(null, $dest);
$cp->execute();
$this->copyFluidbookFiles();\r
$this->makeJSON();\r
\r
- $this->buildPath = WS_PACKAGER . '/nwbuild/' . $this->version . '/' . $this->book_id;\r
+\r
+ $this->buildPath = wsBook::getPackagerDir($this->book_id, true) . 'nwbuild/' . $this->version . '/' . $this->book_id;\r
if (!file_exists($this->buildPath)) {\r
mkdir($this->buildPath, 0777, true);\r
}\r
$cl->debug();\r
\r
$this->replaceFFMpeg();\r
- if(!file_exists($this->getAppPath())){\r
- die('Error while building mac app : '.$cl->commande.' // '.$cl->output);\r
+ if (!file_exists($this->getAppPath())) {\r
+ die('Error while building mac app : ' . $cl->commande . ' // ' . $cl->output);\r
}\r
\r
$this->signApp();\r
$this->book_id = $book_id;
$this->vdir = $vdir;
- $this->dir = ROOT . '/fluidbook/packager/' . $book_id . '/';
+ $this->dir = wsBook::getPackagerDir($book_id);
$this->whole = $whole;
if (!file_exists($this->dir)) {
protected function copyFluidbookFiles()
{
- // Copie du FB vers un répertoire temporaire
- $cp = new cubeCommandLine('cp');
- $cp->setArg('R');
- $cp->setArg('p');
- $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*');
- $cp->setArg(null, $this->vdir);
- $cp->execute();
+
}
protected function copyOtherFiles($files)
protected function getURLBase($ext = '')
{
- $res = '/fluidbook' . $this->getRelativeBase();
+ if ($this->book->region === 'UE') {
+ $res = '/fluidbook';
+ } else {
+ $res = '/usstorage';
+ }
+
+
+ $res = $this->getRelativeBase();
if ($ext != '') {
$res .= '.' . $ext;
}
protected function getPathBase($ext = '')
{
- $res = WS_FILES . $this->getRelativeBase();
+ if ($this->book->region === 'UE') {
+ $base = WS_FILES;
+ } else {
+ $res = US_FILES;
+ }
+ if (!file_exists($base . '/packager/download')) {
+ mkdir($base . '/packager/download', 0777, true);
+ }
+ $res = $base . $this->getRelativeBase();
if ($ext != '') {
$res .= '.' . $ext;
}
$zip->debug();
}
- if (!file_exists(WS_FILES . '/packager/download')) {
- mkdir(WS_FILES . '/packager/download', 0777, true);
- }
-
if ($rename) {
rename($zipfile, $final);
}
public function getFinalPackageDir()
{
$dir = $this->vdir;
- $dir .= '/m/';
+ $dir .= '/m/';
return $dir;
}
$cp = new cubeCommandLine('cp');\r
$cp->setArg('R');\r
$cp->setArg('p');\r
- $cp->setArg(null, WS_BOOKS . '/html5/' . $this->book->book_id . '/*');\r
+ $cp->setArg(null, wsBook::getDir($this->book->book_id, 'html5') . '*');\r
$cp->setArg(null, $this->vdir);\r
$cp->execute();\r
\r
$lang->nsis = 'English';\r
}\r
\r
- if (!file_exists(WS_FILES . '/packager/download')) {\r
- mkdir(WS_FILES . '/packager/download', 0777, true);\r
- }\r
-\r
$fname = $this->exeName;\r
$title = $this->appName;\r
\r