code contd..
$dom = $_SERVER['HTTP_HOST'];
$allDoms = false;
if(strlen($_GET['dom']) > 1)
$dom = $_GET['dom'];
if($_GET['dom'] == '*')
$allDoms = true;
$intprot = $_SERVER['HTTP_USER_AGENT'];
while($row = mysql_fetch_array($query)){
//get all sites stats
$total ++;
$used = 0;
if($row['cloak'] == 1){
$totalSpiders ++;
$used = 1;
}
if($row['cloak'] == 2){
$totalRedirects ++;
$used = 2;
}
if($row['cloak'] == 3){
$totalBlanks ++;
$used = 3;
}
if(stristr($row['useragent'], "Xenu") || $row['ip'] == '71.201.6.81' || $row['ip'] == $intprot){
if($used == 1)
$totalSpiders --; else if($used == 2)
$totalRedirects --; else if($used = 3)
$totalBlanks --;
$total --;
}
if($used != 1){
if(stristr($row['useragent'], "MSIE"))
$totalIE ++; else if(stristr($row['useragent'], "Mozilla") && stristr($row['useragent'], "Gec"))
$totalFF ++; else
$totalOther ++;
}
if($_REQUEST['parse'] == 1){ // print and calculate stats for parsed page
if($row['domain'] == $dom || $allDoms){
$early = mktime($_GET['hour'], $_GET['minute'], 0, $_GET['month'], $_GET['day'], $_GET['year']);
$late = mktime($_GET['hour2'], $_GET['minute2'], 0, $_GET['month2'], $_GET['day2'], $_GET['year2']);
if($late >= strtotime($row['datetime']) && $early <= strtotime($row['datetime'])){
$siteTotal ++;
$color = "";
$used = 0;
if($row['cloak'] == 1){
$color = " bgcolor=#AEF9B0";
$spiders ++;
$used = 1;
}
if($row['cloak'] == 2){
$color = " bgcolor=#EF9E9C";
$redirects ++;
$used = 2;
}
if($row['cloak'] == 3){
$color = " bgcolor=#BCDBDC";
$blanks ++;
$used = 3;
}
if($used != 1){
if(stristr($row['useragent'], "MSIE"))
$IE ++; else if(stristr($row['useragent'], "Mozilla") && stristr($row['useragent'], "Gec"))
$FF ++; else
$Other ++;
}
$check = mysql_query("SELECT * FROM `tbl_users` WHERE ip='$intprot'") or die(mysql_error());
if(stristr($row['ref'], "cache") || mysql_num_rows($check) > 3 || stristr($row['ref'], "site:")){
$color = " bgcolor=#FF1A1A";
$alarms ++;
}
if(stristr($row['useragent'], "Xenu") || $row['ip'] == '71.201.6.81' || $row['ip'] == $intprot){
$color = " bgcolor=#CCCCCC";
if($used == 1)
$spiders --; else if($used == 2)
$redirects --; else if($used = 3)
$blanks --;
}
if($_GET['norows'] != 1){ //no rows displayed
echo "<tr" . $color . ">";
echo "<td>", $row['id'], " </td><td>", $row['domain'], " </td><td>", $row['cloak'], " </td><td>", $row['useragent'], " </td><td>", $row['ref'], " </td><td>", $row['page'], " </td><td>", $row['ip'], " </td><td>", $row['datetime'], " </td>";
echo "</tr>";
}
}
}
} else if(! isset($_GET['parse']))// print and calculate stats for non parsed page
{
if($row['domain'] == $dom){
$siteTotal ++;
$color = "";
$used = 0;
if($row['cloak'] == 1){
$color = " bgcolor=#AEF9B0";
$spiders ++;
$used = 1;
}
if($row['cloak'] == 2){
$color = " bgcolor=#EF9E9C";
$redirects ++;
$used = 2;
}
if($row['cloak'] == 3){
$color = " bgcolor=#BCDBDC";
$blanks ++;
$used = 3;
}
if($used != 1){
if(stristr($row['useragent'], "MSIE"))
$IE ++; else if(stristr($row['useragent'], "Mozilla") && stristr($row['useragent'], "Gec"))
$FF ++; else
$Other ++;
}
$check = mysql_query("SELECT * FROM `tbl_users` WHERE ip='$intprot'") or die(mysql_error());
if(stristr($row['ref'], "cache") || mysql_num_rows($check) > 3){
$color = " bgcolor=#FF1A1A";
$alarms ++;
}
if(stristr($row['useragent'], "Xenu") || $row['ip'] == '71.201.6.81' || $row['ip'] == $intprot){
$color = " bgcolor=#CCCCCC";
if($used == 1)
$spiders --; else if($used == 2)
$redirects --; else if($used = 3)
$blanks --;
}
if($_GET['norows'] != 1){ //no rows displayed
echo "<tr" . $color . ">";
echo "<td>", $row['id'], " </td><td>", $row['domain'], " </td><td>", $row['cloak'], " </td><td>", $row['useragent'], " </td><td>", $row['ref'], " </td><td>", $row['page'], " </td><td>", $row['ip'], " </td><td>", $row['datetime'], " </td>";
echo "</tr>";
}
}
}
}
$endTime = microtime();
echo "</table><br /><br />";
echo "<span align=center>";
echo ('<table width="300" border="1" align="center">
<tr>
<td>
<b><u>This Site</u></b><br /><br />
Site total: <b>' . $siteTotal . '</b><br>
Spider visits: <b>' . $spiders . '</b><br>
Redirect visits: <b>' . $redirects . '</b><br>
404 visits: <b>' . $blanks . '</b><br>
Alarms: <b>' . $alarms . '</b><br>
<br>
MSIE Users: <b>' . $IE . ' (' . round(($IE / ($IE + $FF + $Other)) * 100, 2) . '%)</b><br>
Mozilla Users: <b>' . $FF . ' (' . round(($FF / ($IE + $FF + $Other)) * 100, 2) . '%)</b><br>
Other Users: <b>' . $Other . ' (' . round(($Other / ($IE + $FF + $Other)) * 100, 2) . '%)</b><br>
</td>
</tr>
<tr>
<td>
<b><u>All Sites</u></b><br /><br />
All sites total: <b>' . $total . '</b><br>
All Spider visits: <b>' . $totalSpiders . '</b><br>
All Redirect visits: <b>' . $totalRedirects . '</b><br>
All 404 visits: <b>' . $totalBlanks . '</b><br>
All Alarms: <b>' . $totalAlarms . '</b><br>
<br>
MSIE Users: <b>' . $totalIE . ' (' . round(($totalIE / ($totalIE + $totalFF + $totalOther)) * 100, 2) . '%)</b><br>
Mozilla Users: <b>' . $totalFF . ' (' . round(($totalFF / ($totalIE + $totalFF + $totalOther)) * 100, 2) . '%)</b><br>
Other Users: <b>' . $totalOther . ' (' . round(($totalOther / ($totalIE + $totalFF + $totalOther)) * 100, 2) . '%)</b><br>
</td>
</tr>
<tr>
<td>
<b><u>More</u></b><br /><br />
Execution Time: <b>' . ($startTime-$endTime) . ' sec</b><br>
</td>
</tr>
</table>');
echo "</span><br><br><br><br><br><br>";
?>
<a name="link"
href="<?
echo ($_SERVER['PHP_SELF']);
if(strlen($_SERVER['QUERY_STRING']) > 1)
echo ("?" . $_SERVER['QUERY_STRING']);
?>#top">Top</a>
| <a href="<?
echo ($_SERVER['PHP_SELF']);
?>?parse=0">Date</a> | <a
href="<?
echo ($_SERVER['PHP_SELF']);
?>">Main</a></p>