Contains a counter, a reminder statement, a user IP, and an ad image of his own.
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 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);
$f
$maginx = 20;
$maginy = 20;
Defines the IP and hostname, of course, the client's
$ip = getenv (' remote_addr ');
$host = gethostbyaddr ($IP);
$today = getdate ();
$wday = $today [' wday '];
Reminder pieces, weekends and weekends remind classes
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, 98, $white);
Defining brushes
$style = Array ($white, $white, $white, $white, $white, $white, $white, $white, $white, $red);
Imagesetstyle ($im, $style);
There's a sporty effect that's brushed with a brush, which is equivalent to the brush tool in Photoshop
ADS is my own ad map.
$brush = Imagecreatefrompng ("Http://172.24.16.80/testpic/smile1.png");
$brush 1 = imagecreatefrompng ("Http://172.24.16.80/testpic/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);
The end of the picture inevitable statement
Imagepng ($im);
Imagedestroy ($im);
?>
The above describes the Nvidia Control Panel does not show the PHP dynamic display signature and IP principle, including the Nvidia Control Panel does not display aspects of the content, I hope to be interested in PHP tutorial friends helpful.