Browse Source

Installer: Nicer pre-installation test

pull/40/head
Michael Foster 11 years ago
parent
commit
f06978659b
  1. 19
      inc/config.php
  2. 191
      install.php
  3. 54
      templates/installer/check-requirements.html

19
inc/config.php

@ -418,16 +418,17 @@
$config['thumb_keep_animation_frames'] = 1; $config['thumb_keep_animation_frames'] = 1;
// Thumbnailing method: // Thumbnailing method:
// - 'gd' PHP GD (default). Only handles the most basic image formats (GIF, JPEG, PNG). // - 'gd' PHP GD (default). Only handles the most basic image formats (GIF, JPEG, PNG).
// This is a prerequisite for Tinyboard no matter what method you choose. // This is a prerequisite for Tinyboard no matter what method you choose.
// - 'imagick' PHP's ImageMagick bindings. Fast and efficient, supporting many image formats. // - 'imagick' PHP's ImageMagick bindings. Fast and efficient, supporting many image formats.
// A few minor bugs. http://pecl.php.net/package/imagick // A few minor bugs. http://pecl.php.net/package/imagick
// - 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in // - 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in
// PHP Imagick. // PHP Imagick. `convert` produces the best still thumbnails and is highly recommended.
// - 'convert+gifsicle' Same as above, with the exception of using `gifsicle` (command line application) // - 'convert+gifsicle' Same as above, with the exception of using `gifsicle` (command line application)
// instead of `convert` for resizing gifs. It's faster and resulting animated gifs // instead of `convert` for resizing GIFs. It's faster and resulting animated thumbnails
// have less artifacts than if resized with ImageMagick. // have less artifacts than if resized with ImageMagick.
$config['thumb_method'] = 'gd'; $config['thumb_method'] = 'gd';
// $config['thumb_method'] = 'convert';
// Strip EXIF metadata from JPEG files // Strip EXIF metadata from JPEG files
$config['strip_exif'] = false; $config['strip_exif'] = false;

191
install.php

@ -388,53 +388,156 @@ if ($step == 0) {
} elseif ($step == 1) { } elseif ($step == 1) {
$page['title'] = 'Pre-installation test'; $page['title'] = 'Pre-installation test';
$page['body'] = '<table class="test">'; $can_exec = true;
if (!function_exists('shell_exec'))
function rheader($item) { $can_exec = false;
global $page, $config; elseif (in_array('shell_exec', array_map('trim', explode(', ', ini_get('disable_functions')))))
$can_exec = false;
$page['body'] .= '<tr class="h"><th colspan="2">' . $item . '</th></tr>'; elseif (ini_get('safe_mode'))
} $can_exec = false;
elseif (trim(shell_exec('echo "TEST"')) !== 'TEST')
function row($item, $result) { $can_exec = false;
global $page, $config, $__is_error;
if (!$result) if (!defined('PHP_VERSION_ID')) {
$__is_error = true; $version = explode('.', PHP_VERSION);
$page['body'] .= '<tr><th>' . $item . '</th><td><img style="width:16px;height:16px" src="' . $config['dir']['static'] . ($result ? 'ok.png' : 'error.png') . '" /></td></tr>'; define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
} }
// Required extensions // Required extensions
rheader('PHP extensions'); $extensions = array(
row('PDO', extension_loaded('pdo')); 'PDO' => array(
row('GD', extension_loaded('gd')); 'installed' => extension_loaded('pdo'),
'required' => true
// GD tests ),
rheader('GD tests'); 'PDO' => array(
row('JPEG', function_exists('imagecreatefromjpeg')); 'installed' => extension_loaded('gd'),
row('PNG', function_exists('imagecreatefrompng')); 'required' => true
row('GIF', function_exists('imagecreatefromgif')); ),
'Imagick' => array(
// Database drivers 'installed' => extension_loaded('imagick'),
$drivers = PDO::getAvailableDrivers(); 'required' => false
)
rheader('PDO drivers <em>(currently installed drivers)</em>'); );
foreach ($drivers as &$driver) {
row($driver, true); $tests = array(
} array(
'category' => 'PHP',
// Permissions 'name' => 'PHP &ge; 5.2.5',
rheader('File permissions'); 'result' => PHP_VERSION_ID >= 50205,
row('<em>root directory</em> (' . getcwd() . ')', is_writable('.')); 'required' => true,
'message' => 'Tinyboard requires PHP 5.2.5 or better.',
$page['body'] .= '</table> ),
<p style="text-align:center"> array(
<a href="?step=2"' . 'category' => 'PHP',
(isset($__is_error) ? ' onclick="return confirm(\'Are you sure you want to continue when errors exist?\')"' : '') . 'name' => 'PHP &ge; 5.3',
'>Continue' . (isset($__is_error) ? ' anyway' : '') . '</a> 'result' => PHP_VERSION_ID >= 50300,
</p>'; 'required' => false,
'message' => 'PHP &ge; 5.3, though not required, is recommended to make the most out of Tinyboard configuration files.',
echo Element('page.html', $page); ),
array(
'category' => 'PHP',
'name' => 'mbstring extension installed',
'result' => extension_loaded('mbstring'),
'required' => true,
'message' => 'You must install the PHP <a href="http://www.php.net/manual/en/mbstring.installation.php">mbstring</a> extension.',
),
array(
'category' => 'Database',
'name' => 'PDO extension installed',
'result' => extension_loaded('pdo'),
'required' => true,
'message' => 'You must install the PHP <a href="http://www.php.net/manual/en/intro.pdo.php">PDO</a> extension.',
),
array(
'category' => 'Database',
'name' => 'MySQL PDO driver installed',
'result' => extension_loaded('pdo') && in_array('mysql1', PDO::getAvailableDrivers()),
'required' => true,
'message' => 'The required <a href="http://www.php.net/manual/en/ref.pdo-mysql.php">PDO MySQL driver</a> is not installed.',
),
array(
'category' => 'Image processing',
'name' => 'GD extension installed',
'result' => extension_loaded('gd'),
'required' => true,
'message' => 'You must install the PHP <a href="http://www.php.net/manual/en/intro.image.php">GD</a> extension. GD is a requirement even if you have chosen another image processor for thumbnailing.',
),
array(
'category' => 'Image processing',
'name' => 'GD: JPEG',
'result' => function_exists('imagecreatefromjpeg'),
'required' => true,
'message' => 'imagecreatefromjpeg() does not exist. This is a problem.',
),
array(
'category' => 'Image processing',
'name' => 'GD: PNG',
'result' => function_exists('imagecreatefrompng'),
'required' => true,
'message' => 'imagecreatefrompng() does not exist. This is a problem.',
),
array(
'category' => 'Image processing',
'name' => 'GD: GIF',
'result' => function_exists('imagecreatefromgif'),
'required' => true,
'message' => 'imagecreatefromgif() does not exist. This is a problem.',
),
array(
'category' => 'Image processing',
'name' => 'Imagick extension installed',
'result' => extension_loaded('imagick1'),
'required' => false,
'message' => '(Optional) The PHP <a href="http://www.php.net/manual/en/imagick.installation.php">Imagick</a> (ImageMagick) extension is not installed. You may not use Imagick for better (and faster) image processing.',
),
array(
'category' => 'Image processing',
'name' => '`convert` (command-line ImageMagick)',
'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.',
),
array(
'category' => 'Image processing',
'name' => '`identify` (command-line ImageMagick)',
'result' => $can_exec && shell_exec('which identify'),
'required' => false,
'message' => '(Optional) `identify` was not found or executable; command-line ImageMagick image processing cannot be enabled.',
),
array(
'category' => 'Image processing',
'name' => '`gifsicle` (command-line animted GIF thumbnailing)',
'result' => $can_exec && shell_exec('which gifsicle1'),
'required' => false,
'message' => '(Optional) `gifsicle` was not found or executable; you may not use `convert+gifsicle` for better animated GIF thumbnailing.',
),
array(
'category' => 'File permissions',
'name' => getcwd(),
'result' => is_writable('.'),
'required' => true,
'message' => 'Tinyboard does not have permission to create directories (boards) here. You will need to <code>chmod</code> (or operating system equivalent) appropriately.'
),
array(
'category' => 'File permissions',
'name' => getcwd() . '/inc/instance-config.php',
'result' => is_writable('inc/instance-config.php'),
'required' => false,
'message' => 'Tinyboard does not have permission to make changes to inc/instance-config.php. To complete the installation, you will be asked to manually copy and paste code into the file instead.'
)
);
$config['font_awesome'] = true;
echo Element('page.html', array(
'body' => Element('installer/check-requirements.html', array(
'extensions' => $extensions,
'tests' => $tests,
'config' => $config
)),
'title' => 'Checking environment',
'config' => $config
));
} elseif ($step == 2) { } elseif ($step == 2) {
// Basic config // Basic config
$page['title'] = 'Configuration'; $page['title'] = 'Configuration';

54
templates/installer/check-requirements.html

@ -0,0 +1,54 @@
<div style="max-width:700px;margin:auto">
<h2 style="text-align:center">Pre-installation tests</h2>
<table class="modlog" style="margin-top:10px;max-width:600px">
<tr>
<th>Category</th>
<th>Test</th>
<th>Result</th>
</tr>
{% set errors = 0 %}
{% set warnings = 0 %}
{% for test in tests %}
<tr>
<td class="minimal"><strong>{{ test.category }}</strong></td>
<td>{{ test.name }}</td>
<td class="minimal" style="text-align:center">
{% if test.result %}
<i style="color:#090" class="icon-check-sign"></i>
{% else %}
{% if test.required %}
{% set errors = errors + 1 %}
<i style="color:#d00" class="icon-exclamation-sign"></i>
{% else %}
{% set warnings = warnings + 1 %}
<i style="color:#f80" class="icon-warning-sign"></i>
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{% if errors or warnings %}
<p><strong>There were {{ errors }} error(s) and {{ warnings }} warning(s).</strong></p>
<ul>
{% for test in tests if not test.result%}
<li style="margin-bottom:5px">
{% if test.required %}
<i style="color:#d00" class="icon-exclamation-sign"></i> <strong>Error:</strong>
{% else %}
<i style="color:#f80" class="icon-warning-sign"></i> <strong>Warning:</strong>
{% endif %}
{{ test.message }}
</li>
{% endfor %}
</ul>
{% if errors %}
<p style="text-align:center"><a href="?step=2">Clik here to ignore errors and attempt installing anyway (not recommended).</a></p>
{% else %}
<p style="text-align:center"><a href="?step=2">Clik here to proceed with installation.</a></p>
{% endif %}
{% else %}
<p>There were no errors or warnings. Good!</p>
<p style="text-align:center"><a href="?step=2">Clik here to proceed with installation.</a></p>
{% endif %}
</div>
Loading…
Cancel
Save