From 789938229073b01cdc945f7a7f14db82633102d1 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 12:36:11 +0200 Subject: [PATCH 01/20] Resize only collection logos --- lib/classes/appbox.class.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/classes/appbox.class.php b/lib/classes/appbox.class.php index f5c310550d..e3eea59181 100644 --- a/lib/classes/appbox.class.php +++ b/lib/classes/appbox.class.php @@ -104,23 +104,6 @@ class appbox extends base throw new \InvalidArgumentException('Invalid file format'); } $filename = $pathfile->getPathname(); - - //resize collection logo - $imageSpec = new ImageSpecification(); - $imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO); - $imageSpec->setDimensions(120, 24); - - $tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox') . '.jpg'; - - try { - $core['media-alchemyst'] - ->open($pathfile->getPathname()) - ->turninto($tmp, $imageSpec) - ->close(); - $filename = $tmp; - } catch (\MediaAlchemyst\Exception $e) { - - } } switch ($pic_type) { @@ -128,6 +111,23 @@ class appbox extends base $collection->reset_watermark(); break; case collection::PIC_LOGO: + + $imageSpec = new ImageSpecification(); + $imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO); + $imageSpec->setDimensions(120, 24); + + $tmp = tempnam(sys_get_temp_dir(), 'tmpdatabox') . '.jpg'; + + try { + $core['media-alchemyst'] + ->open($pathfile->getPathname()) + ->turninto($tmp, $imageSpec) + ->close(); + $filename = $tmp; + } catch (\MediaAlchemyst\Exception $e) { + + } + break; case collection::PIC_PRESENTATION: break; case collection::PIC_STAMP: From af257ef83680d5b8cfe0b0d307705e0de1339986 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 14:23:19 +0200 Subject: [PATCH 02/20] Escape command lines --- .../sphinxGenerateSuggestion.class.php | 14 ++- .../module/console/systemBackupDB.class.php | 27 +++-- lib/classes/recordutils/image.class.php | 114 ++++++------------ lib/classes/task/Scheduler.class.php | 2 +- lib/classes/task/abstract.class.php | 14 --- lib/classes/task/period/cindexer.class.php | 12 +- www/admin/runscheduler.php | 2 +- 7 files changed, 70 insertions(+), 115 deletions(-) diff --git a/lib/classes/module/console/sphinxGenerateSuggestion.class.php b/lib/classes/module/console/sphinxGenerateSuggestion.class.php index 725b2ecb51..adcccb7cbf 100644 --- a/lib/classes/module/console/sphinxGenerateSuggestion.class.php +++ b/lib/classes/module/console/sphinxGenerateSuggestion.class.php @@ -15,9 +15,11 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link www.phraseanet.com */ + use Alchemy\Phrasea\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Process\ProcessBuilder; class module_console_sphinxGenerateSuggestion extends Command { @@ -67,15 +69,21 @@ class module_console_sphinxGenerateSuggestion extends Command return 1; } + $builder = ProcessBuilder::create(array('/usr/local/bin/indexer')); + $builder->add('metadatas' . $index) + ->add('--buildstops') + ->add($tmp_file) + ->add(1000000) + ->add('--buildfreqs'); + + $builder->getProcess()->run(); + if ( ! file_exists($tmp_file)) { $output->writeln(" file '" . $tmp_file . "' does not exist"); return 1; } - $cmd = '/usr/local/bin/indexer metadatas' . $index . ' --buildstops ' . $tmp_file . ' 1000000 --buildfreqs'; - exec($cmd); - try { $connbas = connection::getPDOConnection($sbas_id); } catch (Exception $e) { diff --git a/lib/classes/module/console/systemBackupDB.class.php b/lib/classes/module/console/systemBackupDB.class.php index 2f615ae1f5..efe8a2d262 100644 --- a/lib/classes/module/console/systemBackupDB.class.php +++ b/lib/classes/module/console/systemBackupDB.class.php @@ -18,6 +18,7 @@ use Alchemy\Phrasea\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Process\ProcessBuilder; class module_console_systemBackupDB extends Command { @@ -73,18 +74,22 @@ class module_console_systemBackupDB extends Command $output->write(sprintf('Generating %s ... ', $filename)); - $command = sprintf( - 'mysqldump --host %s --port %s --user %s --password=%s' - . ' --database %s --default-character-set=utf8 > %s' - , $base->get_host() - , $base->get_port() - , $base->get_user() - , $base->get_passwd() - , $base->get_dbname() - , escapeshellarg($filename) - ); + $builder = ProcessBuilder::create(array( + 'mysqldump', + '--host='.$base->get_host(), + '--port='.$base->get_port(), + '--user='.$base->get_user(), + '--password='.$base->get_passwd(), + '--databases', $base->get_dbname(), + '--default-character-set=utf8' + )); - system($command); + $proces = $builder->getProcess(); + $proces->run(); + + if ($proces->isSuccessful()) { + file_put_contents($filename, $proces->getOutput()); + } if (file_exists($filename) && filesize($filename) > 0) { $output->writeln('OK'); diff --git a/lib/classes/recordutils/image.class.php b/lib/classes/recordutils/image.class.php index 419523e3e8..469c275c7e 100644 --- a/lib/classes/recordutils/image.class.php +++ b/lib/classes/recordutils/image.class.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +use Symfony\Component\Process\ProcessBuilder; + /** * * @@ -286,15 +288,15 @@ class recordutils_image extends recordutils $newh = $image_height + $stampheight; - $cmd = $registry->get('GV_imagick'); - $cmd .= ' -extent "' . $image_width . 'x' . $newh - . '" -draw "image SrcOver 0,' . $image_height . ' ' - . $image_width . ',' . $stampheight . '\'' . $pathTmpStamp . '\'"'; + $builder = ProcessBuilder::create(array($registry->get('GV_imagick'))); + $builder->add('-extent') + ->add($image_width . 'x' . $newh) + ->add('-draw') + ->add('image SrcOver 0,' . $image_height . ' ' . $image_width . ',' . $stampheight . '"' . $pathTmpStamp . '"') + ->add($pathIn) + ->add($pathOut); - $cmd.= " \"" . $pathIn . "\""; # <<-- le doc original - $cmd.= " \"" . $pathOut . "\""; # <-- le doc stampe - - exec($cmd); + $builder->getProcess()->run(); unlink($pathTmpStamp); @@ -302,7 +304,7 @@ class recordutils_image extends recordutils return $pathOut; } - return $subdef->get_pathfile();; + return $subdef->get_pathfile(); } /** @@ -332,7 +334,7 @@ class recordutils_image extends recordutils $pathOut = $subdef->get_path() . 'watermark_' . $subdef->get_file(); - if ( ! is_file($pathIn)) { + if (!is_file($pathIn)) { return false; } @@ -341,32 +343,19 @@ class recordutils_image extends recordutils } if ($registry->get('GV_pathcomposite') && - file_exists($registry->get('GV_RootPath') . 'config/wm/' . $base_id)) { // si il y a un WM - $cmd = $registry->get('GV_pathcomposite') . " "; - $cmd .= $registry->get('GV_RootPath') . 'config/wm/' . $base_id . " "; - $cmd .= " \"" . $pathIn . "\" "; # <<-- la preview original - $cmd .= " -strip -watermark 90% -gravity center "; - $cmd .= " \"" . $pathOut . "\""; # <-- la preview temporaire + file_exists($registry->get('GV_RootPath') . 'config/wm/' . $base_id)) { - $descriptorspec = array(0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") - ); - $process = proc_open($cmd, $descriptorspec, $pipes); - if (is_resource($process)) { - fclose($pipes[0]); - $err = ""; - while ( ! feof($pipes[1])) - $out = fgets($pipes[1], 1024); - fclose($pipes[1]); - while ( ! feof($pipes[2])) - $err .= fgets($pipes[2], 1024); - fclose($pipes[2]); - $return_value = proc_close($process); - } + $builder = ProcessBuilder::create(array( + $registry->get('GV_pathcomposite'), + $registry->get('GV_RootPath') . 'config/wm/' . $base_id, + $pathIn, + '-strip', '-watermark', '90%', '-gravity', 'center', + $pathOut + )); + + $builder->getProcess()->run(); } elseif ($registry->get('GV_imagick')) { $collname = phrasea::bas_names($base_id); - $cmd = $registry->get('GV_imagick'); $tailleimg = @getimagesize($pathIn); $max = ($tailleimg[0] > $tailleimg[1] ? $tailleimg[0] : $tailleimg[1]); @@ -380,50 +369,23 @@ class recordutils_image extends recordutils else $decalage = 1; - $cmd .= " -fill white -draw \"line 0,0 " - . $tailleimg[0] . "," . $tailleimg[1] . "\""; - $cmd .= " -fill black -draw \"line 1,0 " - . ($tailleimg[0] + 1) . "," . ($tailleimg[1]) . "\""; + $builder = ProcessBuilder::create(array( + $registry->get('GV_imagick'), + '-fill', 'white', '-draw', 'line 0,0 ' . $tailleimg[0] . ',' . $tailleimg[1] . '', + '-fill', 'black', '-draw', 'line 1,0 ' . $tailleimg[0] + 1 . ',' . $tailleimg[1] . '', + '-fill', 'white', '-draw', 'line ' . $tailleimg[0] . ',0 0,' . $tailleimg[1] . '', + '-fill', 'black', '-draw', 'line ' . ($tailleimg[0] + 1) . ',0 0,' . $tailleimg[1] . '', + '-fill', 'white', '-gravity', 'NorthWest', '-pointsize', $tailleText, '-draw', 'text 0,0 ' . $collname, + '-fill', 'black', '-gravity', 'NorthWest', '-pointsize', $tailleText, '-draw', 'text ' . $decalage . ', 1 ' . $collname, + '-fill', 'white', '-gravity', 'center', '-pointsize', $tailleText, '-draw', 'text 0,0 ' . $collname, + '-fill', 'black', '-gravity', 'center', '-pointsize', $tailleText, '-draw', 'text ' . $decalage . ', 1 ' . $collname, + '-fill', 'white', '-gravity', 'SouthEast', '-pointsize', $tailleText, '-draw', 'text 0,0 ' . $collname, + '-fill', 'black', '-gravity', 'SouthEast', '-pointsize', $tailleText, '-draw', 'text ' . $decalage . ', 1 ' . $collname, + $pathIn, $pathOut + )); - $cmd .= " -fill white -draw \"line " - . $tailleimg[0] . ",0 0," . $tailleimg[1] . "\""; - $cmd .= " -fill black -draw \"line " - . ($tailleimg[0] + 1) . ",0 1," . ($tailleimg[1]) . "\""; - - $cmd .= " -fill white -gravity NorthWest -pointsize " - . " $tailleText -draw \"text 0,0 '$collname'\""; - $cmd .= " -fill black -gravity NorthWest -pointsize " - . " $tailleText -draw \"text $decalage,1 '$collname'\""; - - $cmd .= " -fill white -gravity center -pointsize " - . " $tailleText -draw \"text 0,0 '$collname'\""; - $cmd .= " -fill black -gravity center -pointsize " - . " $tailleText -draw \"text $decalage,1 '$collname'\""; - - $cmd .= " -fill white -gravity SouthEast -pointsize " - . " $tailleText -draw \"text 0,0 '$collname'\""; - $cmd .= " -fill black -gravity SouthEast -pointsize " - . " $tailleText -draw \"text $decalage,1 '$collname'\""; - - $cmd.= " \"" . $pathIn . "\""; # <<-- la preview original - $cmd.= " \"" . $pathOut . "\""; # <-- la preview temporaire - - $descriptorspec = array(0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") - ); - $process = proc_open($cmd, $descriptorspec, $pipes); - if (is_resource($process)) { - fclose($pipes[0]); - $err = ""; - while ( ! feof($pipes[1])) - $out = fgets($pipes[1], 1024); - fclose($pipes[1]); - while ( ! feof($pipes[2])) - $err .= fgets($pipes[2], 1024); - fclose($pipes[2]); - $return_value = proc_close($process); - } + $process = $builder->getProcess(); + $process->run(); } if (is_file($pathOut)) { diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index 9cfce19a53..4cf5b1454d 100755 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -331,7 +331,7 @@ class task_Scheduler $descriptors[2] = array('file', $nullfile, 'a+'); $taskPoll[$tkey]["process"] = proc_open( - $taskPoll[$tkey]["cmd"] . ' ' . implode(' ', $taskPoll[$tkey]["args"]) + escapeshellarg($taskPoll[$tkey]["cmd"]) . ' ' . implode(' ', array_map('escapeshellarg', $taskPoll[$tkey]["args"])) , $descriptors , $taskPoll[$tkey]["pipes"] , $registry->get('GV_RootPath') . "bin/" diff --git a/lib/classes/task/abstract.class.php b/lib/classes/task/abstract.class.php index e6ee6d92c7..be7d16beae 100755 --- a/lib/classes/task/abstract.class.php +++ b/lib/classes/task/abstract.class.php @@ -877,18 +877,4 @@ abstract class task_abstract return $this; } - - /** - * Escape a shell command. - * - * As this function is buggy under windows, this method check the - * environment - * - * @param string $command - * @return string - */ - protected static function escapeShellCmd($command) - { - return defined('PHP_WINDOWS_VERSION_BUILD') ? escapeshellarg($command) : escapeshellcmd($command); - } } diff --git a/lib/classes/task/period/cindexer.class.php b/lib/classes/task/period/cindexer.class.php index 52438d0e31..a759deb003 100755 --- a/lib/classes/task/period/cindexer.class.php +++ b/lib/classes/task/period/cindexer.class.php @@ -454,17 +454,11 @@ class task_period_cindexer extends task_abstract $pipes = array(); - $logcmd = self::escapeShellCmd($cmd); - foreach ($args_nopwd as $arg) { - $logcmd .= ' ' . escapeshellarg($arg); - } + $logcmd = escapeshellarg($cmd).' '.implode(' ', array_map('escapeshellarg', $args_nopwd)); + $execmd = escapeshellarg($cmd).' '.implode(' ', array_map('escapeshellarg', $args)); - $this->log(sprintf('cmd=\'%s\'', self::escapeShellCmd($logcmd))); + $this->log(sprintf('cmd=\'%s\'', $logcmd)); - $execmd = self::escapeShellCmd($cmd); - foreach ($args as $arg) { - $execmd .= ' ' . escapeshellarg($arg); - } $process = proc_open($execmd, $descriptors, $pipes, $this->binpath, null, array('bypass_shell' => true)); $pid = NULL; diff --git a/www/admin/runscheduler.php b/www/admin/runscheduler.php index be82f880a3..4ac0b86780 100644 --- a/www/admin/runscheduler.php +++ b/www/admin/runscheduler.php @@ -47,7 +47,7 @@ if (defined('PHP_WINDOWS_VERSION_BUILD')) { $phpcli = $registry->get('GV_cli'); -$cmd = $phpcli . ' -f ' . $registry->get('GV_RootPath') . "bin/console scheduler:start"; +$cmd = escapeshellarg($phpcli) . ' -f ' . __DIR__ . "/../../bin/console scheduler:start"; $descriptors[1] = array("file", $nullfile, "a+"); From 2c17ee7a72721578820171f271c69021014fe9f2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 14:53:05 +0200 Subject: [PATCH 03/20] Add patch to version 3.7.3 --- lib/classes/patch/373.class.php | 97 +++++++++++++++ lib/classes/registry.class.php | 18 +++ lib/conf.d/_GV_template.inc | 204 ++++++++++++++++---------------- 3 files changed, 217 insertions(+), 102 deletions(-) create mode 100644 lib/classes/patch/373.class.php diff --git a/lib/classes/patch/373.class.php b/lib/classes/patch/373.class.php new file mode 100644 index 0000000000..99b3bafc52 --- /dev/null +++ b/lib/classes/patch/373.class.php @@ -0,0 +1,97 @@ +release; + } + + public function require_all_upgrades() + { + return false; + } + + /** + * + * @return Array + */ + public function concern() + { + return $this->concern; + } + + /** + * @param base $databox + */ + public function apply(base &$appbox) + { + $registry = $appbox->get_registry(); + + $sql = 'UPDATE registry SET type = :type, value = :value + WHERE `key` = :key'; + + $stmt = $appbox->get_connection()->prepare($sql); + + $binaries = array( + 'GV_cli', + 'GV_imagick', + 'GV_pathcomposite', + 'GV_swf_extract', + 'GV_pdf2swf', + 'GV_swf_render', + 'GV_unoconv', + 'GV_ffmpeg', + 'GV_ffprobe', + 'GV_mp4box', + 'GV_pdftotext', + 'GV_cli', + ); + + foreach ($binaries as $binary) { + + $value = is_executable($registry->get($binary)) ? $registry->get($binary) : ''; + + $stmt->execute(array( + ':type' => \registry::TYPE_BINARY, + ':key' => $binary, + ':value' => $value, + )); + } + + $stmt->closeCursor(); + + return true; + } +} + diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index 37d36ba538..ea37777b85 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -32,7 +32,11 @@ class registry implements registryInterface const TYPE_ARRAY = 'array'; const TYPE_ENUM_MULTI = 'enum_multi'; const TYPE_INTEGER = 'integer'; + const TYPE_ENUM = 'enum'; const TYPE_STRING = 'string'; + const TYPE_TEXT = 'text'; + const TYPE_TIMEZONE = 'timezone'; + const TYPE_BINARY = 'binary'; /** * @@ -105,11 +109,21 @@ class registry implements registryInterface $value = unserialize($row['value']); break; case self::TYPE_STRING: + case self::TYPE_ENUM: + case self::TYPE_TIMEZONE: + case self::TYPE_TEXT: + case self::TYPE_BINARY: default: $value = $row['value']; break; } + if ($row['type'] == self::TYPE_BINARY) { + if (!is_executable($value)) { + continue; + } + } + $this->cache->save($row['key'], $value); } if ($loaded === true) @@ -153,6 +167,10 @@ class registry implements registryInterface $value = (array) $value; break; case self::TYPE_STRING; + case self::TYPE_ENUM: + case self::TYPE_TIMEZONE: + case self::TYPE_TEXT: + case self::TYPE_BINARY: default: $sql_value = (string) $value; $value = (string) $value; diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index fe4de236b6..a059c31fdb 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -79,14 +79,14 @@ $GV = array( 'section' => _('GV::section:: Serveur HTTP'), 'vars' => array( array( - 'type' => 'timezone', + 'type' => \registry::TYPE_TIMEZONE, 'name' => 'GV_timezone', 'comment' => _('reglages:: Timezone de l\'installation'), 'default' => 'Europe/Paris', 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_sit', 'comment' => _('reglages:: Nom de linstallation'), 'default' => $GV_sit, @@ -94,7 +94,7 @@ $GV = array( 'required' => true ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_default_lng', 'comment' => _('reglages:: Langue par defaut'), 'default' => 'fr_FR', @@ -102,7 +102,7 @@ $GV = array( 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_STATIC_URL', 'end_slash' => false, 'comment' => _('reglages:: URL statique (optionnel)'), @@ -115,19 +115,19 @@ $GV = array( 'rolled' => true, 'vars' => array( array( - 'type' => 'text', + 'type' => \registry::TYPE_TEXT, 'name' => 'GV_message', 'comment' => _('reglages:: Message a diffuser aux utilisateurs'), 'default' => "May the force be with you" ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_message_on', 'comment' => _('reglages:: activation du message a diffuser aux utilistaeurs'), 'default' => false ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_log_errors', 'comment' => _('reglages:: logguer les erreurs'), 'default' => false @@ -137,14 +137,14 @@ $GV = array( 'section' => _('GV::section:: Connectivite aux webservices'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_google_api', 'comment' => _('reglages:: Utiliser els google apis'), 'default' => true, 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_i18n_service', 'comment' => _('reglages:: Service phrasea de localisation'), 'default' => 'http://localization.webservice.alchemyasp.com/', @@ -152,20 +152,20 @@ $GV = array( 'required' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_captchas', 'comment' => _('reglages:: Utilisation de l\'api recpatcha'), 'default' => false, 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_captcha_public_key', 'comment' => _('reglages:: clef publique recaptcha'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_captcha_private_key', 'comment' => _('reglages:: clef privee recaptcha'), 'default' => '' @@ -175,26 +175,26 @@ $GV = array( 'section' => _('GV::section:: Connectivite a Youtube'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_youtube_api', 'comment' => sprintf(_('reglages:: Utiliser l\'api youtube, voir %s,
mettre la callback a WEBSITE_URL/prod/bridge/callback/youtube'), $youtube_console_url), 'default' => false, 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_youtube_client_id', 'comment' => _('reglages:: Youtube client id'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_youtube_client_secret', 'comment' => _('reglages:: Youtube clientsecret'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_youtube_dev_key', 'comment' => sprintf(_('reglages:: Youtube cle developpeur, voir %s'), $dashboard_youtube), 'default' => '' @@ -204,20 +204,20 @@ $GV = array( 'section' => _('GV::section:: Connectivite a FlickR'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_flickr_api', 'comment' => sprintf(_('reglages:: Utiliser l api flickr, voir %s, puis set la callback a %s'), $create_api_flickr, $flickr_callback), 'default' => false, 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_flickr_client_id', 'comment' => _('reglages:: FlickR client id'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_flickr_client_secret', 'comment' => _('reglages:: FlickR client secret'), 'default' => '' @@ -227,20 +227,20 @@ $GV = array( 'section' => _('GV::section:: Connectivite a Dailymotion'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_dailymotion_api', 'comment' => sprintf(_('reglages:: Utiliser l api dailymotion, voir %s, puis set la callback a %s'), $create_api_dailymotion, $dailymotion_callback), 'default' => false, 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_dailymotion_client_id', 'comment' => _('reglages:: dailymotion client id'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_dailymotion_client_secret', 'comment' => _('reglages:: dailymotion client secret'), 'default' => '' @@ -250,7 +250,7 @@ $GV = array( 'section' => _('GV::section:: Client Phraseanet API'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_client_navigator', 'comment' => _('reglages:: Authoriser l\'application smartphone *Phraseanet Navigator* à se connecter sur cette instance'), 'default' => false, @@ -261,7 +261,7 @@ $GV = array( 'section' => _('GV::section:: Gestionnaire d\'evenements'), 'vars' => array( array( - 'type' => 'enum_multi', + 'type' => \registry::TYPE_ENUM_MULTI, 'name' => 'GV_events', 'default' => null, 'comment' => _('reglages:: Evenements'), @@ -269,7 +269,7 @@ $GV = array( 'default' => array_keys($eventsmanager->list_all('event')) ), array( - 'type' => 'enum_multi', + 'type' => \registry::TYPE_ENUM_MULTI, 'name' => 'GV_notifications', 'default' => null, 'comment' => _('reglages:: Notifications'), @@ -281,7 +281,7 @@ $GV = array( 'section' => _('GV::section:: Stockage des documents'), 'vars' => array( array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_base_datapath_noweb', 'end_slash' => true, 'comment' => _('Default path for datas'), @@ -294,31 +294,31 @@ $GV = array( 'section' => _('GV::section:: Serveur Sphinx'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_sphinx', 'comment' => _('Utiliser Sphinx'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_sphinx_host', 'comment' => _('reglages:: de l\'adresse du serveur sphinx'), 'default' => '127.0.0.1' ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_sphinx_port', 'comment' => _('reglages:: port du serveur sphinx'), 'default' => 9306 ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_sphinx_rt_host', 'comment' => _('reglages:: de l\'adresse du serveur RT sphinx'), 'default' => '127.0.0.1' ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_sphinx_rt_port', 'comment' => _('reglages:: port du serveur RT sphinx'), 'default' => 9308 @@ -329,7 +329,7 @@ $GV = array( 'section' => _('Phrasea Engine'), 'vars' => array( array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_phrasea_sort', 'comment' => _('Default results sort'), 'default' => '', @@ -340,66 +340,66 @@ $GV = array( 'section' => _('GV::section:: Executables externes'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_modxsendfile', 'comment' => _('reglages:: mod_xsendfileapache active'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_X_Accel_Redirect', 'comment' => _('reglages:: Path en acces pour X-Accel-Redirect (NginX Uniquement)'), 'default' => '', 'end_slash' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_X_Accel_Redirect_mount_point', 'comment' => _('reglages:: Point de montage pour X-Accel-Redirect (NginX Uniquement)'), 'default' => 'noweb', 'end_slash' => false ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_h264_streaming', 'comment' => _('reglages:: activation du stream h264 via mod_token - attention, necessite les modules apache mod_h264_streaming et mod_auth_token'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_mod_auth_token_directory', 'end_slash' => true, 'comment' => _('reglages:: point de montage du dossier protege via auth_token'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_mod_auth_token_directory_path', 'end_slash' => false, 'comment' => _('reglages:: path complet du dossier protege via auth_token'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_mod_auth_token_passphrase', 'comment' => _('reglages:: passphrase du mod_auth_token (definie dans le fichier de configuration apache)'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_cli', 'comment' => _('reglages:: executable PHP CLI'), 'default' => '', 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_PHP_INI', 'comment' => _('reglages:: path du php.ini specifique (vide si non utilise)'), 'default' => '' ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_imagine_driver', 'default' => '', 'comment' => _('Imagine driver'), @@ -411,79 +411,79 @@ $GV = array( ) ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_imagick', 'default' => '', 'comment' => _('reglages:: chemin de l\'executable convert'), 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_pathcomposite', 'default' => '', 'comment' => _('reglages:: chemin de l\'executable composite'), 'required' => true ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_swf_extract', 'comment' => _('reglages:: chemin de l\'executable swfextract'), 'default' => '', 'required' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_pdf2swf', 'comment' => _('reglages:: chemin de l\'executable pdf2swf'), 'default' => '', 'required' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_swf_render', 'comment' => _('reglages:: chemin de l\'executable swfrender'), 'default' => '', 'required' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_unoconv', 'comment' => _('reglages:: chemin de l\'executable unoconv'), 'default' => '', 'required' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_ffmpeg', 'comment' => _('reglages:: chemin de l\'executable FFmpeg'), 'default' => '' ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ffmpeg_threads', 'comment' => _('Number of threads allowed for FFmpeg'), 'default' => 2 ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_ffprobe', 'comment' => _('FFprobe path'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_mp4box', 'comment' => _('reglages:: chemin de l\'executable MP4Box'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_BINARY, 'name' => 'GV_pdftotext', 'comment' => _('reglages:: chemin de l\'executable pdftotext (xpdf)'), 'default' => '' ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_pdfmaxpages', 'comment' => _('reglages:: nombre maximum de page a extraire (PDF)'), 'default' => 5 @@ -493,13 +493,13 @@ $GV = array( 'section' => _('GV::section:: Repertoires utilitaires'), 'vars' => array( array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_filesOwner', 'comment' => _('reglages:: proprietaire des fichiers'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_filesGroup', 'comment' => _('reglages:: groupes des fichiers'), 'default' => '' @@ -509,34 +509,34 @@ $GV = array( 'section' => _('GV::section:: Configuration principale'), 'vars' => array( array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_adminMail', 'comment' => _('reglages:: email de l\'administrateur'), 'default' => 'support@alchemy.fr' ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_view_bas_and_coll', 'comment' => _('reglages:: Afficher le nom des bases et des collections'), 'default' => true, 'required' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_choose_export_title', 'comment' => _('reglages:: activer le choix du nom de fichier a l\'export'), 'default' => false, 'required' => true ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_default_export_title', 'comment' => _('reglages:: choix par defaut des noms de fichier a l\'export'), 'default' => 'support@alchemy.fr', 'available' => array('title' => 'Titre du document', 'original' => 'Nom original') ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_social_tools', 'comment' => _('reglages:: Active les partages Facebook et Twitter'), 'available' => array('none' => 'Disabled', 'publishers' => 'Publishers', 'all' => 'Activated'), @@ -549,7 +549,7 @@ $GV = array( 'rolled' => true, 'vars' => array( array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_home_publi', 'comment' => _('reglages:: presentation sur la home'), 'default' => 'COOLIRIS', @@ -562,19 +562,19 @@ $GV = array( 'rolled' => true, 'vars' => array( array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_min_letters_truncation', 'comment' => _('reglages:: Nombre minimal de lettre avec la troncature (Recherche)'), 'default' => 1 ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_defaultQuery', 'comment' => _('reglages:: Question par defaut'), 'default' => 'all' ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_defaultQuery_type', 'comment' => _('reglages:: type de document cherches par defaut e l\'ouverture du site'), 'available' => array('0' => 'Documents', '1' => 'Regroupements'), @@ -586,7 +586,7 @@ $GV = array( 'rolled' => true, 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_anonymousReport', 'comment' => _('reglages:: report anonyme (masque les infos concernant les utilisateurs)'), 'default' => false, @@ -598,22 +598,22 @@ $GV = array( 'rolled' => true, 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_thesaurus', 'comment' => _('reglages:: Activation de l\'outil thesaurus'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_multiAndReport', 'comment' => _('reglages:: Activation du Mode MultiDOC'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_seeOngChgDoc', 'comment' => _('reglages:: Substitution de HD d\'un record '), 'default' => false ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_seeNewThumb', 'comment' => _('reglages:: Substitution de thumbnail d\'un record'), 'default' => false @@ -624,49 +624,49 @@ $GV = array( 'section' => _('GV::section:: Envois de mails'), 'vars' => array( array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_defaulmailsenderaddr', 'comment' => _('reglages:: Expediteur mail par defaut'), 'default' => 'phraseanet@example.com' ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_smtp', 'comment' => _('reglages:: Utilisation d\'un serveur SMTP'), 'default' => false ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_smtp_auth', 'comment' => _('reglages:: Activation de l\'authentification smtp'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_host', 'comment' => _('reglages:: Hote SMTP'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_port', 'comment' => _('reglages:: Port SMTP'), 'default' => '' ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_smtp_secure', 'comment' => _('reglages:: Utiliser une conenction SSL'), 'default' => false ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_user', 'comment' => _('reglages:: User SMTP'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_smtp_password', 'comment' => _('reglages:: Mot de passe SMTP'), 'default' => '' @@ -676,13 +676,13 @@ $GV = array( 'section' => _('GV::section:: Exports FTP'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_activeFTP', 'comment' => _('reglages:: active la possibilite d\'exports FTP ou non (onglet dans multiexports)'), 'default' => false ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_ftp_for_user', 'comment' => _('reglages:: Donne ou non export FTP aux utilisateurs ou e l\'admin uniquement'), 'default' => false @@ -692,75 +692,75 @@ $GV = array( 'section' => _('GV::section:: Configuration du client'), 'vars' => array( array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_download_max', 'comment' => _('Maximum megabytes allowed in download (if request is bigger, then mail is still available)'), 'default' => 120 ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_search', 'comment' => _('reglages:: position de l\'onglet de recherche'), 'default' => 1 ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_advsearch', 'comment' => _('reglages:: position de l\'onglet de recherche avancee'), 'default' => 2 ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_topics', 'comment' => _('reglages:: position de l\'onglet des topics'), 'default' => 0 ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ong_actif', 'comment' => _('reglages:: numero de l\'onglet actif'), 'default' => 1 ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_client_render_topics', 'comment' => _('reglages:: rendu des topics'), 'available' => array('tree' => 'Arbres', 'popups' => 'Menus deroulants'), 'default' => 'tree' ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_rollover_reg_preview', 'comment' => _('reglages:: Voir le rollover sur les regroupements (fenetre de preview)'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_rollover_chu', 'comment' => _('reglages:: Voir le rollover sur les elements du chutier'), 'default' => true ), array( - 'type' => 'enum', + 'type' => \registry::TYPE_ENUM, 'name' => 'GV_client_coll_ckbox', 'comment' => _('reglages:: Presentation des collections'), 'default' => 'checkbox', 'available' => array('popup' => 'Menu deroulant', 'checkbox' => 'case a cocher') ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_viewSizeBaket', 'comment' => _('reglages:: Voir taille HD total des doc d\'un chutiers'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_clientAutoShowProposals', 'comment' => _('reglages:: Afficher automatiquement l\'onglet des propositions s\'il y\'en a'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_needAuth2DL', 'comment' => _('reglages:: Il est necessaire d\'etre connecte pour pouvoir telecharger en compte invite'), 'default' => true @@ -770,13 +770,13 @@ $GV = array( 'section' => _('GV::section:: Parametrage de l\'inscription'), 'vars' => array( array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_autoselectDB', 'comment' => _('reglages:: A true, cette option descative le choix de selection des bases sur lesquelles on s\'inscrit, et l\'inscription se fait sur toutes les bases ou jai le droit de m\'inscrire'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_autoregister', 'comment' => _('reglages:: Activation de l\'autoinscription'), 'default' => false @@ -786,13 +786,13 @@ $GV = array( 'section' => _('GV::section:: Configuration du push'), 'vars' => array( array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_validation_reminder', 'comment' => _('reglages:: Nombre de jour avant la fin de la validation pour envoie de mail de rappel'), 'default' => 2 ), array( - 'type' => 'integer', + 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_val_expiration', 'comment' => _('reglages:: dure de validite des liens genere pour les validations, si 0 => validite permanente'), 'default' => 10 @@ -802,37 +802,37 @@ $GV = array( 'section' => _('GV::section:: Indexation par les robots'), 'vars' => array( array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_homeTitle', 'comment' => _('reglages :: Titre de l\'installation'), 'default' => 'Phraseanet' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_metaKeywords', 'comment' => _('reglages:: Mots clefs pour l\'indexation des robots de moteurs de recherche'), 'default' => '' ), array( - 'type' => 'text', + 'type' => \registry::TYPE_TEXT, 'name' => 'GV_metaDescription', 'comment' => _('reglages :: Description de l\'installation'), 'default' => '' ), array( - 'type' => 'string', + 'type' => \registry::TYPE_STRING, 'name' => 'GV_googleAnalytics', 'comment' => _('reglages:: identifiant google analytics'), 'default' => '' ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_allow_search_engine', 'comment' => _('Allow the website to be indexed by search engines like Google'), 'default' => true ), array( - 'type' => 'boolean', + 'type' => \registry::TYPE_BOOLEAN, 'name' => 'GV_display_gcf', 'comment' => _('reglages:: Afficher le bandeau Google Chrome Frame'), 'default' => true From 8459996df3e92384d6a544628712cdadf6d2ae75 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 14:53:24 +0200 Subject: [PATCH 04/20] Bump to version 3.7.3 --- lib/Alchemy/Phrasea/Core/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index f14171371d..e8614bc0c4 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core; */ class Version { - protected static $number = '3.7.2'; + protected static $number = '3.7.3'; protected static $name = 'Carnosaurus'; public static function getNumber() From c762e7f0abe05c0d4902aa0db3264636b8f279a9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 15:11:55 +0200 Subject: [PATCH 05/20] Registry is more strong --- lib/classes/registry.class.php | 17 +++++++---------- lib/classes/setup.class.php | 26 +++++++++----------------- lib/conf.d/bases_structure.xml | 2 +- www/admin/global_values.php | 20 ++++++++------------ 4 files changed, 25 insertions(+), 40 deletions(-) diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index ea37777b85..6c34f5a89a 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -29,7 +29,6 @@ class registry implements registryInterface protected static $_instance; const TYPE_BOOLEAN = 'boolean'; - const TYPE_ARRAY = 'array'; const TYPE_ENUM_MULTI = 'enum_multi'; const TYPE_INTEGER = 'integer'; const TYPE_ENUM = 'enum'; @@ -105,7 +104,6 @@ class registry implements registryInterface $value = (int) $row['value']; break; case self::TYPE_ENUM_MULTI: - case self::TYPE_ARRAY: $value = unserialize($row['value']); break; case self::TYPE_STRING: @@ -118,12 +116,6 @@ class registry implements registryInterface break; } - if ($row['type'] == self::TYPE_BINARY) { - if (!is_executable($value)) { - continue; - } - } - $this->cache->save($row['key'], $value); } if ($loaded === true) @@ -159,9 +151,8 @@ class registry implements registryInterface public function set($key, $value, $type) { $this->load(); - + switch ($type) { - case self::TYPE_ARRAY: case self::TYPE_ENUM_MULTI: $sql_value = serialize($value); $value = (array) $value; @@ -185,6 +176,12 @@ class registry implements registryInterface break; } + if ($value != '' && $type == self::TYPE_BINARY) { + if (!is_executable($value)) { + return $this; + } + } + $conn = connection::getPDOConnection(); $sql = 'REPLACE INTO registry (`id`, `key`, `value`, `type`) diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php index e9cef760fc..dcb8dad0a5 100644 --- a/lib/classes/setup.class.php +++ b/lib/classes/setup.class.php @@ -127,7 +127,6 @@ class setup case registry::TYPE_INTEGER: case registry::TYPE_BOOLEAN: case registry::TYPE_STRING: - case registry::TYPE_ARRAY: $type = $datas['type']; break; default: @@ -174,13 +173,15 @@ class setup } } - $type = 'string'; + $type = $variable['type']; switch ($variable['type']) { - case 'string': - case 'password': + case \registry::TYPE_STRING: + case \registry::TYPE_BINARY: + case \registry::TYPE_TEXT: + case \registry::TYPE_TIMEZONE: $datas[$variable['name']] = (string) trim($datas[$variable['name']]); break; - case 'enum': + case \registry::TYPE_ENUM: if (!isset($variable['available'])) { $variable['error'] = 'avalaibility'; } elseif (!is_array($variable['available'])) { @@ -189,25 +190,16 @@ class setup $variable['error'] = 'avalaibility'; } break; - case 'enum_multi': + case \registry::TYPE_ENUM_MULTI: if (!isset($datas[$variable['name']])) $datas[$variable['name']] = null; $datas[$variable['name']] = ($datas[$variable['name']]); - $type = 'array'; break; - case 'boolean': + case \registry::TYPE_BOOLEAN: $datas[$variable['name']] = strtolower($datas[$variable['name']]) === 'true' ? '1' : '0'; - $type = 'boolean'; break; - case 'integer': + case \registry::TYPE_INTEGER: $datas[$variable['name']] = (int) trim($datas[$variable['name']]); - $type = 'integer'; - break; - case 'text': - $datas[$variable['name']] = trim($datas[$variable['name']]); - break; - case 'timezone': - $datas[$variable['name']] = trim($datas[$variable['name']]); break; default: $error = true; diff --git a/lib/conf.d/bases_structure.xml b/lib/conf.d/bases_structure.xml index 1ea92ec016..d77c322149 100644 --- a/lib/conf.d/bases_structure.xml +++ b/lib/conf.d/bases_structure.xml @@ -1633,7 +1633,7 @@ type - enum('string','boolean','array','integer') + enum('string','boolean','array','integer','text','binary','timezone','enum_multi','enum') string diff --git a/www/admin/global_values.php b/www/admin/global_values.php index 06362a9f5b..a39491363d 100644 --- a/www/admin/global_values.php +++ b/www/admin/global_values.php @@ -164,19 +164,20 @@ foreach ($GV as $section) { switch ($value['type']) { - case 'boolean': + case \registry::TYPE_BOOLEAN: $input = ' '; break; - case 'string': + case \registry::TYPE_BINARY: + case \registry::TYPE_STRING: $input = ''; break; - case 'text': + case \registry::TYPE_TEXT: $input = ''; break; - case 'enum': + case \registry::TYPE_ENUM: $input = ''; break; - case 'enum_multi': + case \registry::TYPE_ENUM_MULTI: if (isset($value['available']) && is_array($value['available'])) { foreach ($value['available'] as $k => $v) $input .= '
'; @@ -194,16 +195,11 @@ foreach ($GV as $section) { echo '

erreur avec la valeur ' . $value['name'] . '

'; } break; - case 'list': - - break; - case 'integer': + case \registry::TYPE_INTEGER: $input .= ''; break; - case 'password': - $input .= ''; break; - case 'timezone': + case \registry::TYPE_TIMEZONE: if (trim($currentValue) === '') { $datetime = new DateTime(); $currentValue = $datetime->getTimezone()->getName(); From 667c83eaf14f5fde6b738da69151709131f0e846 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 15:16:20 +0200 Subject: [PATCH 06/20] Fix array to string issue --- lib/classes/connection.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/connection.class.php b/lib/classes/connection.class.php index 1a86e5cbfe..e057c8ef87 100755 --- a/lib/classes/connection.class.php +++ b/lib/classes/connection.class.php @@ -75,7 +75,7 @@ class connection } $string .= "\nPOST datas :\n "; foreach ($_POST as $key => $value) { - $string .= "\t\t" . $key . ' = ' . $value . "\n"; + $string .= "\t\t" . $key . ' = ' . (is_scalar($value) ? $value : 'non-scalar value') . "\n"; } $string .= "\n\n\n\n"; From a95b1f1780217a2baa0943aecfc9c770841bc76d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 15:16:42 +0200 Subject: [PATCH 07/20] Fix patch --- lib/classes/patch/320aa.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/classes/patch/320aa.class.php b/lib/classes/patch/320aa.class.php index 713cb630aa..84bee9d930 100644 --- a/lib/classes/patch/320aa.class.php +++ b/lib/classes/patch/320aa.class.php @@ -58,7 +58,7 @@ class patch_320aa implements patchInterface } else { return; } - + require __DIR__ . '/../../../lib/conf.d/_GV_template.inc'; define('GV_STATIC_URL', ''); @@ -88,7 +88,6 @@ class patch_320aa implements patchInterface case registry::TYPE_INTEGER: case registry::TYPE_BOOLEAN: case registry::TYPE_STRING: - case registry::TYPE_ARRAY: $type = $datas['type']; break; default: From bcc2e9a58c60c43fea93567fc482c38ef8c4caf3 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 16:40:38 +0200 Subject: [PATCH 08/20] Updtae HTML5 icon --- templates/web/prod/upload/upload.html.twig | 2 +- www/skins/icons/html5-logo.jpeg | Bin 755 -> 0 bytes www/skins/icons/html5-logo.png | Bin 0 -> 910 bytes 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 www/skins/icons/html5-logo.jpeg create mode 100644 www/skins/icons/html5-logo.png diff --git a/templates/web/prod/upload/upload.html.twig b/templates/web/prod/upload/upload.html.twig index dbada965d2..d579baabad 100644 --- a/templates/web/prod/upload/upload.html.twig +++ b/templates/web/prod/upload/upload.html.twig @@ -37,7 +37,7 @@ - +

diff --git a/www/skins/icons/html5-logo.jpeg b/www/skins/icons/html5-logo.jpeg deleted file mode 100644 index deb6868477c27887ddb6e148dc79e11bbb53d81c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 755 zcmex=~;k+`^QRlZ%U&n^BUFPtsIH zPQ{cYps8tU`u_lfAP0j2g90<75(ASUBeNjm|04|IKxcv+iU4fvEUZ8YT>%D0W@aX4 zb{1x+93vAm3oDx-gOH-qL3YQ$iHj~iG&BlM6c!N$DwkknV1g-xs0S+t%BTo}3}Rtq zgXPL@PBIkUnNYLk{g!RpZ}+Ue^*zhZV&#?;5X^koM}gP>h`YRDZ5pX zHGaW5D`_>+Jss;-*?L9Y<51l)WrE0>0{Qg5-E-%dZ);YpeLZEp!jwNRBX<;5U2a-@ zEaOh(rhC`K1y9u-sSBI^ckj2B);iOLaSN$KJR7hVPp#i&uZrJzCZA za*VPMK4UUA1%brOwyLLs+Qs&h6%hg5PQ%+Z@gkRoz?czBjK2DXd7q;1ay{}-v YUMM^(`pB&Y44d22CBc*fy<nMx zdw&-!0hD>B7u20i&vZDOWbAaf93ueZ`Qz68UPc8YpgV{WEge^>Og(8Ibid?ENNS5u37=$myVBO{6lePDx;QXdc}`8~>V- zB+<_kt8u%-+OA3cbrT6!JCQdprIQYktSnAe>fjJ0uitY6A^z>zRd>*>UoF-oAK%&c zcHXf&EZ!Z7+_e@6^0U%>kI+Ehejr@bEwU!-76*h&QvCwA{FV7TxeZLsjY*$t!}(5* zFd7(iNbAAvzLw+UoZ2bh*uN3a7cAiHzSzr1<>x? zhqT8AMmy6{iX92^br~Ry95Hsw2H@S68(@~++iLGENAU`?V<$D&W&!4B?Ji+O$^g-k ztGM6?FmO?VyJj0V1n!`|wB1hKUecTKKHf3cjXxGx2KA)u6FFnb&XeXrGYup}D#Czx z$iKoF1D%sDiezN$H&4^%Ar;S)&L`x8A4deHqb)TB0g&J4z>>2trl1u03oHbn0S<_1 kfw!N|7p`~f@4o;80M6u#p4NrF0{{R307*qoM6N<$f)8$*L;wH) literal 0 HcmV?d00001 From b9a7080357048ea684d38c6dc8a9353a55263773 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 16:43:18 +0200 Subject: [PATCH 09/20] Switch to binary config file --- .../Phrasea/Controller/Setup/Installer.php | 32 +++++--- lib/Alchemy/Phrasea/Core.php | 32 ++++---- lib/classes/API/V1/adapter.class.php | 19 ++--- lib/classes/patch/373.class.php | 51 +++++++++---- lib/classes/recordutils/image.class.php | 10 +-- lib/classes/registry.class.php | 15 +++- lib/classes/setup.class.php | 22 +++--- lib/classes/task/Scheduler.class.php | 4 +- lib/conf.d/_GV_template.inc | 73 ------------------- .../Alchemy/Phrasea/Application/SetupTest.php | 20 ++--- tests/registryTest.php | 27 ------- www/admin/runscheduler.php | 2 +- 12 files changed, 126 insertions(+), 181 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php index a2b5fcec64..cf4eb4c116 100644 --- a/lib/Alchemy/Phrasea/Controller/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Controller/Setup/Installer.php @@ -11,11 +11,11 @@ namespace Alchemy\Phrasea\Controller\Setup; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Silex\Application; use Silex\ControllerProviderInterface; use Silex\ControllerCollection; +use \Symfony\Component\Yaml\Dumper; /** * @@ -211,23 +211,31 @@ class Installer implements ControllerProviderInterface } } + $binaries = array( + 'php' => $request->get('binary_php'), + 'convert' => $request->get('binary_convert'), + 'composite' => $request->get('binary_composite'), + 'swf_extract' => $request->get('binary_swfextract'), + 'pdf2swf' => $request->get('binary_pdf2swf'), + 'swf_render' => $request->get('binary_swfrender'), + 'unoconv' => $request->get('binary_unoconv'), + 'ffmpeg' => $request->get('binary_ffmpeg'), + 'mp4box' => $request->get('binary_MP4Box'), + 'pdftotext' => $request->get('binary_xpdf'), + ); + + $binariesFile = __DIR__ . '/../../../../../config/binaries.yml'; + $dumper = new Dumper(); + file_put_contents($binariesFile, $dumper->dump(array('binaries' => $binaries), 4)); + + @chmod($binariesFile, 0600); + $registry = \registry::get_instance(); \setup::create_global_values($registry); $appbox->set_registry($registry); $registry->set('GV_base_datapath_noweb', \p4string::addEndSlash($request->get('datapath_noweb')), \registry::TYPE_STRING); - $registry->set('GV_ServerName', $servername, \registry::TYPE_STRING); - $registry->set('GV_cli', $request->get('binary_php'), \registry::TYPE_STRING); - $registry->set('GV_imagick', $request->get('binary_convert'), \registry::TYPE_STRING); - $registry->set('GV_pathcomposite', $request->get('binary_composite'), \registry::TYPE_STRING); - $registry->set('GV_swf_extract', $request->get('binary_swfextract'), \registry::TYPE_STRING); - $registry->set('GV_pdf2swf', $request->get('binary_pdf2swf'), \registry::TYPE_STRING); - $registry->set('GV_swf_render', $request->get('binary_swfrender'), \registry::TYPE_STRING); - $registry->set('GV_unoconv', $request->get('binary_unoconv'), \registry::TYPE_STRING); - $registry->set('GV_ffmpeg', $request->get('binary_ffmpeg'), \registry::TYPE_STRING); - $registry->set('GV_mp4box', $request->get('binary_MP4Box'), \registry::TYPE_STRING); - $registry->set('GV_pdftotext', $request->get('binary_xpdf'), \registry::TYPE_STRING); $user = \User_Adapter::create($appbox, $request->get('email'), $request->get('password'), $request->get('email'), true); diff --git a/lib/Alchemy/Phrasea/Core.php b/lib/Alchemy/Phrasea/Core.php index 488a330d18..1472f7dc30 100644 --- a/lib/Alchemy/Phrasea/Core.php +++ b/lib/Alchemy/Phrasea/Core.php @@ -166,32 +166,32 @@ class Core extends \Pimple $conf = new ParameterBag(); - if ($core->getRegistry()->get('GV_ffmpeg')) { - $conf->set('ffmpeg', $core->getRegistry()->get('GV_ffmpeg')); + if ($core->getRegistry()->get('ffmpeg_binary')) { + $conf->set('ffmpeg', $core->getRegistry()->get('ffmpeg_binary')); } if ($core->getRegistry()->get('GV_ffmpeg_threads')) { $conf->set('ffmpeg.threads', $core->getRegistry()->get('GV_ffmpeg_threads')); } - if ($core->getRegistry()->get('GV_ffprobe')) { - $conf->set('ffprobe', $core->getRegistry()->get('GV_ffprobe')); + if ($core->getRegistry()->get('ffprobe_binary')) { + $conf->set('ffprobe', $core->getRegistry()->get('ffprobe_binary')); } if ($core->getRegistry()->get('GV_imagine_driver')) { $conf->set('imagine', $core->getRegistry()->get('GV_imagine_driver')); } - if ($core->getRegistry()->get('GV_mp4box')) { - $conf->set('MP4Box', $core->getRegistry()->get('GV_mp4box')); + if ($core->getRegistry()->get('mp4box_binary')) { + $conf->set('MP4Box', $core->getRegistry()->get('mp4box_binary')); } - if ($core->getRegistry()->get('GV_unoconv')) { - $conf->set('Unoconv', $core->getRegistry()->get('GV_unoconv')); + if ($core->getRegistry()->get('unoconv_binary')) { + $conf->set('Unoconv', $core->getRegistry()->get('unoconv_binary')); } - if ($core->getRegistry()->get('GV_pdf2swf')) { - $conf->set('Pdf2Swf', $core->getRegistry()->get('GV_pdf2swf')); + if ($core->getRegistry()->get('pdf2swf')) { + $conf->set('Pdf2Swf', $core->getRegistry()->get('pdf2swf_binary')); } - if ($core->getRegistry()->get('GV_swf_render')) { - $conf->set('SwfRender', $core->getRegistry()->get('GV_swf_render')); + if ($core->getRegistry()->get('swf_render_binary')) { + $conf->set('SwfRender', $core->getRegistry()->get('swf_render_binary')); } - if ($core->getRegistry()->get('GV_swf_extract')) { - $conf->set('SwfExtract', $core->getRegistry()->get('GV_swf_extract')); + if ($core->getRegistry()->get('swf_extract_binary')) { + $conf->set('SwfExtract', $core->getRegistry()->get('swf_extract_binary')); } $drivers = new \MediaAlchemyst\DriversContainer($conf, $core['monolog']); @@ -223,8 +223,8 @@ class Core extends \Pimple $this['pdf-to-text'] = $this->share(function () use ($core) { try { - if ($core->getRegistry()->get('GV_pdftotext')) { - $pdftotext = new PdfToText($core->getRegistry()->get('GV_pdftotext'), $core['monolog']); + if ($core->getRegistry()->get('pdftotext_binary')) { + $pdftotext = new PdfToText($core->getRegistry()->get('pdftotext_binary'), $core['monolog']); } else { $pdftotext = PdfToText::load($core['monolog']); } diff --git a/lib/classes/API/V1/adapter.class.php b/lib/classes/API/V1/adapter.class.php index 5de5365cdd..4f933dc679 100644 --- a/lib/classes/API/V1/adapter.class.php +++ b/lib/classes/API/V1/adapter.class.php @@ -434,16 +434,17 @@ class API_V1_adapter extends API_V1_Abstract ), ), 'binary' => array( - 'phpCli' => $registry->get('GV_cli'), + 'phpCli' => $registry->get('php_binary'), 'phpIni' => $registry->get('GV_PHP_INI'), - 'imagick' => $registry->get('GV_imagick'), - 'swfExtract' => $registry->get('GV_swf_extract'), - 'pdf2swf' => $registry->get('GV_pdf2swf'), - 'swfRender' => $registry->get('GV_swf_render'), - 'unoconv' => $registry->get('GV_unoconv'), - 'ffmpeg' => $registry->get('GV_ffmpeg'), - 'mp4box' => $registry->get('GV_mp4box'), - 'pdftotext' => $registry->get('GV_pdftotext'), + 'imagick' => $registry->get('convert_binary'), + 'swfExtract' => $registry->get('swf_extract_binary'), + 'pdf2swf' => $registry->get('pdf2swf_binary'), + 'swfRender' => $registry->get('swf_render_binary'), + 'unoconv' => $registry->get('unoconv_binary'), + 'ffmpeg' => $registry->get('ffmpeg_binary'), + 'ffprobe' => $registry->get('ffprobe_binary'), + 'mp4box' => $registry->get('mp4box_binary'), + 'pdftotext' => $registry->get('pdftotext_binary'), 'pdfmaxpages' => $registry->get('GV_pdfmaxpages'),), 'mainConfiguration' => array( 'adminMail' => $registry->get('GV_adminMail'), diff --git a/lib/classes/patch/373.class.php b/lib/classes/patch/373.class.php index 99b3bafc52..4184c1ca2b 100644 --- a/lib/classes/patch/373.class.php +++ b/lib/classes/patch/373.class.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +use Symfony\Component\Yaml\Dumper; + /** * * @license http://opensource.org/licenses/gpl-3.0 GPLv3 @@ -56,14 +58,10 @@ class patch_373 implements patchInterface */ public function apply(base &$appbox) { - $registry = $appbox->get_registry(); - - $sql = 'UPDATE registry SET type = :type, value = :value - WHERE `key` = :key'; - + $sql = 'SELECT * FROM registry WHERE `key` = :key'; $stmt = $appbox->get_connection()->prepare($sql); - $binaries = array( + $Regbinaries = array( 'GV_cli', 'GV_imagick', 'GV_pathcomposite', @@ -75,18 +73,43 @@ class patch_373 implements patchInterface 'GV_ffprobe', 'GV_mp4box', 'GV_pdftotext', - 'GV_cli', ); - foreach ($binaries as $binary) { + $mapping = array( + 'GV_cli' => 'php_binary', + 'GV_imagick' => 'convert_binary', + 'GV_pathcomposite' => 'composite_binary', + 'GV_swf_extract' => 'swf_extract_binary', + 'GV_pdf2swf' => 'pdf2swf_binary', + 'GV_swf_render' => 'swf_render_binary', + 'GV_unoconv' => 'unoconv_binary', + 'GV_ffmpeg' => 'ffmpeg_binary', + 'GV_ffprobe' => 'ffprobe_binary', + 'GV_mp4box' => 'mp4box_binary', + 'GV_pdftotext' => 'pdftotext_binary', + ); - $value = is_executable($registry->get($binary)) ? $registry->get($binary) : ''; + foreach ($Regbinaries as $name) { + $stmt->execute(array(':key' => $name)); + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $value = is_executable($row['value']) ? $row['value'] : ''; - $stmt->execute(array( - ':type' => \registry::TYPE_BINARY, - ':key' => $binary, - ':value' => $value, - )); + $binaries[$mapping[$name]] = $value; + } + + $stmt->closeCursor(); + + $binariesFile = __DIR__ . '/../../../config/binaries.yml'; + $dumper = new Dumper(); + file_put_contents($binariesFile, $dumper->dump(array('binaries' => $binaries), 4)); + + @chmod($binariesFile, 0600); + + $sql = 'DELETE FROM registry WHERE `key` = :key'; + $stmt = $appbox->get_connection()->prepare($sql); + + foreach ($Regbinaries as $name) { + $stmt->execute(array(':key' => $name)); } $stmt->closeCursor(); diff --git a/lib/classes/recordutils/image.class.php b/lib/classes/recordutils/image.class.php index 469c275c7e..bacb05b1ba 100644 --- a/lib/classes/recordutils/image.class.php +++ b/lib/classes/recordutils/image.class.php @@ -85,7 +85,7 @@ class recordutils_image extends recordutils return $subdef->get_pathfile(); } - if ( ! $registry->get('GV_imagick')) { + if ( ! $registry->get('convert_binary')) { return $subdef->get_pathfile(); } @@ -288,7 +288,7 @@ class recordutils_image extends recordutils $newh = $image_height + $stampheight; - $builder = ProcessBuilder::create(array($registry->get('GV_imagick'))); + $builder = ProcessBuilder::create(array($registry->get('convert_binary'))); $builder->add('-extent') ->add($image_width . 'x' . $newh) ->add('-draw') @@ -346,7 +346,7 @@ class recordutils_image extends recordutils file_exists($registry->get('GV_RootPath') . 'config/wm/' . $base_id)) { $builder = ProcessBuilder::create(array( - $registry->get('GV_pathcomposite'), + $registry->get('composite_binary'), $registry->get('GV_RootPath') . 'config/wm/' . $base_id, $pathIn, '-strip', '-watermark', '90%', '-gravity', 'center', @@ -354,7 +354,7 @@ class recordutils_image extends recordutils )); $builder->getProcess()->run(); - } elseif ($registry->get('GV_imagick')) { + } elseif ($registry->get('convert_binary')) { $collname = phrasea::bas_names($base_id); $tailleimg = @getimagesize($pathIn); $max = ($tailleimg[0] > $tailleimg[1] ? $tailleimg[0] : $tailleimg[1]); @@ -370,7 +370,7 @@ class recordutils_image extends recordutils $decalage = 1; $builder = ProcessBuilder::create(array( - $registry->get('GV_imagick'), + $registry->get('convert_binary'), '-fill', 'white', '-draw', 'line 0,0 ' . $tailleimg[0] . ',' . $tailleimg[1] . '', '-fill', 'black', '-draw', 'line 1,0 ' . $tailleimg[0] + 1 . ',' . $tailleimg[1] . '', '-fill', 'white', '-draw', 'line ' . $tailleimg[0] . ',0 0,' . $tailleimg[1] . '', diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index 6c34f5a89a..6237cd1980 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +use Symfony\Component\Yaml\Parser; + /** * * @license http://opensource.org/licenses/gpl-3.0 GPLv3 @@ -66,6 +68,17 @@ class registry implements registryInterface $this->cache->save('GV_ServerName', $configuration->getPhraseanet()->get('servername')); $this->cache->save('GV_debug', $configuration->isDebug()); $this->cache->save('GV_maintenance', $configuration->isMaintained()); + + $binariesFile = __DIR__ . '/../../config/binaries.yml'; + + if (file_exists($binariesFile)) { + $parser = new Parser(); + $binaries = $parser->parse(file_get_contents($binariesFile)); + + foreach ($binaries['binaries'] as $name => $path) { + $this->cache->save($name, $path); + } + } } return $this; @@ -151,7 +164,7 @@ class registry implements registryInterface public function set($key, $value, $type) { $this->load(); - + switch ($type) { case self::TYPE_ENUM_MULTI: $sql_value = serialize($value); diff --git a/lib/classes/setup.class.php b/lib/classes/setup.class.php index dcb8dad0a5..55691183e2 100644 --- a/lib/classes/setup.class.php +++ b/lib/classes/setup.class.php @@ -246,17 +246,17 @@ class setup $finder = new \Symfony\Component\Process\ExecutableFinder(); $binaries = array( - 'PHP CLI' => $registry->get('GV_cli', $finder->find('php')), - 'ImageMagick (convert)' => $registry->get('GV_imagick', $finder->find('convert')), - 'PDF 2 SWF' => $registry->get('GV_pdf2swf', $finder->find('pdf2swf')), - 'Unoconv' => $registry->get('GV_unoconv', $finder->find('unoconv')), - 'SWFextract' => $registry->get('GV_swf_extract', $finder->find('swfextract')), - 'SWFrender' => $registry->get('GV_swf_render', $finder->find('swfrender')), - 'MP4Box' => $registry->get('GV_mp4box', $finder->find('MP4Box')), - 'xpdf (pdf2text)' => $registry->get('GV_pdftotext', $finder->find('pdftotext')), - 'ImageMagick (composite)' => $registry->get('GV_pathcomposite', $finder->find('composite')), - 'FFmpeg' => $registry->get('GV_ffmpeg', $finder->find('ffmpeg')), - 'FFprobe' => $registry->get('GV_ffprobe', $finder->find('ffprobe')), + 'PHP CLI' => $registry->get('php_binary', $finder->find('php')), + 'ImageMagick (convert)' => $registry->get('convert_binary', $finder->find('convert')), + 'PDF 2 SWF' => $registry->get('pdf2swf_binary', $finder->find('pdf2swf')), + 'Unoconv' => $registry->get('unoconv_binary', $finder->find('unoconv')), + 'SWFextract' => $registry->get('swf_extract_binary', $finder->find('swfextract')), + 'SWFrender' => $registry->get('swf_render_binary', $finder->find('swfrender')), + 'MP4Box' => $registry->get('mp4box_binary', $finder->find('MP4Box')), + 'xpdf (pdf2text)' => $registry->get('pdftotext_binary', $finder->find('pdftotext')), + 'ImageMagick (composite)' => $registry->get('composite_binary', $finder->find('composite')), + 'FFmpeg' => $registry->get('ffmpeg_binary', $finder->find('ffmpeg')), + 'FFprobe' => $registry->get('ffprobe_binary', $finder->find('ffprobe')), 'phraseanet_indexer' => $finder->find('phraseanet_indexer'), ); diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index 4cf5b1454d..f464724e16 100755 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -59,7 +59,7 @@ class task_Scheduler $registry = $appbox->get_registry(); //prevent scheduler to fail if GV_cli is not provided - if ( ! is_executable($registry->get('GV_cli'))) { + if ( ! is_executable($registry->get('php_binary'))) { throw new \RuntimeException('PHP cli is not provided in registry'); } @@ -220,7 +220,7 @@ class task_Scheduler $taskPoll[$tkey] = array( "task" => $task, "current_status" => $status, - "cmd" => $registry->get('GV_cli'), + "cmd" => $registry->get('php_binary'), "args" => array( '-f', $registry->get('GV_RootPath') . 'bin/console', diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index a059c31fdb..6de418148d 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -385,13 +385,6 @@ $GV = array( 'comment' => _('reglages:: passphrase du mod_auth_token (definie dans le fichier de configuration apache)'), 'default' => false ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_cli', - 'comment' => _('reglages:: executable PHP CLI'), - 'default' => '', - 'required' => true - ), array( 'type' => \registry::TYPE_STRING, 'name' => 'GV_PHP_INI', @@ -410,78 +403,12 @@ $GV = array( \MediaAlchemyst\Driver\Imagine::DRIVER_GD => 'GD', ) ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_imagick', - 'default' => '', - 'comment' => _('reglages:: chemin de l\'executable convert'), - 'required' => true - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_pathcomposite', - 'default' => '', - 'comment' => _('reglages:: chemin de l\'executable composite'), - 'required' => true - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_swf_extract', - 'comment' => _('reglages:: chemin de l\'executable swfextract'), - 'default' => '', - 'required' => false - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_pdf2swf', - 'comment' => _('reglages:: chemin de l\'executable pdf2swf'), - 'default' => '', - 'required' => false - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_swf_render', - 'comment' => _('reglages:: chemin de l\'executable swfrender'), - 'default' => '', - 'required' => false - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_unoconv', - 'comment' => _('reglages:: chemin de l\'executable unoconv'), - 'default' => '', - 'required' => false - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_ffmpeg', - 'comment' => _('reglages:: chemin de l\'executable FFmpeg'), - 'default' => '' - ), array( 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_ffmpeg_threads', 'comment' => _('Number of threads allowed for FFmpeg'), 'default' => 2 ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_ffprobe', - 'comment' => _('FFprobe path'), - 'default' => '' - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_mp4box', - 'comment' => _('reglages:: chemin de l\'executable MP4Box'), - 'default' => '' - ), - array( - 'type' => \registry::TYPE_BINARY, - 'name' => 'GV_pdftotext', - 'comment' => _('reglages:: chemin de l\'executable pdftotext (xpdf)'), - 'default' => '' - ), array( 'type' => \registry::TYPE_INTEGER, 'name' => 'GV_pdfmaxpages', diff --git a/tests/Alchemy/Phrasea/Application/SetupTest.php b/tests/Alchemy/Phrasea/Application/SetupTest.php index f62acd1948..ab3b14ed28 100644 --- a/tests/Alchemy/Phrasea/Application/SetupTest.php +++ b/tests/Alchemy/Phrasea/Application/SetupTest.php @@ -47,16 +47,16 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAbstract $params = array( 'GV_base_datapath_noweb', 'GV_ServerName', - 'GV_cli', - 'GV_imagick', - 'GV_pathcomposite', - 'GV_swf_extract', - 'GV_pdf2swf', - 'GV_swf_render', - 'GV_unoconv', - 'GV_ffmpeg', - 'GV_mp4box', - 'GV_pdftotext', + 'php_binary', + 'convert_binary', + 'composite_binary', + 'swf_extract_binary', + 'pdf2swf_binary', + 'swf_render_binary', + 'unoconv_binary', + 'ffmpeg_binary', + 'mp4box_binary', + 'pdftotext_binary', ); $registry = $this->appbox->get_registry(); diff --git a/tests/registryTest.php b/tests/registryTest.php index 342e38100b..56a1450566 100644 --- a/tests/registryTest.php +++ b/tests/registryTest.php @@ -88,33 +88,6 @@ class registryTest extends PhraseanetPHPUnitAbstract $this->object->set('key_test', true, registry::TYPE_BOOLEAN); $this->assertTrue($this->object->get('key_test') === true); - /** - * Set value with type array - */ - $this->object->set('key_test', 'value1', registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array('value1')); - - $this->object->set('key_test', 1, registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array(1)); - - $this->object->set('key_test', '1', registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array('1')); - - $this->object->set('key_test', array('caca'), registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array('caca')); - - $this->object->set('key_test', '0', registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array('0')); - - $this->object->set('key_test', 0, registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array(0)); - - $this->object->set('key_test', false, registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array(false)); - - $this->object->set('key_test', true, registry::TYPE_ARRAY); - $this->assertTrue($this->object->get('key_test') === array(true)); - /** * Set value with type enum_multi */ diff --git a/www/admin/runscheduler.php b/www/admin/runscheduler.php index 4ac0b86780..15b3dc253a 100644 --- a/www/admin/runscheduler.php +++ b/www/admin/runscheduler.php @@ -45,7 +45,7 @@ if (defined('PHP_WINDOWS_VERSION_BUILD')) { $nullfile = 'NUL'; } -$phpcli = $registry->get('GV_cli'); +$phpcli = $registry->get('php_binary'); $cmd = escapeshellarg($phpcli) . ' -f ' . __DIR__ . "/../../bin/console scheduler:start"; From a6c4d8b0a5acfe59698b50c8f384a35a89184a5e Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 16:58:31 +0200 Subject: [PATCH 10/20] Move GV_cli to configuration file --- lib/classes/appbox.class.php | 6 ++++-- lib/classes/patch/373.class.php | 20 ++++++++++++++++++++ lib/classes/registry.class.php | 7 ++++++- lib/conf.d/_GV_template.inc | 10 ---------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lib/classes/appbox.class.php b/lib/classes/appbox.class.php index e3eea59181..d630775cb0 100644 --- a/lib/classes/appbox.class.php +++ b/lib/classes/appbox.class.php @@ -492,7 +492,7 @@ class appbox extends base $Core->getConfiguration()->setConnexions($connexion); - $services = $Core->getConfiguration()->getConfigurations(); + $services = $Core->getConfiguration()->getServices(); foreach ($services as $serviceName => $service) { if ($serviceName === "doctrine_prod") { @@ -504,10 +504,12 @@ class appbox extends base ); } } - $Core->getConfiguration()->setConfigurations($services); + $Core->getConfiguration()->setServices($services); $arrayConf = $Core->getConfiguration()->getConfigurations(); + $arrayConf['key'] = md5(time() . '--' . mt_rand(1000000, 9999999)); + foreach ($arrayConf as $key => $value) { if (is_array($value) && array_key_exists('phraseanet', $value)) { $arrayConf[$key]["phraseanet"]["servername"] = $serverName; diff --git a/lib/classes/patch/373.class.php b/lib/classes/patch/373.class.php index 4184c1ca2b..90f63a92cd 100644 --- a/lib/classes/patch/373.class.php +++ b/lib/classes/patch/373.class.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Alchemy\Phrasea\Core\Configuration; use Symfony\Component\Yaml\Dumper; /** @@ -114,6 +115,25 @@ class patch_373 implements patchInterface $stmt->closeCursor(); + $GV_sit = null; + + $sql = 'SELECT value FROM registry WHERE `key` = :key'; + $stmt = $appbox->get_connection()->prepare($sql); + $stmt->execute(array(':key'=>'GV_sit')); + $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); + + $configuration = Configuration::build(); + + $configs = $configuration->getConfigurations(); + $configs['key'] = $row['value']; + $configuration->setConfigurations($configs); + + $sql = 'DELETE FROM registry WHERE `key` = :key'; + $stmt = $appbox->get_connection()->prepare($sql); + $stmt->execute(array(':key'=>'GV_sit')); + $stmt->closeCursor(); + return true; } } diff --git a/lib/classes/registry.class.php b/lib/classes/registry.class.php index 6237cd1980..2948f68549 100644 --- a/lib/classes/registry.class.php +++ b/lib/classes/registry.class.php @@ -65,10 +65,15 @@ class registry implements registryInterface $this->cache->save('GV_RootPath', dirname(dirname(__DIR__)) . '/'); if ($configuration->isInstalled()) { + + $config = $configuration->getConfigurations(); + $this->cache->save('GV_ServerName', $configuration->getPhraseanet()->get('servername')); $this->cache->save('GV_debug', $configuration->isDebug()); $this->cache->save('GV_maintenance', $configuration->isMaintained()); - + if (isset($config['key'])) { + $this->cache->save('GV_sit', $config['key']); + } $binariesFile = __DIR__ . '/../../config/binaries.yml'; if (file_exists($binariesFile)) { diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index 6de418148d..a9a4ee2531 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -6,8 +6,6 @@ if (($pos = strpos($cwd, 'lib/conf.d')) !== false) $EOL = PHP_EOL; -$GV_sit = md5(time() . '--' . mt_rand(1000000, 9999999)); - include_once dirname(__FILE__) . "/../../lib/classes/User/Interface.class.php"; include_once dirname(__FILE__) . "/../../lib/classes/User/Adapter.class.php"; @@ -85,14 +83,6 @@ $GV = array( 'default' => 'Europe/Paris', 'required' => true ), - array( - 'type' => \registry::TYPE_STRING, - 'name' => 'GV_sit', - 'comment' => _('reglages:: Nom de linstallation'), - 'default' => $GV_sit, - 'readonly' => true, - 'required' => true - ), array( 'type' => \registry::TYPE_ENUM, 'name' => 'GV_default_lng', From bb905a66eb9ce349add9478697d4ef5b5b0ce9d3 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 16:58:47 +0200 Subject: [PATCH 11/20] Update configuration sample --- config/config.sample.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.sample.yml b/config/config.sample.yml index 525ed668c3..51db7023b4 100644 --- a/config/config.sample.yml +++ b/config/config.sample.yml @@ -3,6 +3,7 @@ #Declare which environment will be used by the application environment : prod +key : null #Declare all your environment configurations From 1fac463f2f5cc3d8b3290e2acc11065895ecfaea Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 5 Oct 2012 17:23:44 +0200 Subject: [PATCH 12/20] Add registry tests --- tests/registryTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/registryTest.php b/tests/registryTest.php index 56a1450566..e8b2c66fea 100644 --- a/tests/registryTest.php +++ b/tests/registryTest.php @@ -157,4 +157,14 @@ class registryTest extends PhraseanetPHPUnitAbstract $this->object->un_set('key_test'); $this->assertFalse($this->object->is_set('key_test')); } + + public function testGVSit() + { + $this->assertNotNull($this->object->get('GV_sit')); + } + public function testGVSitNotModifiable() + { + $gv_sit = $this->object->get('GV_sit'); + $this->assertEquals($gv_sit, $this->object->get('GV_sit')); + } } From c01af76587cab0673cb92e253a8c99b32e875a34 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 9 Oct 2012 14:18:31 +0200 Subject: [PATCH 13/20] Add TOU route --- config/nginx.rewrite.rules | 2 +- lib/Alchemy/Phrasea/Controller/Prod/TOU.php | 20 ++++++++++++++++++++ templates/web/prod/TOU.html.twig | 9 +++++++++ www/.htaccess | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 templates/web/prod/TOU.html.twig diff --git a/config/nginx.rewrite.rules b/config/nginx.rewrite.rules index 5e54b68b17..66733c814c 100644 --- a/config/nginx.rewrite.rules +++ b/config/nginx.rewrite.rules @@ -32,7 +32,7 @@ rewrite ^/prod/story/.*$ /prod/router.php last; rewrite ^/prod/WorkZone/.*$ /prod/router.php last; rewrite ^/prod/language/.*$ /prod/router.php last; rewrite ^/prod/tools/.*$ /prod/router.php last; -rewrite ^/prod/TOU/.*$ /prod/router.php last; +rewrite ^/prod/TOU/.?$ /prod/router.php last; rewrite ^/prod/upload/.*$ /prod/router.php last; rewrite ^/prod/lazaret/.*$ /prod/router.php last; rewrite ^/prod/UserPreferences/.*$ /prod/router.php last; diff --git a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php index 917de3c92a..90d036082e 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/TOU.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/TOU.php @@ -56,6 +56,26 @@ class TOU implements ControllerProviderInterface return new Response($datas, 200, array('Content-Type' => 'application/json')); }); + $controllers->get('/', function(Application $app, Request $request) { + + $appbox = \appbox::get_instance($app['Core']); + + $data = array(); + + foreach ($appbox->get_databoxes() as $databox) { + + $cgus = $databox->get_cgus(); + + if (!isset($cgus[\Session_Handler::get_locale()])) { + continue; + } + + $data[$databox->get_viewname()] = $cgus[\Session_Handler::get_locale()]['value']; + } + + return new Response($app['Core']['Twig']->render('/prod/TOU.html.twig', array('TOUs' => $data))); + }); + return $controllers; } } diff --git a/templates/web/prod/TOU.html.twig b/templates/web/prod/TOU.html.twig new file mode 100644 index 0000000000..cd6b7cf190 --- /dev/null +++ b/templates/web/prod/TOU.html.twig @@ -0,0 +1,9 @@ +

+ {% for name, TOU in TOUs %} +

{{ name }}

+ {{ TOU }} + {% if loop.last == false %} +
+ {% endif %} + {% endfor %} +
\ No newline at end of file diff --git a/www/.htaccess b/www/.htaccess index 211328fe0b..63823f5de3 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -32,7 +32,7 @@ RewriteRule ^prod/push/.*$ /prod/router.php [L] RewriteRule ^prod/printer/.*$ /prod/router.php [L] RewriteRule ^prod/story/.*$ /prod/router.php [L] - RewriteRule ^prod/TOU/.*$ /prod/router.php [L] + RewriteRule ^prod/TOU/.?$ /prod/router.php [L] RewriteRule ^prod/WorkZone/.*$ /prod/router.php [L] RewriteRule ^prod/language/.*$ /prod/router.php [L] RewriteRule ^prod/tools/.*$ /prod/router.php [L] From 12ea1fc1846cabfcf2b115228900119c79c0f978 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 9 Oct 2012 14:19:38 +0200 Subject: [PATCH 14/20] Add option to re-accept terms of use at download --- lib/conf.d/_GV_template.inc | 6 + templates/web/common/dialog_export.twig | 143 +++++++++++++++++++++--- www/prod/jquery.Dialog.js | 12 +- www/prod/page0.js | 4 +- 4 files changed, 141 insertions(+), 24 deletions(-) diff --git a/lib/conf.d/_GV_template.inc b/lib/conf.d/_GV_template.inc index fe4de236b6..29e57981e3 100644 --- a/lib/conf.d/_GV_template.inc +++ b/lib/conf.d/_GV_template.inc @@ -764,6 +764,12 @@ $GV = array( 'name' => 'GV_needAuth2DL', 'comment' => _('reglages:: Il est necessaire d\'etre connecte pour pouvoir telecharger en compte invite'), 'default' => true + ), + array( + 'type' => 'boolean', + 'name' => 'GV_requireTOUValidationForExport', + 'comment' => _('Users must accept Terms of Use for each export'), + 'default' => false ) ) ), array( diff --git a/templates/web/common/dialog_export.twig b/templates/web/common/dialog_export.twig index 4fc7309291..e99ed0b97e 100644 --- a/templates/web/common/dialog_export.twig +++ b/templates/web/common/dialog_export.twig @@ -106,18 +106,20 @@ {% for name, values in download.get_display_download() %} {% if values.available > 0 %} -
+
- {% set title%} - {% trans 'Documents indisponibles' %} - {% endset %} {% if values.refused|length > 0 %} - + {% endif %} {{ _self.choose_title('download', choose_export_title, default_export_title) }} + + {% if registry.get('GV_requireTOUValidationForExport') == true %} +
+ +
+ {% endif %}
@@ -179,12 +194,17 @@ {% set title%} {% trans 'Documents indisponibles' %} {% endset %} {% if values.refused|length > 0 %} - + {% endif %} {{ _self.choose_title('sendmail', choose_export_title, default_export_title) }} + + {% if registry.get('GV_requireTOUValidationForExport') == true %} +
+ +
+ {% endif %}
@@ -345,7 +378,10 @@ {% trans 'Documents indisponibles' %} {% endset %} {% if values.refused|length > 0 %} - + + {% set title%} + {% trans 'Documents indisponibles' %} + {% endset %} + + + + {% if registry.get('GV_requireTOUValidationForExport') == true %} +
+ +
+ {% endif %}
@@ -400,12 +449,14 @@ - {% set title%} - {% trans 'Documents indisponibles' %} - {% endset %} {% if values.refused|length > 0 %} - + + {% set title%} + {% trans 'Documents indisponibles' %} + {% endset %} + + + {% endif %} + + {% if values.refused|length > 0 %} {% endif %} + + {% if registry.get('GV_requireTOUValidationForExport') == true %} +
+ +
+ {% endif %}
@@ -453,6 +517,25 @@