|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/****************************************************************** |
|
5
|
|
|
mod_stats.php Muze Ariadne |
|
6
|
|
|
------------------------------------------------------------------ |
|
7
|
|
|
Author: Florian Overkamp ([email protected]) |
|
8
|
|
|
Date: 4 february 2003 |
|
9
|
|
|
|
|
10
|
|
|
Copyright 2003 ObSimRef and Muze |
|
11
|
|
|
|
|
12
|
|
|
This file is part of Ariadne. |
|
13
|
|
|
|
|
14
|
|
|
Ariadne is free software; you can redistribute it and/or modify |
|
15
|
|
|
it under the terms of the GNU General Public License as published |
|
16
|
|
|
by the Free Software Foundation; either version 2 of the License, |
|
17
|
|
|
or (at your option) any later version. |
|
18
|
|
|
|
|
19
|
|
|
Ariadne is distributed in the hope that it will be useful, |
|
20
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22
|
|
|
GNU General Public License for more details. |
|
23
|
|
|
|
|
24
|
|
|
You should have received a copy of the GNU General Public License |
|
25
|
|
|
along with Ariadne; if not, write to the Free Software |
|
26
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
27
|
|
|
02111-1307 USA |
|
28
|
|
|
|
|
29
|
|
|
------------------------------------------------------------------- |
|
30
|
|
|
|
|
31
|
|
|
Description: |
|
32
|
|
|
|
|
33
|
|
|
This module calls the stats tools with the given |
|
34
|
|
|
options. |
|
35
|
|
|
|
|
36
|
|
|
******************************************************************/ |
|
37
|
|
|
|
|
38
|
|
|
$StatsSupportedTools = "phpOpenTracker"; |
|
39
|
|
|
|
|
40
|
|
|
class stats { |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
function log() { |
|
|
|
|
|
|
44
|
|
|
// all info is gathered from the php/webserver environment |
|
45
|
|
|
global $AR, $StatsSupportedTools; |
|
46
|
|
|
global $path; |
|
47
|
|
|
|
|
48
|
|
|
if($AR->Stats->makestats && (stristr($StatsSupportedTools, $AR->Stats->tool)!=false)) { |
|
|
|
|
|
|
49
|
|
|
// Go Go Go |
|
50
|
|
|
$client_id = $_SERVER[$AR->Stats->clientvar]; |
|
51
|
|
|
$referer = $_SERVER['HTTP_REFERER']; |
|
52
|
|
|
|
|
53
|
|
|
//$cookie=ldGetCredentials(); |
|
54
|
|
|
//$username = $cookie[$ARCurrent->session->id]['login']; |
|
55
|
|
|
|
|
56
|
|
|
// log the entry if there is a CLIENT_ID |
|
57
|
|
|
if((isset($client_id)) || (!$AR->Stats->logdefault)) { |
|
58
|
|
|
// Take logdefault if there is no CLIENT_ID |
|
59
|
|
|
|
|
60
|
|
|
// Mangle the path (adjust to your own taste) |
|
61
|
|
|
$logpath = $path; |
|
62
|
|
|
$proceed = true; |
|
63
|
|
|
|
|
64
|
|
|
// Small tests for stuff we never want to log (i.e. access to /system/) |
|
65
|
|
|
// set $proceed to false if you wish to skip this log |
|
66
|
|
|
if(is_array($AR->Stats->ignore)) { |
|
67
|
|
|
foreach($AR->Stats->ignore as $ignorepath) { |
|
68
|
|
|
if(substr($logpath, 0, strlen($ignorepath)) == $ignorepath) $proceed = false; |
|
69
|
|
|
// path may contain NLS data |
|
70
|
|
|
if(substr($logpath, 3, strlen($ignorepath)) == $ignorepath) $proceed = false; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
if($proceed) { |
|
75
|
|
|
// Do the logging |
|
76
|
|
|
debug ("mod_stats::log: path = $logpath", "class"); |
|
77
|
|
|
switch($AR->Stats->tool) { |
|
78
|
|
|
case "phpOpenTracker": $this->opentrackerlog($logpath, $referer, $client_id); |
|
79
|
|
|
} |
|
80
|
|
|
} else { |
|
81
|
|
|
debug ("mod_stats::log: path NOT logged ($logpath)", "class"); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
// |
|
88
|
|
|
// All function below are tool-specific |
|
89
|
|
|
// |
|
90
|
|
|
|
|
91
|
|
|
function opentrackerlog($logpath, $referer, $client_id) { |
|
92
|
|
|
// opentracker specific |
|
93
|
|
|
global $AR; |
|
94
|
|
|
|
|
95
|
|
|
// phpOpenTracker User Tracking |
|
96
|
|
|
require_once($AR->Stats->path); |
|
97
|
|
|
debug ("mod_stats::opentrackerlog: logging $logpath to phpOpenTracker", "class"); |
|
98
|
|
|
// log the visitor |
|
99
|
|
|
if($client_id != "") { |
|
100
|
|
|
debug ("mod_stats::opentrackerlog: client_id = $client_id", "class"); |
|
101
|
|
|
@phpOpenTracker::log( Array( |
|
102
|
|
|
'document' => $logpath, |
|
103
|
|
|
'referer' => $referer, |
|
104
|
|
|
'client_id' => $client_id) |
|
105
|
|
|
); |
|
106
|
|
|
} else { |
|
107
|
|
|
debug ("mod_stats::opentrackerlog: logging without client_id", "class"); |
|
108
|
|
|
@phpOpenTracker::log( Array( |
|
109
|
|
|
'document' => $logpath, |
|
110
|
|
|
'referer' => $referer) |
|
111
|
|
|
); |
|
112
|
|
|
} |
|
113
|
|
|
// --- |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
// Class end |
|
117
|
|
|
} |
|
118
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: