Webalizer/Statistik-Funktio...
bernd authored 15 years ago
|
1) <?php
|
Added license tags for CC0,...
Bernd Wurst authored 13 years ago
|
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4)
|
Lizenzinfos in eigenes Modu...
Bernd Wurst authored 11 years ago
|
5) Written 2008-2014 by schokokeks.org Hosting, namely
|
Added license tags for CC0,...
Bernd Wurst authored 13 years ago
|
6) Bernd Wurst <bernd@schokokeks.org>
7) Hanno Böck <hanno@schokokeks.org>
8)
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10)
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
12) http://creativecommons.org/publicdomain/zero/1.0/
13)
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
|
Webalizer/Statistik-Funktio...
bernd authored 15 years ago
|
16)
17) require_once("inc/base.php");
18) require_once("vhosts.php");
19)
20) require_role(ROLE_SYSTEMUSER);
21)
22) $section = 'vhosts_stats';
23)
24) // Stellt sicher, dass der angegebene VHost dem User gehört
25) $vhost = get_vhost_details($_REQUEST['vhost']);
26)
27) if (! isset($_REQUEST['file']))
28) {
29) $_REQUEST['file'] = 'index.html';
30) }
31)
32) if (!preg_match('/((daily_|hourly_|ctry_)?(usage|agent|search|ref|url|site)(_[0-9]+)?|index)\.(png|html)/', $_REQUEST['file']))
33) {
34) system_failure("Ungültiger Dateiname: »".filter_input_general($_REQUEST['file'])."«");
35) }
36)
37) $path = '/home/stats/webalizer/data/' . $vhost['fqdn'];
38) $file = $path . '/' . $_REQUEST['file'];
39)
40) if ( is_file($file) )
41) {
42) DEBUG("opening file ".$file);
43) if (preg_match('/\.png/', $file))
44) {
45) //Binärdateien
46) header("Content-Type: image/png");
47) header("Content-Length: " . filesize($file));
48) header("Content-Transfer-Encoding: binary\n");
49)
50) $fp = fopen($file, "r");
51) fpassthru($fp);
52) die();
53) }
54)
55) $html = iconv('latin9', 'utf8', file_get_contents($file));
56) DEBUG($html);
57) // Nur content vom HTML
58) $html = preg_replace(':^.*?<BODY[^>]*>(.*)</BODY>.*$:si', '$1', $html);
59) DEBUG($html);
60)
|
Diverse XML-Fehler behoben
bernd authored 15 years ago
|
61) // <BR> rewriten
62) $html = preg_replace('/<BR>/', '<BR />', $html);
63) // <HR> rewriten
64) $html = preg_replace('/<HR>/', '<HR />', $html);
65) // <P> rewriten
66) $html = preg_replace('/<P>/', '<BR />', $html);
67) // NOWRAP rewriten
68) $html = preg_replace('/NOWRAP/', 'nowrap="nowrap"', $html);
69) // lowercase tag names and keys
|
preg_replace(/.../e) ersetz...
Bernd Wurst authored 11 years ago
|
70) $html = preg_replace_callback('/(<[^ >]+[ >])/', function ($s) { return strtolower($s[0]); }, $html);
71) $html = preg_replace_callback('/( [A-Z]+=)/', function ($s) { return strtolower($s[0]); }, $html);
|
Diverse XML-Fehler behoben
bernd authored 15 years ago
|
72) // xml-values mit anführungszeichen
73) $html = preg_replace('/=([-0-9a-zA-Z]+)([ >])/', '="$1"$2', $html);
|
Webalizer/Statistik-Funktio...
bernd authored 15 years ago
|
74) // Bilder rewriten
|
Diverse XML-Fehler behoben
bernd authored 15 years ago
|
75) $html = preg_replace('_<img ([^>]+[^/])>_', '<img $1 />', $html);
76)
77) // Bilder rewriten
78) $html = preg_replace('/src="((daily_|hourly_|ctry_)?usage(_[0-9]+)?\.png)"/', 'src="showstats?vhost='.$vhost['id'].'&file=$1"', $html);
|
Webalizer/Statistik-Funktio...
bernd authored 15 years ago
|
79) // Interne Links rewriten
|
Diverse XML-Fehler behoben
bernd authored 15 years ago
|
80) $html = preg_replace('!href="(./)?((usage|agent|search|ref|url|site|index)(_[0-9]+)?\.html)"!', 'href="showstats?vhost='.$vhost['id'].'&file=$2"', $html);
|