From 456e4424f4e457b67c61a6961bb4bc44058f1738 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 18 Mar 2010 10:57:30 +0000 Subject: Show some stats. --- utils/modules/sitestats.php | 103 +++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 25 deletions(-) diff --git a/utils/modules/sitestats.php b/utils/modules/sitestats.php index c4bafbf..63db39a 100644 --- a/utils/modules/sitestats.php +++ b/utils/modules/sitestats.php @@ -9,6 +9,11 @@ class SiteStats { public $statsdir; public $stats = array(); + private $referers = array(); + private $pages = array(); + private $visitors = array(); + + // Admin config public $admin_title = "Site Stats"; public $admin_submodules = array("Overview" => "overview"); @@ -17,6 +22,7 @@ class SiteStats { { switch($action) { default: + $this->readSingle(time()); break; } } @@ -26,40 +32,87 @@ class SiteStats { switch($sub) { case "overview": $this->admin_overview($action, $vars); + + $hits = 0; + foreach($this->visitors as $k => $v) { + $hits += $v; + } + + echo "

".$hits." hits.

\n"; + + echo "

Referers:

\n"; + echo "\n"; + + echo "

Pages:

\n"; + echo "\n"; + + echo "

Visitors:

\n"; + echo "

".sizeof($this->visitors)." unique visitors.

\n"; + echo "\n"; + break; } } - /* - public function write() - { - $fp = fopen($this->file, "w"); - fwrite($fp, "\n"); - - fwrite($fp, "\n"); - foreach($this->configs as $name => $value) { - fwrite($fp, " \n"); - } - fwrite($fp, "\n"); - - fclose($fp); - } - */ private function read($file) { - /* + $xml = file_get_contents($file); + + $xml = "\n\n" . $xml . "\n\n"; + $dom = new DomDocument; $dom->preserveWhiteSpace = TRUE; - $dom->load($this->file); - $configElems = $dom->getElementsByTagName('config'); + $dom->loadXML($xml); + $entries = $dom->getElementsByTagName('entry'); + + foreach($entries as $entry) { + + $skip = false; + $remoteaddrs = $entry->getElementsByTagName('remoteaddr'); + foreach($remoteaddrs as $remoteaddr) { + $addr = $remoteaddr->textContent; + if($addr == "87.63.201.210") $skip = true; + } + + $agents = $entry->getElementsByTagName('agent'); + foreach($agents as $agent) { + $ag = $agent->textContent; + if(stripos($ag, "bot") > 0) $skip = true; + } + + if($skip == true) continue; - foreach ($configElems as $config) { - $this->setValue($config->getAttribute('name'), - unserialize(htmlspecialchars_decode($config->getAttribute('value'), ENT_QUOTES))); + $this->visitors[$addr]++; + + $refs = $entry->getElementsByTagName('referer'); + foreach($refs as $ref) { + $url = $ref->textContent; + if(strpos($url, "executionroom.com") > 0 || $url == "") {} else $this->referers[$url]++; + } + + $pages = $entry->getElementsByTagName('page'); + foreach($pages as $page) { + $pg = $page->textContent; + if($pg != "") $this->pages[$pg]++; + } + } - */ + + arsort($this->referers); + arsort($this->pages); + arsort($this->visitors); } public function log($loadtime) @@ -114,7 +167,7 @@ class SiteStats { if($readall) { $this->readAll(); } else { - $this->readSingle(time()); + // $this->readSingle(time()); } } } -- cgit v1.2.3