diff --git a/e107_plugins/log/stats.php b/e107_plugins/log/stats.php
index 50b0d21d0..0f32f0ed1 100644
--- a/e107_plugins/log/stats.php
+++ b/e107_plugins/log/stats.php
@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/log/stats.php,v $
-| $Revision: 1.5 $
-| $Date: 2007-11-01 20:28:21 $
+| $Revision: 1.6 $
+| $Date: 2007-11-04 09:24:59 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -22,6 +22,14 @@ require_once("../../class2.php");
@include_once(e_PLUGIN."log/languages/English.php");
+$bar = (file_exists(THEME."images/bar.png") ? THEME."images/bar.png" : e_IMAGE."generic/bar.png");
+$eplug_css[] = "";
+
+/*
function core_head() {
$bar = (file_exists(THEME."images/bar.png") ? THEME."images/bar.png" : e_IMAGE."generic/bar.png");
return "";
}
+*/
require_once(HEADERF);
@@ -65,6 +74,20 @@ if($stat -> error)
exit;
}
+
+$oses_map = array (
+"Windows" => "windows",
+"Mac" => "mac",
+"Linux" => "linux",
+"BeOS" => "beos",
+"FreeBSD" => "freebsd",
+"NetBSD" => "netbsd",
+"Unspecified"=> "unspecified",
+"OpenBSD" => "openbsd",
+"Unix" => "unix",
+"Spiders" => "spiders",
+);
+
$browser_map = array (
'Netcaptor' => "netcaptor",
'Internet Explorer' => "explorer",
@@ -439,8 +462,8 @@ switch($action)
if (ADMIN == TRUE)
$text .= $stat -> renderAlltimeVisits(TRUE);
break;
- case 3 :
- case 14 :
+ case 3 : // 'Normal' render
+ case 14 : // 'Consolidated' render
if($pref['statBrowser'])
{
$text .= $stat -> renderBrowsers(display_pars($pref['statBrowser']), $action==3);
@@ -450,10 +473,11 @@ switch($action)
$text .= ADSTAT_L7;
}
break;
- case 4:
+ case 4: // 'Normal' render
+ case 15 : // 'Consolidated' render
if($pref['statOs'])
{
- $text .= $stat -> renderOses(display_pars($pref['statOs']));
+ $text .= $stat -> renderOses(display_pars($pref['statOs']), $action==4);
}
else
{
@@ -537,6 +561,7 @@ switch($action)
12 - Today's error page visits
13 - All-time error page visits
14 - Consolidated browser view (not listed as a menu option)
+15 - Consolidated OS view (not listed as a menu option)
*/
$path = e_PLUGIN."log/stats.php";
@@ -831,7 +856,7 @@ class siteStats
/* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
// List browsers. $selection is an array of the info required - '2' = current month's stats, '1' = all-time stats (default)
- // If $show_version is FALSE, browsers are consolidated across versions - e.g. 1 line for Firefox
+ // If $show_version is FALSE, browsers are consolidated across versions - e.g. 1 line for Firefox using info from $browser_map
function renderBrowsers($selection, $show_version=TRUE)
{
global $sql, $browser_map;
@@ -839,7 +864,7 @@ class siteStats
if (!is_array($selection)) $selection = array(1);
$text = '';
- echo "Show browsers; expanded = ".($show_version ? 'TRUE' : 'FALSE')."
";
+// echo "Show browsers; expanded = ".($show_version ? 'TRUE' : 'FALSE')."
";
foreach ($selection as $act)
{
unset($statBrowser);
@@ -871,7 +896,7 @@ class siteStats
$b_type = '';
foreach ($browser_map as $name => $file)
{
- if(stristr($b_full, $name) === 0)
+ if(stripos($b_full, $name) === 0)
{ // Match here
$b_type = $name;
break;
@@ -879,7 +904,7 @@ class siteStats
}
if (!$b_type) $b_type = $b_full; // Default is an unsupported browser - use the whole name
- if (array_key_exists($temp_array,$b_type))
+ if (array_key_exists($b_type,$temp_array))
{
$temp_array[$b_type] += $v;
}
@@ -949,15 +974,19 @@ class siteStats
return $text;
}
- /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
-
- function renderOses($selection)
+ /* -------------------------------------------------------
+ Show operating systems. Only show different versions of the operating system if $show_version == TRUE
+ Uses $oses_map
+ -----------------------------------------------------------*/
+ function renderOses($selection, $show_version=TRUE)
{
- global $sql;
+ global $sql, $oses_map;
if (!$selection) $selection = array(1);
if (!is_array($selection)) $selection = array(1);
$text = '';
+// echo "Show OSes; expanded = ".($show_version ? 'TRUE' : 'FALSE')."
";
+
$statOs = array();
foreach ($selection as $act)
{
@@ -979,6 +1008,38 @@ class siteStats
}
}
+
+ if ($show_version == FALSE)
+ {
+ $temp_array = array();
+ foreach ($statOs as $b_full=>$v)
+ {
+ $b_type = '';
+ foreach ($oses_map as $name => $file)
+ {
+ if(stripos($b_full, $name) === 0)
+ { // Match here
+ $b_type = $name;
+ break;
+ }
+ }
+ if (!$b_type) $b_type = $b_full; // Default is an unsupported browser - use the whole name
+
+ if (array_key_exists($b_type,$temp_array))
+ {
+ $temp_array[$b_type] += $v;
+ }
+ else
+ {
+ $temp_array[$b_type] = $v; // New browser found
+ }
+ }
+ $statOs = $temp_array;
+ unset($temp_array);
+ }
+
+
+
if($this -> order)
{
ksort($statOs);
diff --git a/e107_plugins/log/stats_csv.php b/e107_plugins/log/stats_csv.php
new file mode 100644
index 000000000..4d6b9d79a
--- /dev/null
+++ b/e107_plugins/log/stats_csv.php
@@ -0,0 +1,343 @@
+ADSTAT_L6,'statOs'=>ADSTAT_L7,'statScreen'=>ADSTAT_L8,'statDomain'=>ADSTAT_L9,'statReferer'=>ADSTAT_L10,'statQuery'=>ADSTAT_L11);
+
+$separator_char = array(1 => ',', 2 => '|');
+$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')
+{
+ $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;
+ }
+ else
+ { // Actually do export
+ $message = export_stats($export_type, $export_date, $export_filter, $first_date, $last_date, $separator_char[$export_char], $quote_char[$export_quote], $export_stripurl);
+ }
+}
+
+
+if (isset($message) && $message)
+{
+ require_once(e_ADMIN."auth.php");
+ $ns->tablerender("", "