PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/includes/phpthumb/demo/phpThumb.demo.check.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 467 lines | 395 code | 50 blank | 22 comment | 56 complexity | 9963bb105199c15eb39fb683675e90d5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. //////////////////////////////////////////////////////////////
  3. /// phpThumb() by James Heinrich <info@silisoftware.com> //
  4. // available at http://phpthumb.sourceforge.net ///
  5. //////////////////////////////////////////////////////////////
  6. /// //
  7. // phpThumb.demo.check.php //
  8. // James Heinrich <info@silisoftware.com> //
  9. // //
  10. // Configuration analyzer for phpThumb settings and server //
  11. // settings that may affect phpThumb performance //
  12. // Live demo is at http://phpthumb.sourceforge.net/demo/ //
  13. // //
  14. //////////////////////////////////////////////////////////////
  15. $ServerInfo['gd_string'] = 'unknown';
  16. $ServerInfo['gd_numeric'] = 0;
  17. //ob_start();
  18. if (!include_once('../phpthumb.functions.php')) {
  19. ob_end_flush();
  20. die('failed to include_once("../phpthumb.functions.php")');
  21. }
  22. if (!include_once('../phpthumb.class.php')) {
  23. //ob_end_flush();
  24. die('failed to include_once("../phpthumb.class.php")');
  25. }
  26. //ob_end_clean();
  27. $phpThumb = new phpThumb();
  28. if (include_once('../phpThumb.config.php')) {
  29. foreach ($PHPTHUMB_CONFIG as $key => $value) {
  30. $keyname = 'config_'.$key;
  31. $phpThumb->setParameter($keyname, $value);
  32. }
  33. }
  34. $ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
  35. $ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
  36. $ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
  37. $gd_info = gd_info();
  38. ?>
  39. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  40. <html>
  41. <head>
  42. <title>phpThumb configuration analyzer</title>
  43. <link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
  44. </head>
  45. <body bgcolor="#CCCCCC">
  46. This demo analyzes your settings (phpThumb.config.php and server/PHP) for <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a>.<br>
  47. <br>
  48. <table border="1">
  49. <tr><th colspan="8">&lt;-- bad . . . . . good --&gt;</th></tr>
  50. <tr>
  51. <td bgcolor="red">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  52. <td bgcolor="orange">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  53. <td bgcolor="yellow">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  54. <td bgcolor="olive">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  55. <td bgcolor="darkgreen">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  56. <td bgcolor="green">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  57. <td bgcolor="lightgreen">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  58. <td bgcolor="lime">&nbsp;&nbsp;&nbsp;&nbsp;</td>
  59. </tr>
  60. </table>
  61. <table border="1" cellspacing="0" cellpadding="2">
  62. <tr bgcolor="#EEEEEE"><th>Setting</th><th colspan="2">Value</th><th>Comments</th></tr>
  63. <?php
  64. $versions['raw'] = array(
  65. 'latest' => phpthumb_functions::SafeURLread('http://phpthumb.sourceforge.net/?latestversion=1', $dummy),
  66. 'this' => $phpThumb->phpthumb_version,
  67. );
  68. foreach ($versions['raw'] as $key => $value) {
  69. eregi('^([0-9\.]+)\-?(([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}))?', $value, $matches);
  70. @list($huge, $major, $minor) = @explode('.', @$matches[1]);
  71. @list($year, $month, $day, $hour, $min) = @$matches[3];
  72. $versions['base'][$key] = $matches[1];
  73. $versions['huge'][$key] = $huge;
  74. $versions['major'][$key] = $major;
  75. $versions['minor'][$key] = $minor;
  76. $versions['stamp'][$key] = $matches[2];
  77. $versions['year'][$key] = $year;
  78. $versions['month'][$key] = $month;
  79. $versions['day'][$key] = $day;
  80. $versions['hour'][$key] = $hour;
  81. $versions['min'][$key] = $min;
  82. $versions['date'][$key] = @mktime($hour, $min, 0, $month, $day, $year);
  83. }
  84. $downloadlatest = 'Download the latest version from <a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a>';
  85. echo '<tr><th nowrap>Latest phpThumb version:</th><th colspan="2">'.$versions['raw']['latest'].'</th><td>'.$downloadlatest.'</td></tr>';
  86. echo '<tr><th nowrap>This phpThumb version:</th><th colspan="2" bgcolor="';
  87. if (!$versions['base']['latest']) {
  88. // failed to get latest version number
  89. echo 'white';
  90. $message = 'Latest version unknown.<br>'.$downloadlatest;
  91. } elseif (phpthumb_functions::version_compare_replacement($versions['base']['this'], $versions['base']['latest'], '>')) {
  92. // new than latest, must be beta version
  93. echo 'lightblue';
  94. $message = 'This must be a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
  95. } elseif (($versions['base']['latest'] == $versions['base']['this']) && ($versions['stamp']['this'] > $versions['stamp']['latest'])) {
  96. // new than latest, must be beta version
  97. echo 'lightblue';
  98. $message = 'You must be using a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
  99. } elseif ($versions['base']['latest'] == $versions['base']['this']) {
  100. // latest version
  101. echo 'lime';
  102. $message = 'You are using the latest released version.';
  103. } elseif ($versions['huge']['latest'].$versions['major']['latest'] == $versions['huge']['this'].$versions['major']['this']) {
  104. echo 'olive';
  105. $message = 'One (or more) minor version(s) have been released since this version.<br>'.$downloadlatest;
  106. } 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))) {
  107. echo 'yellow';
  108. $message = 'One (or more) major version(s) have been released since this version, you really should upgrade.<br>'.$downloadlatest;
  109. } else {
  110. echo 'orange';
  111. $message = 'Fundamental changes have been made since this version.<br>'.$downloadlatest;
  112. }
  113. echo '">'.$phpThumb->phpthumb_version;
  114. echo '</th><td>'.$message.'.<br></td></tr>';
  115. echo '<tr><th>phpThumb.config.php:</th><th colspan="2" bgcolor="';
  116. if (file_exists('../phpThumb.config.php') && !file_exists('../phpThumb.config.php.default')) {
  117. echo 'lime">"phpThumb.config.php" exists and "phpThumb.config.php.default" does not';
  118. } elseif (file_exists('../phpThumb.config.php') && file_exists('../phpThumb.config.php.default')) {
  119. echo 'yellow">"phpThumb.config.php" and "phpThumb.config.php.default" both exist';
  120. } elseif (!file_exists('../phpThumb.config.php') && file_exists('../phpThumb.config.php.default')) {
  121. echo 'yellow">rename "phpThumb.config.php.default" to "phpThumb.config.php"';
  122. } else {
  123. echo 'yellow">"phpThumb.config.php" not found (nor "phpThumb.config.php")';
  124. }
  125. echo '</th><td>"phpThumb.config.php.default" that comes in the distribution must be renamed to "phpThumb.config.php" before phpThumb.php can be used. Avoid having both files present to minimize confusion.</td></tr>';
  126. echo '<tr><th>cache directory:</th><th colspan="2">';
  127. $orig_config_cache_directory = $phpThumb->config_cache_directory;
  128. $phpThumb->setCacheDirectory();
  129. echo '<div style="background-color: '.( is_dir($phpThumb->config_cache_directory) ? 'lime;">exists' : 'red;">does NOT exist').'</div>';
  130. echo '<div style="background-color: '.(is_readable($phpThumb->config_cache_directory) ? 'lime;">readable' : 'red;">NOT readable').'</div>';
  131. echo '<div style="background-color: '.(is_writable($phpThumb->config_cache_directory) ? 'lime;">writable' : 'red;">NOT writable').'</div>';
  132. echo '</th><td>Original: "'.htmlentities($orig_config_cache_directory).'"<br>Resolved: "'.htmlentities($phpThumb->config_cache_directory).'"<br>Must exist and be both readable and writable by PHP.</td></tr>';
  133. echo '<tr><th>cache write test:</th><th colspan="2">';
  134. $phpThumb->rawImageData = 'phpThumb.demo.check.php_cachetest';
  135. $phpThumb->SetCacheFilename();
  136. echo '<div>'.htmlentities($phpThumb->cache_filename ? implode(' / ', split('[/\\]', $phpThumb->cache_filename)) : 'NO CACHE FILENAME RESOLVED').'</div>';
  137. echo '<div>directory '.(is_dir(dirname($phpThumb->cache_filename)) ? 'exists' : 'does NOT exist').' (before EnsureDirectoryExists())</div>';
  138. phpthumb_functions::EnsureDirectoryExists(dirname($phpThumb->cache_filename));
  139. echo '<div style="background-color: '.(is_dir(dirname($phpThumb->cache_filename)) ? 'lime;">directory exists' : 'red;">directory does NOT exist').' (after EnsureDirectoryExists())</div>';
  140. if ($fp = @fopen($phpThumb->cache_filename, 'wb')) {
  141. fwrite($fp, 'this is a test from '.__FILE__);
  142. fclose($fp);
  143. echo '<div style="background-color: lime;">write test succeeded</div>';
  144. $old_perms = substr(sprintf('%o', fileperms($phpThumb->cache_filename)), -4);
  145. @chmod($phpThumb->cache_filename, 0644);
  146. clearstatcache();
  147. $new_perms = substr(sprintf('%o', fileperms($phpThumb->cache_filename)), -4);
  148. echo '<div style="background-color: '.(($new_perms == '0644') ? 'lime' : (($new_perms > '0644') ? 'orange' : 'red')).';">chmod($phpThumb->cache_filename, 0644) from "'.htmlentities($old_perms).'" resulted in permissions "'.htmlentities($new_perms).'"</div>';
  149. if (@unlink($phpThumb->cache_filename)) {
  150. echo '<div style="background-color: lime;">delete test succeeded</div>';
  151. } else {
  152. echo '<div style="background-color: red;">delete test FAILED</div>';
  153. }
  154. $phpThumb->CleanUpCacheDirectory();
  155. } else {
  156. echo '<div style="background-color: red;">write test FAILED</div>';
  157. }
  158. //echo '</th><td>Original: "'.htmlentities($orig_config_cache_directory).'"<br>Resolved: "'.htmlentities($phpThumb->config_cache_directory).'"<br>Must exist and be both readable and writable by PHP.</td></tr>';
  159. echo '</th><td>Created and deletes a sample cache file to see if you actually have create/delete permission.<br>If <i>Safe Mode</i> is enabled this is often broken.</td></tr>';
  160. echo '<tr><th>temp directory:</th><th colspan="2">';
  161. $orig_config_temp_directory = $phpThumb->config_temp_directory;
  162. $phpThumb->phpThumb_tempnam();
  163. echo '<div style="background-color: '.( is_dir($phpThumb->config_temp_directory) ? 'lime;">exists' : 'red;">does NOT exist').'</div>';
  164. echo '<div style="background-color: '.(is_readable($phpThumb->config_temp_directory) ? 'lime;">readable' : 'red;">NOT readable').'</div>';
  165. echo '<div style="background-color: '.(is_writable($phpThumb->config_temp_directory) ? 'lime;">writable' : 'red;">NOT writable').'</div>';
  166. echo '</th><td>Original: "'.htmlentities($orig_config_temp_directory).'"<br>Resolved: "'.htmlentities($phpThumb->config_temp_directory).'"<br>Must exist and be both readable and writable by PHP.</td></tr>';
  167. echo '<tr><th>PHP version:</th><th colspan="2" bgcolor="';
  168. if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=')) {
  169. echo 'lime';
  170. } elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.4.2', '=')) {
  171. echo 'darkgreen';
  172. } elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.3', '>=')) {
  173. echo 'lightgreen';
  174. } elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.2.0', '>=')) {
  175. echo 'green';
  176. } elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
  177. echo 'yellow';
  178. } elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.0.6', '>=')) {
  179. echo 'orange';
  180. } else {
  181. echo 'red';
  182. }
  183. echo '">'.phpversion();
  184. echo '</th><td>PHP5 is ideal (support for numerous built-in filters which are much faster than my code).<br>PHP v4.4.2 contains a bug in fopen over HTTP (phpThumb has a workaround)<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>';
  185. echo '<tr><th>GD version:</th><th colspan="2" bgcolor="';
  186. if ($ServerInfo['gd_numeric'] >= 2) {
  187. if (eregi('bundled', @$ServerInfo['gd_string'])) {
  188. echo 'lime';
  189. } else {
  190. echo 'yellow';
  191. }
  192. } elseif ($ServerInfo['im_version']) {
  193. echo 'orange';
  194. } else {
  195. echo 'red';
  196. }
  197. echo '">'.@$ServerInfo['gd_string'];
  198. echo '</th><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. ImageRotate is only available in the bundled version of GD2.<br>GD1 will also (mostly) work, at much-reduced image quality and several features disabled. phpThumb can perform most operations with ImageMagick only, even if GD is not available.</td></tr>';
  199. echo '<tr><th>ImageMagick version:</th><th colspan="2" bgcolor="';
  200. if (eregi(' ([0-9]+)/([0-9]+)/([0-9]+) ', $ServerInfo['im_version'], $matches)) {
  201. list($dummy, $m, $d, $y) = $matches;
  202. if ($y < 70) {
  203. $y += 2000;
  204. } elseif ($y < 100) {
  205. $y += 1900;
  206. }
  207. $IMreleaseDate = mktime(12, 0, 0, $m, $d, $y);
  208. $IMversionAge = (time() - $IMreleaseDate) / 86400;
  209. }
  210. if ($ServerInfo['im_version']) {
  211. if ($IMversionAge < (365 * 1)) {
  212. echo 'lime';
  213. } elseif ($IMversionAge < (365 * 2)) {
  214. echo 'lightgreen';
  215. } elseif ($IMversionAge < (365 * 3)) {
  216. echo 'green';
  217. } elseif ($IMversionAge < (365 * 4)) {
  218. echo 'darkgreen';
  219. } else {
  220. echo 'olive';
  221. }
  222. } elseif (@$ServerInfo['gd_string']) {
  223. echo 'orange';
  224. } else {
  225. echo 'red';
  226. }
  227. echo '">"'.$phpThumb->ImageMagickCommandlineBase().'"<br>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').(@$IMversionAge ? '<br><br>This version of ImageMagick is '.(($IMversionAge < 180) ? number_format($IMversionAge / 30, 2).' months' : number_format($IMversionAge / 365, 2).' years').' old<br>(see www.imagemagick.org for new versions)' : '');
  228. echo '</th><td>ImageMagick is faster than GD, can process larger images without PHP memory_limit issues, can resize animated GIFs. phpThumb can perform most operations with ImageMagick only, even if GD is not available.</td></tr>';
  229. echo '<tr><th>ImageMagick features:</th><th colspan="2">|';
  230. $GDfeatures['red'] = array('help', 'thumbnail', 'resize', 'crop', 'repage', 'coalesce', 'gravity', 'background', 'interlace', 'flatten', 'border', 'bordercolor', 'dither', 'quality');
  231. $GDfeatures['orange'] = array('version', 'blur', 'colorize', 'colors', 'colorspace', 'contrast', 'contrast-stretch', 'edge', 'emboss', 'fill', 'flip', 'flop', 'gamma', 'gaussian', 'level', 'modulate', 'monochrome', 'negate', 'normalize', 'rotate', 'sepia-tone', 'threshold', 'unsharp');
  232. foreach ($GDfeatures as $missingcolor => $features) {
  233. foreach ($features as $dummy => $feature) {
  234. echo '| <span style="background-color: '.($phpThumb->ImageMagickSwitchAvailable($feature) ? 'lime' : $missingcolor).';">'.htmlentities($feature).'</span> |';
  235. }
  236. }
  237. echo '|</th><td>All of these parameters may be called by phpThumb, depending on parameters used. Green means the feature is available; red means a critical feature is missing; orange means an optional filter/feature is missing.</td></tr>';
  238. echo '<tr><th>ImageMagick formats:</th><th colspan="2"><textarea rows="10" cols="50" wrap="off">';
  239. echo htmlentities($phpThumb->ImageMagickFormatsList());
  240. echo '</textarea></th><td>ImageMagick can only read/write formats as listed here. You may need to recompile ImageMagick if you need to use a format not listed</td></tr>';
  241. echo '<tr><th>GD features:</th><th colspan="2">';
  242. $GDfeatures['red'] = array('JPG Support', 'PNG Support');
  243. $GDfeatures['orange'] = array('GIF Read Support', 'GIF Create Support', 'FreeType Support');
  244. foreach ($GDfeatures as $missingcolor => $features) {
  245. foreach ($features as $dummy => $feature) {
  246. echo '<div style="background-color: '.($gd_info[$feature] ? 'lime' : $missingcolor).';">'.htmlentities($feature).'</div>';
  247. }
  248. }
  249. echo '</th><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>';
  250. echo '<tr><th>GD extension "EXIF"</th><th colspan="2" bgcolor="';
  251. if (extension_loaded('exif')) {
  252. echo 'lime';
  253. } elseif (@$ServerInfo['gd_string']) {
  254. echo 'orange';
  255. }
  256. echo '">'.(extension_loaded('exif') ? 'TRUE' : 'FALSE');
  257. echo '</th><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>';
  258. echo '<tr><th>php_sapi_name()</th><th colspan="2" bgcolor="';
  259. $php_sapi_name = strtolower(function_exists('php_sapi_name') ? php_sapi_name() : '');
  260. if (!$php_sapi_name || (eregi('~', dirname($_SERVER['PHP_SELF'])) && ($php_sapi_name != 'apache'))) {
  261. echo 'red';
  262. } elseif ($php_sapi_name == 'cgi-fcgi') {
  263. echo 'orange';
  264. } elseif ($php_sapi_name == 'cgi') {
  265. echo 'yellow';
  266. } elseif ($php_sapi_name == 'apache') {
  267. echo 'lime';
  268. } else {
  269. echo 'green';
  270. }
  271. echo '">'.$php_sapi_name.'</th>';
  272. echo '<td>SAPI mode preferred to CGI mode. FCGI mode has unconfirmed strange behavior (notably more than one space in "wmt" filter text causes errors). If not working in "apache" (SAPI) mode, <i>apache_lookup_uri()</i> will not work.</td></tr>';
  273. echo '<tr><th>Server Software</th><th colspan="2" bgcolor="';
  274. $server_software = getenv('SERVER_SOFTWARE');
  275. if (!$server_software) {
  276. echo 'red';
  277. } elseif (eregi('^Apache/([0-9\.]+)', $server_software, $matches)) {
  278. if (phpthumb_functions::version_compare_replacement($matches[1], '2.0.0', '>=')) {
  279. echo 'lightgreen';
  280. } else {
  281. echo 'lime';
  282. }
  283. } else {
  284. echo 'darkgreen';
  285. }
  286. echo '">'.$server_software.'</th>';
  287. echo '<td>Apache v1.x has the fewest compatability problems. IIS has numerous annoyances. Apache v2.x is broken when lookup up <i>/~user/filename.jpg</i> style relative filenames using <i>apache_lookup_uri()</i>.</td></tr>';
  288. echo '<tr><th>curl_version:</th><th colspan="2" bgcolor="';
  289. $curl_version = (function_exists('curl_version') ? curl_version() : '');
  290. if (is_array($curl_version)) {
  291. $curl_version = @$curl_version['version'];
  292. }
  293. if ($curl_version) {
  294. echo 'lime';
  295. } else {
  296. echo 'yellow';
  297. }
  298. echo '">'.$curl_version.'</th>';
  299. echo '<td>Best if available. HTTP source images will be unavailable if CURL unavailable and <i>allow_url_fopen</i> is also disabled.</td></tr>';
  300. echo '<tr bgcolor="#EEEEEE"><th colspan="4">&nbsp;</th></tr>';
  301. echo '<tr bgcolor="#EEEEEE"><th>function_exists:</th><th colspan="2">Value</th><th>Comments</th></tr>';
  302. $FunctionsExist = array(
  303. 'ImageRotate' => array('orange', 'required for "ra" and "ar" filters.'),
  304. 'exif_read_data' => array('yellow', 'required for "ar" filter.'),
  305. 'exif_thumbnail' => array('yellow', 'required to extract EXIF thumbnails.'),
  306. 'memory_get_usage' => array('lightgreen', 'mostly used for troubleshooting.'),
  307. 'version_compare' => array('darkgreen', 'available in PHP v4.1.0+, internal workaround available'),
  308. 'file_get_contents' => array('darkgreen', 'available in PHP v4.3.0+, internal workaround available'),
  309. 'file_put_contents' => array('darkgreen', 'available in PHP v5.0.0+, internal workaround available'),
  310. 'is_executable' => array('yellow', 'available in PHP3, except only PHP5 for Windows. poor internal workaround available'),
  311. 'gd_info' => array('olive', 'available in PHP v4.3.0+ (with bundled GD2), internal workaround available'),
  312. 'ImageTypes' => array('red', 'required for GD image output.'),
  313. 'ImageCreateFromJPEG' => array('orange', 'required for JPEG source images using GD.'),
  314. 'ImageCreateFromGIF' => array('yellow', 'useful for GIF source images using GD.'),
  315. 'ImageCreateFromPNG' => array('orange', 'required for PNG source images using GD and other source image formats using ImageMagick.'),
  316. 'ImageCreateFromWBMP' => array('yellow', 'required for WBMP source images using GD.'),
  317. 'ImageCreateFromString' => array('orange', 'required for HTTP and non-file image sources.'),
  318. 'ImageCreateTrueColor' => array('orange', 'required for all non-ImageMagick filters.'),
  319. 'ImageIsTrueColor' => array('olive', 'available in PHP v4.3.2+ with GD v2.0.1+'),
  320. 'ImageFilter' => array('yellow', 'PHP5 only. Required for some filters (but most can use ImageMagick instead)'),
  321. );
  322. foreach ($FunctionsExist as $function => $details) {
  323. list($color, $description) = $details;
  324. echo '<tr><th>'.$function.'</th><th colspan="2" bgcolor="';
  325. if (function_exists(strtolower($function))) {
  326. echo 'lime">TRUE';
  327. } else {
  328. echo $color.'">FALSE';
  329. }
  330. echo '</th><td>'.$description.'</td></tr>';
  331. }
  332. echo '<tr bgcolor="#EEEEEE"><th colspan="4">&nbsp;</th></tr>';
  333. echo '<tr bgcolor="#EEEEEE"><th>Setting</th><th>Master Value</th><th>Local Value</th><th>Comments</th></tr>';
  334. $SettingFeatures = array(
  335. 'magic_quotes_runtime' => array('red', 'lime', 'This setting is evil. Turn it off.'),
  336. 'magic_quotes_gpc' => array('yellow', 'lime', 'This setting is bad. Turn it off, if possible. phpThumb will attempt to work around it if it is enabled.'),
  337. 'safe_mode' => array('orange', 'lime', 'Best if off. Calls to ImageMagick will be disabled if safe_mode is set to prevent writing temp files (limiting max image resolution, no animated GIF resize). Raw image data sources (e.g. from MySQL database) may not work. Temp files may be disabled. Features will be limited. If disabled in Master but enabled in Local, edit httpd.conf and set (php_admin_value safe_mode "Off") between <VirtualHost> tags'),
  338. 'allow_url_fopen' => array('lime', 'yellow', 'Best if on. HTTP source images will be unavailable if disabled and CURL is unavailable.'),
  339. );
  340. foreach ($SettingFeatures as $feature => $FeaturesDetails) {
  341. list($color_true, $color_false, $reason) = $FeaturesDetails;
  342. echo '<tr><th>'.$feature.':</th>';
  343. echo '<th bgcolor="'.(@get_cfg_var($feature) ? $color_true : $color_false).'">'.$phpThumb->phpThumbDebugVarDump((bool) @get_cfg_var($feature)).'</th>';
  344. echo '<th bgcolor="'.(preg_match('#(1|ON)#i', @ini_get($feature)) ? $color_true : $color_false).'">'.$phpThumb->phpThumbDebugVarDump((bool) preg_match('#(1|ON)#i', ini_get($feature))).'</th>';
  345. echo '<td>'.htmlentities($reason).'</td></tr>';
  346. }
  347. $MissingFunctionSeverity = array(
  348. 'shell_exec' => 'red',
  349. 'system' => 'red',
  350. 'passthru' => 'red',
  351. 'exec' => 'red',
  352. 'curl_exec' => 'orange',
  353. );
  354. $DisabledFunctions[0] = explode(',', @get_cfg_var('disable_functions'));
  355. $DisabledFunctions[1] = explode(',', @ini_get('disable_functions'));
  356. echo '<tr><th>disable_functions:</th>';
  357. for ($i = 0; $i <= 1; $i++) {
  358. //echo '<th bgcolor="'.(count($DisabledFunctions[$i]) ? 'yellow' : 'lime').'">';
  359. echo '<th>';
  360. $disabled_functions = '';
  361. foreach ($DisabledFunctions[$i] as $key => $value) {
  362. if (@$MissingFunctionSeverity[$value]) {
  363. $DisabledFunctions[$i][$key] = '<span style="background-color: '.$MissingFunctionSeverity[$value].';">'.$value.'</span>';
  364. }
  365. }
  366. echo implode(', ', $DisabledFunctions[$i]);
  367. echo '</th>';
  368. }
  369. echo '<td>Best if nothing disabled. Calls to ImageMagick will be prevented if exec+system+shell_exec+passthru are disabled.</td></tr>';
  370. echo '<tr><th>memory_limit:</th><th bgcolor="';
  371. $memory_limit = @get_cfg_var('memory_limit');
  372. if (!$memory_limit) {
  373. echo 'lime';
  374. } elseif ($memory_limit >= 32) {
  375. echo 'lime';
  376. } elseif ($memory_limit >= 24) {
  377. echo 'lightgreen';
  378. } elseif ($memory_limit >= 16) {
  379. echo 'green';
  380. } elseif ($memory_limit >= 12) {
  381. echo 'darkgreen';
  382. } elseif ($memory_limit >= 8) {
  383. echo 'olive';
  384. } elseif ($memory_limit >= 4) {
  385. echo 'yellow';
  386. } elseif ($memory_limit >= 2) {
  387. echo 'orange';
  388. } else {
  389. echo 'red';
  390. }
  391. echo '">'.($memory_limit ? $memory_limit : '<i>unlimited</i>').'</th><th bgcolor="';
  392. $memory_limit = @ini_get('memory_limit');
  393. if (!$memory_limit) {
  394. echo 'lime';
  395. } elseif ($memory_limit >= 32) {
  396. echo 'lime';
  397. } elseif ($memory_limit >= 24) {
  398. echo 'lightgreen';
  399. } elseif ($memory_limit >= 16) {
  400. echo 'green';
  401. } elseif ($memory_limit >= 12) {
  402. echo 'darkgreen';
  403. } elseif ($memory_limit >= 8) {
  404. echo 'olive';
  405. } elseif ($memory_limit >= 4) {
  406. echo 'yellow';
  407. } elseif ($memory_limit >= 2) {
  408. echo 'orange';
  409. } else {
  410. echo 'red';
  411. }
  412. echo '">'.($memory_limit ? $memory_limit : '<i>unlimited</i>').'</th>';
  413. echo '<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>';
  414. ?>
  415. </table>
  416. </body>
  417. </html>