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

php生成扭曲及旋转的验证码图片

<?php
function make_rand($length="32"){//验证码文字生成函数
$str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$result="";
for($i=0;$i<$length;$i++){
$num[$i]=rand(0,61);
$result.=$str[$num[$i]];
}
return $result;
}
$checkcode = make_rand(5);
$im_x=160;
$im_y=32;
function make_crand($length="5") {
$string = '';
for($i=0;$i<$length;$i++) {
$string .= chr(rand(0xB0,0xF7)).chr(rand(0xA1,0xFE));
}
return $string;
}
function getAuthImage($text , $im_x = 230 , $im_y = 32) {
$im = imagecreatetruecolor($im_x,$im_y);
$text_c = ImageColorAllocate($im, mt_rand(0,100),mt_rand(0,100),mt_rand(0,100));
$tmpC0=mt_rand(100,255);
$tmpC1=mt_rand(100,255);
$tmpC2=mt_rand(100,255);
$buttum_c = ImageColorAllocate($im,$tmpC0,$tmpC1,$tmpC2);
imagefill($im, 16, 13, $buttum_c);
//echo $text;
$font = 'c:\\WINDOWS\\Fonts\\simsun.ttc';
//echo strlen($text);
$text=iconv("gb2312","UTF-8",$text);
//echo mb_strlen($text,"UTF-8");
for ($i=0;$i<mb_strlen($text);$i++)
{
$tmp =mb_substr($text,$i,1,"UTF-8");
$array = array(-1,0,1);
$p = array_rand($array);
$an = $array[$p]*mt_rand(1,9);//角度
$size = 20;
imagettftext($im,$size,$an,10+$i*$size*2,25,$text_c,$font,$tmp);
}
$distortion_im = imagecreatetruecolor ($im_x, $im_y);
imagefill($distortion_im, 16, 13, $buttum_c);
for ( $i=0; $i<$im_x; $i++) {
for ( $j=0; $j<$im_y; $j++) {
$rgb = imagecolorat($im, $i , $j);
if( (int)($i+20+sin($j/$im_y*2*M_PI)*10) <= imagesx($distortion_im) && (int)($i+20+sin($j/$im_y*2*M_PI)*10) >=0 ) {
imagesetpixel ($distortion_im, (int)($i+10+sin($j/$im_y*2*M_PI-M_PI*0.5)*3) , $j , $rgb);
}
}


相关文档:

PHP获取汉字拼音首字母

<FORM METHOD=POST ACTION="#">
<INPUT TYPE="text" NAME="name">
<INPUT TYPE="submit" value="query" name="sub">
</FORM>
<?php
function getinitial($str)
{
$asc=ord(substr($str,0,1)); //ord()获取ASCII
if ($asc<160) //非中文
{
if ($asc>=48 ......

40条优化php代码的小实例

40条优化php代码的小实例
1.如果一个方法能被静态,那就声明他为静态的,速度可提高1/4;
2.echo的效率高于print,因为echo没有返回值,print返回一个整型;
3.在循环之前设置循环的最大次数,而非在在循环中;
4.销毁变量去释放内存,特别是大的数组;
5.避免使用像__get, __set, __autoload等魔术方法;
6.requiere_once( ......

PHP的日期时间运算总结




<?php
//GB2312的Encode
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
/*重点了解strtotime()函数
1、strftime比time()好用,可以直接把常用的’2010-02-03‘转成时间戳。
2、date( ......

PHP数据结构——二分查找与顺序查找

<?php
//--------------------
// 基本数据结构
//--------------------
//二分查找(数组里查找某个元素)
function bin_sch($arr, $low, $high, $k) {
if($low<=$high) {
$mid = intval(($low+$high)/2);
if($arr[$mid] == $k) {
return $mid;
} elseif($k<$ ......

PHP无限分类的例子(包括数据库)转

其他常见的无限分类方法:
1,简单的通过递归查询加目录path字段的无限分类
缺点:查询数据库次数太多,不方便其他操作,比如删除节点。添加节点,移动节点
2,左右值无限分类,预排序二叉树
缺点:操作繁琐,数据库冗余,且添加删除修改都要进行左右值更新
本分类方法的优势:
1,数据库结构简单,只有 cid parentid ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号