易截截图软件、单文件、免安装、纯绿色、仅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();
?>


相关文档:

php自用数据缓存类

刚换了一个工作,现在没什么事做,写了一个数据缓存的类。
可以缓存数组,字符,对象等,执行效率还没有测试,先放出来吧。
实例如下:
 * @example
 * require 'MyCache.class.php';
 * $mc = new MyCache("./test/cache");
 * $a = "hello world111";
 * $mc->set("ss", $a);
  ......

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 的错误报告

PHP 的错误报告
display_errors = Off
error_reporting = E_ALL
display_errors  是否显示错误。默认值是 Off。要让开发过程更加轻松,请把这个值设为 On:
display_errors = On
error_reporting 变量的默认值是 E_ALL。这个设置会显示从不良编码实践到无害提示到出错的所有信息。E_ALL 对于开发过程来说有点太细 ......

[转]续 “创造世界上最简单的 php开发模式”

  “技术问题都是可以解决的,技术问题不是最最重要的”
   最近帮过一些人解决技术问题,发现一个很严重的问题,他们的做法和我最开始写程序的时候是一样的,这样下去会走好多的弯路。现在有一类程序员太多,他们总是一味的追求“所谓的技术难点”,总是把心事放在一些边边角角的“程序代码 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号