d2047d87210ad602613285456d222c3114d204ae
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) 
Bernd Wurst warning about shutdown of t...

Bernd Wurst authored 5 years ago

24) warning('Diese Statistiken werden in Kürze abgeschafft. Wenn Sie eine solche Funktion weiterhin nutzen möchten, können Sie mit dem Programm "webalizer" selbst solche Statistiken erstellen lassen. Auf Anfrage können wir Ihnen die bestehenden Daten verfügbar machen um die rückblickenden Auswertungen zu erhalten.');
25) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

26) // Stellt sicher, dass der angegebene VHost dem User gehört
27) $vhost = get_vhost_details($_REQUEST['vhost']);
28) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 14 years ago

31) }
32) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 14 years ago

35) }
36) 
Bernd Wurst Ermögliche die Verwendung v...

Bernd Wurst authored 6 years ago

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

bernd authored 14 years ago

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

Hanno authored 6 years ago

40) if (is_file($file)) {
41)     DEBUG("opening file ".$file);
42)     if (preg_match('/\.png/', $file)) {
43)         //Binärdateien
44)         header("Content-Type: image/png");
45)         header("Content-Length: " . filesize($file));
46)         header("Content-Transfer-Encoding: binary\n");
Hanno remove whitespace in empty...

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

79)     // Bilder rewriten
80)     $html = preg_replace('/src="((daily_|hourly_|ctry_)?usage(_[0-9]+)?\.png)"/', 'src="showstats?vhost='.$vhost['id'].'&amp;file=$1"', $html);
81)     // Interne Links rewriten
82)     $html = preg_replace('!href="(./)?((usage|agent|search|ref|url|site|index)(_[0-9]+)?\.html)"!', 'href="showstats?vhost='.$vhost['id'].'&amp;file=$2"', $html);
83)     output($html);
84) } else {
85)     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.");