LinuxÒÁµéÔ°ÂÛ̳'s Archiver

smartmouse ·¢±íÓÚ 2006-6-5 13:46

¡¾Ô­´´¡¿Ò»¸ö¼òµ¥µÄphpͼƬ¼ÆÊýÆ÷

[PHP]
<?
Header("Content-type: image/PNG");
function CreateFile($filename,$content)
{                       
                if (is_file ($filename))
                {
                                @unlink ($filename);
                }
                          $handle    = fopen ($filename,"w"); //´ò¿ªÎļþÖ¸Õ룬´´½¨Îļþ
                          /*
                        ¡¡¼ì²éÎļþÊÇ·ñ±»´´½¨ÇÒ¿Éд
                          */
                          if (!is_writable ($filename))
                          {
                                 die ("Îļþ£º".$filename."²»¿Éд£¬Çë¼ì²éÆäÊôÐÔºóÖØÊÔ£¡");
                          }
                          if (!fwrite ($handle,$content))
                          {  //½«ÐÅϢдÈëÎļþ
                                 die ("Éú³ÉÎļþ".$filename."ʧ°Ü£¡");
                          }
                        //  echo "<br>дÈëÎļþ".$filename;
                          fclose ($handle); //¹Ø±ÕÖ¸?
}
srand((double)microtime()*1000000);
$counterfile = 'blogcounter.txt';
$counter = @file_get_contents($counterfile );
$content = $counter+1;
@CreateFile($counterfile,$content);
$len = strlen($counter);
$im = imagecreate(($len+1)*10+5,15);
$black = ImageColorAllocate($im, 0,255,0);
$white = ImageColorAllocate($im, 255,255,255);
$green = ImageColorAllocate($im, 223,11,216);
//imagefill($im,45,18,$white);
imagefilledrectangle($im,0,0,($len+1)*10+5,20,$white);
//½«¼¼ÊõÆ÷»æÈëͼƬ
@ImageTTFText($im, 8,0, 5,12, $green, "counter.ttf",$counter);
//imagestring($im, 4, 4, 1, $HTTP_GET_VARS['authnum'], $green);
for($i=0;$i<200;$i++) //¼ÓÈë¸ÉÈÅÏóËØ
{
        imagesetpixel($im, rand()%50 , rand()%50 , $black);
}
ImagePNG($im);
ImageDestroy($im);
?>
[/PHP]
¸½¼þ£º[url]http://www.0223.cn/phpcounter.rar[/url]

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.