Location: PHPKode > projects > PHPSiteStats > phpsitestats/index.php
<?php include("inc.header.php"); ?>

<p>&nbsp;</p>

<table>
        <th width='25'>type</th>
        <th width='100'>actions</th>
        <th width='150'>log name</th>
        <th width='200'>path/filename or table name</th>
        <th width='50'>log size</th>
        <th width='50'>hits</th>
        <?php  if ($cfg_database=="on" && isset($cfg_dlogs)){   foreach($cfg_dlogs as $logs_name => $logs_path) { ?>
                <tr>
                        <td align="left">
                                <img src='gfx/ico_dbase.gif' alt='Database Log'>
                        <td align="center">
                                <a href="index.php?action=db_visit_months&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_visit.gif' alt='Visitor Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_link_months&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_link.gif' alt='Link Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_sites&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_site.gif' alt='Site Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_ref&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_ref.gif' alt='Referrer Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_browser&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_browser.gif' alt='Browser Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_query&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_query.gif' alt='Query Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_spider&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_spider.gif' alt='Spider Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_os&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_os.gif' alt='OS Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_ip&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_ip.gif' alt='IP Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_view&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_view.gif' alt='View Log Table' height='16' width='16' border='0'></a>
                                <a href="index.php?action=edit&log_name=<?php echo $logs_name; ?>&log_path=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_edit.gif' alt='Edit Log Record' height='16' width='16' border='0'></a>
                                <a href="index.php?action=delete&log_name=<?php echo $logs_name; ?>">
                                <img src='gfx/ico_delete.gif' alt='Delete Log Record' height='16' width='16' border='0'></a>
                                <a href="index.php?action=db_export&log_name=<?php echo $logs_name; ?>&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_down.gif' alt='Export Log' height='16' width='16' border='0'></a>
                        <td align="left">
                                <?php echo $logs_name; ?>
                        <td align="left">
                                <?php echo $logs_path; ?>
                        <td align="center">
                                <?php if ($cfg_show_size=="on"){ db_show_size($cfg_dbname,$logs_path); } ?>
                        <td align="center">
                                <?php if ($cfg_show_visits=="on"){db_visits_show($logs_path); } ?>
        <?php } }else{
   echo "<tr><td></td><td colspan=6 align=center><img src=gfx/ico_notice.gif align=absmiddle> No database logs available</td></tr>\n";
} ?>
        <?php   if (isset($cfg_flogs)){     foreach($cfg_flogs as $logs_name => $logs_path) { ?>
                <tr>
                        <td align="left">
                                <img src='gfx/ico_file.gif' alt='File Log'>
                        <td align="center">
                                <a href="index.php?action=fl_visit_months&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_visit.gif' alt='Visitor Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_link_months&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_link.gif' alt='Link Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_sites&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_site.gif' alt='Site Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_ref&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_ref.gif' alt='Referrer Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_browser&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_browser.gif' alt='Browser Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_query&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_query.gif' alt='Query Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_spider&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_spider.gif' alt='Spider Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_os&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_os.gif' alt='OS Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_ip&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_ip.gif' alt='IP Statistics' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_view&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_view.gif' alt='View Logfile' height='16' width='16' border='0'></a>
                                <a href="index.php?action=edit&log_name=<?php echo $logs_name; ?>&log_path=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_edit.gif' alt='Edit Log Record' height='16' width='16' border='0'></a>
                                <a href="index.php?action=delete&log_name=<?php echo $logs_name; ?>">
                                <img src='gfx/ico_delete.gif' alt='Delete Log Record' height='16' width='16' border='0'></a>
                                <a href="index.php?action=fl_export&log_name=<?php echo $logs_name; ?>&logfile=<?php echo $logs_path; ?>">
                                <img src='gfx/ico_down.gif' alt='Export Log' height='16' width='16' border='0'></a>
                        <td align="left">
                                <?php echo $logs_name; ?>
                        <td align="left">
                                <?php echo $logs_path; ?>
                        <td align="center">
                                <?php if ($cfg_show_size=="on"){ fl_show_size($logs_path); } ?>
                        <td align="center">
                                <?php if ($cfg_show_visits=="on"){ fl_visits_show($logs_path); } ?>
        <?php } }else{
   echo "<tr><td></td><td colspan=6 align=center><img src=gfx/ico_notice.gif align=absmiddle> No file logs available</td></tr>\n";
} ?>
</table>

<p>&nbsp;</p>

<?php

if (isset($_GET['action']) || isset($_POST['action'])) {

//get post/get data
if (isset($_GET['action'])) {$action = $_GET['action'];};
if (isset($_POST['action'])) {$action = $_POST['action'];};
if (isset($_GET['log_name'])) {$log_name = $_GET['log_name'];};
if (isset($_GET['log_path'])) {$log_path = $_GET['log_path']; };
if (isset($_GET['logfile'])) {$logfile = $_GET['logfile'];};
if (isset($_GET['month'])) {$month = $_GET['month'];};

if ($cfg_show_graph == "on"){
        if ($action == "fl_visit_days" || $action == "fl_visit_months" || $action == "db_visit_days" || $action == "db_visit_months"){
                echo "<img src=inc.func.php?graphic=progress&logfile=$logfile&what=$action&month=$month><br><br>";
        }
        if ($action == "fl_link_days" || $action == "fl_link_months" || $action == "db_link_days" || $action == "db_link_months"){
                echo "<img src=inc.func.php?graphic=progress&logfile=$logfile&what=$action&month=$month><br><br>";
        }
        if ($action == "fl_site_days" || $action == "fl_site_months" || $action == "db_site_days" || $action == "db_site_months"){
                echo "<img src=inc.func.php?graphic=progress&logfile=$logfile&what=$action&month=$month&extra=$site><br><br>";
        }
        if ($action == "fl_ip_days" || $action == "fl_ip_months" || $action == "db_ip_days" || $action == "db_ip_months"){
                echo "<img src=inc.func.php?graphic=progress&logfile=$logfile&what=$action&month=$month&extra=$ip><br><br>";
        }
        if ($action == "fl_spider_days" || $action == "fl_spider_months" || $action == "db_spider_days" || $action == "db_spider_months"){
                echo "<img src=inc.func.php?graphic=progress&logfile=$logfile&what=$action&month=$month&extra=$spider><br><br>";
        }
        if ($action == "fl_sites" || $action == "fl_ref" || $action == "fl_browser" || $action == "fl_spider" || $action == "fl_os" || $action == "fl_ip"){
                echo "<img src=inc.func.php?graphic=percentage&logfile=$logfile&what=$action&month=$month><br><br>";
        }
        if ($action == "db_sites" || $action == "db_ref" || $action == "db_browser" || $action == "db_spider" || $action == "db_os" || $action == "db_ip"){
                echo "<img src=inc.func.php?graphic=percentage&logfile=$logfile&what=$action&month=$month><br><br>";
        }
        if ($action == "db_query" || $action == "db_querys" || $action == "fl_query" || $action == "fl_querys"){
                echo "<img src=inc.func.php?graphic=percentage&logfile=$logfile&what=$action&month=$site><br><br>";
        }
}

//
//visits
//

if ($action == "fl_visit_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = fl_get_visit_months($logfile);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=fl_visit_days&month=$month&logfile=$logfile target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'visits','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_visit_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = fl_get_visit_days($logfile,$fmonth,$fyear);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'visits','days');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_visit_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = db_get_visit_months($logfile);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=db_visit_days&month=$month&logfile=$logfile target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'visits','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_visit_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = db_get_visit_days($logfile,$fmonth,$fyear);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'visits','days');
        echo "<center></tr></td>";
        echo "</table>";
}

//
//links
//

if ($action == "fl_link_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = fl_get_link_months($logfile);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=fl_link_days&month=$month&logfile=$logfile target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_link_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = fl_get_link_days($logfile,$fmonth,$fyear);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','days');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_link_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = db_get_link_months($logfile);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=db_link_days&month=$month&logfile=$logfile target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_link_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = db_get_link_days($logfile,$fmonth,$fyear);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','days');
        echo "<center></tr></td>";
        echo "</table>";
}

//
//sites
//

if ($action == "fl_sites"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Sites</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = fl_get_sites($logfile);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $t => $m){
                     if ($m > $_SESSION['cfg_minhit']){
                         $date[$t] = $m;
                     }else{
                         $skip_l += $m;
                         $skip_s++;
                     }
                }
                foreach ($date as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=fl_site_months&site=$month&logfile=$logfile target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','sites');
        echo "<br>$skip_l links from $skip_s sites with under $cfg_minhit links/site skipped";
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_site_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = fl_get_site_months($logfile,$site);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=fl_site_days&month=$month&logfile=$logfile&site=$site target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_site_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = fl_get_site_days($logfile,$fmonth,$fyear,$site);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','days');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_sites"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Sites</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = db_get_sites($logfile);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $t => $m){
                     if ($m > $cfg_minhit){
                         $date[$t] = $m;
                     }else{
                         $skip_l += $m;
                         $skip_s++;
                     }
                }
                foreach ($date as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=db_site_months&site=$month&logfile=$logfile target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','sites');
        echo "<br>$skip_l links from $skip_s sites with under $cfg_minhit links/site skipped";
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_site_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = db_get_site_months($logfile,$site);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=db_site_days&month=$month&logfile=$logfile&site=$site target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_site_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = db_get_site_days($logfile,$fmonth,$fyear,$site);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'links','days');
        echo "<center></tr></td>";
        echo "</table>";
}

//
//ips
//

if ($action == "fl_ip"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Ip's</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                $ips = fl_get_ips($logfile);
                if ($_GET['sort'] == a) {asort ($ips);}
                if ($_GET['sort'] == k) {ksort ($ips);}
                foreach ($ips as $t => $m){
                     if ($m > $cfg_minip){
                         $date[$t] = $m;
                     }else{
                         $skip_l += $m;
                         $skip_s++;
                     }
                }
                foreach ($date as $ip => $ip_num) {
                        $ip = substr ($ip,0,100);
                        echo "<tr><td class=tdark><a href=index.php?action=fl_ip_months&ip=$ip&logfile=$logfile target=_self>$ip</a></td><td class=tlight>$ip_num</td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($ips,'hits','ips');
        echo "<br>$skip_l hits from $skip_s ip's with under $cfg_minip hits/ip skipped";
        echo "<center></tr></td>";
        echo "</table>";
}

if ($action == "fl_ip_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = fl_get_ip_months($logfile,$ip);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=fl_ip_days&month=$month&logfile=$logfile&ip=$ip target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_ip_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = fl_get_ip_days($logfile,$fmonth,$fyear,$ip);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','days');
        echo "<center></tr></td>";
        echo "</table>";
}

if ($action == "db_ip"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Ip's</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                $ips = db_get_ips($logfile);
                if ($_GET['sort'] == a) {asort ($ips);}
                if ($_GET['sort'] == k) {ksort ($ips);}
                foreach ($ips as $t => $m){
                     if ($m > $cfg_minip){
                         $date[$t] = $m;
                     }else{
                         $skip_l += $m;
                         $skip_s++;
                     }
                }
                foreach ($date as $ip => $ip_num) {
                        $ip = substr ($ip,0,100);
                        echo "<tr><td class=tdark><a href=index.php?action=db_ip_months&ip=$ip&logfile=$logfile target=_self>$ip</a></td><td class=tlight>$ip_num</td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($ips,'hits','ips');
        echo "<br>$skip_l hits from $skip_s ip's with under $cfg_minip hits/ip skipped";
        echo "<center></tr></td>";
        echo "</table>";
}

if ($action == "db_ip_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = db_get_ip_months($logfile,$ip);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=db_ip_days&month=$month&logfile=$logfile&ip=$ip target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','months');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_ip_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = db_get_ip_days($logfile,$fmonth,$fyear,$ip);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','days');
        echo "<center></tr></td>";
        echo "</table>";
}

//
//spiders
//

if ($action == "fl_spider"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>spider's</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                $spiders = fl_get_spiders($logfile);
                if ($_GET['sort'] == a) {asort ($spiders);}
                if ($_GET['sort'] == k) {ksort ($spiders);}
                foreach ($spiders as $t => $m){
                      $date[$t] = $m;
                }
                foreach ($date as $spider => $spider_num) {
                        $spider = substr ($spider,0,100);
                        if ($spider == "_other"){
                        echo "<tr><td class=tdark><b>$spider</b></td><td class=tlight>$spider_num</td></tr>\n";
                        }else{
                        echo "<tr><td class=tdark><a href=index.php?action=fl_spider_months&spider=$spider&logfile=$logfile target=_self>$spider</a></td><td class=tlight>$spider_num</td></tr>\n";
                        }
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($spiders,'hits','spiders','from');
        echo "<center></tr></td>";
        echo "</table>";
}

if ($action == "fl_spider_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = fl_get_spider_months($logfile,$spider);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=fl_spider_days&month=$month&logfile=$logfile&spider=$spider target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','months','from');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_spider_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = fl_get_spider_days($logfile,$fmonth,$fyear,$spider);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','days','from');
        echo "<center></tr></td>";
        echo "</table>";
}

if ($action == "db_spider"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>spider's</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                $spiders = db_get_spiders($logfile);
                if ($_GET['sort'] == a) {asort ($spiders);}
                if ($_GET['sort'] == k) {ksort ($spiders);}
                foreach ($spiders as $t => $m){
                     $date[$t] = $m;
                }
                foreach ($date as $spider => $spider_num) {
                        $spider = substr ($spider,0,100);
                        if ($spider == "_other"){
                        echo "<tr><td class=tdark><b>$spider</b></td><td class=tlight>$spider_num</td></tr>\n";
                        }else{
                        echo "<tr><td class=tdark><a href=index.php?action=db_spider_months&spider=$spider&logfile=$logfile target=_self>$spider</a></td><td class=tlight>$spider_num</td></tr>\n";
                        }
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($spiders,'hits','spiders','from');
        echo "<center></tr></td>";
        echo "</table>";
}

if ($action == "db_spider_months"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>Months</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                $dates = db_get_spider_months($logfile,$spider);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $month => $month_num) {
                        echo "<tr><td class=tdark><a href=index.php?action=db_spider_days&month=$month&logfile=$logfile&spider=$spider target=_self>$month</a></td><td class=tlight><b>$month_num</b></td></tr>\n";
               }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','months','from');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "db_spider_days"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=k target=_self>Days</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&month=$month&sort=a target=_self>hits</a></b></td></tr>";
        list($fmonth,$fyear)= split ("\.", $month, 2);
                $dates = db_get_spider_days($logfile,$fmonth,$fyear,$spider);
                if ($_GET['sort'] == a) {asort ($dates);}
                if ($_GET['sort'] == k) {ksort ($dates);}
                foreach ($dates as $day => $day_num) {
                        echo "<tr><td class=tdark>$day</td><td class=tlight><b>$day_num</b></td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($dates,'hits','days','from');
        echo "<center></tr></td>";
        echo "</table>";
}


//
//unified actions
//

if ($action == "fl_ref" || $action == "db_ref"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>referrers</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                if ($action == "db_ref"){
                   $refs = db_get_refs($logfile);
                }
                if ($action == "fl_ref"){
                   $refs = fl_get_refs($logfile);
                }
                if ($_GET['sort'] == a) {asort ($refs);}
                if ($_GET['sort'] == k) {ksort ($refs);}
                foreach ($refs as $ref => $ref_num) {
                        $sref = substr ($ref,0,70);
                        echo "<tr><td class=tdark><a href=\"$ref\">&nbsp; $sref</a></td><td class=tlight>$ref_num</td></tr>\n";
                }
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_browser" || $action == "db_browser"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>browsers</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                if ($action == "fl_browser"){
                    $browsers = fl_get_browsers($logfile);
                }
                if ($action == "db_browser"){
                    $browsers = db_get_browsers($logfile);
                }
                if ($_GET['sort'] == a) {asort ($browsers);}
                if ($_GET['sort'] == k) {ksort ($browsers);}
                foreach ($browsers as $browser => $browser_num) {
                        $browser = substr ($browser,0,100);
                        echo "<tr><td class=tdark>$browser</td><td class=tlight>$browser_num</td></tr>\n";
                }
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_query" || $action == "db_query"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>site</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>queries</a></b></td></tr>";
                echo "<base target=_blank>";
                if ($action == "fl_query"){
                    $querys = fl_get_queries($logfile);
                }
                if ($action == "db_query"){
                    $querys = db_get_queries($logfile);
                }
                if ($_GET['sort'] == a) {asort ($querys);}
                if ($_GET['sort'] == k) {ksort ($querys);}
                foreach ($querys as $query => $query_num) {
                        $query = substr ($query,0,100);
                        echo "<tr><td class=tdark><a href=index.php?action=".$action."s&month=$month&logfile=$logfile&site=$query target=_self>$query</a></td><td class=tlight>$query_num</td></tr>\n";
                }
        echo "<tr><td colspan=2 class=tlight><center>";
        show_avg($querys,'queries','engines');
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_querys" || $action == "db_querys"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k&site=$site target=_self>query</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a&site=$site target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                if ($action == "fl_querys"){
                    $querys = fl_get_queries($logfile,$_GET[site]);
                }
                if ($action == "db_querys"){
                    $querys = db_get_queries($logfile,$_GET[site]);
                }
                if ($_GET['sort'] == a) {asort ($querys);}
                if ($_GET['sort'] == k) {ksort ($querys);}
                foreach ($querys as $query => $query_num) {
                        $query = substr ($query,0,100);
                        echo "<tr><td class=tdark>$query</td><td class=tlight>$query_num</td></tr>\n";
                }
        echo "<center></tr></td>";
        echo "</table>";
}
if ($action == "fl_os" || $action == "db_os"){
        echo "<table class=table cellspacing=1><tr><td class=tdark><b><a href=index.php?action=$action&logfile=$logfile&sort=k target=_self>oss</a></b></td>
                <td class=tlight><b><a href=index.php?action=$action&logfile=$logfile&sort=a target=_self>hits</a></b></td></tr>";
                echo "<base target=_blank>";
                if ($action == "fl_os"){
                    $oss = fl_get_oss($logfile);
                }
                if ($action == "db_os"){
                    $oss = db_get_oss($logfile);
                }
                if ($_GET['sort'] == a) {asort ($oss);}
                if ($_GET['sort'] == k) {ksort ($oss);}
                foreach ($oss as $os => $os_num) {
                        $os = substr ($os,0,100);
                        echo "<tr><td class=tdark>$os</td><td class=tlight>$os_num</td></tr>\n";
                }
        echo "<center></tr></td>";
        echo "</table>";
}

//
//misc actions
//

if ($action == "fl_view"){
        echo "<textarea class=input cols='140' rows='40' wrap='OFF'>";
        fl_file_echo($logfile);
        echo "</textarea>";
}
if ($action == "db_view"){
        echo "<textarea class=input cols='140' rows='40' wrap='OFF'>";
        db_table_echo ($logfile);
        echo "</textarea>";
}
if ($action == "fl_export"){
        $outfile = "backup/". get_fname($logfile) . ".gz";
        do_gzip($logfile,$outfile);
        //make sure file is writable if not chmod it
        do_chmod($outfile);
        echo "<a href='$outfile'> $outfile </a><br>
        <img src=gfx/ico_notice.gif align=absmiddle border=0> If yoy Save target most of the times the server will do a runtime decompression of the file to your browser<br>
        <img src=gfx/ico_help.gif align=absmiddle border=0> If you want to get the compressed file you have to download this link with a download manager";
}
if ($action == "db_export"){
        $fname = "backup/". $logfile . ".sql";
        do_backup($logfile,$fname);
        //make sure file is writable if not chmod it
        do_chmod($fname);
        //make the sql file
        do_backup($logfile,$fname);
        //compress the file
        $outfile = $fname . ".gz";
        do_gzip($fname,$outfile);
        //delete the sql file
        unlink($fname);
        echo "<a href='$outfile'> $outfile </a><br>
        <img src=gfx/ico_notice.gif align=absmiddle border=0> If yoy Save target most of the times the server will do a runtime decompression of the file to your browser<br>
        <img src=gfx/ico_help.gif align=absmiddle border=0> If you want to get the compressed file you have to download this link with a download manager";
}
if ($action == "delete"){
        fl_chmod("inc.conf.php");
        conf_remove("inc.conf.php",$log_name);
        echo "<br><img src=gfx/ico_yes.gif> $log_name was successfully removed<br>";
}
if ($action == "edit"){
        echo "
        <form action='index.php' method='post'><input class=input type='hidden' name='action' value='$action'>
        <input class=input type='hidden' name='old_val' value='$log_path'><input class=input type='hidden' name='old_var' value='$log_name'>
        <table><th width='250' align=left>Log path/filename</th><th width='150' align=left>Display name</th><br>
        <tr><td><input class=input type='text' name='new_val' size='34' maxvalue='40' value='$log_path'></td>
        <td><input class=input type='text' name='new_var' size='20' maxvalue='20' value='$log_name'></td>
        </tr><tr><td colspan=2 align=right><input class=input type='submit' name='submit' value='Edit Log Record' ></tr></table>
        </form>
        ";
        if ($_POST['submit'] && $_POST['new_var'] && $_POST['new_val'] && $_POST['old_var'] && $_POST['old_val']){
                        //get post data
                        $new_var = $_POST['new_var'];
                        $new_val = $_POST['new_val'];
                        $old_var = $_POST['old_var'];
                        $old_val = $_POST['old_val'];

                        fl_chmod("inc.conf.php");
                        conf_replace("inc.conf.php",$old_var,$new_var);
                        conf_replace("inc.conf.php",$old_val,$new_val);
                        echo "<br><img src=gfx/ico_yes.gif> $old_val was successfully edited<br>";
        }
}


}
?>

</center>
</body>
</html>
Return current item: PHPSiteStats