PHP Generate verification Code second bomb, strong attack

Source: Internet
Author: User
function Getverify ()
{

Session_Start ();
Ob_clean (); Clear Buffer
Header ("Content-type:image/png");

$img _width=40;
$img _height=20;

Srand (Microtime () *100000);
for ($i =0; $i <4; $i + +)
{
$new _number.=dechex (rand (0,15));
}

$_session[check_auth]= $new _number;
$new _number=imagecreate ($img _width, $img _height);//Create an image
Imagecolorallocate ($new _number,255,255,255); Set the background color to white

for ($i =0; $i <>
{
$font =mt_rand (3,5);
$x =mt_rand + $img _width* $i/4;
$y =mt_rand (1, $img _HEIGHT/4);
$color =imagecolorallocate ($new _number,mt_rand (0,100), Mt_rand (0,150), Mt_rand (0,200));//Set character color
Imagestring ($new _number, $font, $x, $y, $_session[check_auth][$i], $color);//Output character
}
Save verification Code in $_session
$_session["verify"]=$_session[check_auth];

Imagepng ($new _number);
Imagedestroy ($new _number);

}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.