mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 22:57:14 +02:00
Site-Statistics plugin fixes, cleanup etc.
This commit is contained in:
@@ -664,7 +664,19 @@ class e_admin_log
|
|||||||
|
|
||||||
$date = ($append == true) ? date('Y-m-d') : date('Y-m-d_H-i-s').'_'.crc32($text);
|
$date = ($append == true) ? date('Y-m-d') : date('Y-m-d_H-i-s').'_'.crc32($text);
|
||||||
|
|
||||||
$fileName = e_LOG.$date."_".$this->logFile.".log";
|
$dir = e_LOG;
|
||||||
|
|
||||||
|
if(e_CURRENT_PLUGIN) // If it's a plugin, create a subfolder.
|
||||||
|
{
|
||||||
|
$dir = e_LOG.e_CURRENT_PLUGIN."/";
|
||||||
|
|
||||||
|
if(!is_dir($dir))
|
||||||
|
{
|
||||||
|
mkdir($dir,0755);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileName = $dir.$date."_".$this->logFile.".log";
|
||||||
|
|
||||||
if($append == true)
|
if($append == true)
|
||||||
{
|
{
|
||||||
@@ -679,11 +691,15 @@ class e_admin_log
|
|||||||
$app = null;
|
$app = null;
|
||||||
$text = $head . $text;
|
$text = $head . $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_put_contents($fileName, $text, $app))
|
if(file_put_contents($fileName, $text, $app))
|
||||||
{
|
{
|
||||||
$this->_allMessages = array();
|
$this->_allMessages = array();
|
||||||
return $this->logFile;
|
return $this->logFile;
|
||||||
|
}
|
||||||
|
elseif(getperms('0') && E107_DEBUG_LEVEL > 0)
|
||||||
|
{
|
||||||
|
echo "Could Save to Log File: ".$fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -701,7 +717,7 @@ class e_admin_log
|
|||||||
*/
|
*/
|
||||||
public function toFile($name,$logTitle='',$append=false)
|
public function toFile($name,$logTitle='',$append=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->logFile = $name;
|
$this->logFile = $name;
|
||||||
$this->saveToFile($logTitle,$append);
|
$this->saveToFile($logTitle,$append);
|
||||||
$this->logFile = null;
|
$this->logFile = null;
|
||||||
|
@@ -2588,7 +2588,7 @@ class e107
|
|||||||
if(isset($GLOBALS['_E107']['minimal']) || e_AJAX_REQUEST || deftrue('e_MINIMAL'))
|
if(isset($GLOBALS['_E107']['minimal']) || e_AJAX_REQUEST || deftrue('e_MINIMAL'))
|
||||||
{
|
{
|
||||||
$_e107vars = array('forceuserupdate', 'online', 'theme', 'menus', 'prunetmp');
|
$_e107vars = array('forceuserupdate', 'online', 'theme', 'menus', 'prunetmp');
|
||||||
|
$GLOBALS['_E107']['minimal'] = true;
|
||||||
// lame but quick - allow online when ajax request only, additonal checks are made in e_online class
|
// lame but quick - allow online when ajax request only, additonal checks are made in e_online class
|
||||||
if(e_AJAX_REQUEST && !isset($GLOBALS['_E107']['online']) && !isset($GLOBALS['_E107']['minimal'])) unset($_e107vars[1]);
|
if(e_AJAX_REQUEST && !isset($GLOBALS['_E107']['online']) && !isset($GLOBALS['_E107']['minimal'])) unset($_e107vars[1]);
|
||||||
|
|
||||||
|
@@ -20,31 +20,30 @@
|
|||||||
|
|
||||||
if (!defined('e107_INIT')){ exit; }
|
if (!defined('e107_INIT')){ exit; }
|
||||||
|
|
||||||
$pathtologs = e_LOG;
|
$pathtologs = e_LOG;
|
||||||
$date = date("z.Y", time());
|
$date = date("z.Y", time());
|
||||||
$yesterday = date("z.Y",(time() - 86400)); // This makes sure year wraps round OK
|
$yesterday = date("z.Y",(time() - 86400)); // This makes sure year wraps round OK
|
||||||
$date2 = date("Y-m-j", (time() -86400)); // Yesterday's date for the database summary
|
$date2 = date("Y-m-j", (time() -86400)); // Yesterday's date for the database summary
|
||||||
$date3 = date("Y-m", (time() -86400)); // Current month's date for monthly summary (we're working with yesterday's data)
|
$date3 = date("Y-m", (time() -86400)); // Current month's date for monthly summary (we're working with yesterday's data)
|
||||||
|
|
||||||
$pfileprev = "logp_".$yesterday.".php"; // Yesterday's log file
|
$pfileprev = "logp_".$yesterday.".php"; // Yesterday's log file
|
||||||
$pfile = "logp_".$date.".php"; // Today's log file
|
$pfile = "logp_".$date.".php"; // Today's log file
|
||||||
$ifileprev = "logi_".$yesterday.".php";
|
$ifileprev = "logi_".$yesterday.".php";
|
||||||
$ifile = "logi_".$date.".php";
|
$ifile = "logi_".$date.".php";
|
||||||
|
|
||||||
if(file_exists($pathtologs.$pfile))
|
if(file_exists($pathtologs.$pfile)) /* log file is up to date, no consolidation required */
|
||||||
{
|
{
|
||||||
/* log file is up to date, no consolidation required */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(!file_exists($pathtologs.$pfileprev))
|
else if(!file_exists($pathtologs.$pfileprev)) // See if any older log files
|
||||||
{ // See if any older log files
|
{
|
||||||
if (($retvalue = check_for_old_files($pathtologs)) === FALSE)
|
if (($retvalue = check_for_old_files($pathtologs)) === FALSE) /* no logfile found at all - create - this will only ever happen once ... */
|
||||||
{ /* no logfile found at all - create - this will only ever happen once ... */
|
{
|
||||||
createLog($pathtologs);
|
createLog($pathtologs);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
// ... if we've got files
|
|
||||||
list($pfileprev,$ifileprev,$date2,$tstamp) = explode('|',$retvalue);
|
list($pfileprev,$ifileprev,$date2,$tstamp) = explode('|',$retvalue); // ... if we've got files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -63,10 +62,10 @@ $qry .= ")";
|
|||||||
/* log file is out of date - consolidation required */
|
/* log file is out of date - consolidation required */
|
||||||
|
|
||||||
/* get existing stats ... */
|
/* get existing stats ... */
|
||||||
//if($sql -> db_Select("logstats", "*", "log_id='statBrowser' OR log_id='statOs' OR log_id='statScreen' OR log_id='statDomain' OR log_id='statTotal' OR log_id='statUnique' OR log_id='statReferer' OR log_id='statQuery'"))
|
//if($sql->select("logstats", "*", "log_id='statBrowser' OR log_id='statOs' OR log_id='statScreen' OR log_id='statDomain' OR log_id='statTotal' OR log_id='statUnique' OR log_id='statReferer' OR log_id='statQuery'"))
|
||||||
if($sql -> db_Select("logstats", "*", $qry))
|
if($sql->select("logstats", "*", $qry))
|
||||||
{ // That's read in all the stats we need to modify
|
{ // That's read in all the stats we need to modify
|
||||||
while($row = $sql -> db_Fetch())
|
while($row = $sql->fetch())
|
||||||
{
|
{
|
||||||
if($row['log_id'] == "statUnique")
|
if($row['log_id'] == "statUnique")
|
||||||
{
|
{
|
||||||
@@ -90,20 +89,21 @@ if($sql -> db_Select("logstats", "*", $qry))
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// this must be the first time a consolidation has happened - this will only ever happen once ...
|
// this must be the first time a consolidation has happened - this will only ever happen once ...
|
||||||
$sql -> db_Insert("logstats", "0, 'statBrowser', ''");
|
$sql->insert("logstats", "0, 'statBrowser', ''");
|
||||||
$sql -> db_Insert("logstats", "0, 'statOs', ''");
|
$sql->insert("logstats", "0, 'statOs', ''");
|
||||||
$sql -> db_Insert("logstats", "0, 'statScreen', ''");
|
$sql->insert("logstats", "0, 'statScreen', ''");
|
||||||
$sql -> db_Insert("logstats", "0, 'statDomain', ''");
|
$sql->insert("logstats", "0, 'statDomain', ''");
|
||||||
$sql -> db_Insert("logstats", "0, 'statReferer', ''");
|
$sql->insert("logstats", "0, 'statReferer', ''");
|
||||||
$sql -> db_Insert("logstats", "0, 'statQuery', ''");
|
$sql->insert("logstats", "0, 'statQuery', ''");
|
||||||
$sql -> db_Insert("logstats", "0, 'statTotal', '0'");
|
$sql->insert("logstats", "0, 'statTotal', '0'");
|
||||||
$sql -> db_Insert("logstats", "0, 'statUnique', '0'");
|
$sql->insert("logstats", "0, 'statUnique', '0'");
|
||||||
$statBrowser =array();
|
|
||||||
$statOs =array();
|
$statBrowser =array();
|
||||||
$statScreen =array();
|
$statOs =array();
|
||||||
$statDomain =array();
|
$statScreen =array();
|
||||||
$statReferer =array();
|
$statDomain =array();
|
||||||
$statQuery =array();
|
$statReferer =array();
|
||||||
|
$statQuery =array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,25 +160,25 @@ foreach($searchInfo as $name => $amount)
|
|||||||
$mon_statQuery[$name] += $amount;
|
$mon_statQuery[$name] += $amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
$browser = serialize($statBrowser);
|
$browser = serialize($statBrowser);
|
||||||
$os = serialize($statOs);
|
$os = serialize($statOs);
|
||||||
$screen = serialize($statScreen);
|
$screen = serialize($statScreen);
|
||||||
$domain = serialize($statDomain);
|
$domain = serialize($statDomain);
|
||||||
$refer = serialize($statReferer);
|
$refer = serialize($statReferer);
|
||||||
$squery = serialize($statQuery);
|
$squery = serialize($statQuery);
|
||||||
|
|
||||||
$statTotal += $siteTotal;
|
$statTotal += $siteTotal;
|
||||||
$statUnique += $siteUnique;
|
$statUnique += $siteUnique;
|
||||||
|
|
||||||
// Save cumulative results - always keep track of these, even if the $pref doesn't display them
|
// Save cumulative results - always keep track of these, even if the $pref doesn't display them
|
||||||
$sql -> db_Update("logstats", "log_data='{$browser}' WHERE log_id='statBrowser'");
|
$sql->update("logstats", "log_data='{$browser}' WHERE log_id='statBrowser'");
|
||||||
$sql -> db_Update("logstats", "log_data='{$os}' WHERE log_id='statOs'");
|
$sql->update("logstats", "log_data='{$os}' WHERE log_id='statOs'");
|
||||||
$sql -> db_Update("logstats", "log_data='{$screen}' WHERE log_id='statScreen'");
|
$sql->update("logstats", "log_data='{$screen}' WHERE log_id='statScreen'");
|
||||||
$sql -> db_Update("logstats", "log_data='{$domain}' WHERE log_id='statDomain'");
|
$sql->update("logstats", "log_data='{$domain}' WHERE log_id='statDomain'");
|
||||||
$sql -> db_Update("logstats", "log_data='{$refer}' WHERE log_id='statReferer'");
|
$sql->update("logstats", "log_data='{$refer}' WHERE log_id='statReferer'");
|
||||||
$sql -> db_Update("logstats", "log_data='{$squery}' WHERE log_id='statQuery'");
|
$sql->update("logstats", "log_data='{$squery}' WHERE log_id='statQuery'");
|
||||||
$sql -> db_Update("logstats", "log_data='".intval($statTotal)."' WHERE log_id='statTotal'");
|
$sql->update("logstats", "log_data='".intval($statTotal)."' WHERE log_id='statTotal'");
|
||||||
$sql -> db_Update("logstats", "log_data='".intval($statUnique)."' WHERE log_id='statUnique'");
|
$sql->update("logstats", "log_data='".intval($statUnique)."' WHERE log_id='statUnique'");
|
||||||
|
|
||||||
|
|
||||||
// Now save the relevant monthly results - only where enabled
|
// Now save the relevant monthly results - only where enabled
|
||||||
@@ -189,9 +189,10 @@ foreach ($stats_list as $s)
|
|||||||
$srcvar = 'mon_'.$s;
|
$srcvar = 'mon_'.$s;
|
||||||
$destvar = 'smon_'.$s;
|
$destvar = 'smon_'.$s;
|
||||||
$$destvar = serialize($$srcvar);
|
$$destvar = serialize($$srcvar);
|
||||||
if (!$sql -> db_Update("logstats", "log_data='".$$destvar."' WHERE log_id='".$s.":".$date3."'"))
|
|
||||||
|
if (!$sql->update("logstats", "log_data='".$$destvar."' WHERE log_id='".$s.":".$date3."'"))
|
||||||
{
|
{
|
||||||
$sql -> db_Insert("logstats", "0, '".$s.":".$date3."', '".$$destvar."'");
|
$sql->insert("logstats", "0, '".$s.":".$date3."', '".$$destvar."'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,9 +200,9 @@ foreach ($stats_list as $s)
|
|||||||
|
|
||||||
|
|
||||||
/* get page access monthly info from db */
|
/* get page access monthly info from db */
|
||||||
if($sql -> db_Select("logstats", "*", "log_id='{$date3}' "))
|
if($sql->select("logstats", "*", "log_id='{$date3}' "))
|
||||||
{
|
{
|
||||||
$tmp = $sql -> db_Fetch();
|
$tmp = $sql->fetch();
|
||||||
$monthlyInfo = unserialize($tmp['log_data']);
|
$monthlyInfo = unserialize($tmp['log_data']);
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
$MonthlyExistsFlag = TRUE;
|
$MonthlyExistsFlag = TRUE;
|
||||||
@@ -219,18 +220,18 @@ $monthlyinfo = serialize($monthlyInfo);
|
|||||||
|
|
||||||
if($MonthlyExistsFlag)
|
if($MonthlyExistsFlag)
|
||||||
{
|
{
|
||||||
$sql -> db_Update("logstats", "log_data='{$monthlyinfo}' WHERE log_id='{$date3}'");
|
$sql->update("logstats", "log_data='{$monthlyinfo}' WHERE log_id='{$date3}'");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql->db_Insert("logstats", "0, '{$date3}', '{$monthlyinfo}'");
|
$sql->insert("logstats", "0, '{$date3}', '{$monthlyinfo}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* collate page total information */
|
/* collate page total information */
|
||||||
if($sql -> db_Select("logstats", "*", "log_id='pageTotal' "))
|
if($sql->select("logstats", "*", "log_id='pageTotal' "))
|
||||||
{
|
{
|
||||||
$tmp = $sql -> db_Fetch();
|
$tmp = $sql->fetch();
|
||||||
$pageTotal = unserialize($tmp['log_data']);
|
$pageTotal = unserialize($tmp['log_data']);
|
||||||
unset($tmp);
|
unset($tmp);
|
||||||
}
|
}
|
||||||
@@ -248,9 +249,9 @@ foreach($pageInfo as $key => $info)
|
|||||||
|
|
||||||
$pagetotal = serialize($pageTotal);
|
$pagetotal = serialize($pageTotal);
|
||||||
|
|
||||||
if(!$sql -> db_Update("logstats", "log_data='{$pagetotal}' WHERE log_id='pageTotal' "))
|
if(!$sql->update("logstats", "log_data='{$pagetotal}' WHERE log_id='pageTotal' "))
|
||||||
{
|
{
|
||||||
$sql -> db_Insert("logstats", "0, 'pageTotal', '{$pagetotal}' ");
|
$sql->insert("logstats", "0, 'pageTotal', '{$pagetotal}' ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ foreach($pageInfo as $key => $value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = $dailytotal.chr(1).$uniquetotal.chr(1) . $data;
|
$data = $dailytotal.chr(1).$uniquetotal.chr(1) . $data;
|
||||||
$sql -> db_Insert("logstats", "0, '$date2', '".$tp -> toDB($data, true)."'");
|
$sql->insert("logstats", "0, '$date2', '".$tp -> toDB($data, true)."'");
|
||||||
|
|
||||||
|
|
||||||
/* ok, we're finished with the log file now, we can empty it ... */
|
/* ok, we're finished with the log file now, we can empty it ... */
|
||||||
|
@@ -17,11 +17,12 @@ if (!defined('e107_INIT')) { exit; }
|
|||||||
|
|
||||||
if (vartrue($pref['statActivate']))
|
if (vartrue($pref['statActivate']))
|
||||||
{
|
{
|
||||||
if(!$pref['statCountAdmin'] && ADMIN)
|
|
||||||
|
if(!$pref['statCountAdmin'] && ADMIN) // don't count admin visits
|
||||||
{
|
{
|
||||||
/* don't count admin visits */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page to log here
|
// Page to log here
|
||||||
|
|
||||||
if(USER_AREA)
|
if(USER_AREA)
|
||||||
@@ -34,6 +35,7 @@ if (vartrue($pref['statActivate']))
|
|||||||
if (is_numeric(e_QUERY)) $err_flag .= '/'.substr(e_QUERY,0,10); // This should pick up the error code - and limit numeric length to upset the malicious
|
if (is_numeric(e_QUERY)) $err_flag .= '/'.substr(e_QUERY,0,10); // This should pick up the error code - and limit numeric length to upset the malicious
|
||||||
$err_flag .= "&err_referer=".$_SERVER['HTTP_REFERER'];
|
$err_flag .= "&err_referer=".$_SERVER['HTTP_REFERER'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
$logJS = "
|
$logJS = "
|
||||||
@@ -107,8 +109,11 @@ $(function() {
|
|||||||
type: 'get',
|
type: 'get',
|
||||||
url: url,
|
url: url,
|
||||||
data: {'lv' :logString},
|
data: {'lv' :logString},
|
||||||
success: function() {
|
success: function(e) {
|
||||||
//alert(logString);
|
if(e)
|
||||||
|
{
|
||||||
|
alert(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -118,8 +123,7 @@ $(function() {
|
|||||||
|
|
||||||
if(USER_AREA)
|
if(USER_AREA)
|
||||||
{
|
{
|
||||||
$e107 = e107::getInstance();
|
e107::js('footer-inline', $logJS, 'jquery');
|
||||||
$e107->getJs()->headerInline($logJS, 5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,15 +2,12 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright 2001-2010 e107 Inc (e107.org)
|
* Copyright 2001-2013 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* Site access logging - 'receiver'
|
* Site access logging - 'receiver'
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* File to log page accesses - called with
|
/* File to log page accesses - called with
|
||||||
@@ -26,13 +23,22 @@
|
|||||||
// Normally the file is 'silent' - if any errors occur, any error message appears in the page header.
|
// Normally the file is 'silent' - if any errors occur, any error message appears in the page header.
|
||||||
*/
|
*/
|
||||||
//error_reporting(0);
|
//error_reporting(0);
|
||||||
error_reporting(E_ALL);
|
// error_reporting(E_ALL);
|
||||||
|
define('e_MINIMAL',true);
|
||||||
|
require_once("../../class2.php"); // More secure to include it.
|
||||||
|
header('Cache-Control: no-cache, must-revalidate'); // See if this discourages browser caching
|
||||||
|
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
||||||
|
|
||||||
|
if (!vartrue($pref['statActivate']))
|
||||||
|
{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up path to log files.
|
* Set up path to log files.
|
||||||
* The log file directory contains a flag file which defines whether logging is enabled.
|
* The log file directory contains a flag file which defines whether logging is enabled.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
function setLogPath()
|
function setLogPath()
|
||||||
{
|
{
|
||||||
$siteRoot = realpath(dirname(__FILE__).'./../../').'/';
|
$siteRoot = realpath(dirname(__FILE__).'./../../').'/';
|
||||||
@@ -47,10 +53,10 @@ function setLogPath()
|
|||||||
define('e_LOG', $logDir);
|
define('e_LOG', $logDir);
|
||||||
return $logEnable;
|
return $logEnable;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// if (!setLogPath()) exit(); // Could be logging disabled, missing files, all sorts of things. Just do nothing.
|
||||||
if (!setLogPath()) exit(); // Could be logging disabled, missing files, all sorts of things. Just do nothing.
|
//print_r(base64_decode($_GET['lv']));
|
||||||
|
|
||||||
define('log_INIT', TRUE);
|
define('log_INIT', TRUE);
|
||||||
|
|
||||||
|
|
||||||
@@ -64,35 +70,31 @@ $pageUnique = array('page' => 1, 'content' => array('content'));
|
|||||||
//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING']));
|
//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING']));
|
||||||
$logVals = urldecode(base64_decode($_GET['lv']));
|
$logVals = urldecode(base64_decode($_GET['lv']));
|
||||||
|
|
||||||
|
$lg = e107::getAdminLog();
|
||||||
//file_put_contents(e_LOG."test.log",print_r($logVals,true)); // , FILE_APPEND | LOCK_EX
|
$lg->addDebug(print_r($logVals, true));
|
||||||
|
$lg->toFile('SiteStats','Statistics Log', true);
|
||||||
|
|
||||||
parse_str($logVals, $vals);
|
parse_str($logVals, $vals);
|
||||||
|
|
||||||
// We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1:
|
// We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1:
|
||||||
// @todo may be able to remove this check once minimum PHP version finalised
|
// @todo may be able to remove this check once minimum PHP version finalised
|
||||||
if (function_exists('date_default_timezone_get'))
|
if (function_exists('date_default_timezone_get'))
|
||||||
{
|
{
|
||||||
// Just set a default - it should default to UTC if no timezone set
|
date_default_timezone_set(@date_default_timezone_get()); // Just set a default - it should default to UTC if no timezone set
|
||||||
date_default_timezone_set(@date_default_timezone_get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
header('Cache-Control: no-cache, must-revalidate'); // See if this discourages browser caching
|
|
||||||
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
|
|
||||||
|
|
||||||
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logVals."\n"); fclose($logfp);
|
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logVals."\n"); fclose($logfp);
|
||||||
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, print_r($vals, TRUE)."\n"); fclose($logfp);
|
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, print_r($vals, TRUE)."\n"); fclose($logfp);
|
||||||
|
|
||||||
$colour = strip_tags((isset($vals['colour']) ? $vals['colour'] : ''));
|
$colour = strip_tags((isset($vals['colour']) ? $vals['colour'] : ''));
|
||||||
$res = strip_tags((isset($vals['res']) ? $vals['res'] : ''));
|
$res = strip_tags((isset($vals['res']) ? $vals['res'] : ''));
|
||||||
$self = strip_tags((isset($vals['eself']) ? $vals['eself'] : ''));
|
$self = strip_tags((isset($vals['eself']) ? $vals['eself'] : ''));
|
||||||
$ref = addslashes(strip_tags((isset($vals['referer']) ? $vals['referer'] : '')));
|
$ref = addslashes(strip_tags((isset($vals['referer']) ? $vals['referer'] : '')));
|
||||||
$logQry = isset($vals['qry']) && $vals['qry'];
|
$logQry = isset($vals['qry']) && $vals['qry'];
|
||||||
|
$date = date('z.Y', time());
|
||||||
$date = date('z.Y', time());
|
$logPfile = e_LOG.'logp_'.$date.'.php';
|
||||||
$logPfile = e_LOG.'logp_'.$date.'.php';
|
|
||||||
|
|
||||||
//$logString = "Colour: {$colour} Res: {$res} Self: {$self} Referrer: {$ref} ErrCode: {$vals['err_direct']}\n";
|
//$logString = "Colour: {$colour} Res: {$res} Self: {$self} Referrer: {$ref} ErrCode: {$vals['err_direct']}\n";
|
||||||
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logString); fclose($logfp);
|
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logString); fclose($logfp);
|
||||||
@@ -171,16 +173,19 @@ $p_handle = fopen($logPfile, 'r+');
|
|||||||
if($p_handle && flock( $p_handle, LOCK_EX ) )
|
if($p_handle && flock( $p_handle, LOCK_EX ) )
|
||||||
{
|
{
|
||||||
$log_file_contents = '';
|
$log_file_contents = '';
|
||||||
while (!feof($p_handle))
|
while (!feof($p_handle)) // Assemble a string of data
|
||||||
{ // Assemble a string of data
|
{
|
||||||
$log_file_contents.= fgets($p_handle,1000);
|
$log_file_contents.= fgets($p_handle,1000);
|
||||||
}
|
}
|
||||||
$log_file_contents = str_replace(array('<'.'?php','?'.'>'),'',$log_file_contents);
|
$log_file_contents = str_replace(array('<'.'?php','?'.'>'),'',$log_file_contents);
|
||||||
if (eval($log_file_contents) === FALSE) echo "error in log file contents<br /><br /><br /><br />";
|
if (eval($log_file_contents) === FALSE && getperms('0'))
|
||||||
|
{
|
||||||
|
echo "Error in log file contents: ".$logPfile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
elseif(getperms('0'))
|
||||||
{
|
{
|
||||||
echo "Couldn't log data<br /><br /><br /><br />";
|
echo "Couldn't log data to: ".$logPfile; // returned to js popup.
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +241,7 @@ if ($p_handle)
|
|||||||
|
|
||||||
|
|
||||||
// Get current IP address - return as a hex-encoded string
|
// Get current IP address - return as a hex-encoded string
|
||||||
|
/*
|
||||||
function getip()
|
function getip()
|
||||||
{
|
{
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
@@ -293,6 +299,6 @@ function getip()
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
@@ -713,7 +713,7 @@ class siteStats
|
|||||||
$this -> fileRecent = vartrue($visitInfo);
|
$this -> fileRecent = vartrue($visitInfo);
|
||||||
|
|
||||||
/* get main stat info from database */
|
/* get main stat info from database */
|
||||||
if($sql -> db_Select('logstats', 'log_data', "log_id='pageTotal'"))
|
if($sql->select('logstats', 'log_data', "log_id='pageTotal'"))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$this -> dbPageInfo = unserialize($row['log_data']);
|
$this -> dbPageInfo = unserialize($row['log_data']);
|
||||||
@@ -881,7 +881,7 @@ class siteStats
|
|||||||
$sql = e107::getDB();
|
$sql = e107::getDB();
|
||||||
|
|
||||||
$text = '';
|
$text = '';
|
||||||
$sql -> db_Select("logstats", "*", "log_id='pageTotal' ");
|
$sql->select("logstats", "*", "log_id='pageTotal' ");
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$pageTotal = unserialize($row['log_data']);
|
$pageTotal = unserialize($row['log_data']);
|
||||||
$total = 0;
|
$total = 0;
|
||||||
@@ -917,8 +917,12 @@ class siteStats
|
|||||||
<col style='width: 10%;' />
|
<col style='width: 10%;' />
|
||||||
<col style='width: 10%;' />
|
<col style='width: 10%;' />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr>\n<td class='fcaption' >".ADSTAT_L19."</td>\n
|
<tr>
|
||||||
<td class='fcaption' colspan='2'>".ADSTAT_L23."</td>\n<td class='fcaption' style='text-align: center;'>%</td>\n</tr>\n";
|
<th class='fcaption' >".ADSTAT_L19."</th>\n
|
||||||
|
<th class='fcaption' colspan='2'>".ADSTAT_L23."</th>
|
||||||
|
<th class='fcaption' style='text-align: center;'>%</th>
|
||||||
|
</tr>\n";
|
||||||
|
|
||||||
foreach($totalArray as $key => $info)
|
foreach($totalArray as $key => $info)
|
||||||
{
|
{
|
||||||
if($info['ttlv'])
|
if($info['ttlv'])
|
||||||
@@ -1134,7 +1138,7 @@ class siteStats
|
|||||||
$pars = make_bits('statOs',$act); // Get the query, plus maybe date for heading
|
$pars = make_bits('statOs',$act); // Get the query, plus maybe date for heading
|
||||||
if (!is_array($pars)) return $pars; // Return error if necessary
|
if (!is_array($pars)) return $pars; // Return error if necessary
|
||||||
|
|
||||||
if ($entries = $sql -> db_Select("logstats", "*", $pars['query']))
|
if ($entries = $sql->select("logstats", "*", $pars['query']))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$statOs = unserialize($row['log_data']);
|
$statOs = unserialize($row['log_data']);
|
||||||
@@ -1267,7 +1271,7 @@ class siteStats
|
|||||||
$pars = make_bits('statDomain',$act); // Get the query, plus maybe date for heading
|
$pars = make_bits('statDomain',$act); // Get the query, plus maybe date for heading
|
||||||
if (!is_array($pars)) return $pars; // Return error if necessary
|
if (!is_array($pars)) return $pars; // Return error if necessary
|
||||||
|
|
||||||
if ($entries = $sql -> db_Select('logstats', 'log_data', $pars['query']))
|
if ($entries = $sql->select('logstats', 'log_data', $pars['query']))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$statDom = unserialize($row['log_data']);
|
$statDom = unserialize($row['log_data']);
|
||||||
@@ -1456,7 +1460,7 @@ class siteStats
|
|||||||
$pars = make_bits('statReferer',$act); // Get the query, plus maybe date for heading
|
$pars = make_bits('statReferer',$act); // Get the query, plus maybe date for heading
|
||||||
if (!is_array($pars)) return $pars; // Return error if necessary
|
if (!is_array($pars)) return $pars; // Return error if necessary
|
||||||
|
|
||||||
if ($entries = $sql -> db_Select('logstats', 'log_data', $pars['query']))
|
if ($entries = $sql->select('logstats', 'log_data', $pars['query']))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$statRefer = unserialize($row['log_data']);
|
$statRefer = unserialize($row['log_data']);
|
||||||
@@ -1550,7 +1554,7 @@ class siteStats
|
|||||||
$pars = make_bits('statQuery',$act); // Get the query, plus maybe date for heading
|
$pars = make_bits('statQuery',$act); // Get the query, plus maybe date for heading
|
||||||
if (!is_array($pars)) return $pars; // Return error if necessary
|
if (!is_array($pars)) return $pars; // Return error if necessary
|
||||||
|
|
||||||
if ($entries = $sql -> db_Select("logstats", "*", $pars['query']))
|
if ($entries = $sql->select("logstats", "*", $pars['query']))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$statQuery = unserialize($row['log_data']);
|
$statQuery = unserialize($row['log_data']);
|
||||||
@@ -1631,8 +1635,8 @@ class siteStats
|
|||||||
$text = "
|
$text = "
|
||||||
<table class='table table-striped fborder' style='width: 100%;'>
|
<table class='table table-striped fborder' style='width: 100%;'>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='fcaption' style='width: 30%;'>".ADSTAT_L18."</td>
|
<th class='fcaption' style='width: 30%;'>".ADSTAT_L18."</th>
|
||||||
<td class='fcaption' style='width: 70%;'>Information</td>
|
<th class='fcaption' style='width: 70%;'>Information</th>
|
||||||
</tr>\n";
|
</tr>\n";
|
||||||
|
|
||||||
foreach($recentArray as $key => $info)
|
foreach($recentArray as $key => $info)
|
||||||
@@ -1683,7 +1687,7 @@ class siteStats
|
|||||||
DESC LIMIT 0,14
|
DESC LIMIT 0,14
|
||||||
";
|
";
|
||||||
|
|
||||||
if($amount = $sql -> db_Select_gen($qry))
|
if($amount = $sql->gen($qry))
|
||||||
{
|
{
|
||||||
$array = $sql -> db_getList();
|
$array = $sql -> db_getList();
|
||||||
|
|
||||||
@@ -1847,7 +1851,7 @@ class siteStats
|
|||||||
$sql = e107::getDB();
|
$sql = e107::getDB();
|
||||||
|
|
||||||
// Month format entries have log_id = yyyy-mm
|
// Month format entries have log_id = yyyy-mm
|
||||||
if(!$entries = $sql -> db_Select("logstats", "*", "log_id REGEXP('^[[:digit:]]+\-[[:digit:]]+$') ORDER BY CONCAT(LEFT(log_id,4), RIGHT(log_id,2)) DESC"))
|
if(!$entries = $sql->select("logstats", "*", "log_id REGEXP('^[[:digit:]]+\-[[:digit:]]+$') ORDER BY CONCAT(LEFT(log_id,4), RIGHT(log_id,2)) DESC"))
|
||||||
{
|
{
|
||||||
return ADSTAT_L42;
|
return ADSTAT_L42;
|
||||||
}
|
}
|
||||||
@@ -1858,6 +1862,7 @@ class siteStats
|
|||||||
$monthTotal = array(); // Array of totals, one per month, with 'totalv', 'uniquev' sub-indices
|
$monthTotal = array(); // Array of totals, one per month, with 'totalv', 'uniquev' sub-indices
|
||||||
$mtotal = 0;
|
$mtotal = 0;
|
||||||
$utotal = 0;
|
$utotal = 0;
|
||||||
|
|
||||||
foreach($array as $info)
|
foreach($array as $info)
|
||||||
{
|
{
|
||||||
$date = $info['log_id'];
|
$date = $info['log_id'];
|
||||||
@@ -1891,8 +1896,8 @@ class siteStats
|
|||||||
<th class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L34."</th>
|
<th class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L34."</th>
|
||||||
</tr>\n";
|
</tr>\n";
|
||||||
|
|
||||||
foreach($monthTotal as $date => $total) {
|
foreach($monthTotal as $date => $total)
|
||||||
|
{
|
||||||
list($year, $month) = explode("-", $date);
|
list($year, $month) = explode("-", $date);
|
||||||
$date = strftime ("%B %Y", mktime (0,0,0,$month,1,$year));
|
$date = strftime ("%B %Y", mktime (0,0,0,$month,1,$year));
|
||||||
$barWidth = round(($total['totalv']/$mtotal) * 100, 2);
|
$barWidth = round(($total['totalv']/$mtotal) * 100, 2);
|
||||||
@@ -1910,7 +1915,8 @@ class siteStats
|
|||||||
<th class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L34."</th>
|
<th class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L34."</th>
|
||||||
</tr>\n";
|
</tr>\n";
|
||||||
|
|
||||||
foreach($monthTotal as $date => $total) {
|
foreach($monthTotal as $date => $total)
|
||||||
|
{
|
||||||
$barWidth = round(($total['uniquev']/$utotal) * 100, 2);
|
$barWidth = round(($total['uniquev']/$utotal) * 100, 2);
|
||||||
list($year, $month) = explode("-", $date);
|
list($year, $month) = explode("-", $date);
|
||||||
$date = strftime ("%B %Y", mktime (0,0,0,$month,1,$year));
|
$date = strftime ("%B %Y", mktime (0,0,0,$month,1,$year));
|
||||||
@@ -1997,7 +2003,7 @@ class siteStats
|
|||||||
function remove_entry($toremove)
|
function remove_entry($toremove)
|
||||||
{ // Note - only removes info from the database - not from the current page file
|
{ // Note - only removes info from the database - not from the current page file
|
||||||
$sql = e107::getDB();
|
$sql = e107::getDB();
|
||||||
if ($sql -> db_Select("logstats", "*", "log_id='pageTotal'"))
|
if ($sql->select("logstats", "*", "log_id='pageTotal'"))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
$dbPageInfo = unserialize($row[2]);
|
$dbPageInfo = unserialize($row[2]);
|
||||||
|
Reference in New Issue
Block a user