create() 공개 정적인 메소드

Instantiation
public static create ( $phrase = null )
예제 #1
0
파일: home.php 프로젝트: s137740/lg
 function validate_code()
 {
     $this->load->library("ValidateCode");
     $_vc = new ValidateCode();
     $_vc->create();
 }
예제 #2
0
        for ($i = 0; $i < $this->lenght; $i++) {
            $color = imagecolorallocate($this->img, mt_rand(10, 100), mt_rand(10, 100), mt_rand(10, 100));
            imagettftext($this->img, $this->fontSize, mt_rand(-40, 40), $x * $i + mt_rand(0, 5), $y, $color, $this->fontfile, $this->code[$i]);
        }
    }
    /**
     * [outPut 向浏览器输出png]
     * @return [image] [输出图片]
     */
    private function outPut()
    {
        header('Content-type:image/png');
        imagepng($this->img);
        imagedestroy($this->img);
    }
    /**
     * [create 生成]
     * @return [type] [description]
     */
    public function create()
    {
        $this->createBg();
        $this->createCode();
        $this->createMix();
        $this->createText();
        $this->outPut();
    }
}
$code = new ValidateCode();
$code->create();
예제 #3
0
        for ($i = 0; $i < $strLength; $i++) {
            $this->str .= substr($dictionary, mt_rand(0, strlen($dictionary) - 1), 1);
        }
    }
    public function create()
    {
        $this->handle = imagecreate($this->width, $this->height);
        $backGroudColor = imagecolorallocate($this->handle, 255, 255, 255);
        imagefill($this->handle, 0, 0, $backGroudColor);
        $strColor = imagecolorallocate($this->handle, 0, 0, 0);
        imagestring($this->handle, 30, 10, 0, $this->str, $strColor);
        $this->interferce();
        header("Content-Type:image/png");
        imagepng($this->handle);
    }
    private function interferce()
    {
        for ($i = 0; $i < 3; $i++) {
            $lineColor = imagecolorallocate($this->handle, rand(0, 255), rand(0, 255), rand(0, 255));
            imageline($this->handle, rand(0, 80), rand(0, 20), rand(0, 80), rand(0, 20), $lineColor);
        }
        for ($i = 0; $i < 100; $i++) {
            $pxColor = imagecolorallocate($this->handle, rand(0, 255), rand(0, 255), rand(0, 255));
            imagesetpixel($this->handle, rand(0, 80), rand(0, 20), $pxColor);
        }
    }
}
$validateCode = new ValidateCode();
$_SESSION['code'] = $validateCode->str;
$validateCode->create();