echo 'orange';
} elseif ($php_sapi_name == 'cgi') {
    echo 'yellow';
} elseif ($php_sapi_name == 'apache') {
    echo 'lime';
} else {
    echo 'green';
}
echo ';">' . htmlentities($php_sapi_name) . '</th>';
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>';
echo '<tr><th>Server Software</th><th colspan="2" style="background-color: ';
$server_software = getenv('SERVER_SOFTWARE');
if (!$server_software) {
    echo 'red';
} elseif (preg_match('#^Apache/([0-9\\.]+)#i', $server_software, $matches)) {
    if (phpThumb_functions::version_compare_replacement($matches[1], '2.0.0', '>=')) {
        echo 'lightgreen';
    } else {
        echo 'lime';
    }
} else {
    echo 'darkgreen';
}
echo ';">' . $server_software . '</th>';
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>';
echo '<tr><th>curl_version:</th><th colspan="2" style="background-color: ';
$curl_version = function_exists('curl_version') ? curl_version() : '';
if (is_array($curl_version)) {
    $curl_version = @$curl_version['version'];
}
if ($curl_version) {
 static function SanitizeFilename($filename)
 {
     $filename = preg_replace('/[^' . preg_quote(' !#$%^()+,-.;<>=@[]_{}') . 'a-zA-Z0-9]/', '_', $filename);
     if (phpThumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
         $filename = trim($filename, '.');
     }
     return $filename;
 }
 function Smooth(&$gdimg, $amount = 6)
 {
     $amount = min(25, max(0, $amount));
     if ($amount == 0) {
         return true;
     }
     if (phpThumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpThumb_functions::gd_is_bundled()) {
         if (ImageFilter($gdimg, IMG_FILTER_SMOOTH, $amount)) {
             return true;
         }
         $this->DebugMessage('FAILED: ImageFilter($gdimg, IMG_FILTER_SMOOTH, ' . $amount . ')', __FILE__, __LINE__);
         // fall through and try it the hard way
     }
     // currently not implemented "the hard way"
     $this->DebugMessage('FAILED: phpThumb_filters::Smooth($gdimg, ' . $amount . ') [function not implemented]', __FILE__, __LINE__);
     return false;
 }
$PHPTHUMB_CONFIG['temp_directory'] = $PHPTHUMB_CONFIG['cache_directory'];
// set to same as cache directory
// NOTE: "max_source_pixels" only affects GD-resized thumbnails. If you have ImageMagick
//       installed it will bypass most of these limits
// maximum number of pixels in source image to attempt to process entire image in GD mode.
// If this is zero then no limit on source image dimensions.
// If this is nonzero then this is the maximum number of pixels the source image
// can have to be processed normally, otherwise the embedded EXIF thumbnail will
// be used (if available) or an "image too large" notice will be displayed.
// This is to be used for large source images (> 1600x1200) and low PHP memory
// limits. If PHP runs out of memory the script will usually just die with no output.
// To calculate this number, multiply the dimensions of the largest image
// you can process with your memory limitation (e.g. 1600 * 1200 = 1920000)
// As a general guideline, this number will be about 20% of your PHP memory
// configuration, so 8M = 1,677,722; 16M = 3,355,443; 32M = 6,710,886; etc.
if (phpThumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && !defined('memory_get_usage') && !@ini_get('memory_limit')) {
    // memory_get_usage() will only be defined if your PHP is compiled with the --enable-memory-limit configuration option.
    $PHPTHUMB_CONFIG['max_source_pixels'] = 0;
    // no memory limit
} else {
    // calculate default max_source_pixels as 1/6 of memory limit configuration
    $PHPTHUMB_CONFIG['max_source_pixels'] = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 / 6);
    //$PHPTHUMB_CONFIG['max_source_pixels'] = 0;       // no memory limit
    //$PHPTHUMB_CONFIG['max_source_pixels'] = 1920000; // allow 1600x1200 images (2Mpx), no larger (about 12MB memory required)
    //$PHPTHUMB_CONFIG['max_source_pixels'] = 2795000; // 16MB memory limit
    //$PHPTHUMB_CONFIG['max_source_pixels'] = 3871488; // allow 2272x1704 images (4Mpx), no larger (about 24MB memory required)
}
// ImageMagick configuration
$PHPTHUMB_CONFIG['prefer_imagemagick'] = true;
// If true, use ImageMagick to resize thumbnails if possible, since it is usually faster than GD functions; if false only use ImageMagick if PHP memory limit is too low.
$PHPTHUMB_CONFIG['imagemagick_use_thumbnail'] = true;