]> _ Git - cubeextranet.git/commitdiff
#1993
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 16 Feb 2018 15:53:02 +0000 (15:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 16 Feb 2018 15:53:02 +0000 (15:53 +0000)
14 files changed:
.htaccess
inc/postconfig.inc.php
inc/ws/Controlleur/class.ws.conversion.session.php
inc/ws/Controlleur/class.ws.droits.php
inc/ws/Controlleur/class.ws.flash.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Controlleur/class.ws.stats.php
inc/ws/Metier/class.ws.box.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/class.ws.tools.php
inc/ws/Util/html5/master/class.ws.html5.compiler.php
index.php
info.php [new file with mode: 0644]
swf/_src/WSComposer.as3proj

index a2b022692dc8e985941e9d0efdd9553311b61372..bd87e9dd3fef8fa2365a0ab2b32b4eb88374f5bb 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -4,6 +4,8 @@ Options +FollowSymlinks
 AddDefaultCharset UTF-8\r
 AddCharset UTF-8 log\r
 \r
+\r
+\r
 # Static\r
 <IfModule mod_expires.c>\r
 #      ExpiresActive On\r
@@ -63,6 +65,8 @@ AddCharset UTF-8 log
        RewriteCond %{HTTP_HOST} fluidbook\r
        RewriteRule ^favicon.ico$ images/ws/favicon.ico [L]\r
 \r
+       RewriteRule ^index.php/(.*)$ - [L]\r
+\r
        RewriteRule ^voir_book/(.*)$ viewer1/$1 [L,R=301]\r
 \r
        RewriteRule ^ajax/supprimeFichier/([0-9]+)/(.*)$ index.php/ajax/supprimeFichier/$1/$2 [L]\r
index 9baa3bc95afb99cc6ace99c63a0f88616ed47d41..cfffff18455ecab5ce310ba7a1d6a9494afffd47 100644 (file)
@@ -18,9 +18,16 @@ define('DEV', $dev);
 //define('DB_HOST', ':/var/run/mysqld/mysqld.sock');\r
 \r
 \r
-define('AMARCORD', true);\r
-define('SERVER', 'avanger');\r
-define('DB_HOST', 'alien.cubedesigners.com');\r
+\r
+if ($_SERVER['SERVER_ADDR'] == '147.135.136.182') {\r
+       define('SERVER', 'alien');\r
+       define('DB_HOST', 'localhost');\r
+       define('AMARCORD', false);\r
+} else {\r
+       define('AMARCORD', true);\r
+       define('SERVER', 'amarcord');\r
+       define('DB_HOST', 'alien.cubedesigners.com');\r
+}\r
 define('DB_NAME', 'extranet');\r
 define('DB_USER', 'extranet');\r
 define('DB_PASSWORD', 'WvcAeYBDnrB93RXa');\r
index 0a17859a1a870d96de168aadfb73135478bf96f0..c7891046d83232399f4ea361073a7f5e84a82ea2 100644 (file)
@@ -126,6 +126,9 @@ class wsConversionSession {
                        $this->currentDoc = unserialize($doc_serialized);\r
 \r
                        $core->reloadDBConnection();\r
+                       $dao = new wsDAODocument($core->con);\r
+                       $daoBook = new wsDAOBook($core->con);\r
+\r
                        if (!$this->reload) {\r
                                // On n'ajoute les fichiers à la fin du fluidbook que si l'on\r
                                // n'est pas en train de recharger le fluidbook\r
@@ -138,6 +141,7 @@ class wsConversionSession {
                        }\r
                        $this->processedDoc++;\r
 \r
+\r
                        ob_flush();\r
                }\r
 \r
@@ -168,12 +172,12 @@ class wsConversionSession {
 \r
        public function getProgress() {\r
                $res = array("progress" => $this->progress,\r
-                       'totalDoc' => $this->totalDoc,\r
-                       'currentDocPage' => $this->currentDocPage,\r
-                       'totalDocPage' => $this->totalDocPage,\r
-                       'totalPages' => $this->totalPages,\r
-                       'processedPages' => $this->processedPages,\r
-                       'processedDoc' => max($this->processedDoc + 1, $this->totalDoc));\r
+                            'totalDoc' => $this->totalDoc,\r
+                            'currentDocPage' => $this->currentDocPage,\r
+                            'totalDocPage' => $this->totalDocPage,\r
+                            'totalPages' => $this->totalPages,\r
+                            'processedPages' => $this->processedPages,\r
+                            'processedDoc' => max($this->processedDoc + 1, $this->totalDoc));\r
                if ($this->currentDoc) {\r
                        $res['currentDoc'] = $this->currentDoc->file;\r
                }\r
@@ -204,7 +208,7 @@ class wsConversionSession {
        }\r
 \r
        public function __destruct() {\r
-               \r
+\r
        }\r
 \r
        public static function openFromGUID($guid) {\r
@@ -220,6 +224,4 @@ class wsConversionSession {
                return CACHE . '/conversionSessions/' . $guid . '.obj';\r
        }\r
 \r
-}\r
-\r
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 1756e82707e5b19ddae9cfdc51f289687d2b442c..caedb25bbd18926857ab8088d0c76c060e45536f 100644 (file)
@@ -58,7 +58,8 @@ class wsDroits {
 \r
        protected static function gradeIn($list, $error = false) {\r
                global $core;\r
-               if (!in_array($core->user->ws_grade, $list)) {\r
+\r
+               if (null === $core->user || !isset($core->user->ws_grade) || !in_array($core->user->ws_grade, $list)) {\r
                        if ($error) {\r
                                commonDroits::error();\r
                        }\r
@@ -91,7 +92,7 @@ class wsDroits {
                        if (!$admin && !in_array($signature->signature_id, $mySignatures)) {\r
                                continue;\r
                        }\r
-                       if(!$signature->active){\r
+                       if (!$signature->active) {\r
                                continue;\r
                        }\r
                        $res[$signature->nom] = $signature->signature_id;\r
index 70f0d1672dcb7f7cac2a575a5c90268263b6f5d4..f491aba6c34b97983f60d9ec23fd88c634dcde37 100644 (file)
@@ -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)));
                }
        }
 
index 5f560cfc20ecb7fa6a0263f17d93710f8ddd50fd..d820dd2e79c7ce443e2a6fc129cf4901a385ae7a 100644 (file)
@@ -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) . '<br />';
        }
 
+
        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() {
index e905e1f2a8fdf11c83075504c4c28e102e2ba19c..aa8e6ff4b129ddd60e84b5770ad366b461efc61b 100644 (file)
@@ -52,13 +52,15 @@ class wsStats {
 \r
                self::forceComputation($bid);\r
 \r
-               cubePHP::set_memory('512M');\r
+               cubePHP::set_memory('4G');\r
 \r
                self::$xls = new PHPExcel();\r
                self::$xls->removeSheetByIndex(0);\r
 \r
+\r
                $global = self::load_stats($bid);\r
 \r
+\r
                $exporturl = SITE_PATH . 'statsxls/' . $bid;\r
                if (!is_null($annee)) {\r
                        $exporturl .= '/' . $annee;\r
@@ -75,6 +77,7 @@ class wsStats {
 \r
                $listeShortcuts = array();\r
 \r
+\r
                $listeMois = null;\r
                foreach ($years as $y) {\r
                        $selectedYear = __('Toutes');\r
@@ -95,6 +98,7 @@ class wsStats {
                        }\r
                        $annees[(string)$y['year']] = SITE_PATH . 'stats/' . $bid . '/' . (string)$y['year'];\r
                }\r
+\r
                $listeAnnees = new commonShortcuts(__('Année'), $annees, $selectedYear);\r
                $listeShortcuts[] = $listeAnnees;\r
                if (!is_null($listeMois)) {\r
@@ -117,8 +121,11 @@ class wsStats {
                        self::$xls->setActiveSheetIndex(0);\r
                        $writer = new PHPExcel_Writer_Excel2007();\r
                        $writer->setPHPExcel(self::$xls);\r
-                       $writer->save(self::_getXLSFile($bid, $annee, $mois));\r
+                       $xlsfile = self::_getXLSFile($bid, $annee, $mois);\r
+                       cubePHP::set_memory('4G');\r
+                       $writer->save($xlsfile);\r
                } catch (Exception $e) {\r
+                       die($e->getMessage());\r
                }\r
 \r
                return $res;\r
index d0558f59af1f278e485b10135bb5241e9ab0b815..046fbf64a305751804daea83dc0de581cc78d4e9 100644 (file)
@@ -2,23 +2,21 @@
 \r
 class wsBox extends cubeMetier {\r
 \r
-    protected $top;\r
-    protected $left;\r
-    protected $right;\r
-    protected $bottom;\r
-    protected $width;\r
-    protected $height;\r
+       protected $top;\r
+       protected $left;\r
+       protected $right;\r
+       protected $bottom;\r
+       protected $width;\r
+       protected $height;\r
 \r
-    public function __construct($top, $left, $right, $bottom) {\r
-        $this->top = $top;\r
-        $this->left = $left;\r
-        $this->right = $right;\r
-        $this->bottom = $bottom;\r
+       public function __construct($top, $left, $right, $bottom) {\r
+               $this->top = $top;\r
+               $this->left = $left;\r
+               $this->right = $right;\r
+               $this->bottom = $bottom;\r
 \r
-        $this->width = $this->right - $this->left;\r
-        $this->height = $this->bottom - $this->top;\r
-    }\r
+               $this->width = floatval($this->right) - floatval($this->left);\r
+               $this->height = floatval($this->bottom) - floatval($this->top);\r
+       }\r
 \r
 }\r
-\r
-?>
\ No newline at end of file
index 2560509a9978aeef363b086d372d0a0339b39dac..5b817725be425daab3b2bc48ae3539091b250b51 100644 (file)
@@ -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;
index 9a19a5d577305c9161eccfa9d213286668787e63..139d21be2972f63955fd0687b9709531b30dce5f 100644 (file)
@@ -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('|\<image([^>]*)\>|', 'wsTools::optimizeRaster', $svg);
+                                       file_put_contents(sprintf($optimized, '-' . $resolution), $osvg);
+                               }
+                       }
                        return true;
                }
                return false;
        }
 
+       public static function optimizeRaster($matches) {
+               
+               return '<image />';
+       }
+
        public static function copy($source, $dest) {
                if (!file_exists($source)) {
                        return;
index 1fb4700e2f0d605a8e4a86090c2925216f0f7e4f..24e639e2ddd7781771e20edd857b7f8543473632 100644 (file)
@@ -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);
index 9aefacc8751e4cf405d4f8f888d4e66ba698aae3..f23ea3c0d7f8673eb8c62f97d7081fa6d65ac35a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,11 +1,5 @@
 <?php
-
-require_once 'inc/ZendFramework/ChromeLogger/ChromePhp.php';
-ChromePhp::getInstance()->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 (file)
index 0000000..2786b5e
--- /dev/null
+++ b/info.php
@@ -0,0 +1,4 @@
+<?php\r
+trigger_error('test');\r
+phpinfo();\r
+?>
\ No newline at end of file
index aba683de2a30441334f0d1667e703b16ad968948..a35a02df0d891dbe0a6705d21d94e48d733ad56c 100644 (file)
@@ -91,7 +91,7 @@
   <!-- Executed before build -->\r
   <preBuildCommand />\r
   <!-- Executed after build -->\r
-  <postBuildCommand alwaysRun="False">"H:\Applications\PortableApps\PuTTYPortable\App\PuTTY\pscp.exe" -agent -batch "$(OutputDir)\$(OutputName)" extranet@extranet.cubedesigners.com:/home/extranet/www/swf</postBuildCommand>\r
+  <postBuildCommand alwaysRun="False">"C:\ProgramData\chocolatey\lib\kitty\tools\kscp.exe" -agent -batch "$(OutputDir)\$(OutputName)" extranet@extranet.cubedesigners.com:/home/extranet/www/swf</postBuildCommand>\r
   <!-- Other project options -->\r
   <options>\r
     <option showHiddenPaths="False" />\r