diff --git a/e107_plugins/log/admin_config.php b/e107_plugins/log/admin_config.php index ccd256012..c0a335392 100644 --- a/e107_plugins/log/admin_config.php +++ b/e107_plugins/log/admin_config.php @@ -11,23 +11,23 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/log/admin_config.php,v $ -| $Revision: 1.1.1.1 $ -| $Date: 2006-12-02 04:35:27 $ -| $Author: mcfly_e107 $ +| $Revision: 1.2 $ +| $Date: 2007-11-01 20:28:20 $ +| $Author: e107steved $ +----------------------------------------------------------------------------+ + +To do: +1. Admin log for changes */ + + require_once("../../class2.php"); -if (!getperms("P")) { +if (!getperms("P")) +{ header("location:../index.php"); exit; } -if (isset($_POST['updateStats'])) -{ - header("location: ".e_PLUGIN."log/admin_updateroutine.php"); - exit; -} - require_once(e_ADMIN."auth.php"); require_once(e_HANDLER."userclass_class.php"); @@ -35,17 +35,122 @@ define("LOGPATH", e_PLUGIN."log/"); include_lan(LOGPATH."languages/admin/".e_LANGUAGE.".php"); +if (e_QUERY) +{ + $sl_qs = explode(".", e_QUERY); +} +$action = varset($sl_qs[0],'config'); +$params = varset($sl_qs[1],''); + +// 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_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; + } +} + + + +//--------------------------------------------- +// Remove page entries +//--------------------------------------------- if(isset($_POST['openRemPageD'])) { - rempage(); + $action = 'rempage'; } + if(isset($_POST['remSelP'])) { - rempagego(); + $action = 'rempage'; + rempagego(); // Do the deletions - then redisplay the list of pages } +//--------------------------------------------- +// Wipe accumulated stats +//--------------------------------------------- if(IsSet($_POST['wipeSubmit'])) { foreach($_POST['wipe'] as $key => $wipe) @@ -82,92 +187,110 @@ if(IsSet($_POST['wipeSubmit'])) -if(!is_writable(LOGPATH."logs")) { - $message = "You must set the permissions of the e107_plugins/log/logs folder to 777 (chmod 777)"; +if(!is_writable(LOGPATH."logs")) +{ + $message = "".ADSTAT_L38.""; } -if (isset($_POST['updatesettings'])) { - $pref['statActivate'] = $_POST['statActivate']; +if (isset($_POST['updatesettings'])) +{ + $pref['statActivate'] = $_POST['statActivate']; $pref['statCountAdmin'] = $_POST['statCountAdmin']; - $pref['statUserclass'] = $_POST['statUserclass']; - $pref['statBrowser'] = $_POST['statBrowser']; - $pref['statOs'] = $_POST['statOs']; - $pref['statScreen'] = $_POST['statScreen']; - $pref['statDomain'] = $_POST['statDomain']; - $pref['statRefer'] = $_POST['statRefer']; - $pref['statQuery'] = $_POST['statQuery']; - $pref['statRecent'] = $_POST['statRecent']; + $pref['statUserclass'] = $_POST['statUserclass']; + $pref['statBrowser'] = intval($_POST['statBrowser']); + $pref['statOs'] = intval($_POST['statOs']); + $pref['statScreen'] = intval($_POST['statScreen']); + $pref['statDomain'] = intval($_POST['statDomain']); + $pref['statRefer'] = intval($_POST['statRefer']); + $pref['statQuery'] = intval($_POST['statQuery']); + $pref['statRecent'] = intval($_POST['statRecent']); $pref['statDisplayNumber'] = $_POST['statDisplayNumber']; + $pref['statPrevMonth'] = intval($_POST['statPrevMonth']); save_prefs(); $message = ADSTAT_L17; } -if (isset($message)) { - $ns->tablerender("", "