SS7。5我想把电话号码生成为图片``网上找到一个代码不知道咋整合到模型里去``- <?php //前面不要有空行
- 2$id=$_GET[id];
- 3include("admin/config.php");
- 4$sql="select * from user where id=$id";
- 5$data=mysql_fetch_array(mysql_query($sql));
- 6$p=SBC_DBC($data[Phone],1);
- 7function get_str($str,$strlen=16) {
- 8$str=stripslashes($str);
- 9 for($i=0;$i<$strlen;$i++)
- 10 if(ord(substr($str,$i,1))>0xa0) $j++;
- 11 if($j%2!=0) $strlen++;
- 12 $tmp_str=substr($str,0,$strlen);
- 13 return $tmp_str;
- 14}
- 15if($p<>''){
- 16//生成5位的数字图片
- 17Header("Content-type:image/png"); //告诉浏览器,下面的数据是图片,而不要按文字显示
- 18
- 19//定义图片宽高
- 20$nwidth=120;
- 21$nheight=25;
- 22$im=@imagecreate($nwidth,$nheight) or die("Can't initialize new GD image stream"); //建立图象
- 23
- 24//图片色彩设置
- 25$background_color=imagecolorallocate($im,255,255,255); //匹配颜色
- 26$text_color=imagecolorallocate($im,23,14,91);
- 27
- 28//绘制图片边框
- 29imagefilledrectangle($im,0,0,$nwidth-1,$nheight-1,$background); //矩形区域着色
- 30imagerectangle($im,0,0,$nwidth-1,$nheight-1,$background_color); //绘制矩形
- 31
- 32//srand((double)microtime()*1000000); //取得目前时间的百万分之一秒值,以执行时的百万分之一秒当乱数种子
- 33//$randval=rand();
- 34$randval=$p; //5位数
- 35imagestring($im,8,10,2,$randval,$text_color); //绘制横式字串
- 36
- 37
- 38//加入干扰因素
- 39//for($i=0;$i<478;$i++)
- 40//{
- 41//$randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
- 42//imagesetpixel($im,rand()%100,rand()%30,$randcolor); //点
- 43//}
- 44//imagestring($im,3,5,5,"A Simple Text String",$text_color);
- 45//imageinterlace($im,1);
- 46imagepng($im); //建立png图型
- 47imagedestroy($im); //结束图型
- 48
- 49}else{
- 50echo "<font size=2>商家未输入电话号码</font>";
- 51}
- 52
- 53?>
复制代码 http://www.cnitblog.com/zozi/archive/2008/08/28/48475.aspx
会的告诉一下咋弄呗 |