2626dd47daad110c63a82c0560b134e2364eeac3
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 Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

27) if (! isset($_REQUEST['file'])) {
28)     $_REQUEST['file'] = 'index.html';
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

29) }
30) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

31) if (!preg_match('/((daily_|hourly_|ctry_)?(usage|agent|search|ref|url|site)(_[0-9]+)?|index)\.(png|html)/', $_REQUEST['file'])) {
32)     system_failure("Ungültiger Dateiname: »".filter_input_general($_REQUEST['file'])."«");
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

33) }
34) 
Bernd Wurst Ermögliche die Verwendung v...

Bernd Wurst authored 6 years ago

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

bernd authored 14 years ago

36) $file = $path . '/' . $_REQUEST['file'];
37) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

38) if (is_file($file)) {
39)     DEBUG("opening file ".$file);
40)     if (preg_match('/\.png/', $file)) {
41)         //Binärdateien
42)         header("Content-Type: image/png");
43)         header("Content-Length: " . filesize($file));
44)         header("Content-Transfer-Encoding: binary\n");
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

45)     
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

46)         $fp = fopen($file, "r");
47)         fpassthru($fp);
48)         die();
49)     }
50) 
51)     $html = iconv('latin9', 'utf8', file_get_contents($file));
52)     DEBUG($html);
53)     // Nur content vom HTML
54)     $html = preg_replace(':^.*?<BODY[^>]*>(.*)</BODY>.*$:si', '$1', $html);
55)     DEBUG($html);
56) 
57)     // <BR> rewriten
58)     $html = preg_replace('/<BR>/', '<BR />', $html);
59)     // <HR> rewriten
60)     $html = preg_replace('/<HR>/', '<HR />', $html);
61)     // <P> rewriten
62)     $html = preg_replace('/<P>/', '<BR />', $html);
63)     // NOWRAP rewriten
64)     $html = preg_replace('/NOWRAP/', 'nowrap="nowrap"', $html);
65)     // lowercase tag names and keys
66)     $html = preg_replace_callback('/(<[^ >]+[ >])/', function ($s) {
67)         return strtolower($s[0]);
68)     }, $html);
69)     $html = preg_replace_callback('/( [A-Z]+=)/', function ($s) {
70)         return strtolower($s[0]);
71)     }, $html);
72)     // xml-values mit anführungszeichen
73)     $html = preg_replace('/=([-0-9a-zA-Z]+)([ >])/', '="$1"$2', $html);
74)     // Bilder rewriten
75)     $html = preg_replace('_<img ([^>]+[^/])>_', '<img $1 />', $html);
bernd Diverse XML-Fehler behoben

bernd authored 14 years ago

76)   
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

77)     // Bilder rewriten
78)     $html = preg_replace('/src="((daily_|hourly_|ctry_)?usage(_[0-9]+)?\.png)"/', 'src="showstats?vhost='.$vhost['id'].'&amp;file=$1"', $html);
79)     // Interne Links rewriten
80)     $html = preg_replace('!href="(./)?((usage|agent|search|ref|url|site|index)(_[0-9]+)?\.html)"!', 'href="showstats?vhost='.$vhost['id'].'&amp;file=$2"', $html);
81)     output($html);
82) } else {
83)     system_failure("Die Statistiken konnten nicht gefunden werden. Beachten Sie bitte, dass die Erstellung regelmäßig nachts geschieht. Neu in Auftrag gegebene Statistiken können Sie erst am darauffolgenden Tag betrachten.");