update installer
This commit is contained in:
parent
a42256b296
commit
8dac72e924
101
install.php
101
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 <code>tmp/cache</code> directory.'
|
||||
),
|
||||
array(
|
||||
'category' => 'File permissions',
|
||||
'name' => getcwd() . '/inc/instance-config.php',
|
||||
'result' => is_writable('inc/instance-config.php'),
|
||||
'required' => false,
|
||||
@ -763,14 +803,24 @@ if ($step == 0) {
|
||||
|
||||
$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 =
|
||||
'<?php
|
||||
'<'.'?php
|
||||
|
||||
/*
|
||||
* Instance Configuration
|
||||
@ -800,28 +854,11 @@ if ($step == 0) {
|
||||
|
||||
';
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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']);
|
||||
|
@ -87,6 +87,9 @@
|
||||
<legend>Miscellaneous</legend>
|
||||
<label for="secure_trip_salt">Secure trip (##) salt:</label>
|
||||
<input type="text" id="secure_trip_salt" name="secure_trip_salt" value="{{ config.secure_trip_salt }}" size="40">
|
||||
|
||||
<label for="more">Additional configuration:</label>
|
||||
<textarea id="more" name="more">{{ more }}</textarea>
|
||||
</fieldset>
|
||||
|
||||
<p style="text-align:center">
|
||||
|
Loading…
Reference in New Issue
Block a user