- ".$frm->admin_button('remSelP', ADSTAT_L31, 'delete')."
-
-
- ";
-
- $ns -> tablerender(ADSTAT_L32, $text);
}
//---------------------------------------------
// Remove page entries - action
//---------------------------------------------
-function rempagego()
-{
- global $sql, $admin_log;
- $sql -> db_Select("logstats", "*", "log_id='pageTotal' ");
- $row = $sql -> db_Fetch();
- $pageTotal = unserialize($row['log_data']);
- $logfile = e_LOG."logp_".date("z.Y", time()).".php";
-
-// $logfile = e_PLUGIN."log/logs/logp_".date("z.Y", time()).".php";
- if(is_readable($logfile))
- {
- require($logfile);
- }
-
- foreach($_POST['remcb'] as $page)
- {
- unset($pageInfo[$page]);
- unset($pageTotal[$page]);
- }
-
- $pagetotal = serialize($pageTotal);
- if(!$sql -> db_Update("logstats", "log_data='{$pagetotal}' WHERE log_id='pageTotal' "))
- {
- $sql -> db_Insert("logstats", "0, 'pageTotal', '{$pagetotal}' ");
- }
- e107::getLog()->add('STAT_03',ADSTAT_L80."[!br!]".implode("[!br!]",$_POST['remcb']),'');
-
- $varStart = chr(36);
- $quote = chr(34);
-
- $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n".
- $varStart."ipAddresses = ".$quote.$ipAddresses.$quote.";\n".
- $varStart."siteTotal = ".$quote.$siteTotal.$quote.";\n".
- $varStart."siteUnique = ".$quote.$siteUnique.$quote.";\n";
-
- $loop = FALSE;
- $data .= $varStart."pageInfo = array(\n";
- foreach($pageInfo as $info)
- {
- $page = preg_replace("/(\?.*)|(\_.*)|(\.php)|(\s)|(\')|(\")|(eself)|( )/", "", basename ($info['url']));
- $page = str_replace("\\", "", $page);
- $info['url'] = preg_replace("/(\s)|(\')|(\")|(eself)|( )/", "", $info['url']);
- $info['url'] = str_replace("\\", "", $info['url']);
- $page = trim($page);
- if($page && !strstr($page, "cache") && !strstr($page, "file:"))
- {
- if($loop){ $data .= ",\n"; }
- $data .= $quote.$page.$quote." => array('url' => '".$info['url']."', 'ttl' => ".$info['ttl'].", 'unq' => ".$info['unq'].")";
- $loop = 1;
- }
- }
-
- $data .= "\n);\n\n?". chr(62);
-
- if ($handle = fopen($logfile, 'w'))
- {
- fwrite($handle, $data);
- }
- fclose($handle);
-}
@@ -826,22 +1281,22 @@ function admin_config_adminmenu()
}
if (!isset($action) || ($action == "")) $action = "config";
- $var['config']['text'] = ADSTAT_L35;
+ $var['config']['text'] = ADSTAT_LAN_35;
$var['config']['link'] = 'admin_config.php';
- $var['export']['text'] = ADSTAT_L36;
+ $var['export']['text'] = ADSTAT_LAN_36;
$var['export']['link'] ='admin_config.php?export';
-// $var['datasets']['text'] = ADSTAT_L63;
+// $var['datasets']['text'] = ADSTAT_LAN_63;
// $var['datasets']['link'] ='admin_config.php?datasets';
- $var['rempage']['text'] = ADSTAT_L26;
+ $var['rempage']['text'] = ADSTAT_LAN_26;
$var['rempage']['link'] ='admin_config.php?rempage';
- $var['history']['text'] = ADSTAT_L69;
+ $var['history']['text'] = ADSTAT_LAN_69;
$var['history']['link'] ='admin_config.php?history';
- show_admin_menu(ADSTAT_L39, $action, $var);
+ show_admin_menu(ADSTAT_LAN_39, $action, $var);
}
diff --git a/e107_plugins/log/consolidate.php b/e107_plugins/log/consolidate.php
index 858a549b5..993ab9968 100644
--- a/e107_plugins/log/consolidate.php
+++ b/e107_plugins/log/consolidate.php
@@ -14,35 +14,291 @@
if (!defined('e107_INIT')){ exit; }
-$pathtologs = e_LOG;
-$date = date("z.Y", time());
-$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
-$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
-$pfile = "logp_".$date.".php"; // Today's log file
-$ifileprev = "logi_".$yesterday.".php";
-$ifile = "logi_".$date.".php";
// Begin v2.x cleanup.
class logConsolidate
{
- function ___construct()
- {
+ protected $pathtologs;
+ protected $date;
+ protected $yesterday;
+ protected $date2;
+ protected $date3;
+ protected $pfileprev;
+ protected $pfile;
+ protected $ifileprev;
+ protected $ifile;
+
+
+ function __construct()
+ {
+ $this->pathtologs = e_LOG;
+ $this->date = date("z.Y", time());
+ $this->yesterday = date("z.Y",(time() - 86400)); // This makes sure year wraps round OK
+ $this->date2 = date("Y-m-j", (time() -86400)); // Yesterday's date for the database summary
+ $this->date3 = date("Y-m", (time() -86400)); // Current month's date for monthly summary (we're working with yesterday's data)
+
+ $this->pfileprev = "logp_".$this->yesterday.".php"; // Yesterday's log file
+ $this->pfile = "logp_".$this->date.".php"; // Today's log file
+ $this->ifileprev = "logi_".$this->yesterday.".php";
+ $this->ifile = "logi_".$this->date.".php";
}
- function createLog($pathtologs, $statTotal='', $statUnique='')
- {
- global $pfile, $ifile;
- if(!is_writable($pathtologs))
+ function run()
+ {
+
+ $sql = e107::getDb();
+ $pref = e107::pref('core');
+
+ $pageInfo = array();
+ $domainInfo = array();
+ $screenInfo = array();
+ $browserInfo = array();
+ $osInfo = array();
+ $refInfo = array();
+ $searchInfo = array();
+
+ $monthlyInfo = array();
+ $mon_statBrowser = array();
+ $mon_statOs = array();
+ $mon_statScreen = array();
+ $mon_statDomain = array();
+ $mon_statQuery = array();
+ $statBrowser = array();
+ $statOs = array();
+ $statScreen = array();
+ $statDomain = array();
+ $statQuery = array();
+ $statReferer = array();
+
+ $statTotal = 0;
+ $statUnique = 0;
+ $siteTotal = 0;
+ $siteUnique = 0;
+
+ $MonthlyExistsFlag = false;
+
+ if(file_exists($this->pathtologs.$this->pfile)) /* log file is up to date, no consolidation required */
{
- echo "Log directory is not writable - please CHMOD ".e_LOG." to 777";
- echo '
Path to logs: '.$pathtologs;
- return FALSE;
+ return false;
+ }
+ else if(!file_exists($this->pathtologs.$this->pfileprev)) // See if any older log files
+ {
+ if (($retvalue = $this->check_for_old_files($this->pathtologs)) === false) /* no logfile found at all - create - this will only ever happen once ... */
+ {
+ $this->createLog();
+ return false;
+ }
+
+ list($this->pfileprev,$this->ifileprev,$this->date2,$tstamp) = explode('|',$retvalue); // ... if we've got files
+ }
+
+ unset($tstamp);
+
+ // List of the non-page-based info which is gathered - historically only 'all-time' stats, now we support monthly as well
+ $stats_list = array('statBrowser','statOs','statScreen','statDomain','statReferer','statQuery');
+
+ $qry = "`log_id` IN ('statTotal','statUnique'";
+ foreach ($stats_list as $s)
+ {
+ $qry .= ",'{$s}'"; // Always read the all-time stats
+ if ($pref[$s] == 2) $qry .= ",'{$s}:{$this->date3}'"; // Look for monthlys as well as cumulative
+ }
+ $qry .= ")";
+
+ /* log file is out of date - consolidation required */
+
+ /* get existing stats ... */
+ //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->select("logstats", "*", $qry))
+ { // That's read in all the stats we need to modify
+ while($row = $sql->fetch())
+ {
+ if($row['log_id'] == "statUnique")
+ {
+ $statUnique = $row['log_data'];
+ }
+ elseif ($row['log_id'] == "statTotal")
+ {
+ $statTotal = $row['log_data'];
+ }
+ elseif (($pos = strpos($row['log_id'],':')) === false)
+ { // Its all-time stats
+ $$row['log_id'] = unserialize($row['log_data']); // $row['log_id'] is the stats type - save in a variable
+ }
+ else
+ { // Its monthly stats
+ $row['log_id'] = 'mon_'.substr($row['log_id'],0,$pos); // Create a generic variable for each monthly stats
+ $$row['log_id'] = unserialize($row['log_data']); // $row['log_id'] is the stats type - save in a variable
+ }
+ }
+ }
+ else
+ {
+ // this must be the first time a consolidation has happened - this will only ever happen once ...
+ $sql->insert("logstats", "0, 'statBrowser', ''");
+ $sql->insert("logstats", "0, 'statOs', ''");
+ $sql->insert("logstats", "0, 'statScreen', ''");
+ $sql->insert("logstats", "0, 'statDomain', ''");
+ $sql->insert("logstats", "0, 'statReferer', ''");
+ $sql->insert("logstats", "0, 'statQuery', ''");
+ $sql->insert("logstats", "0, 'statTotal', '0'");
+ $sql->insert("logstats", "0, 'statUnique', '0'");
+
+ $statBrowser =array();
+ $statOs =array();
+ $statScreen =array();
+ $statDomain =array();
+ $statReferer =array();
+ $statQuery =array();
+ }
+
+
+ foreach ($stats_list as $s)
+ {
+ $varname = 'mon_'.$s;
+ if (!isset($$varname)) $$varname = array(); // Create monthly arrays if they don't exist
+ }
+
+ require($this->pathtologs.$this->pfileprev); // Yesterday's page accesses - $pageInfo array
+ require($this->pathtologs.$this->ifileprev); // Yesterdays browser accesses etc
+
+ foreach($browserInfo as $name => $amount)
+ {
+ $statBrowser[$name] += $amount;
+ $mon_statBrowser[$name] += $amount;
+ }
+
+ foreach($osInfo as $name => $amount)
+ {
+ $statOs[$name] += $amount;
+ $mon_statOs[$name] += $amount;
+ }
+
+ foreach($screenInfo as $name => $amount)
+ {
+ $statScreen[$name] += $amount;
+ $mon_statScreen[$name] += $amount;
+ }
+
+
+ foreach($domainInfo as $name => $amount)
+ {
+ if(!is_numeric($name))
+ {
+ $statDomain[$name] += $amount;
+ $mon_statDomain[$name] += $amount;
+ }
+ }
+
+ foreach($refInfo as $name => $info)
+ {
+ $statReferer[$name]['url'] = $info['url'];
+ $statReferer[$name]['ttl'] += $info['ttl'];
+ $mon_statReferer[$name]['url'] = $info['url'];
+ $mon_statReferer[$name]['ttl'] += $info['ttl'];
+ }
+
+
+ foreach($searchInfo as $name => $amount)
+ {
+ $statQuery[$name] += $amount;
+ $mon_statQuery[$name] += $amount;
+ }
+
+ $browser = serialize($statBrowser);
+ $os = serialize($statOs);
+ $screen = serialize($statScreen);
+ $domain = serialize($statDomain);
+ $refer = serialize($statReferer);
+ $squery = serialize($statQuery);
+
+ $statTotal += $siteTotal;
+ $statUnique += $siteUnique;
+
+ // Save cumulative results - always keep track of these, even if the $pref doesn't display them
+ $sql->update("logstats", "log_data='{$browser}' WHERE log_id='statBrowser'");
+ $sql->update("logstats", "log_data='{$os}' WHERE log_id='statOs'");
+ $sql->update("logstats", "log_data='{$screen}' WHERE log_id='statScreen'");
+ $sql->update("logstats", "log_data='{$domain}' WHERE log_id='statDomain'");
+ $sql->update("logstats", "log_data='{$refer}' WHERE log_id='statReferer'");
+ $sql->update("logstats", "log_data='{$squery}' WHERE log_id='statQuery'");
+ $sql->update("logstats", "log_data='".intval($statTotal)."' WHERE log_id='statTotal'");
+ $sql->update("logstats", "log_data='".intval($statUnique)."' WHERE log_id='statUnique'");
+
+
+ // Now save the relevant monthly results - only where enabled
+ foreach ($stats_list as $s)
+ {
+ if (isset($pref[$s]) && ($pref[$s] > 1))
+ { // Value 2 requires saving of monthly stats
+ $srcvar = 'mon_'.$s;
+ $destvar = 'smon_'.$s;
+ $$destvar = serialize($$srcvar);
+
+ if (!$sql->update("logstats", "log_data='".$$destvar."' WHERE log_id='".$s.":".$this->date3."'"))
+ {
+ $sql->insert("logstats", "0, '".$s.":".$this->date3."', '".$$destvar."'");
+ }
+ }
+ }
+
+
+ /* get page access monthly info from db */
+ if($sql->select("logstats", "*", "log_id='{$this->date3}' "))
+ {
+ $tmp = $sql->fetch();
+ $monthlyInfo = unserialize($tmp['log_data']);
+ unset($tmp);
+ $MonthlyExistsFlag = TRUE;
+ }
+
+ foreach($pageInfo as $key => $info)
+ {
+ $monthlyInfo['TOTAL']['ttlv'] += $info['ttl'];
+ $monthlyInfo['TOTAL']['unqv'] += $info['unq'];
+ $monthlyInfo[$key]['ttlv'] += $info['ttl'];
+ $monthlyInfo[$key]['unqv'] += $info['unq'];
+ }
+
+ $monthlyinfo = serialize($monthlyInfo);
+
+ if($MonthlyExistsFlag)
+ {
+ $sql->update("logstats", "log_data='{$monthlyinfo}' WHERE log_id='{$this->date3}'");
+ }
+ else
+ {
+ $sql->insert("logstats", "0, '{$this->date3}', '{$monthlyinfo}'");
+ }
+
+
+ $this->collatePageTotal($pageInfo);
+ $this->collatePageInfo($pageInfo, $this->date2);
+ $this->resetLogFiles();
+
+ /* and finally, we need to create new logfiles for today ... */
+ $this->createLog();
+
+ return true;
+ }
+
+
+
+
+ function createLog()
+ {
+
+ if(!is_writable($this->pathtologs))
+ {
+ echo "
Log directory is not writable - please CHMOD ".e_LOG." to 777";
+ echo '
Path to logs: '.$this->pathtologs;
+ echo "
";
+
+ return false;
}
$varStart = chr(36);
@@ -61,37 +317,42 @@ class logConsolidate
$data .= "\n);\n\n?". chr(62);
- if(!touch($pathtologs.$pfile)) {
- return FALSE;
+ if(!touch($this->pathtologs.$this->pfile))
+ {
+ return false;
}
- if(!touch($pathtologs.$ifile)) {
- return FALSE;
+ if(!touch($this->pathtologs.$this->ifile))
+ {
+ return false;
}
- if(!is_writable($pathtologs.$pfile)) {
+ if(!is_writable($this->pathtologs.$this->pfile))
+ {
$old = umask(0);
- chmod($pathtologs.$pfile, 0777);
+ chmod($this->pathtologs.$this->pfile, 0777);
umask($old);
- // return FALSE;
+ // return false;
}
- if(!is_writable($pathtologs.$ifile)) {
+ if(!is_writable($this->pathtologs.$this->ifile))
+ {
$old = umask(0);
- chmod($pathtologs.$ifile, 0777);
+ chmod($this->pathtologs.$this->ifile, 0777);
umask($old);
- // return FALSE;
+ // return false;
}
- if ($handle = fopen($pathtologs.$pfile, 'w'))
+ if ($handle = fopen($this->pathtologs.$this->pfile, 'w'))
{
fwrite($handle, $data);
}
+
fclose($handle);
- $data = "";
- if ($handle = fopen($pathtologs.$ifile, 'w'))
+ if ($handle = fopen($this->pathtologs.$this->ifile, 'w'))
{
fwrite($handle, $data);
}
fclose($handle);
- return;
+
+ return true;
}
@@ -117,14 +379,14 @@ class logConsolidate
/**
* Called if both today's and yesterday's log files missing, to see
- * if there are any older files we could process. Return FALSE if nothing
+ * if there are any older files we could process. Return false if nothing
* Otherwise return a string of relevant information
* @param $pathtologs
* @return bool|string
*/
function check_for_old_files($pathtologs)
{
- $no_files = TRUE;
+ // $no_files = TRUE;
if ($dir_handle = opendir($pathtologs))
{
while (false !== ($file = readdir($dir_handle)))
@@ -143,7 +405,7 @@ class logConsolidate
}
}
}
- return FALSE;
+ return false;
}
@@ -178,7 +440,7 @@ class logConsolidate
{
$pageDisallow = "cache|file|eself|admin";
$tagRemove = "(\\\)|(\s)|(\')|(\")|(eself)|( )|(\.php)|(\.html)";
- $tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|( )";
+ // $tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|( )";
preg_match("#/(.*?)(\?|$)(.*)#si", $url, $match);
$match[1] = isset($match[1]) ? $match[1] : '';
@@ -203,6 +465,9 @@ class logConsolidate
$pageName = $err_code.$pageName; // Add the error code at the beginning, so its treated uniquely
+ // filter out any non-utf8 characters which could halt processing.
+ $pageName = urldecode($pageName);
+ $pageName = iconv('UTF-8', 'ASCII//IGNORE', $pageName);
return $pageName;
}
@@ -212,20 +477,26 @@ class logConsolidate
* Process Raw Backup Log File. e. e_LOG."log/2015-09-24_SiteStats.log
* This method can be used in the case of a database corruption to restore stats to the database.
* @param string $file
+ * @param bool $savetoDB
+ * @return bool
* @example processRawBackupLog('2015-09-24_SiteStats.log', false);
*/
function processRawBackupLog($file, $savetoDB=false)
{
$path = e_LOG."log/".$file;
+ $mes = e107::getMessage();
+
if(!is_readable($path))
{
+ $mes->addError( "File Not Found: ".$path);
return false;
}
$handle = fopen($path, "r");
$pageTotal = array();
+ $line = 0;
if ($handle)
{
@@ -233,15 +504,28 @@ class logConsolidate
{
if($vars = $this->splitRawBackupLine($buffer))
{
+
+ if(substr($vars['eself'],0,7) == 'file://')
+ {
+ continue;
+ }
+
$key = $this->getPageKey($vars['eself']);
+ if(empty($key))
+ {
+ continue;
+ }
+
+ if(!isset($pageTotal[$key]))
+ {
+ $pageTotal[$key] = array('url'=>'', 'ttl'=>0, 'unq'=>0);
+ }
+
$pageTotal[$key]['url'] = $vars['eself'];
$pageTotal[$key]['ttl'] += 1;
- if(!isset($pageTotal[$key]['unq']))
- {
- $pageTotal[$key]['unq'] = 0;
- }
+ // echo "\n
line: ".$line." ------- ".$key;
if(isset($vars['unique']))
{
@@ -255,22 +539,28 @@ class logConsolidate
$pageTotal[$key]['unq'] += 1;
}
}
+
+ $line++;
}
if (!feof($handle))
{
- echo "Error: unexpected fgets() fail\n";
+ $mes->addError( "Error: unexpected fgets() fail.");
}
fclose($handle);
- echo "
".$file."
";
- print_a($pageTotal);
+
+ if(e_DEBUG)
+ {
+ $mes->addDebug("
".$file."
");
+ $mes->addDebug(print_a($pageTotal,true));
+ }
}
if($savetoDB === false)
{
- echo "Saving mode is off";
+ $mes->addInfo( "Saving mode is off");
return true;
}
@@ -279,6 +569,8 @@ class logConsolidate
{
list($date,$name) = explode("_", $file, 2);
+ unset($name);
+
$unix = strtotime($date);
$datestamp = date("Y-m-j", $unix);
@@ -289,20 +581,22 @@ class logConsolidate
if($sql->select('logstats','log_id',"log_id='".$datestamp."' "))
{
- $sql->update('logstats', "log_id='".$datestamp."-bak' WHERE log_id='".$datestamp."' ");
+ $sql->update('logstats', "log_id='bak-".$datestamp."' WHERE log_id='".$datestamp."' ");
}
if($this->collatePageInfo($pageTotal, $datestamp))
{
- echo "
Data saved to database with id: ".$datestamp;
+ $mes->addSuccess( "Data saved to database with id: ".$datestamp);
}
else
{
- echo "
Couldn't save data to database with id: ".$datestamp;
+ $mes->addError( "Couldn't save data to database with id: ".$datestamp);
}
}
}
+
+ return true;
}
@@ -318,6 +612,8 @@ class logConsolidate
return $vars;
}
+ unset($datestamp, $bla); // remove editor warnings.
+
return false;
}
@@ -329,7 +625,7 @@ class logConsolidate
{
$sql = e107::getDb();
- $qry = "SELECT * FROM `#logstats` WHERE `log_id` REGEXP '^[0-9]' AND `log_data` LIKE '%http%'";
+ $qry = "SELECT * FROM `#logstats` WHERE `log_id` REGEXP '^[0-9]' AND LENGTH(log_id) > 7 AND `log_data` LIKE '%http%'";
$data = $sql->retrieve($qry,true);
$pageTotal = array();
@@ -474,19 +770,17 @@ class logConsolidate
function resetLogFiles()
{
- global $pathtologs, $pfileprev, $ifileprev;
-
- if(empty($pfileprev) || empty($ifileprev))
+ if(empty($this->pfileprev) || empty($this->ifileprev))
{
return false;
}
/* ok, we're finished with the log file now, we can empty it ... */
- if(!unlink($pathtologs.$pfileprev))
+ if(!unlink($this->pathtologs.$this->pfileprev))
{
$data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n\n\n".chr(47)."* THE INFORMATION IN THIS LOG FILE HAS BEEN CONSOLIDATED INTO THE DATABASE - YOU CAN SAFELY DELETE IT. *". chr(47)."\n\n\n?". chr(62);
- if($handle = fopen($pathtologs.$pfileprev, 'w'))
+ if($handle = fopen($this->pathtologs.$this->pfileprev, 'w'))
{
fwrite($handle, $data);
}
@@ -495,11 +789,11 @@ class logConsolidate
}
- if(!unlink($pathtologs.$ifileprev))
+ if(!unlink($this->pathtologs.$this->ifileprev))
{
$data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n\n\n".chr(47)."* THE INFORMATION IN THIS LOG INFO FILE HAS BEEN CONSOLIDATED INTO THE DATABASE - YOU CAN SAFELY DELETE IT. *". chr(47)."\n\n\n?". chr(62);
- if($handle = fopen($pathtologs.$ifileprev, 'w'))
+ if($handle = fopen($this->pathtologs.$this->ifileprev, 'w'))
{
fwrite($handle, $data);
}
@@ -508,225 +802,14 @@ class logConsolidate
}
-
+ return true;
}
}
-$lgc = new logConsolidate();
-if(file_exists($pathtologs.$pfile)) /* log file is up to date, no consolidation required */
-{
- return;
-}
-else if(!file_exists($pathtologs.$pfileprev)) // See if any older log files
-{
- if (($retvalue = $lgc->check_for_old_files($pathtologs)) === FALSE) /* no logfile found at all - create - this will only ever happen once ... */
- {
- $lgc->createLog($pathtologs);
- return FALSE;
- }
-
- list($pfileprev,$ifileprev,$date2,$tstamp) = explode('|',$retvalue); // ... if we've got files
-}
-
-
-
-// List of the non-page-based info which is gathered - historically only 'all-time' stats, now we support monthly as well
-$stats_list = array('statBrowser','statOs','statScreen','statDomain','statReferer','statQuery');
-
-$qry = "`log_id` IN ('statTotal','statUnique'";
-foreach ($stats_list as $s)
-{
- $qry .= ",'{$s}'"; // Always read the all-time stats
- if ($pref[$s] == 2) $qry .= ",'{$s}:{$date3}'"; // Look for monthlys as well as cumulative
-}
-$qry .= ")";
-
-/* log file is out of date - consolidation required */
-
-/* get existing stats ... */
-//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->select("logstats", "*", $qry))
-{ // That's read in all the stats we need to modify
- while($row = $sql->fetch())
- {
- if($row['log_id'] == "statUnique")
- {
- $statUnique = $row['log_data'];
- }
- elseif ($row['log_id'] == "statTotal")
- {
- $statTotal = $row['log_data'];
- }
- elseif (($pos = strpos($row['log_id'],':')) === FALSE)
- { // Its all-time stats
- $$row['log_id'] = unserialize($row['log_data']); // $row['log_id'] is the stats type - save in a variable
- }
- else
- { // Its monthly stats
- $row['log_id'] = 'mon_'.substr($row['log_id'],0,$pos); // Create a generic variable for each monthly stats
- $$row['log_id'] = unserialize($row['log_data']); // $row['log_id'] is the stats type - save in a variable
- }
- }
-}
-else
-{
- // this must be the first time a consolidation has happened - this will only ever happen once ...
- $sql->insert("logstats", "0, 'statBrowser', ''");
- $sql->insert("logstats", "0, 'statOs', ''");
- $sql->insert("logstats", "0, 'statScreen', ''");
- $sql->insert("logstats", "0, 'statDomain', ''");
- $sql->insert("logstats", "0, 'statReferer', ''");
- $sql->insert("logstats", "0, 'statQuery', ''");
- $sql->insert("logstats", "0, 'statTotal', '0'");
- $sql->insert("logstats", "0, 'statUnique', '0'");
-
- $statBrowser =array();
- $statOs =array();
- $statScreen =array();
- $statDomain =array();
- $statReferer =array();
- $statQuery =array();
-}
-
-
-foreach ($stats_list as $s)
-{
- $varname = 'mon_'.$s;
- if (!isset($$varname)) $$varname = array(); // Create monthly arrays if they don't exist
-}
-
-
-require_once($pathtologs.$pfileprev); // Yesterday's page accesses - $pageInfo array
-require_once($pathtologs.$ifileprev); // Yesterdays browser accesses etc
-
-foreach($browserInfo as $name => $amount)
-{
- $statBrowser[$name] += $amount;
- $mon_statBrowser[$name] += $amount;
-}
-
-foreach($osInfo as $name => $amount)
-{
- $statOs[$name] += $amount;
- $mon_statOs[$name] += $amount;
-}
-
-foreach($screenInfo as $name => $amount)
-{
- $statScreen[$name] += $amount;
- $mon_statScreen[$name] += $amount;
-}
-
-
-foreach($domainInfo as $name => $amount)
-{
- if(!is_numeric($name))
- {
- $statDomain[$name] += $amount;
- $mon_statDomain[$name] += $amount;
- }
-}
-
-foreach($refInfo as $name => $info)
-{
- $statReferer[$name]['url'] = $info['url'];
- $statReferer[$name]['ttl'] += $info['ttl'];
- $mon_statReferer[$name]['url'] = $info['url'];
- $mon_statReferer[$name]['ttl'] += $info['ttl'];
-}
-
-
-foreach($searchInfo as $name => $amount)
-{
- $statQuery[$name] += $amount;
- $mon_statQuery[$name] += $amount;
-}
-
-$browser = serialize($statBrowser);
-$os = serialize($statOs);
-$screen = serialize($statScreen);
-$domain = serialize($statDomain);
-$refer = serialize($statReferer);
-$squery = serialize($statQuery);
-
-$statTotal += $siteTotal;
-$statUnique += $siteUnique;
-
-// Save cumulative results - always keep track of these, even if the $pref doesn't display them
-$sql->update("logstats", "log_data='{$browser}' WHERE log_id='statBrowser'");
-$sql->update("logstats", "log_data='{$os}' WHERE log_id='statOs'");
-$sql->update("logstats", "log_data='{$screen}' WHERE log_id='statScreen'");
-$sql->update("logstats", "log_data='{$domain}' WHERE log_id='statDomain'");
-$sql->update("logstats", "log_data='{$refer}' WHERE log_id='statReferer'");
-$sql->update("logstats", "log_data='{$squery}' WHERE log_id='statQuery'");
-$sql->update("logstats", "log_data='".intval($statTotal)."' WHERE log_id='statTotal'");
-$sql->update("logstats", "log_data='".intval($statUnique)."' WHERE log_id='statUnique'");
-
-
-// Now save the relevant monthly results - only where enabled
-foreach ($stats_list as $s)
-{
- if (isset($pref[$s]) && ($pref[$s] > 1))
- { // Value 2 requires saving of monthly stats
- $srcvar = 'mon_'.$s;
- $destvar = 'smon_'.$s;
- $$destvar = serialize($$srcvar);
-
- if (!$sql->update("logstats", "log_data='".$$destvar."' WHERE log_id='".$s.":".$date3."'"))
- {
- $sql->insert("logstats", "0, '".$s.":".$date3."', '".$$destvar."'");
- }
- }
-}
-
-
-
-/* get page access monthly info from db */
-if($sql->select("logstats", "*", "log_id='{$date3}' "))
-{
- $tmp = $sql->fetch();
- $monthlyInfo = unserialize($tmp['log_data']);
- unset($tmp);
- $MonthlyExistsFlag = TRUE;
-}
-
-foreach($pageInfo as $key => $info)
-{
- $monthlyInfo['TOTAL']['ttlv'] += $info['ttl'];
- $monthlyInfo['TOTAL']['unqv'] += $info['unq'];
- $monthlyInfo[$key]['ttlv'] += $info['ttl'];
- $monthlyInfo[$key]['unqv'] += $info['unq'];
-}
-
-$monthlyinfo = serialize($monthlyInfo);
-
-if($MonthlyExistsFlag)
-{
- $sql->update("logstats", "log_data='{$monthlyinfo}' WHERE log_id='{$date3}'");
-}
-else
-{
- $sql->insert("logstats", "0, '{$date3}', '{$monthlyinfo}'");
-}
-
-
-
-
-
-
-$lgc->collatePageTotal($pageInfo);
-
-$lgc->collatePageInfo($pageInfo, $date2);
-
-$lgc->resetLogFiles();
-
-
-/* and finally, we need to create new logfiles for today ... */
-$lgc->createLog($pathtologs,$statTotal,$statUnique);
diff --git a/e107_plugins/log/e_meta.php b/e107_plugins/log/e_meta.php
index cceb6a8be..342531621 100644
--- a/e107_plugins/log/e_meta.php
+++ b/e107_plugins/log/e_meta.php
@@ -27,6 +27,9 @@ if (vartrue($pref['statActivate']))
if(USER_AREA)
{
require_once(e_PLUGIN.'log/consolidate.php');
+ $lgc = new logConsolidate();
+ $lgc->run();
+
$err_flag = '';
if (defined('ERR_PAGE_ACTIVE'))
{ // We've got an error - set a flag to log it
diff --git a/e107_plugins/log/languages/English_admin.php b/e107_plugins/log/languages/English_admin.php
new file mode 100644
index 000000000..ff7395720
--- /dev/null
+++ b/e107_plugins/log/languages/English_admin.php
@@ -0,0 +1,101 @@
+
You must set the permissions of the e107_plugins/log/logs folder to 777 (chmod 777)");
+define("ADSTAT_LAN_3", "Statistic Logging");
+define("ADSTAT_LAN_4", "Activate statistic logging");
+define("ADSTAT_LAN_5", "Statistic types");
+define("ADSTAT_LAN_6", "Browsers");
+define("ADSTAT_LAN_7", "Operating Systems");
+define("ADSTAT_LAN_8", "Screen resolutions / depths");
+define("ADSTAT_LAN_9", "Countries/domains visited from");
+define("ADSTAT_LAN_10", "Referrers");
+define("ADSTAT_LAN_11", "Search queries");
+define("ADSTAT_LAN_12", "Reset stats");
+define("ADSTAT_LAN_13", "This will erase the all-time stats - careful! Deletes stats to the end of yesterday. There is a separate menu option to delete selected historical data"); // TODO: Condense this help field (minimize)
+define("ADSTAT_LAN_14", "Page counts");
+//define("ADSTAT_LAN_15", "Update Statistic Settings");
+define("ADSTAT_LAN_16", "Site Statistic Settings");
+//define("ADSTAT_LAN_17", "Statistic settings updated");
+define("ADSTAT_LAN_18", "Allow access to main statistics page to ...");
+define("ADSTAT_LAN_19", "Recent visitors");
+define("ADSTAT_LAN_20", "Count admin visits");
+define("ADSTAT_LAN_21", "Maximum records to display on stats page");
+define("ADSTAT_LAN_22", "Run update routine");
+define("ADSTAT_LAN_23", "logs from a previous version of e107 have been detected, update them here");
+define("ADSTAT_LAN_24", "Go to update script");
+//define("ADSTAT_LAN_25", "Selected stats reset");
+define("ADSTAT_LAN_26", "Remove page entries");
+define("ADSTAT_LAN_27", "If your stats have incorrect pages, you can remove them here");
+define("ADSTAT_LAN_28", "Open page");
+define("ADSTAT_LAN_29", "Page Name");
+define("ADSTAT_LAN_30", "Check to remove");
+define("ADSTAT_LAN_31", "Remove selected pages");
+define("ADSTAT_LAN_32", "Page Tidy");
+// define("ADSTAT_LAN_33", "Configure Statistics Logging"); see English_global.php
+// define("ADSTAT_LAN_34", "Site Stats");
+define ('ADSTAT_LAN_35', 'Options');
+define ('ADSTAT_LAN_36', 'Data Export');
+//define ('ADSTAT_LAN_37', 'Create export file');
+define ('ADSTAT_LAN_38', "You must set the e107_plugins/log/logs folder to be writable");
+define ('ADSTAT_LAN_39', 'Stats Logging Functions');
+define ('ADSTAT_LAN_40', 'Export log data');
+define ('ADSTAT_LAN_41', 'Date selection');
+define ('ADSTAT_LAN_42', 'Single Day');
+define ('ADSTAT_LAN_43', 'Daily for a month');
+define ('ADSTAT_LAN_44', 'Monthly for a year');
+define ('ADSTAT_LAN_45', 'All-time');
+define ('ADSTAT_LAN_46', 'Date:');
+define ('ADSTAT_LAN_47', 'Invalid date chosen');
+define ('ADSTAT_LAN_48', 'Monthly and All-time');
+define ('ADSTAT_LAN_49', 'All-time Only');
+define ('ADSTAT_LAN_50', 'None');
+define ('ADSTAT_LAN_51', 'Output Data');
+define ('ADSTAT_LAN_52', 'Page Data');
+define ('ADSTAT_LAN_53', 'No selection possible');
+define ('ADSTAT_LAN_54', 'Invalid type selection');
+define ('ADSTAT_LAN_55', 'Single quote');
+define ('ADSTAT_LAN_56', 'Double quote');
+define ('ADSTAT_LAN_57', 'Comma');
+define ('ADSTAT_LAN_58', 'Pipe (|)');
+define ('ADSTAT_LAN_59', 'CSV separator, quotes');
+define ('ADSTAT_LAN_60', 'Strip site address from URLs');
+define ('ADSTAT_LAN_61', '(if checked, just gives page reference)');
+define ('ADSTAT_LAN_62', 'All-time (detailed)');
+define ('ADSTAT_LAN_63', 'Available Datasets');
+define ('ADSTAT_LAN_64', 'Database records found:');
+define ('ADSTAT_LAN_65', 'DB filter string:');
+define ('ADSTAT_LAN_66', 'Show Datasets');
+define ('ADSTAT_LAN_67', 'Generate a CSV (Comma Separated Variable) file of historical statistics which meets the specified criteria');
+define ('ADSTAT_LAN_68', 'Show the statistics database entries which actually exist and meet the selection criteria');
+define ('ADSTAT_LAN_69', 'Delete historical data');
+define ('ADSTAT_LAN_70', 'Delete data older than:');
+define ('ADSTAT_LAN_71', 'Delete Data');
+define ('ADSTAT_LAN_72', 'Confirm deletion of data older than first day of:');
+//define ('ADSTAT_LAN_73', 'Confirm');
+define ('ADSTAT_LAN_74', '(List of data entries which will be deleted below)');
+define ('ADSTAT_LAN_75', 'Records for deletion');
+define ('ADSTAT_LAN_76', 'Caution! Once deleted, the data cannot be recovered. Backup or export your database first');
+define ('ADSTAT_LAN_77', 'Records deleted:');
+define ('ADSTAT_LAN_78', 'Show previous month as well as current month for non-page access stats');
+define ('ADSTAT_LAN_79', 'Only used if monthly stats collected');
+define ('ADSTAT_LAN_80', 'The following pages were deleted:');
+define ('ADSTAT_LAN_81', 'Statistics cleared:');
+define ('ADSTAT_LAN_82', 'Following values now set:');
+define ('ADSTAT_LAN_83', 'Following log ID entries removed:');
+define ('ADSTAT_LAN_84', '');
+define ('ADSTAT_LAN_85', '');
+
+
+
+?>
\ No newline at end of file