varimage.php
资源名称:BBWPS.rar [点击查看]
上传用户:yttaitong
上传日期:2009-05-10
资源大小:128k
文件大小:1k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
PHP
- <?php
- session_start();
- session_register("randimg");
- if(function_exists("imagecreate")){
- $rndstring = "";
- for($i=0;$i<4;$i++){
- $rndstring .= chr(mt_rand(65,90));
- }
- $_SESSION["randimg"]=strtolower($rndstring);
- $rndcodelen = strlen($rndstring);
- $im = imagecreate(50,20);
- $bgcolor = ImageColorAllocate($im,255,255,255);
- $red = ImageColorAllocate($im,255,0,0);
- $border = ImageColorAllocate($im,122,196,254);
- imagerectangle($im,0,0,49,19,$border);
- for($i=0;$i<$rndcodelen;$i++){
- imagestring($im,mt_rand(2,5),$i*10+6,mt_rand(2,5),$rndstring[$i],$red);
- }
- if(function_exists("imagejpeg")){
- header("content-type:image/jpegrn");
- ImageJpeg($im);
- }else{
- header("content-type:image/pngrn");
- ImagePng($im);
- }
- ImageDestroy($im);
- }else{
- $_SESSION["randimg"]="abcd";
- header("content-type:image/pngrn");
- $fp = fopen("./abcd.bmp","r");
- echo fread($fp,filesize("./abcd.bmp"));
- fclose($fp);
- }
- ?>