Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- error_reporting(E_ALL);
- define("STRING", "WWW.site.RU".iconv("utf-8","cp1251"," (Сайт)"));
- function toUnicodeEntites($text, $from="w")
- { $text = convert_cyr_string($text, $from, "i");
- //print $text;
- $uni = "";
- $len=strlen($text);
- for ($i=0; $i<$len; $i++)
- { $char = $text{$i};
- $code = ord($char);
- $uni .= ($code>175)? "&#" . (1040+($code-176)) . ";" : $char;
- }
- return $uni;
- }
- function thumb($path,$x,$y=0)
- { $t=@getimagesize ($path) or die('К сожалению, эта фотография не может быть отображена!');
- $with=$t[0];
- if ($x == "")
- $x = $with;
- $height=$t[1];
- switch ($t[2])
- { case 1:
- $type='GIF';
- $img=imagecreatefromgif($path);
- break;
- case 2:
- $type='JPEG';
- $img=imagecreatefromjpeg($path);
- break;
- case 3:
- $type='PNG';
- $img=imagecreatefrompng($path);
- break;
- }
- if($y==0)
- {$y=$x*($height/$with);}
- header("Content-type: image/".$type);
- $thumb=ImageCreateTrueColor($x,$y);
- imagecopyresampled($thumb,$img,0,0,0,0,$x,$y,$with,$height);
- //Àäðåñ ñàéòà
- if ($x > 400 and STRING != "")
- { $path = $_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'];
- $path = preg_replace ("/(^.*)(thumb.php)(.*)/", "\\1", $path);
- $config_font = "5";
- $string = STRING;
- $black = imagecolorallocate ($thumb, 0, 0, 0);
- $white = imagecolorallocate ($thumb, 255, 0, 0);
- $x = 10;
- $y = $y-5;
- if (function_exists("imagettftext"))
- {imagettftext($thumb, 22, 0, $x, $y-10, $white, $path."arialbi.ttf", toUnicodeEntites($string));}
- else {imagestring($thumb, "5",$x, $y-20, $string, $white);}
- //
- }
- $thumb=imagejpeg($thumb);
- return $thumb;}
- if (isset ($_GET['id'])) $id = $_GET['id'];
- if(isset ($_GET['w'])) $w = $_GET['w'];else $w = "";
- if ($id){echo thumb($id,$w); echo $path;}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement