ADSTAT_L6,'statOs'=>ADSTAT_L7,'statScreen'=>ADSTAT_L8,'statDomain'=>ADSTAT_L9,'statReferer'=>ADSTAT_L10,'statQuery'=>ADSTAT_L11); $separator_list = array(1 => ADSTAT_L57, 2 => ADSTAT_L58); $separator_char = array(1 => ',', 2 => '|'); $quote_list = array(1 => ADSTAT_L50, 2 => ADSTAT_L55, 3 => ADSTAT_L56); $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); if (isset($_POST['create_export']) && (($action == 'export') || ($action == 'datasets'))) { $first_date = 0; $last_date = 0; $date_error = FALSE; if ($export_type == 'page') { switch ($export_date) { case '1' : // Single day $first_date = gmmktime(0,0,0,$export_month,$export_day,$export_year); $last_date = $first_date+86399; $export_filter = " `log_id`='".date("Y-m-j",$first_date)."'"; break; case '2' : // Daily for a month $first_date = gmmktime(0,0,0,$export_month,1,$export_year); $last_date = gmmktime(0,0,0,$export_month+1,1,$export_year) - 1; $export_filter = " LEFT(`log_id`,8)='".gmstrftime("%Y-%m-",$first_date)."'"; break; case '3' : // Monthly for a Year $first_date = gmmktime(0,0,0,1,1,$export_year); $last_date = gmmktime(0,0,0,1,1,$export_year+1) - 1; $export_filter = " LENGTH(`log_id`)=7 AND LEFT(`log_id`,5)='".gmstrftime("%Y-",$first_date)."'"; break; case '4' : // Accumulated case '5' : $export_filter = "`log_id`='pageTotal'"; $date_error = 'ignore'; break; } } else { // Calculate strings for non-page sources $prefix_len = 0; $export_date = $export2_date; if (isset($stats_list[$export_type])) { $prefix_len = strlen($export_type) + 1; switch ($export2_date) { case '3' : // Monthly for a Year if ($prefix_len > 0) { $first_date = gmmktime(0,0,0,1,1,$export_year); $last_date = gmmktime(0,0,0,1,1,$export_year+1) - 1; $export_filter = " LENGTH(`log_id`)='".($prefix_len + 7)."' AND LEFT(`log_id`,".($prefix_len + 5).")='".$export_type.":".gmstrftime("%Y-",$first_date)."'"; } break; case '4' : // Accumulated $export_filter = " `log_id`='".$export_type."'"; $date_error = 'ignore'; break; } } else { $message = ADSTAT_L54; } } if (($date_error != 'ignore') && (($first_date == 0) || ($last_date == 0) || $date_error)) { $message = ADSTAT_L47; } } // 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); } } //--------------------------------------------- // Remove page entries //--------------------------------------------- if(isset($_POST['openRemPageD'])) { $action = 'rempage'; } if(isset($_POST['remSelP'])) { $action = 'rempage'; rempagego(); // Do the deletions - then redisplay the list of pages } //--------------------------------------------- // Wipe accumulated stats //--------------------------------------------- if(IsSet($_POST['wipeSubmit'])) { $logStr = ''; foreach($_POST['wipe'] as $key => $wipe) { switch($key) { case "statWipePage": $sql -> db_Update("logstats", "log_data='' WHERE log_id='pageTotal' "); $sql -> db_Update("logstats", "log_data='' WHERE log_id='statTotal' "); $sql -> db_Update("logstats", "log_data='' WHERE log_id='statUnique' "); break; case "statWipeBrowser": $sql -> db_Update("logstats", "log_data='' WHERE log_id='statBrowser' "); break; case "statWipeOs": $sql -> db_Update("logstats", "log_data='' WHERE log_id='statOs' "); break; case "statWipeScreen": $sql -> db_Update("logstats", "log_data='' WHERE log_id='statScreen' "); break; case "statWipeDomain": $sql -> db_Update("logstats", "log_data='' WHERE log_id='statDomain' "); break; case "statWipeRefer": $sql -> db_Update("logstats", "log_data='' WHERE log_id='statReferer' "); break; case "statWipeQuery": $sql -> db_Update("logstats", "log_data='' WHERE log_id='statQuery' "); break; } $logStr .= '[!br!]'.$key; } $admin_log->log_event('STAT_01',ADSTAT_L81.$logStr,''); //$message = ADSTAT_L25; // TODO:$emessage $mes->addSuccess(LAN_UPDATED); } if(!is_writable(e_LOG)) { //$message = "".ADSTAT_L38.""; $mes->addError(ADSTAT_L28); } if (isset($_POST['updatesettings'])) { $statList = array( // Type = 0 for direct text, 1 for integer 'statActivate' => 0, 'statCountAdmin' => 0, 'statUserclass' => 0, 'statBrowser' => 1, 'statOs' => 1, 'statScreen' => 1, 'statDomain' => 1, 'statRefer' => 1, 'statQuery' => 1, 'statRecent' => 1, 'statDisplayNumber' => 0, 'statPrevMonth' => 1 ); $logStr = ''; foreach ($statList as $k => $type) { switch ($type) { case 0 : $pref[$k] = $_POST[$k]; break; case 1 : $pref[$k] = intval($_POST[$k]); break; } $logStr .= "[!br!]{$k} => ".$pref[$k]; } save_prefs(); file_put_contents(e_LOG.LogFlagFile, "\n"); // Logging task uses to see if logging enabled $admin_log->log_event('STAT_02',ADSTAT_L82.$logStr,''); } $ns->tablerender($caption, $mes->render() . $text); function gen_select($prompt,$name,$value) { $ret = "
".$prompt."
"; return $ret; } function data_type_select($name,$value) { global $stats_list; $ret = "\n"; return $ret; } switch ($action) { case 'config' : $text = "
".ADSTAT_L4." ".$frm->radio_switch('statActivate', $pref['statActivate'])."
".ADSTAT_L18." ".r_userclass("statUserclass", $pref['statUserclass'],'off','public, member, admin, classes')."
".ADSTAT_L20." ".$frm->radio_switch('statCountAdmin', $pref['statCountAdmin'])."
".ADSTAT_L21."
".ADSTAT_L5." ".gen_select(ADSTAT_L6, 'statBrowser',$pref['statBrowser']) .gen_select(ADSTAT_L7, 'statOs',$pref['statOs']) .gen_select(ADSTAT_L8, 'statScreen',$pref['statScreen']) .gen_select(ADSTAT_L9, 'statDomain',$pref['statDomain']) .gen_select(ADSTAT_L10, 'statRefer',$pref['statRefer']) .gen_select(ADSTAT_L11, 'statQuery',$pref['statQuery']) ."
".ADSTAT_L19." ".$frm->radio_switch('statRecent', $pref['statRecent'])."
".ADSTAT_L78." ".$frm->checkbox('statPrevMonth', 1, varset($pref['statPrevMonth'],0))."".ADSTAT_L79."
".ADSTAT_L12." ".$frm->checkbox('wipe[statWipePage]', 1, false, array('label'=> ADSTAT_L14 ))." ".$frm->checkbox('wipe[statWipeBrowser]', 1, false, array('label'=>ADSTAT_L6))." ".$frm->checkbox('wipe[statWipeOs]', 1, false, array('label'=> ADSTAT_L7 ))." ".$frm->checkbox('wipe[statWipeScreen]', 1, false, array('label'=> ADSTAT_L8 ))." ".$frm->checkbox('wipe[statWipeDomain]', 1, false, array('label'=> ADSTAT_L9 ))." ".$frm->checkbox('wipe[statWipeRefer]', 1, false, array('label'=> ADSTAT_L10 ))." ".$frm->checkbox('wipe[statWipeQuery]', 1, false, array('label'=> ADSTAT_L11 ))."
".$frm->admin_button('wipeSubmit', LAN_RESET, 'delete')."".ADSTAT_L13."
".ADSTAT_L26." ".$frm->admin_button('openRemPageD', ADSTAT_L28, 'other')."".ADSTAT_L27."
".$frm->admin_button('updatesettings', LAN_UPDATE, 'update')."
"; $ns->tablerender(ADSTAT_L16, $text); break; // case config case 'rempage' : // Remove pages rempage(); break; case 'export' : // Export file case 'datasets' : //=========================================================== // EXPORT DATA //=========================================================== $text = "
"; if ($action == 'export') { $text .= "
"; } else { $text .= ""; } $text .= " "; if ($action == 'export') { $text .= ""; } else { $text .= ""; } // Type of output data - page data, browser stats.... $text .= "'; // Period selection type for page data $text .= ""; $text .= ""; if ($action == 'export') { // Separators, quotes $text .= ""; $text .= ""; } if ($export_filter) { if (getperms('0')) $text .= ""; $sql -> db_Select("logstats", "log_id", "{$export_filter} "); $text .= ""; } $text .= "
".ADSTAT_L67."
".ADSTAT_L68."
".ADSTAT_L51."\n".data_type_select('export_type',$export_type).'
".ADSTAT_L41."\n "; // Period selection type for non-page data $text .= " "; $text .= "
".ADSTAT_L46."\n"; // Now put the various dropdowns - their visibility is controlled by the export_type dropdown $text .= "\n   "; $text .= "\n   "; $this_year = date("Y"); $text .= "\n   "; $text .= "\n"; $text .= "
".ADSTAT_L59."\n \n    \n
".ADSTAT_L60." ".$frm->checkbox('export_stripurl', 1)."".ADSTAT_L61."
".ADSTAT_L65."".$export_filter."
".ADSTAT_L64.""; while($row = $sql -> db_Fetch()) { $text .= $row['log_id']."
"; } $text .= "
".$frm->admin_button('create_export', ($action == 'export' ? LAN_CREATE : ADSTAT_L66), 'update')."
"; // Set up the date display boxes $text .= ""; $ns->tablerender(ADSTAT_L40, $text); break; // case 'export' case 'history' : //=========================================================== // DELETE HISTORY //=========================================================== $mes->addWarning(ADSTAT_L76); $text = "
"; $keep_month = varset($_POST['delete_month'],0); $keep_year = varset($_POST['delete_year'],0); if (isset($_POST['delete_history'])) { $text .= ""; $text .= ""; } else { if (isset($_POST['actually_delete'])) { $delete_list = get_for_delete($keep_year,$keep_month); $logStr = ''; // $text .= ""; $text .= ""; $admin_log->log_event('STAT_04',ADSTAT_L83.$logStr,''); } $text .= ""; $text .= ""; } $text .= "
".ADSTAT_L72."".nl_langinfo(constant('MON_'.$keep_month))." ".$keep_year."
".$frm->admin_button('actually_delete', LAN_CONFDELETE, 'delete')."
".ADSTAT_L74."
".ADSTAT_L75."".implode("
",get_for_delete($keep_year,$keep_month))."
Data notionally deleted {$keep_month}-{$keep_year}
".ADSTAT_L77.""; foreach ($delete_list as $k => $v) { $sql->db_Delete('logstats',"log_id='{$k}'"); $text .= $v."
"; $logStr .= "[!br!]{$k} => ".$v; } $text .= "
".ADSTAT_L70."\n   "; $this_year = date("Y"); $text .= "\n
".$frm->admin_button('delete_history',LAN_DELETE,'delete')."
"; $ns->tablerender(ADSTAT_L69, $mes->render().$text); break; // case 'history' } require_once(e_ADMIN."footer.php"); function headerjs() { $script_js = "\n"; return $script_js; } function get_for_delete($keep_year,$keep_month = 1, $filter='*') { global $sql, $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->db_Select('logstats','log_id')) { while ($row = $sql->db_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; } //--------------------------------------------- // Remove page entries - prompt/list //--------------------------------------------- function rempage() { $sql = e107::getDb(); $ns = e107::getRender(); $frm = e107::getForm(); $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); } $sql -> db_Select("logstats", "*", "log_id='pageTotal' "); $row = $sql -> db_Fetch(); $pageTotal = unserialize($row['log_data']); foreach($pageInfo as $url => $tmpcon) { $pageTotal[$url]['url'] = $tmpcon['url']; $pageTotal[$url]['ttlv'] += $tmpcon['ttl']; $pageTotal[$url]['unqv'] += $tmpcon['unq']; } $text = "
"; foreach($pageTotal as $key => $page) { $text .= " "; } $text .= "
".ADSTAT_L29." URL ".ADSTAT_L30." ...
{$key} ".$page['url']."
".$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}' "); } $admin_log->log_event('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); } function admin_config_adminmenu() { if (e_QUERY) { $tmp = explode(".", e_QUERY); $action = $tmp[0]; } if (!isset($action) || ($action == "")) $action = "config"; $var['config']['text'] = ADSTAT_L35; $var['config']['link'] = 'admin_config.php'; $var['export']['text'] = ADSTAT_L36; $var['export']['link'] ='admin_config.php?export'; // $var['datasets']['text'] = ADSTAT_L63; // $var['datasets']['link'] ='admin_config.php?datasets'; $var['rempage']['text'] = ADSTAT_L26; $var['rempage']['link'] ='admin_config.php?rempage'; $var['history']['text'] = ADSTAT_L69; $var['history']['link'] ='admin_config.php?history'; show_admin_menu(ADSTAT_L39, $action, $var); } ?>