From 2a47cfc2ee2120521aae2df0a05a8f4851741220 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 25 Feb 2011 13:16:26 +0000 Subject: [PATCH] --- inc/commons/class.common.core.php | 8 ++-- inc/config.inc.php | 40 ---------------- inc/postconfig.inc.php | 47 +++++++++++++++++++ inc/prepend.php | 3 ++ .../class.ws.conversion.session.php | 30 +++++++++++- inc/ws/Controlleur/class.ws.flash.php | 23 +++++---- inc/ws/Metier/class.ws.document.php | 6 +-- 7 files changed, 100 insertions(+), 57 deletions(-) create mode 100644 inc/postconfig.inc.php diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 5f5f47f64..c9b93a0cb 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -66,12 +66,12 @@ class commonCore extends cubeCore { // On regarde si user_email et user_password ont été postées // Si c'est le cas, on les copie dans la session $_SESSION['errorLogin'] = false; - if (isset($_POST['user_email'])) { - $_SESSION['user_email'] = $_POST['user_email']; + if (isset($_REQUEST['user_email'])) { + $_SESSION['user_email'] = $_REQUEST['user_email']; } - if (isset($_POST['user_password'])) { - $_SESSION['user_password'] = $_POST['user_password']; + if (isset($_REQUEST['user_password'])) { + $_SESSION['user_password'] = $_REQUEST['user_password']; } // Maintenant on vérifie si ces variables sont présentes dans la session if (!isset($_SESSION['user_email']) || !isset($_SESSION['user_password'])) { diff --git a/inc/config.inc.php b/inc/config.inc.php index 78e62e52f..e501b0109 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -3,15 +3,10 @@ define('DB_DRIVER', 'mysql'); define('ROOT', dirname(__FILE__) . '/..'); -$dev = stristr($_SERVER['HTTP_HOST'], 'dev.'); -$extranet = stristr($_SERVER['HTTP_HOST'], 'cubedesigners.com'); -$ws = stristr($_SERVER['HTTP_HOST'], 'fluidbook.com'); - define('WEBROOT', ''); define('SITE_PATH', WEBROOT . '/'); define('FONT_PATH', ROOT . '/fluidbook/fonts/'); define('FTPROOT', '/home/extranet/ftp/'); -define('DEV', $dev); define('WINDOWS', false); define('CONVERTER_PATH', '/bin:/usr/bin:/usr/local/bin:/home/extranet/dev/fluidbook/tools:/usr/local/flex:/usr/local/secureSWF'); define('MXMLC_PATH', '/usr/local/flex/bin/mxmlc'); @@ -19,36 +14,10 @@ define('AS3_SOURCES', '/home/ws/sources/as3'); define('MONITOR_PERFS', true); -if ($dev) { - // Définition de la configuration sur l'environnement de développement - define('DB_HOST', ':/var/run/mysqld/mysqld.sock'); - define('DB_NAME', 'extranet_dev'); - define('DB_USER', 'ws'); - define('DB_PASSWORD', '*arica*2'); - - define('EXTRANET_URL', 'http://dev.extranet.cubedesigners.com'); - define('WS_URL', 'http://dev.ws.fluidbook.com'); -} else { - // Définition des variables dans l'environnement de production - define('DB_HOST', ':/var/run/mysqld/mysqld.sock'); - define('DB_NAME', 'extranet'); - define('DB_USER', 'ws'); - define('DB_PASSWORD', '*arica*2'); - - define('EXTRANET_URL', 'http://extranet.cubedesigners.com'); - define('WS_URL', 'http://workshop.fluidbook.com'); -} - -if ($ws) { - define('MODE', 'ws'); -} elseif ($extranet) { - define('MODE', 'extranet'); -} define('PLAYER_SOURCES', AS3_SOURCES . '/com/fluidbook/player'); define('COMPOSER_SOURCES', AS3_SOURCES . '/com/fluidbook/ws'); -define('STATIC_SERVER', 'http://static.' . $_SERVER['HTTP_HOST'] . WEBROOT); // Workshop define('THEMES', WEBROOT . '/fluidbook/themes/'); define('ICONS', WEBROOT . '/fluidbook/icones/'); @@ -71,15 +40,6 @@ define('L10N', dirname(__FILE__) . '/../l10n'); define('JS_PATH', WEBROOT . '/js'); define('JS', JS_PATH); -define('CSS_PATH', WEBROOT . '/style/' . MODE); -define('STYLE', CSS_PATH); -define('SYSSTYLE', ROOT . '/style/' . MODE); - -define('SYSIMG', ROOT . '/images/' . MODE); -define('IMG', WEBROOT . '/images/' . MODE); - -define('TYPOGRAPHP_PATH', ROOT . '/typo/' . MODE); -define('TYPOGRAPHP_WEBROOT', IMG . '/typographp'); define('JOURNEE', 8); define('TAUX_JOURNALIER', 500); diff --git a/inc/postconfig.inc.php b/inc/postconfig.inc.php new file mode 100644 index 000000000..8ab1e8e97 --- /dev/null +++ b/inc/postconfig.inc.php @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/inc/prepend.php b/inc/prepend.php index 59c217b0f..209f36fe0 100644 --- a/inc/prepend.php +++ b/inc/prepend.php @@ -3,6 +3,9 @@ require_once(dirname(__FILE__) . '/config.inc.php'); // Chargement de la classe cube require_once(dirname(__FILE__) . '/cube/_common.php'); +// Inclusion de la post configuration +require_once(dirname(__FILE__) . '/postconfig.inc.php'); + // Inclusion des classes communes require_once(dirname(__FILE__) . '/commons/_common.php'); diff --git a/inc/ws/Controlleur/class.ws.conversion.session.php b/inc/ws/Controlleur/class.ws.conversion.session.php index e40c29c46..0405e734e 100644 --- a/inc/ws/Controlleur/class.ws.conversion.session.php +++ b/inc/ws/Controlleur/class.ws.conversion.session.php @@ -19,6 +19,9 @@ class wsConversionSession { protected $bookId = null; public $reload = false; + protected $nb_threads = 4; + protected $threads; + public function __construct($guid) { $this->guid = $guid; @@ -58,9 +61,23 @@ class wsConversionSession { return $this->documents[$id]; } + protected function initThreads() + { + if (!cubeThread::available()) { + return; + } + $this->threads = array(); + for ($i = 0;$i <= $this->nb_threads;$i++) { + $this->threads[] = new cubeThread(); + } + } + public function process() { global $core; + + $this->initThreads(); + $this->processing = true; $this->initDocuments(); $this->serialize(); @@ -86,8 +103,19 @@ class wsConversionSession { foreach($docPages as $i => $page) { $this->currentDocPage = $i + 1; $this->totalDocPage = count($docPages); + $this->setProgress(($this->processedPages / $this->totalPages) * 100); - $this->currentDoc->processOnePage($page, true); + + if (cubeThread::available()) { + $t = $this->threads[$i % $this->nb_threads]; + while ($t->isAlive()) { + usleep(500000); + } + $t->setRunnable(array($this->currentDoc, 'processOnePage')); + $t->start($page, true); + } else { + $this->currentDoc->processOnePage($page, true); + } $this->processedPages++; } $doc = $dao->updateFromObject($doc); diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index 9684b2c87..11c5cd463 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -100,20 +100,27 @@ class wsFlash extends cubeFlashGateway { unset($_SESSION['conversionSessionReload']); $session->serialize(); - $http = new cubeHTTP($_SERVER['HTTP_HOST']); - $http->setDataTimeout(1); - try { - $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID)); - } - catch(Exception $e) { - } + $php = new cubeCommandLine('php'); + $php->setPath(CONVERTER_PATH); + $php->setArg('f', ROOT . '/index.php'); + $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->setNohup(true); + $php->execute('exec'); + + $this->xml->addChild('command', html::escapeHTML($php->command)); + exit; } public function processConversionSessionAsync() { cubePHP::neverStop(); try { - $conversion = wsConversionSession::openFromGUID($_POST['sessionConversionGUID']); + $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']); $conversion->process(); } catch(Exception $e) { diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 12f389d24..537d98239 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -74,6 +74,8 @@ class wsDocument extends cubeMetier { if (is_null($this->conversionInfos)) { $this->conversionInfos = new wsDocumentConversionInfos(); } + + } public function copyOriginalFromUpload($tmp_file) @@ -306,10 +308,6 @@ class wsDocument extends cubeMetier { { // $this->makeRealShot($page); if ($force) { - if ($page % 100 == 0) { - sleep(1); - } - $this->addToLog('Processing page #' . $page); $this->makeMiniShot($page); $this->makeSWFFiles($page); -- 2.39.5