Use PHP to implement the login verification code (similar to a line code)

Source: Internet
Author: User
Use PHP to implement the login verification code (similar to a line code), read the login verification code using PHP (similar to a line code ),? PhpfunctionUPCAbarcode ($ code) {$ lw = 2; $ hi = 100; $ Lencode = array ("> <LINKhref =" http://www.php100.com//statics/s

Function UPCAbarcode ($ code ){
$ Lw = 2; $ hi = 100;
$ Lencode = array ('20140901', '20160901', '20160901', '20160301', '20160301 ',
'123', '123', '123', '123', '123 ');
$ Rencode = array ('20140901', '20160901', '20160901', '20160301', '20160301 ',
'123', '123', '123', '123', '123 ');
$ Ends = '20180101'; $ center = '20180101 ';
/* UPC-A Must be 11 digits, we compute the checksum .*/
If (strlen ($ code )! = 11) {die ("UPC-A Must be 11 digits .");}
/* Compute the EAN-13 Checksum digit */
$ Ncode = '0'. $ code;
$ Even = 0; $ odd = 0;
For ($ x = 0; $ x <12; $ x ++ ){
If ($ x % 2) {$ odd + = $ ncode [$ x];} else {$ even + = $ ncode [$ x];}
}
$ Code. = (10-($ odd * 3 + $ even) % 10) % 10;
/* Create the bar encoding using a binary string */
$ Bars = $ ends;
$ Bars. = $ Lencode [$ code [0];
For ($ x = 1; $ x <6; $ x ++ ){
$ Bars. = $ Lencode [$ code [$ x];
}
$ Bars. = $ center;
For ($ x = 6; $ x <12; $ x ++ ){
$ Bars. = $ Rencode [$ code [$ x];
}
$ Bars. = $ ends;
/* Generate the Barcode Image */
$ Img = ImageCreate ($ lw * 95 + 30, $ hi + 30 );
$ Fg = ImageColorAllocate ($ img, 0, 0, 0 );
$ Bg = ImageColorAllocate ($ img, 255,255,255 );
ImageFilledRectangle ($ img, 0, 0, $ lw * 95 + 30, $ hi + 30, $ bg );
$ Shift = 10;
For ($ x = 0; $ x If ($ x <10) | ($ x >=45 & $ x <50) | ($ x >=85) {$ sh = 10 ;} else {$ sh = 0 ;}
If ($ bars [$ x] = '1') {$ color = $ fg;} else {$ color = $ bg ;}
ImageFilledRectangle ($ img, ($ x * $ lw) + 15, 5, ($ x + 1) * $ lw + 14, $ hi + 5 + $ sh, $ color );
}
/* Add the Human Readable Label */
ImageString ($ img, 4,5, $ hi-5, $ code [0], $ fg );
For ($ x = 0; $ x <5; $ x ++ ){
ImageString ($ img, 5, $ lw * (13 + $ x * 6) + 15, $ hi + 5, $ code [$ x + 1], $ fg );
ImageString ($ img, 5, $ lw * (53 + $ x * 6) + 15, $ hi + 5, $ code [$ x + 6], $ fg );
}
ImageString ($ img, 4, $ lw * 95 + 17, $ hi-5, $ code [11], $ fg );
/* Output the Header and Content .*/
Header ("Content-Type: image/png ");
ImagePNG ($ img );
}

UPCAbarcode ('20140901 ');

?>

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.