14 if (function_exists(
'get_defined_functions')) {
15 static $get_defined_functions = array();
16 if (empty($get_defined_functions)) {
17 $get_defined_functions = get_defined_functions();
19 return in_array(strtolower($functionname), $get_defined_functions[
'user']);
21 return function_exists($functionname);
26 if (function_exists(
'get_defined_functions')) {
27 static $get_defined_functions = array();
28 if (empty($get_defined_functions)) {
29 $get_defined_functions = get_defined_functions();
31 return in_array(strtolower($functionname), $get_defined_functions[
'internal']);
33 return function_exists($functionname);
44 static $versiontype_lookup = array();
45 if (empty($versiontype_lookup)) {
46 $versiontype_lookup[
'dev'] = 10001;
47 $versiontype_lookup[
'a'] = 10002;
48 $versiontype_lookup[
'alpha'] = 10002;
49 $versiontype_lookup[
'b'] = 10003;
50 $versiontype_lookup[
'beta'] = 10003;
51 $versiontype_lookup[
'RC'] = 10004;
52 $versiontype_lookup[
'rc'] = 10004;
53 $versiontype_lookup[
'#'] = 10005;
54 $versiontype_lookup[
'pl'] = 10006;
55 $versiontype_lookup[
'p'] = 10006;
57 $version1 = (isset($versiontype_lookup[$version1]) ? $versiontype_lookup[$version1] : $version1);
58 $version2 = (isset($versiontype_lookup[$version2]) ? $versiontype_lookup[$version2] : $version2);
63 return intval($version1 < $version2);
67 return intval($version1 <= $version2);
71 return intval($version1 > $version2);
75 return intval($version1 >= $version2);
80 return intval($version1 == $version2);
85 return intval($version1 != $version2);
88 if ($version1 == $version2) {
90 } elseif ($version1 < $version2) {
98 if (function_exists(
'version_compare')) {
100 return version_compare($version1, $version2, $operator);
104 $version1 = strtr($version1,
'_-+',
'...');
105 $version2 = strtr($version2,
'_-+',
'...');
109 $version1 = preg_replace(
'#([0-9]+)([A-Z]+)([0-9]+)#i',
"$1.$2.$3", $version1);
110 $version2 = preg_replace(
'#([0-9]+)([A-Z]+)([0-9]+)#i',
"$1.$2.$3", $version2);
112 $parts1 = explode(
'.', $version1);
113 $parts2 = explode(
'.', $version1);
114 $parts_count = max(count($parts1), count($parts2));
115 for (
$i = 0;
$i < $parts_count;
$i++) {
117 if ($comparison != 0) {
126 static $phpinfo_array = array();
127 if (empty($phpinfo_array)) {
130 $phpinfo = ob_get_contents();
132 $phpinfo_array = explode(
"\n", $phpinfo);
134 return $phpinfo_array;
139 static $exif_info = array();
140 if (empty($exif_info)) {
144 'EXIF Support' =>
'',
145 'EXIF Version' =>
'',
146 'Supported EXIF Version' =>
'',
147 'Supported filetypes' =>
''
150 foreach ($phpinfo_array as $line) {
151 $line = trim(strip_tags($line));
152 foreach ($exif_info as $key => $value) {
153 if (strpos($line, $key) === 0) {
154 $newvalue = trim(str_replace($key,
'', $line));
155 $exif_info[$key] = $newvalue;
165 if (function_exists(
'image_type_to_mime_type') && ($imagetype >= 1) && ($imagetype <= 16)) {
167 return image_type_to_mime_type($imagetype);
169 static $image_type_to_mime_type = array(
173 4 =>
'application/x-shockwave-flash',
178 9 =>
'application/octet-stream',
180 11 =>
'application/octet-stream',
181 12 =>
'application/octet-stream',
182 13 =>
'application/x-shockwave-flash',
184 15 =>
'image/vnd.wap.wbmp',
187 'gif' =>
'image/gif',
188 'jpg' =>
'image/jpeg',
189 'jpeg' =>
'image/jpeg',
190 'png' =>
'image/png',
191 'bmp' =>
'image/bmp',
192 'ico' =>
'image/x-icon',
195 return (isset($image_type_to_mime_type[$imagetype]) ? $image_type_to_mime_type[$imagetype] :
false);
200 if (($angle % 180) == 0) {
201 return array($width, $height);
203 $newwidth = (abs(sin(deg2rad($angle))) * $height) + (abs(cos(deg2rad($angle))) * $width);
204 $newheight = (abs(sin(deg2rad($angle))) * $width) + (abs(cos(deg2rad($angle))) * $height);
205 return array($newwidth, $newheight);
209 $len = strlen($string);
211 for (
$i = 0;
$i < $len;
$i++) {
212 $output .=
' 0x'.str_pad(dechex(ord($string{
$i})), 2,
'0', STR_PAD_LEFT);
219 return preg_match(
'#^[0-9A-F]{6}$#i', $HexColorString);
225 return ImageColorAllocateAlpha($gdimg_hexcolorallocate, $R, $G, $B, intval($alpha));
227 return ImageColorAllocate($gdimg_hexcolorallocate, $R, $G, $B);
231 static function ImageHexColorAllocate(&$gdimg_hexcolorallocate, $HexColorString, $dieOnInvalid=
false, $alpha=
false) {
232 if (!is_resource($gdimg_hexcolorallocate)) {
233 die(
'$gdimg_hexcolorallocate is not a GD resource in ImageHexColorAllocate()');
236 $R = hexdec(substr($HexColorString, 0, 2));
237 $G = hexdec(substr($HexColorString, 2, 2));
238 $B = hexdec(substr($HexColorString, 4, 2));
242 die(
'Invalid hex color string: "'.$HexColorString.
'"');
244 return ImageColorAllocate($gdimg_hexcolorallocate, 0x00, 0x00, 0x00);
249 return strtoupper(str_pad(dechex(~hexdec($hexcolor) & 0xFFFFFF), 6,
'0', STR_PAD_LEFT));
254 if (!is_resource($img)) {
257 return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
263 foreach ($targetPixel as $channel => $currentvalue) {
264 $diff = max($diff, (max($currentPixel[$channel], $targetPixel[$channel]) - min($currentPixel[$channel], $targetPixel[$channel])) / 255);
270 return round(($r * 0.30) + ($g * 0.59) + ($b * 0.11));
276 return array(
'red'=>$gray,
'green'=>$gray,
'blue'=>$gray);
281 $r = ($rgb >> 16) & 0xFF;
282 $g = ($rgb >> 8) & 0xFF;
284 return ($r * 0.299) + ($g * 0.587) + ($b * 0.114);
288 static function ScaleToFitInBox($width, $height, $maxwidth=null, $maxheight=null, $allow_enlarge=
true, $allow_reduce=
true) {
289 $maxwidth = (is_null($maxwidth) ? $width : $maxwidth);
290 $maxheight = (is_null($maxheight) ? $height : $maxheight);
293 if (($width > $maxwidth) || ($width < $maxwidth)) {
294 $scale_x = ($maxwidth / $width);
296 if (($height > $maxheight) || ($height < $maxheight)) {
297 $scale_y = ($maxheight / $height);
299 $scale = min($scale_x, $scale_y);
300 if (!$allow_enlarge) {
301 $scale = min($scale, 1);
303 if (!$allow_reduce) {
304 $scale = max($scale, 1);
313 $scaleX = ($src_w - 1) / $dst_w;
314 $scaleY = ($src_h - 1) / $dst_h;
316 $scaleX2 = $scaleX / 2.0;
317 $scaleY2 = $scaleY / 2.0;
319 $isTrueColor = ImageIsTrueColor($src_img);
321 for ($y = $src_y; $y < $src_y + $dst_h; $y++) {
324 $siY2 = (int) $sY + $scaleY2;
326 for ($x = $src_x; $x < $src_x + $dst_w; $x++) {
329 $siX2 = (int) $sX + $scaleX2;
333 $c1 = ImageColorAt($src_img, $siX, $siY2);
334 $c2 = ImageColorAt($src_img, $siX, $siY);
335 $c3 = ImageColorAt($src_img, $siX2, $siY2);
336 $c4 = ImageColorAt($src_img, $siX2, $siY);
338 $r = (( $c1 + $c2 + $c3 + $c4 ) >> 2) & 0xFF0000;
339 $g = ((($c1 & 0x00FF00) + ($c2 & 0x00FF00) + ($c3 & 0x00FF00) + ($c4 & 0x00FF00)) >> 2) & 0x00FF00;
340 $b = ((($c1 & 0x0000FF) + ($c2 & 0x0000FF) + ($c3 & 0x0000FF) + ($c4 & 0x0000FF)) >> 2);
344 $c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY2));
345 $c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY));
346 $c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY2));
347 $c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY));
349 $r = ($c1[
'red'] + $c2[
'red'] + $c3[
'red'] + $c4[
'red'] ) << 14;
350 $g = ($c1[
'green'] + $c2[
'green'] + $c3[
'green'] + $c4[
'green']) << 6;
351 $b = ($c1[
'blue'] + $c2[
'blue'] + $c3[
'blue'] + $c4[
'blue'] ) >> 2;
354 ImageSetPixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b);
362 $ImageCreateFunction =
'ImageCreate';
364 $ImageCreateFunction =
'ImageCreateTrueColor';
366 if (!function_exists($ImageCreateFunction)) {
369 if (($x_size <= 0) || ($y_size <= 0)) {
370 return phpthumb::ErrorImage(
'Invalid image dimensions: '.$ImageCreateFunction.
'('.$x_size.
', '.$y_size.
')');
372 return $ImageCreateFunction(round($x_size), round($y_size));
376 static function ImageCopyRespectAlpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $opacity_pct=100) {
377 $opacipct = $opacity_pct / 100;
378 for ($x = $src_x; $x < $src_w; $x++) {
379 for ($y = $src_y; $y < $src_h; $y++) {
382 $alphapct = $OverlayPixel[
'alpha'] / 127;
383 $overlaypct = (1 - $alphapct) * $opacipct;
387 round($RealPixel[
'red'] * (1 - $overlaypct)) + ($OverlayPixel[
'red'] * $overlaypct),
388 round($RealPixel[
'green'] * (1 - $overlaypct)) + ($OverlayPixel[
'green'] * $overlaypct),
389 round($RealPixel[
'blue'] * (1 - $overlaypct)) + ($OverlayPixel[
'blue'] * $overlaypct),
393 ImageSetPixel($dst_im, $dst_x + $x, $dst_y + $y, $newcolor);
401 $old_aspect_ratio = $old_width / $old_height;
402 if (($new_width ===
false) && ($new_height ===
false)) {
404 } elseif ($new_width ===
false) {
405 $new_width = $new_height * $old_aspect_ratio;
406 } elseif ($new_height ===
false) {
407 $new_height = $new_width / $old_aspect_ratio;
409 $new_aspect_ratio = $new_width / $new_height;
410 if ($new_aspect_ratio == $old_aspect_ratio) {
412 } elseif ($new_aspect_ratio < $old_aspect_ratio) {
414 $new_height = $new_width / $old_aspect_ratio;
415 } elseif ($new_aspect_ratio > $old_aspect_ratio) {
417 $new_width = $new_height * $old_aspect_ratio;
419 return array(intval(round($new_width)), intval(round($new_height)));
424 static $DisabledFunctions = null;
425 if (is_null($DisabledFunctions)) {
426 $disable_functions_local = explode(
',', strtolower(@ini_get(
'disable_functions')));
427 $disable_functions_global = explode(
',', strtolower(@get_cfg_var(
'disable_functions')));
428 foreach ($disable_functions_local as $key => $value) {
429 $DisabledFunctions[trim($value)] =
'local';
431 foreach ($disable_functions_global as $key => $value) {
432 $DisabledFunctions[trim($value)] =
'global';
434 if (@ini_get(
'safe_mode')) {
435 $DisabledFunctions[
'shell_exec'] =
'local';
436 $DisabledFunctions[
'set_time_limit'] =
'local';
439 return isset($DisabledFunctions[strtolower($function)]);
444 static $AllowedExecFunctions = array();
445 if (empty($AllowedExecFunctions)) {
446 $AllowedExecFunctions = array(
'shell_exec'=>
true,
'passthru'=>
true,
'system'=>
true,
'exec'=>
true);
447 foreach ($AllowedExecFunctions as $key => $value) {
452 foreach ($AllowedExecFunctions as $execfunction => $is_allowed) {
456 $returnvalue =
false;
457 switch ($execfunction) {
461 $execfunction($command);
462 $returnvalue = ob_get_contents();
468 $lastline = $execfunction($command, $output);
469 $returnvalue = implode(
"\n", $output);
474 $returnvalue = $execfunction($command);
486 if (php_sapi_name() ==
'apache') {
488 $keys = array(
'status',
'the_request',
'status_line',
'method',
'content_type',
'handler',
'uri',
'filename',
'path_info',
'args',
'boundary',
'no_cache',
'no_local_copy',
'allowed',
'send_bodyct',
'bytes_sent',
'byterange',
'clength',
'unparsed_uri',
'mtime',
'request_time');
489 if ($apacheLookupURIobject = @apache_lookup_uri($filename)) {
490 $apacheLookupURIarray = array();
491 foreach ($keys as $key) {
492 $apacheLookupURIarray[$key] = @$apacheLookupURIobject->$key;
494 return $apacheLookupURIarray;
502 static $isbundled = null;
503 if (is_null($isbundled)) {
504 $gd_info = gd_info();
505 $isbundled = (strpos($gd_info[
'GD Version'],
'bundled') !==
false);
512 static $cache_gd_version = array();
513 if (empty($cache_gd_version)) {
514 $gd_info = gd_info();
515 if (preg_match(
'#bundled \((.+)\)$#i', $gd_info[
'GD Version'], $matches)) {
516 $cache_gd_version[1] = $gd_info[
'GD Version'];
517 $cache_gd_version[0] = (float) $matches[1];
519 $cache_gd_version[1] = $gd_info[
'GD Version'];
520 $cache_gd_version[0] = (float) substr($gd_info[
'GD Version'], 0, 3);
523 return $cache_gd_version[intval($fullstring)];
530 if ($fp = @fsockopen(
$url[
'host'], (
$url[
'port'] ?
$url[
'port'] : 80), $errno, $errstr, $timeout)) {
531 fwrite($fp,
'HEAD '.@$url[
'path'].@$url[
'query'].
' HTTP/1.0'.
"\r\n".
'Host: '.@$url[
'host'].
"\r\n\r\n");
533 stream_set_timeout($fp, $timeout);
536 $headerline = fgets($fp, 4096);
537 if (preg_match(
'#^Content-Length: (.*)#i', $headerline, $matches)) {
538 $size = intval($matches[1]);
551 if ($fp = @fsockopen(
$url[
'host'], (
$url[
'port'] ?
$url[
'port'] : 80), $errno, $errstr, $timeout)) {
552 fwrite($fp,
'HEAD '.@$url[
'path'].@$url[
'query'].
' HTTP/1.0'.
"\r\n".
'Host: '.@$url[
'host'].
"\r\n\r\n");
554 stream_set_timeout($fp, $timeout);
557 $headerline = fgets($fp, 4096);
558 if (preg_match(
'#^Last-Modified: (.*)#i', $headerline, $matches)) {
559 $date = strtotime($matches[1]) - date(
'Z');
571 if (function_exists(
'md5_file')) {
572 return md5_file($filename);
574 if ($fp = @fopen($filename,
'rb')) {
577 $buffer = fread($fp, 8192);
579 }
while (strlen($buffer) > 0);
581 return md5($rawData);
588 $arg_list = func_get_args();
589 $acceptable = array();
590 foreach ($arg_list as $arg) {
592 $acceptable[] = $arg;
595 return min($acceptable);
601 while ($number > 0) {
602 $intstring = $intstring.chr($number & 255);
605 return str_pad($intstring, $minbytes,
"\x00", STR_PAD_RIGHT);
610 $arg_list = func_get_args();
611 foreach ($arg_list as $key => $value) {
620 $needle = strtolower($needle);
621 foreach ($haystack as $key => $value) {
622 if (is_array($value)) {
624 } elseif ($needle == strtolower($value)) {
631 static function URLreadFsock($host,
$file, &$errstr, $successonly=
true, $port=80, $timeout=10) {
633 $errstr =
'fsockopen() unavailable';
636 if ($fp = @fsockopen($host, $port, $errno, $errstr, $timeout)) {
637 $out =
'GET '.$file.
' HTTP/1.0'.
"\r\n";
638 $out .=
'Host: '.$host.
"\r\n";
639 $out .=
'Connection: Close'.
"\r\n\r\n";
645 $header_newlocation =
'';
647 $line = fgets($fp, 1024);
649 $Data_header .= $line;
653 if (preg_match(
'#^HTTP/[\\.0-9]+ ([0-9]+) (.+)$#i', rtrim($line), $matches)) {
654 list($dummy, $errno, $errstr) = $matches;
655 $errno = intval($errno);
656 } elseif (preg_match(
'#^Location: (.*)$#i', rtrim($line), $matches)) {
657 $header_newlocation = $matches[1];
659 if ($isHeader && ($line ==
"\r\n")) {
668 $errstr = $errno.
' '.$errstr.($header_newlocation ?
'; Location: '.$header_newlocation :
'');
683 if (!preg_match(
'#^http#i',
$url)) {
687 $pathelements = explode(
'/', $parse_url[
'path']);
688 $CleanPathElements = array();
689 $TranslationMatrix = array(
' '=>
'%20');
690 foreach ($pathelements as $key => $pathelement) {
691 $CleanPathElements[] = strtr($pathelement, $TranslationMatrix);
693 foreach ($CleanPathElements as $key => $value) {
695 unset($CleanPathElements[$key]);
699 $queries = explode($queryseperator, (isset($parse_url[
'query']) ? $parse_url[
'query'] :
''));
700 $CleanQueries = array();
702 @list($param, $value) = explode(
'=',
$query);
703 $CleanQueries[] = strtr($param, $TranslationMatrix).($value ?
'='.strtr($value, $TranslationMatrix) :
'');
705 foreach ($CleanQueries as $key => $value) {
707 unset($CleanQueries[$key]);
711 $cleaned_url = $parse_url[
'scheme'].
'://';
712 $cleaned_url .= (@$parse_url[
'username'] ? $parse_url[
'host'].(@$parse_url[
'password'] ?
':'.$parse_url[
'password'] :
'').
'@' :
'');
713 $cleaned_url .= $parse_url[
'host'];
714 $cleaned_url .= ((!empty($parse_url[
'port']) && ($parse_url[
'port'] != 80)) ?
':'.$parse_url[
'port'] :
'');
715 $cleaned_url .=
'/'.implode(
'/', $CleanPathElements);
716 $cleaned_url .= (@$CleanQueries ?
'?'.implode($queryseperator, $CleanQueries) :
'');
721 $parsedURL = @parse_url(
$url);
722 if (!@$parsedURL[
'port']) {
723 switch (strtolower(@$parsedURL[
'scheme'])) {
725 $parsedURL[
'port'] = 21;
728 $parsedURL[
'port'] = 443;
731 $parsedURL[
'port'] = 80;
742 $alreadyLookedAtURLs[trim(
$url)] =
true;
746 $rawData =
phpthumb_functions::URLreadFsock(@$parsed_url[
'host'], @$parsed_url[
'path'].
'?'.@$parsed_url[
'query'], $errstr,
true, (@$parsed_url[
'port'] ? @$parsed_url[
'port'] : 80), $timeout);
747 if (preg_match(
'#302 [a-z ]+; Location\\: (http.*)#i', $errstr, $matches)) {
748 $matches[1] = trim(@$matches[1]);
749 if (!@$alreadyLookedAtURLs[$matches[1]]) {
751 $error .=
'URL "'.$url.
'" redirected to "'.$matches[1].
'"';
754 $alreadyLookedAtURLs[$matches[1]] =
true;
763 if ($rawData ===
false) {
764 $error .=
'Error opening "'.$url.
'":'.
"\n\n".$errstr;
766 } elseif ($rawData === null) {
768 $error .=
'Error opening "'.$url.
'":'.
"\n\n".$errstr;
775 curl_setopt($ch, CURLOPT_URL,
$url);
776 curl_setopt($ch, CURLOPT_HEADER,
false);
777 curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true);
778 curl_setopt($ch, CURLOPT_BINARYTRANSFER,
true);
779 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
780 $rawData = curl_exec($ch);
782 if (strlen($rawData) > 0) {
783 $error .=
'CURL succeeded ('.strlen($rawData).
' bytes); ';
786 $error .=
'CURL available but returned no data; ';
788 $error .=
'CURL unavailable; ';
791 $BrokenURLfopenPHPversions = array(
'4.4.2');
792 if (in_array(phpversion(), $BrokenURLfopenPHPversions)) {
793 $error .=
'fopen(URL) broken in PHP v'.phpversion().
'; ';
794 } elseif (@ini_get(
'allow_url_fopen')) {
798 if ($fp = fopen(
$url,
'rb')) {
800 $buffer = fread($fp, 8192);
802 }
while (strlen($buffer) > 0);
805 $error_fopen .= trim(strip_tags(ob_get_contents()));
810 $error .=
'; "allow_url_fopen" succeeded ('.strlen($rawData).
' bytes); ';
813 $error .=
'; "allow_url_fopen" enabled but returned no data ('.$error_fopen.
'); ';
815 $error .=
'"allow_url_fopen" disabled; ';
823 $startoffset = (!$directory_elements[0] ? 2 : 1);
824 $open_basedirs = preg_split(
'#[;:]#', ini_get(
'open_basedir'));
825 foreach ($open_basedirs as $key => $open_basedir) {
826 if (preg_match(
'#^'.preg_quote($open_basedir).
'#',
$dirname) && (strlen(
$dirname) > strlen($open_basedir))) {
832 $endoffset = count($directory_elements);
833 for (
$i = $startoffset;
$i <= $endoffset;
$i++) {
835 if (!$test_directory) {
838 if (!@is_dir($test_directory)) {
839 if (@file_exists($test_directory)) {
843 @mkdir($test_directory, 0755);
844 @chmod($test_directory, 0755);
845 if (!@is_dir($test_directory) || !@is_writeable($test_directory)) {
857 if ($dirhandle = @opendir(
$dirname)) {
858 while ((
$file = readdir($dirhandle)) !==
false) {
859 $fullfilename =
$dirname.DIRECTORY_SEPARATOR.$file;
860 if (is_file($fullfilename)) {
861 $AllFiles[] = $fullfilename;
862 } elseif (is_dir($fullfilename)) {
869 $AllFiles[] = $fullfilename;
871 foreach ($subfiles as $filename) {
872 $AllFiles[] = $filename;
880 closedir($dirhandle);
883 return array_unique($AllFiles);
888 $filename = preg_replace(
'/[^'.preg_quote(
' !#$%^()+,-.;<>=@[]_{}').
'a-zA-Z0-9]/',
'_', $filename);
890 $filename = trim($filename,
'.');
901 if (!function_exists(
'gd_info')) {
904 static $gd_info = array();
905 if (empty($gd_info)) {
910 'FreeType Support' =>
false,
911 'FreeType Linkage' =>
'',
912 'T1Lib Support' =>
false,
913 'GIF Read Support' =>
false,
914 'GIF Create Support' =>
false,
915 'JPG Support' =>
false,
916 'PNG Support' =>
false,
917 'WBMP Support' =>
false,
918 'XBM Support' =>
false
921 foreach ($phpinfo_array as $line) {
922 $line = trim(strip_tags($line));
923 foreach ($gd_info as $key => $value) {
925 if (strpos($line, $key) === 0) {
926 $newvalue = trim(str_replace($key,
'', $line));
927 $gd_info[$key] = $newvalue;
931 if (empty($gd_info[
'GD Version'])) {
933 if (function_exists(
'ImageTypes')) {
934 $imagetypes = ImageTypes();
935 if ($imagetypes & IMG_PNG) {
936 $gd_info[
'PNG Support'] =
true;
938 if ($imagetypes & IMG_GIF) {
939 $gd_info[
'GIF Create Support'] =
true;
941 if ($imagetypes & IMG_JPG) {
942 $gd_info[
'JPG Support'] =
true;
944 if ($imagetypes & IMG_WBMP) {
945 $gd_info[
'WBMP Support'] =
true;
949 if (function_exists(
'ImageCreateFromGIF')) {
951 if ($fp_tempfile = @fopen($tempfilename,
'wb')) {
952 fwrite($fp_tempfile, base64_decode(
'R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw=='));
953 fclose($fp_tempfile);
956 $gd_info[
'GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename);
958 unlink($tempfilename);
961 if (function_exists(
'ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
962 $gd_info[
'GD Version'] =
'2.0.1 or higher (assumed)';
963 } elseif (function_exists(
'ImageCreate') && @ImageCreate(1, 1)) {
964 $gd_info[
'GD Version'] =
'1.6.0 or higher (assumed)';
973 if (!function_exists(
'is_executable')) {
975 function is_executable($filename) {
977 return file_exists($filename);
982 if (!function_exists(
'preg_quote')) {
984 function preg_quote($string, $delimiter=
'\\') {
985 static $preg_quote_array = array();
986 if (empty($preg_quote_array)) {
987 $escapeables =
'.\\+*?[^]$(){}=!<>|:';
988 for (
$i = 0;
$i < strlen($escapeables);
$i++) {
989 $strtr_preg_quote[$escapeables{
$i}] = $delimiter.$escapeables{
$i};
992 return strtr($string, $strtr_preg_quote);
996 if (!function_exists(
'file_get_contents')) {
998 function file_get_contents($filename) {
999 if (preg_match(
'#^(f|ht)tp\://#i', $filename)) {
1000 return SafeURLread($filename,
$error);
1002 if ($fp = @fopen($filename,
'rb')) {
1005 $buffer = fread($fp, 8192);
1006 $rawData .= $buffer;
1007 }
while (strlen($buffer) > 0);
1016 if (!function_exists(
'file_put_contents')) {
1018 function file_put_contents($filename, $filedata) {
1019 if ($fp = @fopen($filename,
'wb')) {
1020 fwrite($fp, $filedata);
1028 if (!function_exists(
'imagealphablending')) {
1030 function imagealphablending(&$img, $blendmode=
true) {
1037 if (!function_exists(
'imagesavealpha')) {
1039 function imagesavealpha(&$img, $blendmode=
true) {