From: vincent@cubedesigners.com Date: Fri, 16 Feb 2018 15:53:02 +0000 (+0000) Subject: #1993 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8c0907df7cab031ee71ca2e04bf068931dfddcef;p=cubeextranet.git #1993 --- diff --git a/.htaccess b/.htaccess index a2b022692..bd87e9dd3 100644 --- a/.htaccess +++ b/.htaccess @@ -4,6 +4,8 @@ Options +FollowSymlinks AddDefaultCharset UTF-8 AddCharset UTF-8 log + + # Static # ExpiresActive On @@ -63,6 +65,8 @@ AddCharset UTF-8 log RewriteCond %{HTTP_HOST} fluidbook RewriteRule ^favicon.ico$ images/ws/favicon.ico [L] + RewriteRule ^index.php/(.*)$ - [L] + RewriteRule ^voir_book/(.*)$ viewer1/$1 [L,R=301] RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L] diff --git a/inc/postconfig.inc.php b/inc/postconfig.inc.php index 9baa3bc95..cfffff184 100644 --- a/inc/postconfig.inc.php +++ b/inc/postconfig.inc.php @@ -18,9 +18,16 @@ define('DEV', $dev); //define('DB_HOST', ':/var/run/mysqld/mysqld.sock'); -define('AMARCORD', true); -define('SERVER', 'avanger'); -define('DB_HOST', 'alien.cubedesigners.com'); + +if ($_SERVER['SERVER_ADDR'] == '147.135.136.182') { + define('SERVER', 'alien'); + define('DB_HOST', 'localhost'); + define('AMARCORD', false); +} else { + define('AMARCORD', true); + define('SERVER', 'amarcord'); + define('DB_HOST', 'alien.cubedesigners.com'); +} define('DB_NAME', 'extranet'); define('DB_USER', 'extranet'); define('DB_PASSWORD', 'WvcAeYBDnrB93RXa'); diff --git a/inc/ws/Controlleur/class.ws.conversion.session.php b/inc/ws/Controlleur/class.ws.conversion.session.php index 0a17859a1..c7891046d 100644 --- a/inc/ws/Controlleur/class.ws.conversion.session.php +++ b/inc/ws/Controlleur/class.ws.conversion.session.php @@ -126,6 +126,9 @@ class wsConversionSession { $this->currentDoc = unserialize($doc_serialized); $core->reloadDBConnection(); + $dao = new wsDAODocument($core->con); + $daoBook = new wsDAOBook($core->con); + if (!$this->reload) { // On n'ajoute les fichiers à la fin du fluidbook que si l'on // n'est pas en train de recharger le fluidbook @@ -138,6 +141,7 @@ class wsConversionSession { } $this->processedDoc++; + ob_flush(); } @@ -168,12 +172,12 @@ class wsConversionSession { public function getProgress() { $res = array("progress" => $this->progress, - 'totalDoc' => $this->totalDoc, - 'currentDocPage' => $this->currentDocPage, - 'totalDocPage' => $this->totalDocPage, - 'totalPages' => $this->totalPages, - 'processedPages' => $this->processedPages, - 'processedDoc' => max($this->processedDoc + 1, $this->totalDoc)); + 'totalDoc' => $this->totalDoc, + 'currentDocPage' => $this->currentDocPage, + 'totalDocPage' => $this->totalDocPage, + 'totalPages' => $this->totalPages, + 'processedPages' => $this->processedPages, + 'processedDoc' => max($this->processedDoc + 1, $this->totalDoc)); if ($this->currentDoc) { $res['currentDoc'] = $this->currentDoc->file; } @@ -204,7 +208,7 @@ class wsConversionSession { } public function __destruct() { - + } public static function openFromGUID($guid) { @@ -220,6 +224,4 @@ class wsConversionSession { return CACHE . '/conversionSessions/' . $guid . '.obj'; } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.droits.php b/inc/ws/Controlleur/class.ws.droits.php index 1756e8270..caedb25bb 100644 --- a/inc/ws/Controlleur/class.ws.droits.php +++ b/inc/ws/Controlleur/class.ws.droits.php @@ -58,7 +58,8 @@ class wsDroits { protected static function gradeIn($list, $error = false) { global $core; - if (!in_array($core->user->ws_grade, $list)) { + + if (null === $core->user || !isset($core->user->ws_grade) || !in_array($core->user->ws_grade, $list)) { if ($error) { commonDroits::error(); } @@ -91,7 +92,7 @@ class wsDroits { if (!$admin && !in_array($signature->signature_id, $mySignatures)) { continue; } - if(!$signature->active){ + if (!$signature->active) { continue; } $res[$signature->nom] = $signature->signature_id; diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 70f0d1672..f491aba6c 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -112,12 +112,14 @@ class wsFlash extends cubeFlashGateway { $php = new cubeCommandLine($executable); $php->setPath(CONVERTER_PATH); $php->setArg('f', ROOT . '/index.php'); + $php->setArg('d', 'memory_limit=4G'); $php->setManualArg('--'); $php->setArg('user_email', $_SESSION['user_email']); $php->setArg('user_password', $_SESSION['user_password']); $php->setArg('sessionConversionGUID', $sessionConversionGUID); $php->setArg('PATH_INFO', '/flash/processConversionSessionAsync'); $php->setArg('HTTP_HOST', $_SERVER['HTTP_HOST']); + $php->setArg('SERVER_ADDR', $_SERVER['SERVER_ADDR']); $php->setNohup(true); $php->execute('exec'); @@ -419,7 +421,7 @@ class wsFlash extends cubeFlashGateway { $i->addAttribute('id', $icone->icone_id); $i->addAttribute('nom', $icone->nom); $i->addAttribute('path', ICONS . $icone->icone_id . '.png'); - $i->addAttribute('main', in_array($icone->icone_id,array(13, 15))); + $i->addAttribute('main', in_array($icone->icone_id, array(13, 15))); } } diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 5f560cfc2..d820dd2e7 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -792,7 +792,6 @@ class wsMaintenance { $comp = unserialize($r->composition); $core->con->execute('DELETE FROM book_pages WHERE book_id=\'' . $core->con->escape($book_id) . '\''); - $c = $core->con->openCursor('book_pages'); $c->book_id = $book_id; foreach ($comp as $book_page => $infos) { @@ -1117,7 +1116,7 @@ class wsMaintenance { $fwstk->setPath(CONVERTER_PATH); $fwstk->setArg('--input ' . $out . '/crop.pdf'); $fwstk->setArg('--extractTexts ' . $out . '%s%d.txt'); - $fwstk->setArg('--extractTextsMethod ' . $book->parametres->textExtraction); + $fwstk->setArg('--extractTextsMethod ' . $book->parametres->textExtraction); if ($book->parametres->ignoreSearchSeparators != '') { $fwstk->setArg('--ignoreSeparators ' . $book->parametres->ignoreSearchSeparators); } @@ -1290,6 +1289,7 @@ class wsMaintenance { echo 'error : ' . implode(', ', $error) . '
'; } + public static function getSVGPage($args) { global $core; @@ -1318,10 +1318,9 @@ class wsMaintenance { exit; } - public function testSVG() { - $test = '/home/extranet/www/fluidbook/docs/115864/html/test.svg'; - copy('/home/extranet/www/fluidbook/docs/115864/html/tp1.svg', $test); - wsDocument::cleanSVG($test, true); + public static function testSVG() { + $test = '/home/extranet/www/fluidbook/docs/117077/html/zz%s.svg'; + echo wsTools::optimizeSVG('/home/extranet/www/fluidbook/docs/117077/html/fp11.svg', $test, [150, 300], true); } // public function addSearch() { diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php index e905e1f2a..aa8e6ff4b 100644 --- a/inc/ws/Controlleur/class.ws.stats.php +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -52,13 +52,15 @@ class wsStats { self::forceComputation($bid); - cubePHP::set_memory('512M'); + cubePHP::set_memory('4G'); self::$xls = new PHPExcel(); self::$xls->removeSheetByIndex(0); + $global = self::load_stats($bid); + $exporturl = SITE_PATH . 'statsxls/' . $bid; if (!is_null($annee)) { $exporturl .= '/' . $annee; @@ -75,6 +77,7 @@ class wsStats { $listeShortcuts = array(); + $listeMois = null; foreach ($years as $y) { $selectedYear = __('Toutes'); @@ -95,6 +98,7 @@ class wsStats { } $annees[(string)$y['year']] = SITE_PATH . 'stats/' . $bid . '/' . (string)$y['year']; } + $listeAnnees = new commonShortcuts(__('Année'), $annees, $selectedYear); $listeShortcuts[] = $listeAnnees; if (!is_null($listeMois)) { @@ -117,8 +121,11 @@ class wsStats { self::$xls->setActiveSheetIndex(0); $writer = new PHPExcel_Writer_Excel2007(); $writer->setPHPExcel(self::$xls); - $writer->save(self::_getXLSFile($bid, $annee, $mois)); + $xlsfile = self::_getXLSFile($bid, $annee, $mois); + cubePHP::set_memory('4G'); + $writer->save($xlsfile); } catch (Exception $e) { + die($e->getMessage()); } return $res; diff --git a/inc/ws/Metier/class.ws.box.php b/inc/ws/Metier/class.ws.box.php index d0558f59a..046fbf64a 100644 --- a/inc/ws/Metier/class.ws.box.php +++ b/inc/ws/Metier/class.ws.box.php @@ -2,23 +2,21 @@ class wsBox extends cubeMetier { - protected $top; - protected $left; - protected $right; - protected $bottom; - protected $width; - protected $height; + protected $top; + protected $left; + protected $right; + protected $bottom; + protected $width; + protected $height; - public function __construct($top, $left, $right, $bottom) { - $this->top = $top; - $this->left = $left; - $this->right = $right; - $this->bottom = $bottom; + public function __construct($top, $left, $right, $bottom) { + $this->top = $top; + $this->left = $left; + $this->right = $right; + $this->bottom = $bottom; - $this->width = $this->right - $this->left; - $this->height = $this->bottom - $this->top; - } + $this->width = floatval($this->right) - floatval($this->left); + $this->height = floatval($this->bottom) - floatval($this->top); + } } - -?> \ No newline at end of file diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 2560509a9..5b817725b 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -120,11 +120,17 @@ class wsDocument extends cubeMetier { $out .= "\n"; $out .= $pdfinfo->output; + $this->addToLog('Parse infos'); $this->parseInfos($out); + $this->addToLog('Set Page Infos'); $this->conversionInfos->setPageNumber($this->generalInfos['pages']); + $this->addToLog('Write infos'); file_put_contents($this->infos, $out); + + $this->addToLog('Find cut disposition'); + $this->findCutDisposition(); } @@ -134,6 +140,7 @@ class wsDocument extends cubeMetier { } protected function detectPageDifferences() { + $this->addToLog('Detect page differences'); // Vérifie si la cropbox et la trimbox sont identiques pour toutes les pages $difference = false; foreach ($this->generalInfos['page'] as $page => $infos) { @@ -166,6 +173,7 @@ class wsDocument extends cubeMetier { } protected function detectSpreads() { + $this->addToLog('Detect spreads'); // Détection des spreads $this->autocut = false; @@ -221,6 +229,7 @@ class wsDocument extends cubeMetier { } public function parseInfos($data) { + cubePHP::set_memory('4G'); // This function get general infos (pages sizes, boxes, number sections and // bookmarks // Init arrays @@ -265,8 +274,6 @@ class wsDocument extends cubeMetier { $this->numberSections = $v; } } - - return $res; } @@ -276,14 +283,33 @@ class wsDocument extends cubeMetier { } public function globalOperations() { + $this->addToLog('Get infos'); $this->getInfos(); if ($this->CropAndCut()) { + $this->addToLog('Get infos after crop'); $this->getInfos($this->cropped, true); } + $this->addToLog('Get links'); $this->getLinks(); + $this->addToLog('End of global ops'); + $this->splitDoc(); + } + + public function splitDoc() { + $this->addToLog('Split document'); + mkdir($this->out . '/pdf'); + $pdftk = new cubeCommandLine('pdftk'); + $pdftk->setPath(CONVERTER_PATH); + $pdftk->setArg(null, $this->cropped); + $pdftk->setArg(null, 'burst'); + $pdftk->setArg(null, 'output'); + $pdftk->setArg(null, $this->out . 'pdf/p%d.pdf'); + $pdftk->execute(); + $this->addToLog($pdftk); } public function CropAndCut() { + $this->addToLog('Crop And Cut'); if (!$this->isCropped()) { $this->lnCrop(); return false; @@ -782,7 +808,7 @@ class wsDocument extends cubeMetier { $pdf2swf = new cubeCommandLine($program, null, true); $pdf2swf->setPath(CONVERTER_PATH); - $pdf2swf->setArg('p', $page); + $pdf2swf->setArg('p', 1); $flashversion = 10; if ($method == self::NORMAL) { @@ -820,8 +846,8 @@ class wsDocument extends cubeMetier { $pdf2swf->setArg(null, '-T7'); $pdf2swf->setArg('set alignfonts'); } - $pdf2swf->setArg(null, $this->cropped); - $pdf2swf->setArg('output', $this->out . $prefix . '%.swf'); + $pdf2swf->setArg(null, $this->out . 'pdf/p' . $page . '.pdf'); + $pdf2swf->setArg('output', $this->out . $prefix . $page . '.swf'); $pdf2swf->execute(); if ($version == 'git') { @@ -892,7 +918,7 @@ class wsDocument extends cubeMetier { $pdf2swf = new cubeCommandLine('pdf2swf', null, true); $pdf2swf->setPath(CONVERTER_PATH); $pdf2swf->setArg('set poly2bitmap'); - $pdf2swf->setArg('p', $page); + $pdf2swf->setArg('p', 1); $pdf2swf->setArg('stop'); $pdf2swf->setArg('T', 10); $pdf2swf->setArg('set reordertags', '0'); @@ -909,7 +935,7 @@ class wsDocument extends cubeMetier { $pdf2swf->setArg('set subpixels', '0.01'); $pdf2swf->setArg('set jpegquality', '1'); $pdf2swf->setArg('set disablelinks'); - $pdf2swf->setArg(null, $this->cropped); + $pdf2swf->setArg(null, $this->out . 'pdf/p' . $page . '.pdf'); $pdf2swf->setArg('output', $this->out . 't' . $page . '.swf'); $pdf2swf->execute(); $this->addToLog($pdf2swf, true, $page); @@ -975,7 +1001,7 @@ class wsDocument extends cubeMetier { } $new = WS_DOCS . '/' . $id . '/'; - $old = '/mnt/sshfs/batman/home/extranet/www/fluidbook/docs/' . $id . '/'; + $old = WS_FILES . '/docs1/' . $id . '/'; if (file_exists($new . 'p1.swf')) { self::$_docsDir[$id] = $new; diff --git a/inc/ws/Util/class.ws.tools.php b/inc/ws/Util/class.ws.tools.php index 9a19a5d57..139d21be2 100644 --- a/inc/ws/Util/class.ws.tools.php +++ b/inc/ws/Util/class.ws.tools.php @@ -2,6 +2,8 @@ class wsTools { + protected static $_r; + public static function encodeWebVideos($file, $dir = null, $async = true, $force = false, $format = 'all') { if (is_null($dir)) { $dir = dirname($file); @@ -136,9 +138,10 @@ class wsTools { } } - public static function optimizeSVG($original, $optimized, $force = false) { + public static function optimizeSVG($original, $optimized, $resolutions = [], $force = false) { + if (!file_exists($original)) { - return; + return 'doesnt exists'; } $optimize = $force || @@ -151,12 +154,26 @@ class wsTools { $cmd = "/usr/local/bin/svgcleaner --allow-bigger-file --paths-coordinates-precision 3 --copy-on-error --stdout $original"; $svg = `$cmd`; $svg = substr_replace($svg, 'preserveAspectRatio="none" ', 5, 0); - file_put_contents($optimized, $svg); + $fname = str_replace('%s', '', $optimized); + file_put_contents($fname, $svg); + + if (count($resolutions) > 0) { + foreach ($resolutions as $resolution) { + self::$_r = $resolution; + $osvg = preg_replace_callback('|\]*)\>|', 'wsTools::optimizeRaster', $svg); + file_put_contents(sprintf($optimized, '-' . $resolution), $osvg); + } + } return true; } return false; } + public static function optimizeRaster($matches) { + + return ''; + } + public static function copy($source, $dest) { if (!file_exists($source)) { return; 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 1fb4700e2..24e639e2d 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -1351,6 +1351,7 @@ class wsHTML5Compiler { $lessVariables['z'] = $this->z; $lessVariables['book-page-width'] = $w; $lessVariables['book-page-height'] = $h; + $lessVariables['book-page-ratio'] = $w / $h; $lessVariables['shadow-opacity'] = wsHTML5::colorToArray($this->theme->parametres->bookShadeColor)['opacity'] * 1.2; $lessVariables['edges-display'] = $this->_lessBoolean($this->theme->parametres->usePageEdges); diff --git a/index.php b/index.php index 9aefacc87..f23ea3c0d 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,5 @@ setEnabled(); - require_once(dirname(__FILE__) . '/inc/prepend.php'); - -//ChromePhp::log($_SERVER); ob_start(); header('Access-Control-Allow-Origin: *'); @@ -26,5 +20,7 @@ $standard = 'XHTML 1.0 Transitional'; echo $core->url->getDocument(); $buffer = ob_get_contents(); +cubePHP::set_memory('4G'); + ob_clean(); echo cubePage::page($buffer, $js, $jsvar, $css, array(), 9, false, $meta, array(), $standard); diff --git a/info.php b/info.php new file mode 100644 index 000000000..2786b5e11 --- /dev/null +++ b/info.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/swf/_src/WSComposer.as3proj b/swf/_src/WSComposer.as3proj index aba683de2..a35a02df0 100644 --- a/swf/_src/WSComposer.as3proj +++ b/swf/_src/WSComposer.as3proj @@ -91,7 +91,7 @@ - "H:\Applications\PortableApps\PuTTYPortable\App\PuTTY\pscp.exe" -agent -batch "$(OutputDir)\$(OutputName)" extranet@extranet.cubedesigners.com:/home/extranet/www/swf + "C:\ProgramData\chocolatey\lib\kitty\tools\kscp.exe" -agent -batch "$(OutputDir)\$(OutputName)" extranet@extranet.cubedesigners.com:/home/extranet/www/swf