<?php
/**
 * Copyright (C) OEMARRY Co.,Ltd. All rights reserved.
 * <E-Mail：service@phpcoo.com>
 * Url http://www.phpcoo.com
 *     http://www.oephp.com
 *     http://www.oemarry.com
 * Update 2015.06.01
 */
@session_start();
$act  = isset($_GET['act']) ? trim($_GET['act']) : "";
if ($act == 'verifycode') {
    rand_create();
}

//create randchar
function rand_create() {
    Header("Content-type: image/PNG");
    srand((double)microtime()*1000000);
	#色调参数
    $im = imagecreate(62,20);
    $black = ImageColorAllocate($im, 0,0,0);
    $white = ImageColorAllocate($im, 255,255,255);
    $gray = ImageColorAllocate($im, 200,200,200);
	#制作图形
    imagefill($im,0,0,$gray);
    while (($randval=rand()%100000)<10000);{
        $_SESSION["verifycode"] = $randval;
        imagestring($im, 5, 10, 3, $randval, $black);
    }
    #加入干扰元素
    for ($i=0;$i<200;$i++) {
        $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
        imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
    }
	#输出图片标识
    ImagePNG($im);
    #销毁图片标识
    ImageDestroy($im);
}
?>  