$new_perms = substr(sprintf('%o', fileperms($phpThumb->cache_filename)), -4); 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>'; if (@unlink($phpThumb->cache_filename)) { echo '<div style="background-color: lime;">delete test succeeded</div>'; } else { echo '<div style="background-color: red;">delete test FAILED</div>'; } $phpThumb->CleanUpCacheDirectory(); } else { echo '<div style="background-color: red;">write test FAILED</div>'; } //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>'; echo '</th><td>Created and deletes a sample cache file to see if you actually have create/delete permission</td></tr>'; echo '<tr><th>temp directory:</th><th colspan="2">'; $orig_config_temp_directory = $phpThumb->config_temp_directory; $phpThumb->phpThumb_tempnam(); echo '<div style="background-color: ' . (is_dir($phpThumb->config_temp_directory) ? 'lime;">exists' : 'red;">does NOT exist') . '</div>'; echo '<div style="background-color: ' . (is_readable($phpThumb->config_temp_directory) ? 'lime;">readable' : 'red;">NOT readable') . '</div>'; echo '<div style="background-color: ' . (is_writable($phpThumb->config_temp_directory) ? 'lime;">writable' : 'red;">NOT writable') . '</div>'; 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>'; echo '<tr><th>PHP version:</th><th colspan="2" bgcolor="'; if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=')) { echo 'lime'; } elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.4.2', '=')) { echo 'darkgreen'; } 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';
function gd_info() { static $gd_info = array(); if (empty($gd_info)) { // based on code by johnschaefer at gmx dot de // from PHP help on gd_info() $gd_info = array('GD Version' => '', 'FreeType Support' => false, 'FreeType Linkage' => '', 'T1Lib Support' => false, 'GIF Read Support' => false, 'GIF Create Support' => false, 'JPG Support' => false, 'PNG Support' => false, 'WBMP Support' => false, 'XBM Support' => false); $phpinfo_array = phpThumb_functions::phpinfo_array(); foreach ($phpinfo_array as $line) { $line = trim(strip_tags($line)); foreach ($gd_info as $key => $value) { //if (strpos($line, $key) !== false) { if (strpos($line, $key) === 0) { $newvalue = trim(str_replace($key, '', $line)); $gd_info[$key] = $newvalue; } } } if (empty($gd_info['GD Version'])) { // probable cause: "phpinfo() disabled for security reasons" if (function_exists('ImageTypes')) { $imagetypes = ImageTypes(); if ($imagetypes & IMG_PNG) { $gd_info['PNG Support'] = true; } if ($imagetypes & IMG_GIF) { $gd_info['GIF Create Support'] = true; } if ($imagetypes & IMG_JPG) { $gd_info['JPG Support'] = true; } if ($imagetypes & IMG_WBMP) { $gd_info['WBMP Support'] = true; } } // to determine capability of GIF creation, try to use ImageCreateFromGIF on a 1px GIF if (function_exists('ImageCreateFromGIF')) { if ($tempfilename = phpThumb::phpThumb_tempnam()) { if ($fp_tempfile = @fopen($tempfilename, 'wb')) { fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw==')); // very simple 1px GIF file base64-encoded as string fclose($fp_tempfile); // if we can convert the GIF file to a GD image then GIF create support must be enabled, otherwise it's not $gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename); } unlink($tempfilename); } } if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) { $gd_info['GD Version'] = '2.0.1 or higher (assumed)'; } elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) { $gd_info['GD Version'] = '1.6.0 or higher (assumed)'; } } } return $gd_info; }