Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[疑难] 有谁会把[数据库中的电话号码读取出来并生成图片]模型里用到`

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

会的告诉一下咋弄呗
cometj 发表于 2010-1-12 15:54:30 | 显示全部楼层
呵呵,很复杂,帮你顶
回复

使用道具 举报

寻找盐巴 发表于 2010-4-2 17:18:14 | 显示全部楼层
持续观望,希望有人能做出
回复

使用道具 举报

efenglin 发表于 2010-4-3 22:29:20 | 显示全部楼层
这个得有偿吧!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-9-29 21:22 , Processed in 1.002124 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表