From 8c47bee60d72b1a5bec60ef8a19a99e120b5122e Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 23 Sep 2015 12:54:07 -0700 Subject: [PATCH] New Shortcode added to Stats plugin. Use {LOG_PAGECOUNTER} or {LOG_PAGECOUNTER=unique} in any frontend template to show the total hits for that URL/page. --- e107_plugins/log/e_shortcode.php | 91 ++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 e107_plugins/log/e_shortcode.php diff --git a/e107_plugins/log/e_shortcode.php b/e107_plugins/log/e_shortcode.php new file mode 100644 index 000000000..ea971f114 --- /dev/null +++ b/e107_plugins/log/e_shortcode.php @@ -0,0 +1,91 @@ +select('logstats', 'log_data', "log_id='pageTotal'")) /* get main stat info from database */ + { + $row = $sql->fetch(); + $this->dbPageInfo = unserialize($row['log_data']); + } + else + { + $this->dbPageInfo = array(); + } + + /* temp consolidate today's info (if it exists)... */ + if(is_array($pageInfo)) + { + foreach($pageInfo as $key => $info) + { + $key = preg_replace("/\?.*/", "", $key); + if(array_key_exists($key, $this -> dbPageInfo)) + { + $this -> dbPageInfo[$key]['ttlv'] += $info['ttl']; + $this -> dbPageInfo[$key]['unqv'] += $info['unq']; + } + else + { + $this -> dbPageInfo[$key]['url'] = $info['url']; + $this -> dbPageInfo[$key]['ttlv'] = $info['ttl']; + $this -> dbPageInfo[$key]['unqv'] = $info['unq']; + } + } + } + + + } + + + private function getKey($self) + { + $base = basename($self); + list($url,$qry) = explode(".",$base, 2); + return $url; + } + + + function sc_log_pagecounter($parm) + { + + $id = $this->getKey(e_REQUEST_URL); + + if(isset($this->dbPageInfo[$id]['url']) && ($this->dbPageInfo[$id]['url'] == e_REQUEST_URL)) + { + return ($parm == 'unique') ? number_format($this->dbPageInfo[$id]['unqv']) : number_format($this->dbPageInfo[$id]['ttlv']); + } + + } + +} + + + +?> \ No newline at end of file