How to dynamically display signatures and ip addresses in PHP _ PHP Tutorial

Source: Internet
Author: User
The principles of signature and ip are dynamically displayed in PHP .? Php contains a counter, a reminder statement, user ip address, and advertisement images. Send a Header to the browser, indicating that I am an image Header (Content-type: imagePNG). It is defined here. // Contains a counter, a reminder statement, user ip address, and advertisement image.
// Send a header to the browser, indicating that I am an image
Header ("Content-type: image/PNG ");
// Define the counter here and put it in a file
$ Visited = array ();
If (! File_exists ("Counter "))
{
For ($ I = 0; $ I <24; $ I ++)
$ Visited [$ I] = 0;
$ Str = $ Visited [0];
For ($ I = 1; $ I <24; $ I ++)
$ Str. = ", $ Visited [$ I]";
$ Fp = fopen ("Counter", "w ");
Fputs ($ fp, $ str );
Fclose ($ fp );
}
Else
{
$ Fp = fopen ("Counter", "r ");
$ Str = trim (fgets ($ fp, 100 ));
$ Visited = explode (",", $ str );
Fclose ($ fp );
}
$ Visited [date ("G")] = intval ($ Visited [date ("G")]) + 1;
$ Str = $ Visited [0];
$ Max = intval ($ Visited [0]);
For ($ I = 1; $ I <24; $ I ++)
{
$ Str. = ", $ Visited [$ I]";
If ($ max <= intval ($ Visited [$ I])
$ Max = intval ($ Visited [$ I]);
}
$ Fp = fopen ("Counter", "w ");
Fputs ($ fp, $ str );
Fclose ($ fp );
$ Sum = 0;
For ($ I = 0; $ I <24; $ I ++)
{
$ Sum + = $ Visited [$ I];
}
// The Counter ends.
// Start creating the image definition color font.
$ Im = imagecreate (400,100 );
$ Black = ImageColorAllocate ($ im, 0, 0 );
$ White = ImageColorAllocate ($ im, 255,255,255 );
$ Red = ImageColorAllocate ($ im, 255, 0, 0 );
$ Blue = ImageColorAllocate ($ im, 255 );
$ Font = 5;
$ Magento = 20;
$ Maginy = 20;
// Define the ip address and host name, of course, of the client
$ Ip = getenv ('remote _ ADDR ');
$ Host = gethostbyaddr ($ ip );
$ Today = getdate ();
$ Wday = $ today ['wday'];
// Reminder piece. if it is a weekend or a weekend, the class will be reminded.
If ($ wday = 6 | $ wday = 0 ){
$ Tips = "enjoy the wonderful weekend! ";
} Else {
$ Tips = "you 'd better go to school .";
}
If ($ wday = 1 ){
$ Wday = "Monday ";
} Elseif ($ wday = 2 ){
$ Wday = "Tuesday ";
} Elseif ($ wday = 3 ){
$ Wday = "Wednsday ";
} Elseif ($ wday = 4 ){
$ Wday = "Thursday ";
} Elseif ($ wday = 5 ){
$ Wday = "Friday ";
} Elseif ($ wday = 6 ){
$ Wday = "Saturday ";
} Elseif ($ wday = 0 ){
$ Wday = "Sunday ";
}
// Start creating the image background border
Imagefill ($ im, 0, 0, $ black );
Imagefilledrectangle ($ im, 1, 1,398, 98, $ white );
// Define the paint brush
$ Style = array ($ white, $ red );
Imagesetstyle ($ im, $ style );
// If you have a motion effect, you can use a brush to brush it. this is equivalent to the paint tool in photoshop.
// Ads is my own advertisement diagram
$ Brush = imagecreatefrompng ("http: // 172.24.16.80/testpic/smile1.png ");
$ Brush1 = imagecreatefrompng ("http: // 172.24.16.80/testpic/ads.png ");
$ W2 = imagecolorallocate ($ brushes, 255,255,255 );
Imagecolortransparent ($ brush, $ w2 );
Imagesetbrush ($ im, $ brush );
Imageline ($ im, 36, IMG_COLOR_STYLEDBRUSHED );
Imagecopy ($ im, $ brush1, 270, 40, 0, 0,119, 48 );

// Define output text
Imagestring ($ im, $ font, $ Magento, $ maginy + 20, "Your computer's named: {$ host}", $ red );
Imagestring ($ im, $ font, $ Magento, $ maginy, "Your IP Address is: {$ ip}", $ red );
Imagestring ($ im, 2, 2, "Today is {$ wday} and {$ tips}", $ blue );
Imagestring ($ im, 3,10, $ maginy + 40, "TotalRefreshTimesFromToday: $ sum", $ blue );

// Inevitable statement at the end of the image
ImagePNG ($ im );
ImageDestroy ($ im );
?>

Http://www.bkjia.com/PHPjc/318244.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318244.htmlTechArticle? Php // contains a counter, a reminder statement, user ip address, and advertisement image. // Send a Header to the browser, indicating that I am an image Header ("Content-type: image/PNG"); // This is defined here...

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.