From: vincent@cubedesigners.com Date: Tue, 11 Jul 2017 10:31:10 +0000 (+0000) Subject: fix #1549 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4e56189f2fbfed099a84e83c428601c67f2acd8c;p=cubeextranet.git fix #1549 @2 --- diff --git a/.htaccess b/.htaccess index 6a63fab38..84749924c 100644 --- a/.htaccess +++ b/.htaccess @@ -49,6 +49,8 @@ AddCharset UTF-8 log RewriteCond %{HTTP_HOST} extranet.cubedesigners.com RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] + RewriteRule (.{255}) index.php/$1 [L,QSA] + # Docs RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 85d96928a..90af441b9 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -342,49 +342,56 @@ class wsServices extends cubeFlashGateway { $range[$k] = $r->pages; } - if (!count($range)) { - return; - } + $range = array_unique($range); + sort($range); + + // Paths init $baseDocument = $this->getPDFComplexBaseDocument($book); - fb($baseDocument, '!!'); + if (!file_exists($baseDocument)) { - fb('not exists'); return; } + + if (!count($range)) { + return; + } + + $destDir = WS_CACHE . '/exportpdf/' . $book->cid; if (!file_exists($destDir)) { mkdir($destDir, 0777, true); } $fname = md5(implode(',%ù', $range)) . '.pdf'; - fb($fname); $destFile = $destDir . '/' . $fname; $destURL = '/fluidbook/cache/exportpdf/' . $book->cid . '/' . $fname; - fb($destFile); // If result exists, don't make the pdf again if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) { - fb('already exists'); + } else { - // Prepare the command line - $l = array('A="' . $baseDocument . '"', 'cat'); - foreach ($range as $page) { - if ($page < 1 || $page > $book->parametres->pages) { - continue; + if ($range[0] == 1 && count($range) == $book->parametres->pages && $range[$book->parametres->pages - 1] == $book->parametres->pages) { + `cp $baseDocument $destFile`; + } else { + + // Prepare the command line + $l = array('A="' . $baseDocument . '"', 'cat'); + foreach ($range as $page) { + if ($page < 1 || $page > $book->parametres->pages) { + continue; + } + $l[] = 'A' . $page; } - $l[] = 'A' . $page; + $l[] = 'output'; + $l[] = $destFile; + + $args = implode(' ', $l); + // Execute the command line + $pdftk = new cubeCommandLine('pdftk'); + $pdftk->setPath(CONVERTER_PATH); + $pdftk->setManualArg($args); + $pdftk->execute(); } - $l[] = 'output'; - $l[] = $destFile; - - $args = implode(' ', $l); - // Execute the command line - $pdftk = new cubeCommandLine('pdftk'); - $pdftk->setPath(CONVERTER_PATH); - $pdftk->setManualArg($args); - $pdftk->execute(); - fb($pdftk->commande); - fb($pdftk->output); } return array('url' => $destURL, 'file' => $destFile); @@ -425,6 +432,8 @@ class wsServices extends cubeFlashGateway { public function exportpdf($print = false) { global $core; + set_time_limit(0); + $dao = new wsDAOBook($core->con); if (isset($this->args['cid'])) { $book = $dao->selectByCid($this->args['cid']); diff --git a/index.php b/index.php index a5a9578f6..9aefacc87 100644 --- a/index.php +++ b/index.php @@ -5,7 +5,7 @@ ChromePhp::getInstance()->setEnabled(); require_once(dirname(__FILE__) . '/inc/prepend.php'); -ChromePhp::log($_SERVER); +//ChromePhp::log($_SERVER); ob_start(); header('Access-Control-Allow-Origin: *');