Dynamic display signature and IP principle _php techniques in PHP

Source: Internet
Author: User
<?php
Contains a counter, a reminder statement, User IP, and their own advertising picture.
Send a header to the browser and say I'm a picture
Header ("Content-type:image/png");
This defines the counter and puts 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];
}
Counter End
Start creating a picture definition color font, etc.
$im = Imagecreate (400,100);
$black = Imagecolorallocate ($im, 0,0,0);
$white = Imagecolorallocate ($im, 255,255,255);
$red = Imagecolorallocate ($im, 255,0,0);
$blue = Imagecolorallocate ($im, 0,0,255);
$font = 5;
$maginx = 20;
$maginy = 20;
Define IP and host names, of course, the client's
$ip = getenv (' remote_addr ');
$host = gethostbyaddr ($IP);
$today = getdate ();
$wday = $today [' wday '];
Reminder clips, weekend is not good weekend is to remind the class
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 an image background border
Imagefill ($im, 0,0, $black);
Imagefilledrectangle ($im, 1, 1, 398, $white);
Defining brushes
$style = Array ($white, $white, $white, $white, $white, $white, $white, $white);
Imagesetstyle ($im, $style);
A motion effect is brushed with a brush, which is equivalent to the brush tool in Photoshop
Ads is my own advertising map.
$brush = Imagecreatefrompng ("Yun_qi_img/smile1.png");
$brush 1 = imagecreatefrompng ("Yun_qi_img/ads.png");
$w 2 = imagecolorallocate ($brush, 255,255,255);
Imagecolortransparent ($brush, $w 2);
Imagesetbrush ($im, $brush);
Imageline ($im, 350,20,360,20, img_color_styledbrushed);
Imagecopy ($im, $brush 1, 270, 40, 0, 0, 119, 48);

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

End of picture inevitable statement
Imagepng ($im);
Imagedestroy ($im);
?>

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.