<?PHP
if (! stristr ($_SERVER["HTTP_USER_AGENT"], "active"))
{
die ("ActiveWorlds Browsers only !");
}
header("Status: 404 Not Found");
$Context = './'.urlencode($HTTP_GET_VARS['context']).'.cnt';
for ($i=0; $i<5; $i++)
{
$fp = fopen ($Context, "r+");
if (! $fp)
{
sleep(1);
continue;
}
if (! flock($fp, LOCK_EX))
{
fclose ($fp);
sleep(1);
continue;
}
$num = fgets ($fp);
$num = $num + 1;
fseek ($fp, 0, SEEK_SET);
fwrite ($fp, $num);
flock($fp, LOCK_UN);
fclose ($fp);
exit;
}
?>
<?PHP
$Context = './'.urlencode($HTTP_GET_VARS['context']).'.cnt';
$num = '?';
for ($i=0; $i<5; $i++)
{
$fp = fopen ($Context, "r");
if (! $fp)
{
sleep(1);
continue;
}
if (! flock($fp, LOCK_SH))
{
fclose ($fp);
sleep(1);
continue;
}
$num = fgets ($fp);
flock($fp, LOCK_UN);
fclose ($fp);
break;
}
Header ("Content-type: image/jpeg");
$im = ImageCreate (64, 32);
$cBack = MyImageColor ($im, 0x00, 0x00, 0x00, $HTTP_GET_VARS["bc"]);
$cGreen = MyImageColor ($im, 0x00, 0xff, 0x00, $HTTP_GET_VARS["tc"]);
while ( ($l= strlen($num)) < 5)
switch ($l)
{
case 1 :
case 3 :
$num = ' '.$num;
break;
default :
$num .= ' ';
break;
}
ImageString ($im, 5, 8, 8, $num, $cGreen);
ImageJPEG ($im, "",100);
ImageDestroy ($im);
function MyImageColor ($im, $r, $g, $b, $hex="")
{
if (!empty ($hex))
{
$r = hexdec (substr ($hex, 0, 2));
$g = hexdec (substr ($hex, 2, 2));
$b = hexdec (substr ($hex, 4, 2));
}
ImageColorAllocate ($im, $r, $g, $b);
return (ImageColorClosest ($im, $r, $g, $b));
}
?>