Zhimeng dedecms 5.7 Chinese verification code download

Source: Internet
Author: User
Tags chr imagejpeg php and

I helped the customer build a chinango.com with Zhimeng 5.7. Later, a machine registered a spam member and tried many ways to prevent the problem. Then I found a Chinese verification code from the Internet, the running time is not correct. I can run it after modification, and the spam members are obviously fewer. Now I will share it with you.

Put the vdimgck. php and simhei. ttf files in/include. The source code of the vdimgck. php file is as follows:

The code is as follows: Copy code

<? Php
/**
* Verify the image
* Online files are modified by a Liang
* 834114969@qq.com
* Http://liuzhiliang.com/
*/
Require_once (dirname (_ FILE _). "/common. inc. php ");
// Session save path
$ SessSavePath = DEDEDATA. "/sessions /";

If (is_writeable ($ sessSavePath) & is_readable ($ sessSavePath) {session_save_path ($ sessSavePath );}
If (! Empty ($ pai_domain_cookie) session_set_cookie_params (0, '/', $ pai_domain_cookie );

Session_start ();

// Obtain random characters
$ Rndstring = '';
// $ Ch_h = chr (substr ($ num, 160) + );
// $ Ch_l = chr (substr ($ num, 160) + );
Function c2ch ($ num ){
$ Ch_h = chr (substr ($ num, 160) + );
$ Ch_l = chr (substr ($ num, 160) + );
Return $ ch_h. $ ch_l;
}
Function num_rand (){
Mt_srand (double) microtime () * 1000000 );
$ D = mt_rand (16, 36 );
$ N = mt_rand (1, 19 );
Return c2ch ($ d * 100 + $ n );
}

For ($ I = 0; $ I <4; $ I ++) $ rndstring. = gb2utf8 (num_rand ());
// If GD is supported, draw
If (function_exists ("imagecreate "))
{
// In some cases in Firefox, there will be multiple requests, and refreshing the page within 5 seconds will not change the session
$ Ntime = time ();
If (empty ($ _ SESSION ['securimage _ code_value_last ']) | empty ($ _ SESSION ['securimage _ code_value']) | ($ ntime-$ _ SESSION ['securimage _ code_value_last ']> 1 ))
    {
$ _ SESSION ['securimage _ code_value '] = strtolower ($ rndstring );
$ _ SESSION ['securimage _ code_value_last '] = $ ntime;
    }
$ Rndstring = $ _ SESSION ['securimage _ code_value '];
// Create an image and set the background color
$ X_size = 80;
$ Y_size = 25;
$ Font = 'simhei. Ttf ';
$ Im = imagecreate ($ x_size, $ y_size );
$ Background_color = imagecolorallocate ($ instant, 255,255,255 );

// Random color
$ FontColor [] = imagecolorallocate ($ im, 0x15, 0x15, 0x15 );
$ FontColor [] = imagecolorallocate ($ im, 0x95, 0x1e, 0x04 );
$ FontColor [] = imagecolorallocate ($ im, 0x93, 0x14, 0xa9 );
$ FontColor [] = imagecolorallocate ($ im, 0x12, 0x81, 0x0a );
$ FontColor [] = imagecolorallocate ($ im, 0x06, 0x3a, 0xd5 );
$ C_fontColor = $ fontColor [mt_rand (0, 4)];

Imagettftext ($ im, 15, mt_rand (-), 6, mt_rand (), $ c_fontColor, $ font, substr ($ rndstring ));
Imagettftext ($ im, 15, mt_rand (-8), 37,20, $ c_fontColor, $ font, substr ($ rndstring, 6, 3 ));
Imagettftext ($ im, mt_rand (15, 17), mt_rand (-8), $ c_fontColor, $ font, substr ($ rndstring, 3, 3 ));
Imagettftext ($ im, mt_rand (15,17), mt_rand (-8), 54, mt_rand (19,22), $ c_fontColor, $ font, substr ($ rndstring, 9,3 ));
Imagerectangle ($ im, 0, 0, $ x_size-1, $ y_size-1, $ black );

Header ("Pragma: no-cachern ");
Header ("Cache-Control: no-cachern ");
Header ("Expires: 0rn ");

// Output a specific image format with a priority of gif-> jpg-> png
If (function_exists ("imagejpeg "))
    {
Header ("content-type: image/policrn ");
Imagejpeg ($ im );
    }
Else
    {
Header ("content-type: image/pngrn ");
Imagepng ($ im );
    }
ImageDestroy ($ im );
Exit ();
}
Else
{
// GD is not supported. Only the English letter ABCD is output.
$ _ SESSION ['securimage _ code_value '] = "abcd ";
$ _ SESSION ['securimage _ code_value_last '] = '';
Header ("content-type: image/policrn ");
Header ("Pragma: no-cachern ");
Header ("Cache-Control: no-cachern ");
Header ("Expires: 0rn ");
$ Fp = fopen ("data/vdcode.jpg", "r ");
Echo fread ($ fp, filesize ("data/vdcode.jpg "));
Fclose ($ fp );
Exit ();
}

?>

Complete Chinese verification code download address: http://file.111cn.net/download/2013/06/25/vdimgck.zip

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.