Location: PHPKode > scripts > Visitor Logger > home.txt
<h1>Home</h1>

<?php
if ($_POST['home'] == 7) { $VL_days['msg'] = "Results for the last 7 days"; $VL_days['val'] = 7; }
elseif ($_POST['home'] == 30) { $VL_days['msg'] = "Results for the last 30 days"; $VL_days['val'] = 30; }
elseif ($_POST['home'] == 365) { $VL_days['msg'] = "Results for the last 365 days"; $VL_days['val'] = 365; }
else { $VL_days['msg'] = "Results for today and yesterday"; $VL_days['val'] = 1; }

echo "<form method=\"post\" action=\"".$VL_self."\">";
echo "<select name=\"home\" onChange=\"this.form.submit()\">";
echo "<OPTION value=".$VL_days['val']." selected>".$VL_days['msg']."</OPTION>";
if ($VL_days['val'] != 1) echo "<OPTION value=\"1\">Results for today and yesterday</OPTION>";
if ($VL_days['val'] != 7) echo "<OPTION value=\"7\">Results for the last 7 days</OPTION>";
if ($VL_days['val'] != 30) echo "<OPTION value=\"30\">Results for the last 30 days</OPTION>";
if ($VL_days['val'] != 365) echo "<OPTION value=\"365\">Results for the last 365 days</OPTION>";
echo "</select><noscript><input type=\"submit\" value=\"Update\"></noscript></form>";

$VL_nowdate = getdate();
$VL_nowyear = $VL_nowdate['year'];
$VL_nowmonth = $VL_nowdate['mon'];
$VL_nowday = $VL_nowdate['mday'];

$VL_time = time();
$VL_time = $VL_time - ($VL_days['val'] * 86400);
$VL_thendate = getdate($VL_time);
$VL_thenyear = $VL_thendate['year'];
$VL_thenmonth = $VL_thendate['mon'];
$VL_thenday = $VL_thendate['mday'];

$VL_now = $VL_nowyear."-".$VL_nowmonth."-".$VL_nowday;
$VL_then = $VL_thenyear."-".$VL_thenmonth."-".$VL_thenday;

$VL_query = "select ip,host,browser,flag,referer,lang,time,date from ".$VL_table." where date between '".$VL_then."' and '".$VL_now."' order by id desc";
$VL_result = mysql_query($VL_query,$VL_conn);

$VL_bgcolour = "white";
?>
&nbsp;
<table align=center width=100% border=0 bgcolor=#0000c2 style="font-size: 12px; color: white">
<tr>
<th align=center>IP Address</th>
<th align=center>Host</th>
<th align=center>Browser</th>
<th align=center>Flag</th>
<th align=center>Referer</th>
<th align=center>Ban</th>
<th align=center>Lang</th>
<th align=center>Time</th>
<th align=center>Date</th>
<th align=center>Hits</th>
<th align=center>Info</th>
</tr>
<font color=black>
<?php

while ($VL_row = mysql_fetch_array($VL_result, MYSQL_ASSOC)) {

	if (stristr($VL_row['browser'], 'Bot') === FALSE) {

		$VL_ip_loop = $VL_row['ip'];
		if ($VL_ip[$VL_ip_loop]) $VL_ip[$VL_ip_loop] ++; else $VL_ip[$VL_ip_loop] = 1;

		if ($VL_ip[$VL_ip_loop] == 1) {

			$VL_content[$VL_ip_loop].= "<tr bgcolor=\"".$VL_bgcolour."\" style=\"color: black\">";
			if ($VL_bgcolour == "white") $VL_bgcolour = "#e0ecff"; else $VL_bgcolour = "white";

			foreach ($VL_row as $VL_key => $VL_value) {
				if ($VL_key == "lang") {
					if (file_exists("banned.txt")) {
						include("banned.txt");
							foreach ($VL_banned as $VL_banned_value) {
								if ($VL_row['ip'] == $VL_banned_value) {
									$VL_banned_ip = "TRUE";
									break;
								}
							}
					}
					if ($VL_banned_ip == "TRUE") {
						$VL_content[$VL_ip_loop].= "<td align=center>Banned</td>";
						unset($VL_banned_ip);
					}
					else $VL_content[$VL_ip_loop].= "<form method=\"post\" action=\"".$VL_self."\"><input name=\"ban\" type=\"hidden\" value=\"".$VL_row['ip']."\"><td align=center><input type=\"submit\" value=\"Go\" Title=\"Block IP address ".$VL_row['ip']."\"></td></form>";
				}

				$VL_content[$VL_ip_loop].= "<td align=center>".$VL_value."</td>";
			}

			$VL_content[$VL_ip_loop].= "<td>*****</td>";
			$VL_content[$VL_ip_loop].= "<form method=\"post\" action=\"".$VL_self."\"><input name=\"ip\" type=\"hidden\" value=\"".$VL_row['ip']."\"><td align=center><input type=\"submit\" value=\"Go\" Title=\"See the table for IP address ".$VL_row['ip']."\"></td></form>";
			$VL_content[$VL_ip_loop].= "</tr>";
		}	
	}
}

echo ("<font color=black>");

if ($VL_content) {	
	foreach ($VL_content as $VL_content_key => $VL_content_value) {
		$VL_content_value=str_ireplace("*****", $VL_ip[$VL_content_key], $VL_content_value);
		echo $VL_content_value;
	}
}

?>

</table>
Return current item: Visitor Logger