49fd23ed86038fd5f9a9687e0d8f180438777c9a
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 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) */
bernd Webalizer/Statistik-Funktio...

bernd authored 14 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) 
Bernd Wurst Benutze idn_to_ascii für de...

Bernd Wurst authored 7 years ago

37) $path = '/home/stats/webalizer/data/' . idn_to_ascii($vhost['fqdn']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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) 
bernd Diverse XML-Fehler behoben

bernd authored 14 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
Bernd Wurst preg_replace(/.../e) ersetz...

Bernd Wurst authored 10 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);
bernd Diverse XML-Fehler behoben

bernd authored 14 years ago

72)   // xml-values mit anführungszeichen
73)   $html = preg_replace('/=([-0-9a-zA-Z]+)([ >])/', '="$1"$2', $html);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

74)   // Bilder rewriten
bernd Diverse XML-Fehler behoben

bernd authored 14 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'].'&amp;file=$1"', $html);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

79)   // Interne Links rewriten
bernd Diverse XML-Fehler behoben

bernd authored 14 years ago

80)   $html = preg_replace('!href="(./)?((usage|agent|search|ref|url|site|index)(_[0-9]+)?\.html)"!', 'href="showstats?vhost='.$vhost['id'].'&amp;file=$2"', $html);