From 8dac72e924d658e66c5efe3334aa8ab41d00daca Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 5 May 2016 09:16:09 +0200 Subject: [PATCH] update installer --- install.php | 103 +++++++++++++++++++++++++++------------- templates/installer/config.html | 3 ++ 2 files changed, 73 insertions(+), 33 deletions(-) diff --git a/install.php b/install.php index 968c41de..7a146c8e 100644 --- a/install.php +++ b/install.php @@ -581,6 +581,25 @@ if (file_exists($config['has_installed'])) { die(Element('page.html', $page)); } +function create_config_from_array(&$instance_config, &$array, $prefix = '') { + foreach ($array as $name => $value) { + if (is_array($value)) { + $instance_config .= "\n"; + create_config_from_array($instance_config, $value, $prefix . '[\'' . addslashes($name) . '\']'); + $instance_config .= "\n"; + } else { + $instance_config .= ' $config' . $prefix . '[\'' . addslashes($name) . '\'] = '; + + if (is_numeric($value)) + $instance_config .= $value; + else + $instance_config .= "'" . addslashes($value) . "'"; + + $instance_config .= ";\n"; + } + } +} + if ($step == 0) { // Agreeement $page['body'] = ' @@ -614,7 +633,7 @@ if ($step == 0) { 'installed' => extension_loaded('pdo'), 'required' => true ), - 'PDO' => array( + 'GD' => array( 'installed' => extension_loaded('gd'), 'required' => true ), @@ -627,17 +646,17 @@ if ($step == 0) { $tests = array( array( 'category' => 'PHP', - 'name' => 'PHP ≥ 5.3', - 'result' => PHP_VERSION_ID >= 50300, + 'name' => 'PHP ≥ 5.4', + 'result' => PHP_VERSION_ID >= 50400, 'required' => true, - 'message' => 'vichan requires PHP 5.3 or better.', + 'message' => 'vichan requires PHP 5.4 or better.', ), array( 'category' => 'PHP', - 'name' => 'PHP ≥ 5.4', - 'result' => PHP_VERSION_ID >= 50400, + 'name' => 'PHP ≥ 5.6', + 'result' => PHP_VERSION_ID >= 50600, 'required' => false, - 'message' => 'vichan works best on PHP 5.4 or better.', + 'message' => 'vichan works best on PHP 5.6 or better.', ), array( 'category' => 'PHP', @@ -694,6 +713,7 @@ if ($step == 0) { 'result' => $can_exec && shell_exec('which convert'), 'required' => false, 'message' => '(Optional) `convert` was not found or executable; command-line ImageMagick image processing cannot be enabled.', + 'effect' => function (&$config) { $config['thumb_method'] = 'convert'; }, ), array( 'category' => 'Image processing', @@ -708,6 +728,7 @@ if ($step == 0) { 'result' => $can_exec && shell_exec('which gm'), 'required' => false, 'message' => '(Optional) `gm` was not found or executable; command-line GraphicsMagick (faster than ImageMagick) cannot be enabled.', + 'effect' => function (&$config) { $config['thumb_method'] = 'gm'; }, ), array( 'category' => 'Image processing', @@ -715,13 +736,25 @@ if ($step == 0) { 'result' => $can_exec && shell_exec('which gifsicle'), 'required' => false, 'message' => '(Optional) `gifsicle` was not found or executable; you may not use `convert+gifsicle` for better animated GIF thumbnailing.', + 'effect' => function (&$config) { if ($config['thumb_method'] == 'gm') $config['thumb_method'] = 'gm+gifsicle'; + if ($config['thumb_method'] == 'convert') $config['thumb_method'] = 'convert+gifsicle'; }, ), array( 'category' => 'Image processing', - 'name' => '`md5sum` (quick file hashing)', + 'name' => '`md5sum` (quick file hashing on GNU/Linux)', + 'prereq' => '', 'result' => $can_exec && shell_exec('echo "vichan" | md5sum') == "141225c362da02b5c359c45b665168de -\n", 'required' => false, - 'message' => '(Optional) `md5sum` was not found or executable; file hashing for multiple images will be slower.', + 'message' => '(Optional) `md5sum` was not found or executable; file hashing for multiple images will be slower. Ignore if not using Linux.', + 'effect' => function (&$config) { $config['gnu_md5'] = true; }, + ), + array( + 'category' => 'Image processing', + 'name' => '`/sbin/md5` (quick file hashing on BSDs)', + 'result' => $can_exec && shell_exec('echo "vichan" | /sbin/md5 -r') == "141225c362da02b5c359c45b665168de\n", + 'required' => false, + 'message' => '(Optional) `/sbin/md5` was not found or executable; file hashing for multiple images will be slower. Ignore if not using BSD.', + 'effect' => function (&$config) { $config['bsd_md5'] = true; }, ), array( 'category' => 'File permissions', @@ -739,6 +772,13 @@ if ($step == 0) { ), array( 'category' => 'File permissions', + 'name' => getcwd() . '/tmp/cache', + 'result' => is_dir('tmp/cache') && is_writable('tmp/cache'), + 'required' => true, + 'message' => 'You must give vichan permission to write to the tmp/cache directory.' + ), + array( + 'category' => 'File permissions', 'name' => getcwd() . '/inc/instance-config.php', 'result' => is_writable('inc/instance-config.php'), 'required' => false, @@ -760,17 +800,27 @@ if ($step == 0) { 'message' => 'vichan is still beta software and it\'s not going to come out of beta any time soon. As there are often many months between releases yet changes and bug fixes are very frequent, it\'s recommended to use the git repository to maintain your vichan installation. Using git makes upgrading much easier.' ) ); - + $config['font_awesome'] = true; + $additional_config = array(); + foreach ($tests as $test) { + if ($test['result'] && $test['effect']) { + $test['effect']($additional_config); + } + } + $more = ''; + create_config_from_array($more, $additional_config); + $_SESSION['more'] = $more; + echo Element('page.html', array( 'body' => Element('installer/check-requirements.html', array( 'extensions' => $extensions, 'tests' => $tests, - 'config' => $config + 'config' => $config, )), 'title' => 'Checking environment', - 'config' => $config + 'config' => $config, )); } elseif ($step == 2) { // Basic config @@ -781,14 +831,18 @@ if ($step == 0) { echo Element('page.html', array( 'body' => Element('installer/config.html', array( - 'config' => $config + 'config' => $config, + 'more' => $more, )), 'title' => 'Configuration', 'config' => $config )); } elseif ($step == 3) { + $more = $_POST['more']; + unset($_POST['more']); + $instance_config = -' $value) { - if (is_array($value)) { - $instance_config .= "\n"; - create_config_from_array($instance_config, $value, $prefix . '[\'' . addslashes($name) . '\']'); - $instance_config .= "\n"; - } else { - $instance_config .= ' $config' . $prefix . '[\'' . addslashes($name) . '\'] = '; - - if (is_numeric($value)) - $instance_config .= $value; - else - $instance_config .= "'" . addslashes($value) . "'"; - - $instance_config .= ";\n"; - } - } - } - create_config_from_array($instance_config, $_POST); $instance_config .= "\n"; + $instance_config .= $more; + $instance_config .= "\n"; if (@file_put_contents('inc/instance-config.php', $instance_config)) { header('Location: ?step=4', true, $config['redirect_http']); diff --git a/templates/installer/config.html b/templates/installer/config.html index 193bb98b..973328f5 100644 --- a/templates/installer/config.html +++ b/templates/installer/config.html @@ -87,6 +87,9 @@ Miscellaneous + + +