易截截图软件、单文件、免安装、纯绿色、仅160KB

我的php验证码类


<?php
/*
 * Created on 2010-3-11
 * author:zhangfei
 *我的验证码类
 */
 session_start();
 class Check_Class{
  public $h_img ;
public $c_back ;
public $c_front ;
//构造函数
function Check_Class(){
$h_img  =  imagecreate(100,30);
$c_back  =  imagecolorallocate($h_img,0,0,0);
$c_front  =  imagecolorallocate($h_img,255,255,255);
$_SESSION[randstr]=$randm_string = $this->random(5);//用session保存起来用以后面判断
$this->getLine($h_img);
$this->getPoint($h_img);
$this->paintString($h_img,$randm_string,$c_front);
//显示图片
header("Content-type:  image/jpeg");
imagejpeg($h_img);
imagedestroy($h_img);
}
  //产生随机字符串,包括数字和大小写字母
  function random($length)
{
   $hash = "";
   $chars = "CEFGHIJKLMNOPQRSTUVWXYZ0123456789cefghijklmnopqrstuvwxyz";
   $max = strlen($chars) - 1;
   mt_srand((double)microtime() * 1000000);
   for($i = 0; $i < $length; $i++)
   {
       $hash .= $chars[mt_rand(0, $max)];
   }
   return $hash;
}
//画干扰线的函数
function getLine($h){
for($j=0;$j<5;$j++){
//定义线条
$c_line = imagecolorallocate($h,rand(0,255),rand(0,255),rand(0,255));
//在图片上划线
imageline($h,rand(0,100),rand(0,30),rand(0,100),rand(0,30),$c_line);
}
}
//画噪点
function getPoint($h){
for($ii=0;$ii<400;$ii++){
$c_point = imagecolorallocate($h,rand(0,255),rand(0,255),rand(0,255));//定义噪点颜色
imagesetpixel($h,rand()%100,rand()%30,$c_point);
}
}
//画字符串
function paintString($h,$rd_str,$c_f){
imagestring($h,rand(4,6),rand(1,50),rand(1,15),$rd_str,$c_f);
}
 }
 $chek = new Check_Class();
?>


相关文档:

使用dom和php程序两种方式生成xml

$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;
$root = $doc->createElement('document'); //创建根
$doc->appendChild($root); //加入根
//webSite
$webSite = $doc->createElement('webSite');
$webSite->appendchild($doc ......

PHP正则表达式匹配并输出数组(做小偷程序很有用)

有这么一段HTML,比较不规则的,如果要提取其中的链接地址和链接名称,怎么弄? 内容来自dedecms
//HTML
$str = '<a id="top8" href="http://list.mp3.baidu.com/song/A.htm?top8" class="p14" target="_top">歌曲列表</a><br><a target="_blank" id="bp" href="http://list.mp3.baidu.com/list/ba ......

使用PHP调用Twitter的RSS


“守望轩”博客右侧边栏原来有个“杂感”的栏目,用来记录短的、不能大篇幅成文的短句,或者自己比较喜欢的短句和言论。
这个栏目最开始调用微博饭否的API来做的,因为众所周知的缘故,饭否无法使用了,后来采用腾讯的滔滔API来实现.2010年1月26日滔滔业务将会开始和QQ空间心情整合,只能考虑放弃。 ......

20个PHP常用类库

下面是一些非常有用的PHP类库,相信一定可以为你的WEB开发提供更好和更为快速的方法。
图表库
下面的类库可以让你很简的创建复杂的图表和图片。当然,它们需要GD库的支持。
pChart - 一个可以创建统计图的库。
Libchart - 这也是一个简单的统计图库。
JpGraph - 一个面向对象的图片创建类。
Open F ......

PHP的一个过滤敏感词或脏话的方法

主要使用了  int substr_count ( string haystack, string needle [, int offset [, int length]] )  这个方法,这个方法遍历待测的字符串$str中有没有$allergicWord数组中所包含的敏感词:
      $allergicWord = array('脏话','骂人话');
      $str = '这 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号