awstats-parser
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Sections~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//GENERAL # see below
//MISC # Misc ID" => "Pages" => "Hits" => "Bandwidth
//TIME # Hour" => "Pages" => "Hits" => "Bandwidth" => "Not viewed Pages" => "Not viewed Hits" => "Not viewed Bandwidth
//VISITOR # Host" => "Pages" => "Hits" => "Bandwidth" => "Last visit date" => "[Start date of last visit]" => "[Last page of last visit]
//DAY # Date" => "Pages" => "Hits" => "Bandwidth" => "Visits
//DOMAIN # Domain" => "Pages" => "Hits" => "Bandwidth
//ROBOT # Robot ID" => "Hits" => "Bandwidth" => "Last visit" => "Hits on robots.txt
//SESSION # Session range" => "Number of visits
//SIDER # URL" => "Pages" => "Bandwidth" => "Entry" => "Exit
//FILETYPES # Files type" => "Hits" => "Bandwidth" => "Bandwidth without compression" => "Bandwidth after compression
//OS # OS ID" => "Hits
//BROWSER # Browser ID" => "Hits
//UNKNOWNREFERER # Unknown referer OS" => "Last visit date
//UNKNOWNREFERERBROWSER # Unknown referer Browser" => "Last visit date
//ORIGIN # Origin" => "Pages" => "Hits
//PAGEREFS # External page referers" => "Pages" => "Hits
//ERRORS # Errors" => "Hits" => "Bandwidth
//SIDER_404 # URL with 404 errors" => "Hits" => "Last URL referer
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Sections~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GENERAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
# LastLine = Date of last record processed" => "Last record line number in last log" => "Last record offset in last log" => "Last record signature value
# FirstTime = Date of first visit for history file
# LastTime = Date of last visit for history file
# LastUpdate = Date of last update" => "Nb of parsed records" => "Nb of parsed old records" => "Nb of parsed new records" => "Nb of parsed corrupted- Nb of parsed dropped
# TotalVisits = Number of visits
# TotalUnique = Number of unique visitors
# MonthHostsKnown = Number of hosts known
# MonthHostsUnKnown = Number of hosts unknown
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GENERAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//USER CONFIG
$awstat_path = "/var/lib/awstats";
$config_domain = "www.colddot.nl";
//NAME CHANGERS
$os_array = array(
"winxp" => "Windows XP",
"winxbox" => "Xbox",
"winnt" => "Windows NT",
"winme" => "Windows ME",
"winlong" => "Windows Longhorn",
"wince" => "Windows CE",
"win" => "Windows",
"win2003" => "Windows 2003",
"win2000" => "Windows 2000",
"win98" => "Windows 98",
"win95" => "Windows 95",
"win16" => "Windows 16",
"webtv" => "Web TV",
"sunos" => "Sun OS",
"psp" => "Playstation portable",
"openbsd" => "Open BSD",
"netbsd" => "Net BSD",
"macosx" => "Mac OS X",
"macintosh" => "Mac Intosh",
"linuxubuntu" => "Ubuntu",
"linuxsuse" => "SuSe",
"linuxredhat" => "Red Hat",
"linuxmandr" => "Mandrake",
"linuxfedora" => "Fedora",
"linuxdebian" => "Debian",
"linuxcentos" => "Centos",
"kfreebsd" => "kFree BSD",
"freebsd" => "Free BSD",
"bsdopenbsd" => "BSD Open BSD",
"bsdnetbsd" => "BSD Net BSD",
"bsdfreebsd" => "BSD Free BSD"
);
$bot_array = array(
"googlebot" => "http://www.google.com/bot.html",
"msnbot" => "http://search.msn.com/msnbot.htm",
"slurp" => "http://help.yahoo.com/help/us/ysearch/slurp/",
"girafabot" => "http://www.girafa.com/",
"msiecrawler" => "http://msdn.microsoft.com/workshop/delivery/offline/linkrel.asp",
"mj12bot" => "http://majestic12.co.uk/bot.php",
"jeeves" => "http://sp.ask.com/docs/about/tech_crawling.html",
);
$error_array = array(
"0" => "Onvolledig/Niet gedefinieerd",
"201" => "Angemaakt",
"202" => "Geaccepteerd",
"204" => "Geen inhoud",
"206" => "Gedeeltelijke inhoud",
"301" => "Permanent verplaatst",
"302" => "Verwijzen",
"304" => "Niet veranderd",
"400" => "Verkeerd syntax",
"401" => "Niet geautoriseerd",
"402" => "Niet in gebruik",
"403" => "Verboden",
"404" => "Bestand niet gevonden",
"405" => "Methode niet toegestaan",
"406" => "Niet acceptabel",
"407" => "Proxy-autorisatie vereist",
"408" => "Timeout voor dit verzoek",
"500" => "Interne Server Fout",
"501" => "Niet geimplemeteerd",
"502" => "Server Overbelast",
"503" => "Gateway Timeout",
);
//SCRIPT CONFIG
if(isset($_GET["config"])){
$config_domain = $_GET["config"];
$config_link = "?config=www.".$_GET["config"];
}
//READ CONFIG
$awstats_text = file_get_contents($awstat_path."/awstats".date("mY").".".$config_domain.".txt");
//FUNCTIONS
function os($name){
global $os_array;
$array = array_flip($os_array);
if(in_array($name,$array)){
return $os_array[$name];
}else{
return ucfirst($name);
}
}
function file_size($size,$wat = true) {
$bytes = array("B", "KB", "MB", "GB", "TB", "PB");
$i = 0;
while ($size >= 1024) {
$size = $size/1024;
$i++;
}
if ($i > 1) {
if($wat == true){$extra = " ".$bytes[$i];}else{$extra = NULL;}
return round($size,2).$extra;
} else {
if($wat == true){$extra = " ".$bytes[$i];}else{$extra = NULL;}
return round($size,0).$extra;
}
}
function bot($name){
global $bot_array;
$array = array_flip($bot_array);
if(in_array($name,$array)){
return "<a href=\"".$bot_array[$name]."\">".ucfirst($name)."</a>";
}else{
return ucfirst($name);
}
}
function read_section($section) {
global $awstats_text;
if (preg_match('/\nBEGIN_'.$section.' \d+\n(.*)\nEND_'.$section.'\n/s', $awstats_text, $match)) {
foreach (explode("\n", $match[1]) as $row)
$lines[] = split(' ', trim($row));
}
return $lines;
}
if (!function_exists('is_even')) {
function is_even($getal){
$iNum = ($getal / 2);
$aNum = explode('.', $iNum);
if($aNum[1] == 5){
return FALSE;
}else{
return TRUE;
}
}
}
function procent($hits,$tot_hits){
$deel = $hits / $tot_hits;
return round($deel * 100,1);
}
?>
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Sections~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//GENERAL # see below
//MISC # Misc ID" => "Pages" => "Hits" => "Bandwidth
//TIME # Hour" => "Pages" => "Hits" => "Bandwidth" => "Not viewed Pages" => "Not viewed Hits" => "Not viewed Bandwidth
//VISITOR # Host" => "Pages" => "Hits" => "Bandwidth" => "Last visit date" => "[Start date of last visit]" => "[Last page of last visit]
//DAY # Date" => "Pages" => "Hits" => "Bandwidth" => "Visits
//DOMAIN # Domain" => "Pages" => "Hits" => "Bandwidth
//ROBOT # Robot ID" => "Hits" => "Bandwidth" => "Last visit" => "Hits on robots.txt
//SESSION # Session range" => "Number of visits
//SIDER # URL" => "Pages" => "Bandwidth" => "Entry" => "Exit
//FILETYPES # Files type" => "Hits" => "Bandwidth" => "Bandwidth without compression" => "Bandwidth after compression
//OS # OS ID" => "Hits
//BROWSER # Browser ID" => "Hits
//UNKNOWNREFERER # Unknown referer OS" => "Last visit date
//UNKNOWNREFERERBROWSER # Unknown referer Browser" => "Last visit date
//ORIGIN # Origin" => "Pages" => "Hits
//PAGEREFS # External page referers" => "Pages" => "Hits
//ERRORS # Errors" => "Hits" => "Bandwidth
//SIDER_404 # URL with 404 errors" => "Hits" => "Last URL referer
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Sections~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GENERAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
# LastLine = Date of last record processed" => "Last record line number in last log" => "Last record offset in last log" => "Last record signature value
# FirstTime = Date of first visit for history file
# LastTime = Date of last visit for history file
# LastUpdate = Date of last update" => "Nb of parsed records" => "Nb of parsed old records" => "Nb of parsed new records" => "Nb of parsed corrupted- Nb of parsed dropped
# TotalVisits = Number of visits
# TotalUnique = Number of unique visitors
# MonthHostsKnown = Number of hosts known
# MonthHostsUnKnown = Number of hosts unknown
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~GENERAL~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
//USER CONFIG
$awstat_path = "/var/lib/awstats";
$config_domain = "www.colddot.nl";
//NAME CHANGERS
$os_array = array(
"winxp" => "Windows XP",
"winxbox" => "Xbox",
"winnt" => "Windows NT",
"winme" => "Windows ME",
"winlong" => "Windows Longhorn",
"wince" => "Windows CE",
"win" => "Windows",
"win2003" => "Windows 2003",
"win2000" => "Windows 2000",
"win98" => "Windows 98",
"win95" => "Windows 95",
"win16" => "Windows 16",
"webtv" => "Web TV",
"sunos" => "Sun OS",
"psp" => "Playstation portable",
"openbsd" => "Open BSD",
"netbsd" => "Net BSD",
"macosx" => "Mac OS X",
"macintosh" => "Mac Intosh",
"linuxubuntu" => "Ubuntu",
"linuxsuse" => "SuSe",
"linuxredhat" => "Red Hat",
"linuxmandr" => "Mandrake",
"linuxfedora" => "Fedora",
"linuxdebian" => "Debian",
"linuxcentos" => "Centos",
"kfreebsd" => "kFree BSD",
"freebsd" => "Free BSD",
"bsdopenbsd" => "BSD Open BSD",
"bsdnetbsd" => "BSD Net BSD",
"bsdfreebsd" => "BSD Free BSD"
);
$bot_array = array(
"googlebot" => "http://www.google.com/bot.html",
"msnbot" => "http://search.msn.com/msnbot.htm",
"slurp" => "http://help.yahoo.com/help/us/ysearch/slurp/",
"girafabot" => "http://www.girafa.com/",
"msiecrawler" => "http://msdn.microsoft.com/workshop/delivery/offline/linkrel.asp",
"mj12bot" => "http://majestic12.co.uk/bot.php",
"jeeves" => "http://sp.ask.com/docs/about/tech_crawling.html",
);
$error_array = array(
"0" => "Onvolledig/Niet gedefinieerd",
"201" => "Angemaakt",
"202" => "Geaccepteerd",
"204" => "Geen inhoud",
"206" => "Gedeeltelijke inhoud",
"301" => "Permanent verplaatst",
"302" => "Verwijzen",
"304" => "Niet veranderd",
"400" => "Verkeerd syntax",
"401" => "Niet geautoriseerd",
"402" => "Niet in gebruik",
"403" => "Verboden",
"404" => "Bestand niet gevonden",
"405" => "Methode niet toegestaan",
"406" => "Niet acceptabel",
"407" => "Proxy-autorisatie vereist",
"408" => "Timeout voor dit verzoek",
"500" => "Interne Server Fout",
"501" => "Niet geimplemeteerd",
"502" => "Server Overbelast",
"503" => "Gateway Timeout",
);
//SCRIPT CONFIG
if(isset($_GET["config"])){
$config_domain = $_GET["config"];
$config_link = "?config=www.".$_GET["config"];
}
//READ CONFIG
$awstats_text = file_get_contents($awstat_path."/awstats".date("mY").".".$config_domain.".txt");
//FUNCTIONS
function os($name){
global $os_array;
$array = array_flip($os_array);
if(in_array($name,$array)){
return $os_array[$name];
}else{
return ucfirst($name);
}
}
function file_size($size,$wat = true) {
$bytes = array("B", "KB", "MB", "GB", "TB", "PB");
$i = 0;
while ($size >= 1024) {
$size = $size/1024;
$i++;
}
if ($i > 1) {
if($wat == true){$extra = " ".$bytes[$i];}else{$extra = NULL;}
return round($size,2).$extra;
} else {
if($wat == true){$extra = " ".$bytes[$i];}else{$extra = NULL;}
return round($size,0).$extra;
}
}
function bot($name){
global $bot_array;
$array = array_flip($bot_array);
if(in_array($name,$array)){
return "<a href=\"".$bot_array[$name]."\">".ucfirst($name)."</a>";
}else{
return ucfirst($name);
}
}
function read_section($section) {
global $awstats_text;
if (preg_match('/\nBEGIN_'.$section.' \d+\n(.*)\nEND_'.$section.'\n/s', $awstats_text, $match)) {
foreach (explode("\n", $match[1]) as $row)
$lines[] = split(' ', trim($row));
}
return $lines;
}
if (!function_exists('is_even')) {
function is_even($getal){
$iNum = ($getal / 2);
$aNum = explode('.', $iNum);
if($aNum[1] == 5){
return FALSE;
}else{
return TRUE;
}
}
}
function procent($hits,$tot_hits){
$deel = $hits / $tot_hits;
return round($deel * 100,1);
}
?>