[huskerlug] Re: Hit counter
- From: David William Eder <deder@xxxxxxxxxxx>
- To: huskerlug@xxxxxxxxxxxxx
- Date: Fri, 13 Jun 2003 17:53:51 -0500 (CDT)
Ok, some slight modifications to work with windows.
This is in PHP, so it is pretty cross platform. I've tested the
modifications, should work well on any windows box.
David.
<?
$font = "c:\\windows\\fonts\\arial.ttf";
$fontsize = 36;
// get the filename of the counter
$me = $_SERVER['SCRIPT_FILENAME'];
$magic_offset = 105544330;
// if we are given the reset command, reset the counter to 0
if(isset($_GET['reset']))
touch($me, $magic_offset);
// if we are given the set command ...
if(isset($_GET['set']))
touch($me, $_GET['set'] + $magic_offset);
// increment the count
$count = filemtime($me) + 1;
touch($me, $count);
// add comas
$count = number_format($count - $magic_offset - 1);
// calculate dimensions, etc
if(!isset($angle)) $angle = 0;
$size = ImageTTFBBox ($fontsize, $angle, $font, $count);
$dx = max($size[2], $size[4]) - min($size[0], $size[6]);
$dy = max($size[1], $size[3]) - min($size[5], $size[7]);
$img = ImageCreate($dx, $dy);
// set background and foreground colors here:
$bkgc = ImageColorAllocate($img, 255, 255, 255);
$txtc = ImageColorAllocate($img, 0, 0, 255);
// fight the evil cache...
Header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
Header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
Header('Cache-Control: no-store, no-cache, must-revalidate');
Header('Cache-Control: post-check=0, pre-check=0', false);
Header('Pragma: no-cache');
Header('ETag: '.rand(100000, 999999));
// draw it.
ImageTTFText($img, $fontsize, $angle, 0, -min($size[5], $size[7]), $txtc,
$font, $count);
Header("Content-type: image/png");
ImagePNG($img);
ImageDestroy($img);
?>
----
Husker Linux Users Group mailing list
To unsubscribe, send a message to huskerlug-request@xxxxxxxxxxxxx
with a subject of UNSUBSCRIBE
- Follow-Ups:
- [huskerlug] Re: Hit counter
- From: James Worrest
Other related posts:
- » [huskerlug] Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- » [huskerlug] Re: Hit counter
- [huskerlug] Re: Hit counter
- From: James Worrest