Location: PHPKode > projects > logViewSQL > apache/apache.php
<?php
/* 
 * This is a php frontend for mod_log_sql. It interfaces
 * with the table structure as defined in a MySql database and has been
 * tested only with version 1.16 of mod_log_sql.
 *
 * contact hide@address.com
 *
 */  
    require('db-connect-apache.php');
    require('apache-common.php');


    if($vh){
	    $doHost = " and virtual_host='".$vh."'";
    } else {
	    $doHost = "";
    }
    if($filter==1){
	$addFilter="where ".$filterType."!='".mysql_escape_string(base64_decode($filterValue))."'";
    } else {$addFilter = "";}

    if($addFilter){
    	$query = "select *  from ".mysql_Escape_string($dbs)." ".$addFilter.sensibleFilter(2).$doHost.customFilter(1)." order by time_stamp desc ";
    } else{
    	$query = "select *  from ".mysql_Escape_string($dbs)." ".sensibleFilter(1).$doHost.customFilter(1)." order by time_stamp desc ";
    }
    // Do the query thing
    
    $info = queryWithPage($query, $offset);
    $syslog_rows = mysql_num_rows($info);

    $statusQuery = "select distinct(status) from ".mysql_Escape_string($dbs).sensibleFilter(1);
    $statusRequest = mysql_query($statusQuery);


    function topHitter($dbs){
        $aQuery = mysql_query("select remote_host, count(*) as requests from ".mysql_escape_string($dbs).sensibleFilter(1).customFilter(1)." group by remote_host order by requests desc limit 1");
        $test= mysql_fetch_object($aQuery);
        return $test;
    }
    require("header.php");
?>        <center>
            <table width="98%">
                <tr>
                    <td align=center>
                        <table border="1" cellpadding="1" cellspacing="0">

                            <tr>
                                <td align="center" bgcolor=lemonchiffon>
                                <b>Date</b></td>

                                <td align="center" bgcolor=lemonchiffon><b>Bytes
                                sent</b></td>

                                <td align="center" bgcolor=lemonchiffon colspan=2>
                                <b>URI</b></td>

                                <td align="center" bgcolor=lemonchiffon><b>Remote
                                host</b></td>

                                <td align="center" bgcolor=lemonchiffon>
                                <b>Status</b></td>
                            </tr>
                            <?php
			    	$totalBytes = 0;
                                while ($row = mysql_fetch_object($info))
                                {
				    $totalBytes += $row->bytes_sent;
					print "<tr>";
					print "<td>".myDate($row->time_stamp)."</td>";
					print "<td>".getBytes($row->bytes_sent)."</td>";
					print "<td><a href=\"view-request.php?dbs="
						.$dbs."&uri=".base64_encode($row->request_uri)."\">"
						.getShortString($row->request_uri)."</a>"
						."</td><td width=15><form method=POST>"
						."<input type=hidden name=dbs value=".$dbs." />"
						."<input type=hidden name=filter value=1 />"
						."<input type=hidden name=filterType value=request_uri />"
						."<input type=hidden name=filterValue value=".base64_encode($row->request_uri)." />"
						."<input type=image src=\"resources/images/filter.gif\" border=0>"
						."</form></td>";
					print "<td>(".geoCode($row->remote_host).") <a href=\"view-host.php?dbs=".$dbs."&remoteHost=".$row->remote_host."\">".$row->remote_host."</a></td>";
					print "<td align=center>".getStatusImage($row->status)."</td></tr>\n";	
                                }
				
				print "<tr><td align=right><b>Total Bytes</b></td><td>".getBytes($totalBytes)."</td><td></td><td></td></tr>";
                            ?>
                        </table>
	<?php showPageNav($offset, $query, null); ?>
                    </td>
                    <td valign="top" align="right">
                        <table border=1 cellspacing=0 cellpadding=2>
                            <tr>
                                <td colspan=3 bgcolor=lemonchiffon><b>Hosts stored in this database</b></td>
                            </tr>
                            <?php
                                    $tempQuery = "select distinct(virtual_host) from ".mysql_Escape_string($dbs);
                                            $tempResults = mysql_query($tempQuery);
                                    while(list($aList)=mysql_fetch_array($tempResults)){
                                        print "<tr><td colspan=3><a href=\"apache.php?dbs=".$dbs."&vh=".$aList."\">".$aList."</a></td></tr>\n";
                                    }
                            ?>
                            <tr>
                                <td colspan="3" bgcolor=lemonchiffon><b>Unique status recorded</b>
                                </td>
                            </tr>
                            <?php
                            while(list($aList)=mysql_fetch_array($statusRequest)){
                                print "<tr><td width=50 align=center>".getStatusImage($aList)."</td><td>".getHttpCode($aList)."</td><td>".getNumberStatus($aList, $dbs)."</td></tr>";
                            }
                            ?>
                            <tr>
                                <td bgcolor=lemonchiffon><b>Unique IP's</b></td>

                                <td colspan=2>
                                <?php print '<a href="view-ip.php?dbs='.$dbs.'">'.getUniqueIp().'</a>'; ?></td>
                            </tr>

                            <tr>
                                <td bgcolor=lemonchiffon><b>Most requests</b></td>

                                <td colspan=2><?php $vari = topHitter($dbs); print '<a 
href="view-host.php?dbs='.$dbs.'&remoteHost='.$vari -> remote_host.'">'.$vari->remote_host.'</a> ('.$vari->requests.')'; 
                                ?></td>
                            </tr>
                        </table>			
                    </td>
                </tr>
            </table>
        </center>
<?php require("footer.php"); ?>

Return current item: logViewSQL