summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-03-18 10:57:30 +0000
committerdeva <deva>2010-03-18 10:57:30 +0000
commit456e4424f4e457b67c61a6961bb4bc44058f1738 (patch)
treeb975b16082454484b4bae558a506c37e6c64afbc
parent5f38d6d5c17c01d2f3488965e817478bf3a8cd06 (diff)
Show some stats.
-rw-r--r--utils/modules/sitestats.php103
1 files 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 "<p>".$hits." hits.</p>\n";
+
+ echo "<p><strong>Referers:</strong></p>\n";
+ echo "<ul>\n";
+ foreach($this->referers as $k => $v) {
+ echo " <li>(".$v.") <a href=\"" . $k . "\">".$k."</a></li>\n";
+ }
+ echo "</ul>\n";
+
+ echo "<p><strong>Pages:</strong></p>\n";
+ echo "<ul>\n";
+ foreach($this->pages as $k => $v) {
+ echo " <li>(".$v.") <a href=\"?page=" . $k . "\">".$k."</a></li>\n";
+ }
+ echo "</ul>\n";
+
+ echo "<p><strong>Visitors:</strong></p>\n";
+ echo "<p>".sizeof($this->visitors)." unique visitors.</p>\n";
+ echo "<ul>\n";
+ foreach($this->visitors as $k => $v) {
+ echo " <li>(".$v.") ".$k."</li>\n";
+ }
+ echo "</ul>\n";
+
break;
}
}
- /*
- public function write()
- {
- $fp = fopen($this->file, "w");
- fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-
- fwrite($fp, "<configs>\n");
- foreach($this->configs as $name => $value) {
- fwrite($fp, " <config name=\"".$name."\"\n");
- fwrite($fp, " value=\"".
- htmlspecialchars(serialize($value), ENT_QUOTES, "UTF-8")."\"/>\n");
- }
- fwrite($fp, "</configs>\n");
-
- fclose($fp);
- }
- */
private function read($file)
{
- /*
+ $xml = file_get_contents($file);
+
+ $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<stats>\n" . $xml . "\n</stats>\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());
}
}
}