discourse-legacysite-perl/site/runshops/phpthumb/demo/phpThumb.demo.check.php
2024-06-17 22:42:14 +10:00

278 lines
12 KiB
PHP

<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.check.php //
// James Heinrich <info@silisoftware.com> //
// //
// Configuration analyzer for phpThumb settings and server //
// settings that may affect phpThumb performance //
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
// //
//////////////////////////////////////////////////////////////
$ServerInfo['gd_string'] = 'unknown';
$ServerInfo['gd_numeric'] = 0;
ob_start();
if (!@include_once('../phpthumb.functions.php')) {
ob_end_flush();
die('failed to include_once("../phpthumb.functions.php")');
}
if (!@include_once('../phpthumb.class.php')) {
ob_end_flush();
die('failed to include_once("../phpthumb.class.php")');
}
ob_end_clean();
$phpThumb = new phpThumb();
if (include_once('../phpThumb.config.php')) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_'.$key;
$phpThumb->setParameter($keyname, $value);
}
}
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
$gd_info = gd_info();
?>
<html>
<head>
<title>phpThumb configuration analyzer</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
</head>
<body bgcolor="#C5C5C5">
This demo analyzes your settings (phpThumb.config.php and server/PHP) for <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a>.<br>
<br>
<table border="1">
<tr><th colspan="8">&lt;-- bad to good --&gt;</th></tr>
<tr>
<td bgcolor="red">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="orange">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="yellow">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="olive">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="darkgreen">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="green">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="lightgreen">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="lime">&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<table border="1">
<?php
$versions['raw'] = array(
'latest' => phpthumb_functions::SafeURLread('http://phpthumb.sourceforge.net/?latestversion=1', $dummy),
'this' => $phpThumb->phpthumb_version,
);
foreach ($versions['raw'] as $key => $value) {
eregi('^([0-9\.]+)\-?(([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}))?', $value, $matches);
@list($huge, $major, $minor) = @explode('.', @$matches[1]);
@list($year, $month, $day, $hour, $min) = @$matches[3];
$versions['base'][$key] = $matches[1];
$versions['huge'][$key] = $huge;
$versions['major'][$key] = $major;
$versions['minor'][$key] = $minor;
$versions['stamp'][$key] = $matches[2];
$versions['year'][$key] = $year;
$versions['month'][$key] = $month;
$versions['day'][$key] = $day;
$versions['hour'][$key] = $hour;
$versions['min'][$key] = $min;
$versions['date'][$key] = @mktime($hour, $min, 0, $month, $day, $year);
}
$downloadlatest = 'Download the latest version from <a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a>';
echo '<tr><th nowrap>Latest phpThumb version:</th><th>'.$versions['raw']['latest'].'</th><td>'.$downloadlatest.'</td></tr>';
echo '<tr><th nowrap>This phpThumb version:</th><th bgcolor="';
if (!$versions['base']['latest']) {
// failed to get latest version number
echo 'white';
$message = 'Latest version unknown.<br>'.$downloadlatest;
} elseif (phpthumb_functions::version_compare_replacement($versions['base']['this'], $versions['base']['latest'], '>')) {
// new than latest, must be beta version
echo 'lightblue';
$message = 'This must be a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
} elseif (($versions['base']['latest'] == $versions['base']['this']) && ($versions['stamp']['this'] > $versions['stamp']['latest'])) {
// new than latest, must be beta version
echo 'lightblue';
$message = 'You must be using a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
} elseif ($versions['base']['latest'] == $versions['base']['this']) {
// latest version
echo 'lime';
$message = 'You are using the latest released version.';
} elseif ($versions['huge']['latest'].$versions['major']['latest'] == $versions['huge']['this'].$versions['major']['this']) {
echo 'olive';
$message = 'One (or more) minor version(s) have been released since this version.<br>'.$downloadlatest;
} elseif (floatval($versions['huge']['latest'].str_pad($versions['major']['latest'], 2, '0', STR_PAD_LEFT)) < floatval($versions['huge']['this'].str_pad($t_major, 2, '0', STR_PAD_LEFT))) {
echo 'yellow';
$message = 'One (or more) major version(s) have been released since this version, you really should upgrade.<br>'.$downloadlatest;
} else {
echo 'orange';
$message = 'Fundamental changes have been made since this version.<br>'.$downloadlatest;
}
echo '">'.$phpThumb->phpthumb_version;
echo '</td><td>'.$message.'.<br></td></tr>';
echo '<tr><th>PHP version:</th><th bgcolor="';
if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=')) {
echo 'lime';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.3', '>=')) {
echo 'lightgreen';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.2.0', '>=')) {
echo 'green';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
echo 'yellow';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.0.6', '>=')) {
echo 'orange';
} else {
echo 'red';
}
echo '">'.phpversion();
echo '</td><td>PHP5 is ideal (support for numerous built-in filters which are much faster than my code).<br>PHP v4.3.2+ supports ImageSaveAlpha which is required for proper PNG/ICO output.<br>ImageRotate requires PHP v4.3.0+ (but buggy before v4.3.3).<br>EXIF thumbnail extraction requires PHP v4.2.0+.<br>Most things will work back to PHP v4.1.0, and mostly (perhaps buggy) back to v4.0.6, but no guarantees for any version older than that.</td></tr>';
echo '<tr><th>GD version:</th><th bgcolor="';
if ($ServerInfo['gd_numeric'] >= 2) {
if (eregi('bundled', @$ServerInfo['gd_string'])) {
echo 'lime';
} else {
echo 'yellow';
}
} elseif ($ServerInfo['im_version']) {
echo 'orange';
} else {
echo 'red';
}
echo '">'.@$ServerInfo['gd_string'];
echo '</td><td>GD2-bundled version is ideal.<br>GD2 (non-bundled) is second choice, but there are a number of bugs in the non-bundled version.<br>GD1 will also (mostly) work, at much-reduced image quality and several features disabled. phpThumb can perform basic resizing with ImageMagick only, even if GD is not available.</td></tr>';
echo '<tr><th>ImageMagick version:</th><th bgcolor="';
if ($ServerInfo['im_version']) {
echo 'lime';
} elseif (@$ServerInfo['gd_string']) {
echo 'yellow';
} else {
echo 'red';
}
echo '">'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a');
echo '</td><td>ImageMagick is faster than GD, can process larger images without PHP memory_limit issues, can resize animated GIFs. phpThumb can perform basic resizing with ImageMagick only, even if GD is not available.</td></tr>';
echo '<tr><th>GD features:</th><th>';
$GDfeatures['red'] = array('JPG Support', 'PNG Support');
$GDfeatures['orange'] = array('GIF Read Support', 'GIF Create Support', 'FreeType Support');
foreach ($GDfeatures as $missingcolor => $features) {
foreach ($features as $dummy => $feature) {
echo '<div style="background-color: '.($gd_info[$feature] ? 'lime' : $missingcolor).';">'.htmlentities($feature).'</div>';
}
}
echo '</td><td>PNG support is required for watermarks, overlays, calls to ImageMagick and other internal operations.<br>JPG support is obviously quite useful, but ImageMagick can substitute<br>GIF read support can be bypassed with ImageMagick and/or internal GIF routines.<br>GIF create support can be bypassed with ImageMagick (if no filters are applied)<br>FreeType support is needed for TTF overlays.</td></tr>';
echo '<tr><th>GD extension "EXIF"</th><th bgcolor="';
if (extension_loaded('exif')) {
echo 'lime';
} elseif (@$ServerInfo['gd_string']) {
echo 'orange';
}
echo '">'.(extension_loaded('exif') ? 'TRUE' : 'FALSE');
echo '</td><td>EXIF extension required for auto-rotate images. Also required to extract EXIF thumbnail to use as source if source image is too large for PHP memory_limit and ImageMagick is unavailable.</td></tr>';
echo '<tr><th>magic_quotes_runtime:</th><th bgcolor="';
if (@ini_get('magic_quotes_runtime')) {
echo 'red';
} else {
echo 'lime';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @get_magic_quotes_runtime());
echo '</td><td>This setting is evil. Turn it off.</td></tr>';
echo '<tr><th>magic_quotes_gpc:</th><th bgcolor="';
if (@ini_get('magic_quotes_runtime')) {
echo 'orange';
} else {
echo 'lime';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @get_magic_quotes_gpc());
echo '</td><td>This setting is bad. Turn it off, if possible. phpThumb will attempt to work around it if it is enabled</td></tr>';
echo '<tr><th>safe_mode:</th><th bgcolor="';
if (@ini_get('safe_mode')) {
echo 'yellow';
} else {
echo 'lime';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @ini_get('safe_mode'));
echo '</td><td>Best if off. Calls to ImageMagick will be disabled if on (limiting max image resolution, no animated GIF resize).</td></tr>';
echo '<tr><th>allow_url_fopen:</th><th bgcolor="';
if (@ini_get('allow_url_fopen')) {
echo 'lime';
} else {
echo 'yellow';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @ini_get('allow_url_fopen'));
echo '</td><td>Best if on. HTTP source images will be unavailable if disabled and CURL is unavailable.</td></tr>';
echo '<tr><th>curl_version:</th><th bgcolor="';
if (function_exists('curl_version')) {
echo 'lime';
} else {
echo 'yellow';
}
echo '">'.(function_exists('curl_version') ? curl_version() : 'n/a') ;
echo '</td><td>Best if available. HTTP source images will be unavailable if CURL unavailable and <i>allow_url_fopen</i> is also disabled.</td></tr>';
echo '<tr><th>disable_functions:</th><th bgcolor="';
$disable_functions = @ini_get('disable_functions');
if (!$disable_functions) {
echo 'lime';
} else {
echo 'yellow';
}
echo '">'.eregi_replace('(shell_exec|system|passthru|exec)(,|$)', '<span style="background-color: red;">\\1</span>(\\2)', $disable_functions);
echo '</td><td>Best if nothing disabled. Calls to ImageMagick will be prevented if exec+system+shell_exec+passthru are disabled.</td></tr>';
echo '<tr><th>memory_limit:</th><th bgcolor="';
$memory_limit = @ini_get('memory_limit');
if (!$memory_limit) {
echo 'lime';
} elseif ($memory_limit >= 32) {
echo 'lime';
} elseif ($memory_limit >= 24) {
echo 'lightgreen';
} elseif ($memory_limit >= 16) {
echo 'green';
} elseif ($memory_limit >= 12) {
echo 'darkgreen';
} elseif ($memory_limit >= 8) {
echo 'olive';
} elseif ($memory_limit >= 4) {
echo 'yellow';
} elseif ($memory_limit >= 2) {
echo 'orange';
} else {
echo 'red';
}
echo '">'.($memory_limit ? $memory_limit : '<i>unlimited</i>');
echo '</td><td>The higher the better. Divide by 5 to get maximum megapixels of source image that can be thumbnailed (without ImageMagick).'.($memory_limit ? ' Your setting ('.$memory_limit.') allows images up to approximately '.number_format($memory_limit / 5, 1).' megapixels' : '').'</td></tr>';
?>
</table>
</body>
</html>