echo '">' . $phpThumb->phpthumb_version; echo '</th><td>' . $message . '.<br></td></tr>'; echo '<tr><th>phpThumb.config.php:</th><th colspan="2" bgcolor="'; if (file_exists('../phpThumb.config.php') && !file_exists('../phpThumb.config.php.default')) { echo 'lime">"phpThumb.config.php" exists and "phpThumb.config.php.default" does not'; } elseif (file_exists('../phpThumb.config.php') && file_exists('../phpThumb.config.php.default')) { echo 'yellow">"phpThumb.config.php" and "phpThumb.config.php.default" both exist'; } elseif (!file_exists('../phpThumb.config.php') && file_exists('../phpThumb.config.php.default')) { echo 'yellow">rename "phpThumb.config.php.default" to "phpThumb.config.php"'; } else { echo 'yellow">"phpThumb.config.php" not found (nor "phpThumb.config.php")'; } 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>'; echo '<tr><th>cache directory:</th><th colspan="2">'; $orig_config_cache_directory = $phpThumb->config_cache_directory; $phpThumb->setCacheDirectory(); echo '<div style="background-color: ' . (is_dir($phpThumb->config_cache_directory) ? 'lime;">exists' : 'red;">does NOT exist') . '</div>'; echo '<div style="background-color: ' . (is_readable($phpThumb->config_cache_directory) ? 'lime;">readable' : 'red;">NOT readable') . '</div>'; echo '<div style="background-color: ' . (is_writable($phpThumb->config_cache_directory) ? 'lime;">writable' : 'red;">NOT writable') . '</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 '<tr><th>cache write test:</th><th colspan="2">'; $phpThumb->rawImageData = 'phpThumb.demo.check.php_cachetest'; $phpThumb->SetCacheFilename(); echo '<div>' . htmlentities($phpThumb->cache_filename ? implode(' / ', split('[/\\]', $phpThumb->cache_filename)) : 'NO CACHE FILENAME RESOLVED') . '</div>'; echo '<div>directory ' . (is_dir(dirname($phpThumb->cache_filename)) ? 'exists' : 'does NOT exist') . ' (before EnsureDirectoryExists())</div>'; phpthumb_functions::EnsureDirectoryExists(dirname($phpThumb->cache_filename)); echo '<div style="background-color: ' . (is_dir(dirname($phpThumb->cache_filename)) ? 'lime;">directory exists' : 'red;">directory does NOT exist') . ' (after EnsureDirectoryExists())</div>'; if ($fp = @fopen($phpThumb->cache_filename, 'wb')) { fwrite($fp, 'this is a test from ' . __FILE__); fclose($fp); echo '<div style="background-color: lime;">write test succeeded</div>';
public static function RenderImage($url, &$params, $nw, $nh, $nzc, $nq) { $img_cache = $params->get('img_cache', 'cache'); $cache_maxfiles_img = $params->get('cache_maxfiles_img', '200'); $cache_maxsize_img = $params->get('cache_maxsize_img', '10'); $cache_maxage_img = $params->get('cache_maxage_img', '30'); $w = $nw ? $nw : intval($params->get('imageWidth')); $h = $nh ? $nh : intval($params->get('imageHeight')); $zc = $nzc ? $nzc : intval($params->get('Zoom_Crop', 1)); $q = $nq ? $nq : '99'; $f = $params->def('img_ext', 'jpg'); $thumb_filtercolor = intval($params->get('thumb_filtercolor', 0)); $colorized = $params->get('colorized', '25'); $colorpicker = $params->get('colorpicker', '#0000ff'); $thumb_th = $params->def('thumb_th', 0); $thumb_th_seting = $params->def('thumb_th_seting', 0); $link_enabled = $params->get('link_enabled', 1); $error_image = JPATH_BASE . '/media/mod_junewsultra/' . $params->def('noimage'); $thumb_filters = $params->def('thumb_filters', 1); $usm = $params->def('thumb_unsharp', 1); $thumb_unsharp_amount = $params->def('thumb_unsharp_amount', 80); $thumb_unsharp_radius = $params->def('thumb_unsharp_radius', 1); $thumb_unsharp_threshold = $params->def('thumb_unsharp_threshold', 3); $thumb_blur = $params->def('thumb_blur', 0); $thumb_blur_seting = $params->def('thumb_blur_seting', 1); $thumb_brit = $params->def('thumb_brit', 0); $thumb_brit_seting = $params->def('thumb_brit_seting', 50); $thumb_cont = $params->def('thumb_cont', 0); $thumb_cont_seting = $params->def('thumb_cont_seting', 50); if (preg_match('#^(http|https|ftp)://#i', $url)) { $url = $url; } else { $url = !file_exists($url) ? $error_image : JPATH_BASE . '/' . $url; } $path_parts = pathinfo($url); $imgfile = explode(".", basename($url)); $img_name = $imgfile[0]; $imgurl = str_replace(array('.', ',', '-', '_', '|', '+', '=', '%', '^', '&', '(', ')', ' ', '"', '\''), '', $img_name); $subfolder = $img_cache . '/junewsultra/' . $w . 'x' . $h . '/' . substr(strtolower(MD5($path_parts['dirname'])), -1); $target = $subfolder . '/junews_' . substr(strtolower($imgurl), 0, 150) . '-' . MD5($url . $q . $zc . $f . $params->get('use_imagemagick') . $usm . $thumb_unsharp_amount . $thumb_unsharp_radius . $thumb_unsharp_threshold . $thumb_filtercolor . $colorized . $colorpicker . $thumb_blur . $thumb_blur_seting . $thumb_brit . $thumb_brit_seting . $thumb_cont . $thumb_cont_seting . $thumb_th . $thumb_th_seting) . '.' . $f; if ($link_enabled == 0 && preg_match('#^(http|https|ftp)://#i', $url)) { $outpute = $error_image; return $outpute; } modJUNewsUltraHelper::MakeDirectory($dir = JPATH_BASE . '/' . $subfolder, $mode = 0777); if (file_exists(JPATH_BASE . '/' . $target)) { $outpute = JURI::base(false) . $target; } else { include_once JPATH_BASE . '/modules/mod_junewsultra/img/phpthumb.class.php'; $phpThumb = new phpThumb(); $phpThumb->resetObject(); $phpThumb->setParameter('config_max_source_pixels', round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 / 6)); $phpThumb->setParameter('config_temp_directory', JPATH_BASE . '/' . $img_cache . '/junewsultra/'); $phpThumb->setParameter('config_cache_directory', JPATH_BASE . '/' . $img_cache . '/junewsultra/'); $phpThumb->setCacheDirectory(); $phpThumb->setParameter('config_cache_maxfiles', $cache_maxfiles_img); $phpThumb->setParameter('config_cache_maxsize', $cache_maxsize_img * 1024 * 1024); $phpThumb->setParameter('config_cache_maxage', 86400 * $cache_maxage_img); $phpThumb->setSourceFilename($url); if ($w) { $phpThumb->setParameter('w', $w); } if ($h) { $phpThumb->setParameter('h', $h); } if ($q) { $phpThumb->setParameter('q', $q); } $phpThumb->setParameter('f', $f); $phpThumb->setParameter('zc', $zc); $phpThumb->setParameter('aoe', '1'); switch ($thumb_filtercolor) { case '1': $phpThumb->setParameter('fltr', 'gray'); break; case '2': $phpThumb->setParameter('fltr', 'sep'); break; case '3': $phpThumb->setParameter('fltr', 'th|' . $thumb_th_seting); break; case '4': $phpThumb->setParameter('fltr', 'clr|' . $colorized . '|' . str_replace('#', '', $colorpicker)); break; default: break; } if ($thumb_filters == 1) { if ($usm == 1) { $phpThumb->setParameter('fltr', 'usm|' . $thumb_unsharp_amount . '|' . $thumb_unsharp_radius . '|' . $thumb_unsharp_threshold); } if ($thumb_blur == 1) { $phpThumb->setParameter('fltr', 'blur|' . $thumb_blur_seting); } if ($thumb_brit == 1) { $phpThumb->setParameter('fltr', 'brit|' . $thumb_brit_seting); } if ($thumb_cont == 1) { $phpThumb->setParameter('fltr', 'cont|' . $thumb_cont_seting); } } if ($params->get('use_imagemagick') == 1) { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $imagemagick = $params->get('imagemagick_path') == '' ? 'C:/ImageMagick/convert.exe' : $params->get('imagemagick_path'); } else { $imagemagick = $params->get('imagemagick_path', ''); } $phpThumb->setParameter('config_imagemagick_path', $imagemagick); $phpThumb->setParameter('config_prefer_imagemagick', $params->get('use_imagemagick') == 1 ? true : false); $phpThumb->setParameter('config_imagemagick_use_thumbnail', true); } if ($phpThumb->GenerateThumbnail()) { if ($phpThumb->RenderToFile(JPATH_BASE . '/' . $target)) { $outpute = JURI::base(false) . $target; } else { $outpute = ''; } } else { $outpute = ''; } } return $outpute; }