0) $sql = "DELETE FROM " . db_prefix("referers") . " WHERE last<'".date("Y-m-d H:i:s",strtotime("-".$expire." days"))."'"; db_query($sql); $op = httpget('op'); if ($op=="rebuild"){ $sql = "SELECT * FROM " . db_prefix("referers"); $result = db_query($sql); $number=db_num_rows($result); for ($i=0;$i<$number;$i++){ $row = db_fetch_assoc($result); $site = str_replace("http://","",$row['uri']); if (strpos($site,"/")) $site = substr($site,0,strpos($site,"/")); $sql = "UPDATE " . db_prefix("referers") . " SET site='".addslashes($site)."' WHERE refererid='{$row['refererid']}'"; db_query($sql); } } require_once("lib/superusernav.php"); superusernav(); addnav("Referer Options"); addnav("",$_SERVER['REQUEST_URI']); $sort = httpget('sort'); addnav("Refresh","referers.php?sort=".URLEncode($sort).""); addnav("C?Sort by Count","referers.php?sort=count".($sort=="count DESC"?"":"+DESC")); addnav("U?Sort by URL","referers.php?sort=uri".($sort=="uri"?"+DESC":"")); addnav("T?Sort by Time","referers.php?sort=last".($sort=="last DESC"?"":"+DESC")); addnav("Rebuild Sites","referers.php?op=rebuild"); page_header("Referers"); $order = "count DESC"; if ($sort!="") $order=$sort; $sql = "SELECT SUM(count) AS count, MAX(last) AS last,site FROM " . db_prefix("referers") . " GROUP BY site ORDER BY $order LIMIT 100"; $count = translate_inline("Count"); $last = translate_inline("Last"); $dest = translate_inline("Destination"); $none = translate_inline("`iNone`i"); $notset = translate_inline("`iNot set`i"); $skipped = translate_inline("`i%s records skipped (over a week old)`i"); rawoutput(""); $result = db_query($sql); $number=db_num_rows($result); for ($i=0;$i<$number;$i++){ $row = db_fetch_assoc($result); rawoutput(""); $sql = "SELECT count,last,uri,dest,ip FROM " . db_prefix("referers") . " WHERE site='".addslashes($row['site'])."' ORDER BY {$order} LIMIT 25"; $result1 = db_query($sql); $skippedcount=0; $skippedtotal=0; $number=db_num_rows($result1); for ($k=0;$k<$number;$k++){ $row1=db_fetch_assoc($result1); $diffsecs = strtotime("now")-strtotime($row1['last']); if ($diffsecs<=604800){ rawoutput(""); }else{ $skippedcount++; $skippedtotal+=$row1['count']; } } if ($skippedcount>0){ rawoutput(""); } //output("",true); } rawoutput("
$count$lastURL$destIP
"); output_notl("`b".$row['count']."`b"); rawoutput(""); $diffsecs = strtotime("now")-strtotime($row['last']); //output((int)($diffsecs/86400)."d ".(int)($diffsecs/3600%3600)."h ".(int)($diffsecs/60%60)."m ".(int)($diffsecs%60)."s"); output_notl("`b".dhms($diffsecs)."`b"); rawoutput(""); output_notl("`b".($row['site']==""?$none:$row['site'])."`b"); rawoutput("
"); output_notl($row1['count']); rawoutput(""); //output((int)($diffsecs/86400)."d".(int)($diffsecs/3600%3600)."h".(int)($diffsecs/60%60)."m".(int)($diffsecs%60)."s"); output_notl(dhms($diffsecs)); rawoutput(""); if ($row1['uri']>"") rawoutput("".HTMLEntities(substr($row1['uri'],0,100)).""); else output_notl($none); output_notl("`n"); rawoutput(""); output_notl($row1['dest']==''?$notset:$row1['dest']); rawoutput(""); output_notl($row1['ip']==''?$notset:$row1['ip']); rawoutput("
$skippedtotal"); output_notl(sprintf($skipped,$skippedcount)); rawoutput("
"); page_footer(); ?>