当前位置: 首页 > 图文教程 > 网络编程 > PHP > php将数据库中的电话号码读取出来并生成图片

PHP
php-accelerator网站加速PHP缓冲的方法
特详细的PHPMYADMIN简明安装教程
用PHP读取RSS feed的代码
php自动适应范围的分页代码
PHP+MYSQL 出现乱码的解决方法
php多数据库支持的应用程序设计
推荐学习php sesson的朋友必看PHP会话(Session)使用入门
PHP调用MySQL的存储过程的实现代码
php二分法在IP地址查询中的应用
php IIS日志分析搜索引擎爬虫记录程序
PHP获取网站域名和地址的代码
PHP 数组实例说明
删除数组元素实用的PHP数组函数
PHP去除数组中重复的元素并按键名排序函数
php中的数组操作函数整理
php数组应用之比较两个时间的相减排序
php magic_quotes_gpc的一点认识与分析
php htmlentities和htmlspecialchars 的区别
php过滤危险html代码
PHP Smarty生成EXCEL文档的代码

PHP 中的 php将数据库中的电话号码读取出来并生成图片


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 104 ::
收藏到网摘: n/a

本PHP程序作用是从数据库中读取出手机号码或其他数据并生成图片,起到干扰采集防采集的作用。(英文或数字,如果要支持中文的话需要额外添加字库)。本代码为原创代码。 以下是代码:
复制代码 代码如下:

<?php //前面不要有空行
$id=$_GET[id];
include("admin/config.php");
$sql="select * from user where id=$id";
$data=mysql_fetch_array(mysql_query($sql));
$p=SBC_DBC($data[Phone],1);
function get_str($str,$strlen=16) {
$str=stripslashes($str);
for($i=0;$i<$strlen;$i++)
if(ord(substr($str,$i,1))>0xa0) $j++;
if($j%2!=0) $strlen++;
$tmp_str=substr($str,0,$strlen);
return $tmp_str;
}
if($p<>''){
//生成5位的数字图片
Header("Content-type:image/png"); //告诉浏览器,下面的数据是图片,而不要按文字显示
//定义图片宽高
$nwidth=120;
$nheight=25;
$im=@imagecreate($nwidth,$nheight) or die("Can't initialize new GD image stream"); //建立图象
//图片色彩设置
$background_color=imagecolorallocate($im,255,255,255); //匹配颜色
$text_color=imagecolorallocate($im,23,14,91);
//绘制图片边框
imagefilledrectangle($im,0,0,$nwidth-1,$nheight-1,$background); //矩形区域着色
imagerectangle($im,0,0,$nwidth-1,$nheight-1,$background_color); //绘制矩形
//srand((double)microtime()*1000000); //取得目前时间的百万分之一秒值,以执行时的百万分之一秒当乱数种子
//$randval=rand();
$randval=$p; //5位数
imagestring($im,8,10,2,$randval,$text_color); //绘制横式字串

//加入干扰因素
//for($i=0;$i<478;$i++)
//{
//$randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
//imagesetpixel($im,rand()%100,rand()%30,$randcolor); //点
//}
//imagestring($im,3,5,5,"A Simple Text String",$text_color);
//imageinterlace($im,1);
imagepng($im); //建立png图型
imagedestroy($im); //结束图型
}else{
echo "<font size=2>商家未输入电话号码</font>";
}
?>