1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-04 09:54:56 +02:00

Merge branch 'master' of github.com:e107inc/e107

This commit is contained in:
SecretR 2015-10-26 16:30:45 +02:00
commit ce93537024
16 changed files with 1515 additions and 869 deletions

View File

@ -1249,7 +1249,7 @@ if(e_IFRAME) //<-- Check config and delete buttons if modifying
//e107::js('core','bootstrap/js/bootstrap.min.js');
//e107::css('core','bootstrap/css/bootstrap.min.css');
e107::css('url','{e_THEME}/bootstrap/admin_style.css');
e107::css('url','{e_THEME}/bootstrap3/admin_style.css');
}

View File

@ -788,12 +788,13 @@ class pluginManager{
e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, '');
}
if($_POST['delete_files'])
if(!empty($_POST['delete_files']) && ($plug['plugin_installflag'] == true))
{
include_once(e_HANDLER.'file_class.php');
$fi = new e_file;
$result = $fi->rmtree(e_PLUGIN.$eplug_folder);
$text .= ($result ? '<br />'.EPL_ADLAN_86.e_PLUGIN.$eplug_folder : '<br />'.EPL_ADLAN_87.'<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
if(!empty($eplug_folder))
{
$result = e107::getFile()->rmtree(e_PLUGIN.$eplug_folder);
$text .= ($result ? '<br />'.EPL_ADLAN_86.e_PLUGIN.$eplug_folder : '<br />'.EPL_ADLAN_87.'<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
}
}
else
{

View File

@ -303,7 +303,7 @@ CREATE TABLE news (
news_title varchar(255) NOT NULL default '',
news_sef varchar(200) NOT NULL default '',
news_body longtext NOT NULL,
news_extended text NOT NULL,
news_extended longtext NOT NULL,
news_meta_keywords varchar(255) NOT NULL default '',
news_meta_description text NOT NULL,
news_datestamp int(10) unsigned NOT NULL default '0',

View File

@ -277,11 +277,11 @@ if (isset($footer_js) && is_array($footer_js))
}
}
// Load e_footer.php files.
if (is_array($pref['e_footer_list']))
// Load e_footer.php files.
if (!empty($pref['e_footer_list']) && is_array($pref['e_footer_list']))
{
ob_start();
//ob_start(); // sometimes raw HTML needs to be added at the bottom of every page. eg. <noscript> etc. so allow 'echo' in e_footer files. (but not e_header)
foreach($pref['e_footer_list'] as $val)
{
$fname = e_PLUGIN.$val."/e_footer.php"; // Do not place inside a function - BC $pref required. .
@ -290,11 +290,12 @@ if (is_array($pref['e_footer_list']))
{
$ret = ($e107_debug || isset($_E107['debug'])) ? include_once($fname) : @include_once($fname);
}
}
$e_footer_ouput = ob_get_contents(); // Don't use.
ob_end_clean();
// $e_footer_ouput = ob_get_contents(); // Don't use.
// ob_end_clean();
unset($ret);
}

View File

@ -6434,7 +6434,8 @@ class e_admin_form_ui extends e_form
public function getElementId()
{
$controller = $this->getController();
return str_replace('_', '-', ($controller->getPluginName() == 'core' ? 'core-'.$controller->getTableName() : 'plugin-'.$controller->getPluginName()));
$name = str_replace('_', '-', ($controller->getPluginName() == 'core' ? 'core-'.$controller->getTableName() : 'plugin-'.$controller->getPluginName()));
return e107::getForm()->name2id($name); // prevent invalid ids.
}
/**

View File

@ -2918,7 +2918,7 @@ class e_form
if(count($list))
{
return "<div class='e-related clearfix'><hr><h4>Related</h4><ul class='e-related'>".implode("\n",$list)."</ul></div>"; //XXX Tablerender?
return "<div class='e-related clearfix'><hr><h4>".defset('LAN_RELATED', 'Related')."</h4><ul class='e-related'>".implode("\n",$list)."</ul></div>"; //XXX Tablerender?
}
}
@ -4762,7 +4762,7 @@ class e_form
$key = $att['field'];
}
if($key == 'checkboxes' || $key == 'options' || ($att['type'] === null))
if($key == 'checkboxes' || $key == 'options' || ($att['type'] === null) || ($att['type'] === false))
{
continue;
}

View File

@ -990,8 +990,8 @@ function show_emessage($mode, $message, $line = 0, $file = "") {
<head>
<meta charset="utf-8" />
<title>Error</title>
<link rel="stylesheet" media="all" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
<link rel="stylesheet" media="all" type="text/css" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" />
<link rel="stylesheet" media="all" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" media="all" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<link rel="stylesheet" media="all" type="text/css" href="/e107_web/css/e107.css" />
</head>
<body >

View File

@ -331,7 +331,7 @@ class notify
function notify_flood($data)
{
$this->send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.e107::getIPHandler()->ipDecode($data));
$this->send('flood', NT_LAN_FL_1, NT_LAN_FL_2.': '.e107::getIPHandler()->ipDecode($data, TRUE));
}
function notify_subnews($data)

View File

@ -113,6 +113,7 @@ define("LAN_USER", "User");
define("LAN_EMAIL","Email address");
define("LAN_WROTE", "wrote"); // as in John wrote.." ";
define("LAN_RE_ORDER", "Re-order");
define("LAN_RELATED", "Related");
define("LAN_ENTER_USRNAME_EMAIL", "Please enter your username or email"); // admin php hover field admin name
define("LAN_PWD_REQUIRED", "Password is required"); // admin php hover field admin password

View File

@ -36,7 +36,7 @@ class auth_login extends alt_auth_base
public $Available = FALSE; // Flag indicates whether DB connection available
private $filter; // Filter for eDirectory search
private $copyAttribs; // Any attributes which are to be copied on successful login
private $copyMethods; // Methods which are to be used to copy attributes
public $copyMethods; // Methods which are to be used to copy attributes

View File

@ -105,7 +105,7 @@ class gallery_cat_admin_ui extends e_admin_ui
protected $perPage = 10; //no limit
protected $listOrder = 'media_cat_order';
protected $listQry = "SELECT * FROM #core_media_cat WHERE media_cat_owner = 'gallery' "; // without any Order or Limit.
protected $listQry = "SELECT * FROM `#core_media_cat` WHERE media_cat_owner = 'gallery' "; // without any Order or Limit.
// protected $listQry = "SELECT * FROM #core_media "; // without any Order or Limit.
// protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}";

View File

@ -45,7 +45,7 @@ class list_news
$bullet = $this->parent->getBullet($this->parent->settings['icon']);
$list_caption = $this->parent->settings['caption'];
$list_display = (vartrue($this->parent->settings['open']) ? '' : 'none');
$list_display = (vartrue($this->parent->settings['open']) ? '' : LAN_NONE);
$qry = "
SELECT n.*, c.category_id AS news_category_id, c.category_name AS news_category_name, u.user_id AS news_author_id, u.user_name AS news_author_name

File diff suppressed because it is too large Load Diff

View File

@ -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 '<br />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 "<div class='alert alert-error'>Log directory is not writable - please CHMOD ".e_LOG." to 777";
echo '<br />Path to logs: '.$this->pathtologs;
echo "</div>";
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 = "<?php
$data = "<?php";
$data .= "
/* e107 website system: Log info file: ".date("z:Y", time())." */
";
@ -104,12 +365,13 @@ class logConsolidate
$data .= '$visitInfo'." = array();\n\n";
$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)|(&nbsp;)|(\.php)|(\.html)";
$tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)";
// $tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)";
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<br />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 "<h3>".$file."</h3>";
print_a($pageTotal);
if(e_DEBUG)
{
$mes->addDebug("<h3>".$file."</h3>");
$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 "<br />Data saved to database with id: ".$datestamp;
$mes->addSuccess( "Data saved to database with id: ".$datestamp);
}
else
{
echo "<br />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);

View File

@ -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

View File

@ -0,0 +1,101 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
//define("ADSTAT_ON", "On");
//define("ADSTAT_OFF", "Off");
define("ADSTAT_LAN_1", "This plugin will log all visits to your site, and build detailed statistic screens based on the information gathered.");
define("ADSTAT_LAN_2", "The statistics logger has been successfully installed. To activate, please go to the config screen and click Activate.<br /><b>You must set the permissions of the e107_plugins/log/logs folder to 777 (chmod 777)</b>");
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', '');
?>