gif11.php3
<!--
Warning - remove everything outside of the <?php tags or
your image will break
//gif11.php3 accepts these parameters:
$c; //correlates to group_id in the database -
//unique for each site
$s; //correlates to page in the database
$b; //random number - forces the gif to load, even if cached
//generated by PHP and discarded
-->
<?
php
//database connection code
//and abstraction layer
include('database.php');
//browser detection library
include('browser.php');
$type=0; //impression
$page=$s; //move the $s param for the logger
$group_id=$c; //ditto for the $c param
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-cache");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");
Header( "Content-type: image/gif");
echo readfile ($DOCUMENT_ROOT."/util/clear.gif" );
//
// If eveything resides on the same server, just include
// the following code on every page instead of doing the 1x1 gif trick
//
$sql = "INSERT INTO activity_log "
. "(day,hour,group_id,browser,ver,platform,time,page,type) "
. "VALUES (" . date('Ymd', mktime()) . ",'" . date('H', mktime())
. "','$group_id','" . browser_get_agent() . "','" . browser_get_version()
. "','" . browser_get_platform() . "','" . time() . "','$PHP_SELF','$type');";
$res_logger = db_query ( $sql );
if (!
$res_logger) {
echo "An error occured in the logger.n";
echo db_error();
exit;
}
?>
PHP Code to generate the GIF URL:
<?php
srand
((double)microtime()*1000000);
$random_num=rand(5,95);
?>
<p>
<img src="http://www.yourserver.com/util/gif11.php3?c=4&s=phpbuildercom&b=<?
echo $random_num; ?>" height=1 width=1>
ShowResults.php:
<?php
function html_get_alt_row_color ($i) {
if ($i % 2 == 0) {
return '#FFFFFF';
} else {
return '#EEEEEE';
}
}
Function
ShowResults($result,$title="Untitled") {
/*
Very simple, plain way to show a generic result set
Accepts a result set and title
Makes certain items into HTML links
*/
if ($result) {
$rows = db_numrows($result);
$cols = db_numfields($result);
echo
'
<TABLE BORDER="0" WIDTH="100%">';
echo
'
<TR BGCOLOR="WHITE">
<TD COLSPAN="'.$cols.'"><B><FONT COLOR="BLACK">'.$title.'</B></TD></TR>';
echo
'
<tr>';
for ($i=0; $i < $cols; $i++) {
echo '<td><B>'.db_fieldname($result, $i).'</B></TD>';
}
echo '</tr>';
/* Create the rows */
for ($j = 0; $j < $rows; $j++) {
echo '<TR BGCOLOR="'. html_get_alt_row_color($j) .'">';
for ($i = 0; $i < $cols; $i++) {
echo '<td>'.db_result($result, $j, $i) . '</td>';
}
echo '</tr>';
}
echo '</table>';
} else {
echo db_error();
}
}
?>