addDebug(print_r($logVals, true));
if($_SESSION['stats_log_files'][$count]['complete'] != 1)
{
$_SESSION['stats_log_files'][$count]['complete'] = 1;
// $lg->addSuccess($count."/".$totalFiles."\t".$file." processing", false);
// if($process)
if($lgc->processRawBackupLog($file, true))
{
// sleep(3);
$lg->addSuccess($count."/".$totalFiles."\t".$file." processed.", false);
$_SESSION['stats_log_files'][$count]['complete'] = 1;
$_SESSION['stats_log_files_count']++;
}
else
{
$lg->addError($count."/".$totalFiles."\t".$file." failed.", false);
}
}
else
{
$lg->addWarning($count."/".$totalFiles."\t".$file." skipped", false);
$_SESSION['stats_log_files_count']++;
}
$totalOutput = round(( $count/ $totalFiles) * 100, 1);
if($totalOutput > 99.9)
{
echo 100;
if($lgc->collatePageTotalDB())
{
$lg->addSuccess("Processed All-Time PageTotal", false);
}
else
{
$lg->addError("Failed to Process All-Time PageTotal", false);
}
$lg->addSuccess("Processing Complete.", false);
}
else
{
echo $totalOutput;
}
$lg->toFile('SiteStatsUpgrade','Statistics Update Log', true);
exit;
}
define('LogFlagFile', 'LogFlag.php');
include_lan(e_PLUGIN.'log/languages/'.e_LANGUAGE.'.php');
include_lan(e_PLUGIN.'log/languages/'.e_LANGUAGE.'_admin.php');
if(!is_writable(e_LOG))
{
//$message = "".ADSTAT_LAN_38."";
e107::getMessage()->addError(ADSTAT_LAN_28);
}
e107::css('inline', 'td.last.options { padding-right:20px } ');
// Needed on Windoze platforms - not an ideal solution!
if (!function_exists('nl_langinfo'))
{
define('MON_1',86400);
define('MON_2',2764800);
define('MON_3',5443200);
define('MON_4',8035200);
define('MON_5',10800000);
define('MON_6',13392000);
define('MON_7',15811200);
define('MON_8',19008000);
define('MON_9',21168000);
define('MON_10',23760000);
define('MON_11',26352000);
define('MON_12',28944000);
function nl_langinfo($mon)
{
return date('F',$mon);
}
}
class log_adminArea extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'logstats_ui',
'path' => null,
'ui' => 'logstats_form_ui',
'uipath' => null
),
);
protected $adminMenu = array(
'main/prefs' => array('caption'=> LAN_SETTINGS, 'perm' => 'P'),
'main/list' => array('caption'=> ADSTAT_LAN_48, 'perm' => 'P'),
'main/export' => array('caption'=> ADSTAT_LAN_36, 'perm' => 'P'),
'main/datasets' => array('caption'=> ADSTAT_LAN_63, 'perm' => 'P'),
'main/rempage' => array('caption'=> ADSTAT_LAN_26, 'perm' => 'P'),
'main/history' => array('caption'=> ADSTAT_LAN_69, 'perm' => 'P'),
'main/rebuild' => array('caption'=>'Rebuild Statistic Summaries', 'perm'=> 'P'),
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);
protected $menuTitle = 'Statistic Logging';
}
// 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'=>ADSTAT_LAN_6,'statOs'=>ADSTAT_LAN_7,'statScreen'=>ADSTAT_LAN_8,'statDomain'=>ADSTAT_LAN_9,'statReferer'=>ADSTAT_LAN_10,'statQuery'=>ADSTAT_LAN_11);
$separator_list = array(1 => ADSTAT_LAN_57, 2 => ADSTAT_LAN_58);
$separator_char = array(1 => ',', 2 => '|');
$quote_list = array(1 => ADSTAT_LAN_50, 2 => ADSTAT_LAN_55, 3 => ADSTAT_LAN_56);
$quote_char = array(1 => '', 2 => "'", 3 => '"');
//---------------------------------------------
// Export data file
//---------------------------------------------
$export_filter = ''; // can be 'LIKE', 'REGEX', or simple equality
$export_type = $tp->toDB(varset($_POST['export_type'],'page')); // Page data or one of the other bits of info
$export_date = intval(varset($_POST['export_date'],1));
$export2_date = intval(varset($_POST['export2_date'],3));
$export_year = intval(varset($_POST['export_year'],date('Y')));
$export_month = intval(varset($_POST['export_month'],date('m')));
$export_day = intval(varset($_POST['export_day'],date('j')));
$export_char = varset($_POST['export_char'], 1);
$export_quote = varset($_POST['export_quote'], 1);
$export_stripurl = varset($_POST['export_stripurl'], 0);
class logstats_ui extends e_admin_ui
{
protected $pluginTitle = 'Statistic Logging';
protected $pluginName = 'log';
// protected $eventName = 'log-logstats'; // remove comment to enable event triggers in admin.
protected $table = 'logstats';
protected $pid = 'log_uniqueid';
protected $perPage = 10;
protected $batchDelete = true;
// protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
protected $listQry = "SELECT * FROM `#logstats` WHERE `log_id` = 'pageTotal' OR (`log_id` REGEXP '^[0-9]' AND LENGTH(log_id) > 7 AND LENGTH(log_id) < 11) ";
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = 'CASE log_id WHEN "pageTotal" THEN 9999 ELSE DATE(log_id) END DESC ';
protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
'log_uniqueid' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'log_id' => array ( 'title' => LAN_DATE, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'log_data' => array ( 'title' => ADSTAT_L21, 'type' => 'method', 'data' => 'str', 'width' => '20%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'right', 'thclass' => 'right', ),
'log_data2' => array ( 'title' => ADSTAT_L22, 'type' => 'method', 'data' => false, 'width' => '20%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'right', 'thclass' => 'right', ),
'options' => array ( 'title' => LAN_OPTIONS, 'type' => 'method', 'data' => null, 'width' => '15%', 'thclass' => 'right last', 'class' => 'right last', 'forced' => '1', ),
);
protected $fieldpref = array();
// protected $preftabs = array('General', 'Other' );
protected $prefs = array(
);
public function init()
{
if(!empty($_POST['rebuild']))
{
require_once(e_PLUGIN.'log/consolidate.php');
$lgc = new logConsolidate();
$file = $_POST['rebuild']."_SiteStats.log";
$lgc->processRawBackupLog($file, true);
}
if(!empty($_POST['rebuildTotal']))
{
require_once(e_PLUGIN.'log/consolidate.php');
$lgc = new logConsolidate();
if($lgc->collatePageTotalDB())
{
e107::getMessage()->addSuccess(LAN_UPDATED);
}
else
{
e107::getMessage()->addError(LAN_UPDATED_FAILED);
}
}
// Set drop-down values (if any).
if (isset($_POST['updatesettings']))
{
$this->prefsPageSubmit();
}
if(isset($_POST['remSelP']))
{
$this->rempagePageSubmit(); // Do the deletions - then redisplay the list of pages
}
if(isset($_POST['wipeSubmit']))
{
$this->wipe();
}
}
/**
* Wipe accumulated stats
*/
private function wipe()
{
$sql = e107::getDb();
$logStr = '';
foreach($_POST['wipe'] as $key => $wipe)
{
switch($key)
{
case "statWipePage":
$sql->update("logstats", "log_data='' WHERE log_id='pageTotal' ");
$sql->update("logstats", "log_data='' WHERE log_id='statTotal' ");
$sql->update("logstats", "log_data='' WHERE log_id='statUnique' ");
break;
case "statWipeBrowser":
$sql->update("logstats", "log_data='' WHERE log_id='statBrowser' ");
break;
case "statWipeOs":
$sql->update("logstats", "log_data='' WHERE log_id='statOs' ");
break;
case "statWipeScreen":
$sql->update("logstats", "log_data='' WHERE log_id='statScreen' ");
break;
case "statWipeDomain":
$sql->update("logstats", "log_data='' WHERE log_id='statDomain' ");
break;
case "statWipeRefer":
$sql->update("logstats", "log_data='' WHERE log_id='statReferer' ");
break;
case "statWipeQuery":
$sql->update("logstats", "log_data='' WHERE log_id='statQuery' ");
break;
}
$logStr .= '[!br!]'.$key;
}
e107::getLog()->add('STAT_01',ADSTAT_LAN_81.$logStr,'');
e107::getMessage()->addSuccess(LAN_UPDATED);
}
private function get_for_delete($keep_year,$keep_month = 1, $filter='*')
{
$sql = e107::getDb();
global $stats_list;
$ret = array();
// Its tedious, but the filter criteria are sufficiently tricky that its probably best to read all records and decide what can go
if ($sql->select('logstats','log_id'))
{
while ($row = $sql->fetch())
{
$can_go = FALSE;
$check = FALSE;
$data_type = 'unknown';
$date_info = $row['log_id'];
if (($temp = strpos($date_info,':')) !== FALSE)
{ // its monthly browser stats and similar
// echo "Checking {$date_info}, posn = {$temp} ";
$data_type = substr($date_info,0,$temp);
$date_info = substr($date_info,$temp+1);
$check = TRUE;
// echo "Date string: {$date_info}, data type: {$data_type}
";
if (isset($stats_list[$data_type])) $data_type = $stats_list[$data_type];
}
list($poss_year,$poss_month,$poss_day) = explode('-',$date_info.'--',3);
if (!$check)
{
if (is_numeric($poss_year))
{
$check = TRUE;
if ($poss_day > 0) $data_type = 'daily'; else $data_type = 'monthly';
}
}
if ($check)
{
if ($keep_year == $poss_year)
{
if (($poss_month > 0) && ($poss_month < $keep_month)) $can_go = TRUE;
}
elseif ($keep_year > $poss_year) $can_go = TRUE;
}
if ($can_go)
{
$ret[$row['log_id']] = $row['log_id']." - ".$data_type;
}
}
}
return $ret;
}
private function data_type_select($name,$value)
{
global $stats_list;
$ret = "\n";
return $ret;
}
private function gen_select($prompt,$name,$value)
{
$ret = "