I have been trying to make a script which will allow me to have a random/rotating sig with matching avatar on a forum I frequent, with mixed success. I have managed to make one based around cookies but that unfortunately is stopped from working by Firefox's (and presumably other browsers') tools to stop tracking cookies. My solution to this has been to have the sig and avatar use the time to coordinate, resulting in this script:
Code: Select all
<?
$f[] = "http://www.mywebhost.com/sig1.gif";
$f[] = "http://www.mywebhost.com/sig2.gif";
$f[] = "http://www.mywebhost.com/sig3.gif";
$currdate=getdate();
$currhours=$currdate["hours"];
$currsigs=count($f);
$fnum=$currhours%$currsigs;
$file=$f[$fnum];
$imageInfo = pathinfo($_GET['file']);
$contentType = 'Content-type: '.$imageInfo['extension'];
header ($contentType);
header("Pragma: no-cache");
header("Expires: Sun, 18 May 1980 16:32:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
readfile( $file );
?>
This works perfectly as a .php file on my server. My problem is this: the forum I want to use it on doesn't allow the php extension inside the (IMG) tags so I need the script to run from a file with an image extension (I've chosen .png). My host allows .htaccess use, so this is what is inside .htaccess:
Code: Select all
AddHandler application/x-httpd-php .png
Just to be clear,
this definitely works on my server. In fact, the one I made using cookies ran from a png file in the same directory with almost the exact same code. These are the only lines NOT in my previously working code:
Code: Select all
$currdate=getdate();
$currhours=$currdate["hours"];
$currsigs=count($f);
$fnum=$currhours%$currsigs;
$file=$f[$fnum];
My problem is that my host is not parsing this file, and I must conclude it is due somehow to these lines. My host is using PHP 4.4.2 and Apache 1.3.34 (Unix). Any help you could give me to get this working would be great