Php reads the phone number in the database and generates an image.
Source: Internet
Author: User
The function of this PHP program is to read the mobile phone number or other data from the database and generate images, which can interfere with the collection and prevention function. (English or numbers. if you want to support Chinese characters, you need to add a font ). This code is original code. The following code is used:
The code is as follows:
$ Id = $ _ GET [id];
Include ("admin/config. php ");
$ SQL = "select * from user where id = $ id ";
$ Data = mysql_fetch_array (mysql_query ($ SQL ));
$ P = SBC_DBC ($ data [Phone], 1 );
Function get_str ($ str, $ strlen = 16 ){
$ Str = stripslashes ($ str );
For ($ I = 0; $ I <$ strlen; $ I ++)
If (ord (substr ($ str, $ I, 1)> 0xa0) $ j ++;
If ($ j % 2! = 0) $ strlen ++;
$ Tmp_str = substr ($ str, 0, $ strlen );
Return $ tmp_str;
}
If ($ p <> ''){
// Generate a 5-digit digital image
Header ("Content-type: image/png"); // tell the browser that the following data is an image instead of text
// Define the image width and height
$ Nwidth = 120;
$ Nheight = 25;
$ Im = @ imagecreate ($ nwidth, $ nheight) or die ("Can't initialize new GD image stream"); // create an image
// Set the image color
$ Background_color = imagecolorallocate ($ im, 255,255,255); // match the color
$ Text_color = imagecolorallocate ($ im, 23, 14, 91 );
// Srand (double) microtime () * 1000000); // obtain the value of one second in the current time to one second in the execution time.
// $ Randval = rand ();
$ Randval = $ p; // 5-digit
Imagestring ($ im, 8, 10, 2, $ randval, $ text_color); // draw a horizontal string
// Add interference factors
// For ($ I = 0; $ I <478; $ I ++)
//{
// $ Randcolor = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
// Imagesetpixel ($ im, rand () % 100, rand () % 30, $ randcolor); // point
/
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.