Statistik-Funktion entfernt
Bernd Wurst

Bernd Wurst commited on 2019-07-29 07:26:02
Zeige 6 geänderte Dateien mit 5 Einfügungen und 194 Löschungen.

... ...
@@ -100,10 +100,10 @@ function autoipv6_address($vhost_id, $mode = 1)
100 100
 function list_vhosts($filter=null)
101 101
 {
102 102
     $uid = (int) $_SESSION['userinfo']['uid'];
103
-    $query = "SELECT vh.id,fqdn,domain,docroot,docroot_is_default,php,cgi,vh.certid AS cert, vh.ssl, vh.options,logtype,errorlog,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp, stats FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE uid=:uid ORDER BY domain,hostname";
103
+    $query = "SELECT vh.id,fqdn,domain,docroot,docroot_is_default,php,cgi,vh.certid AS cert, vh.ssl, vh.options,logtype,errorlog,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE uid=:uid ORDER BY domain,hostname";
104 104
     $params = array(":uid" => $uid);
105 105
     if ($filter) {
106
-        $query = "SELECT vh.id,fqdn,domain,docroot,docroot_is_default,php,cgi,vh.certid AS cert, vh.ssl, vh.options,logtype,errorlog,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp, stats FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
106
+        $query = "SELECT vh.id,fqdn,domain,docroot,docroot_is_default,php,cgi,vh.certid AS cert, vh.ssl, vh.options,logtype,errorlog,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
107 107
         $params[":filter"] = "%$filter%";
108 108
     }
109 109
     $result = db_query($query, $params);
... ...
@@ -159,7 +159,6 @@ function empty_vhost()
159 159
     $vhost['autoipv6'] = 2; // 1 => Eine IP pro User, 2 => Eine IP pro VHost
160 160
 
161 161
     $vhost['options'] = 'forwardwww';
162
-    $vhost['stats'] = null;
163 162
     return $vhost;
164 163
 }
165 164
 
... ...
@@ -494,17 +493,16 @@ function save_vhost($vhost)
494 493
                 ":ipv4" => $ipv4,
495 494
                 ":autoipv6" => $autoipv6,
496 495
                 ":options" => $vhost['options'],
497
-                ":stats" => ($vhost['stats'] ? $vhost['stats'] : null),
498 496
                 ":id" => $id);
499 497
     if ($id != 0) {
500 498
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
501
-        db_query("UPDATE vhosts.vhost SET hostname=:hostname, domain=:domain, docroot=:docroot, php=:php, cgi=:cgi, `ssl`=:ssl, hsts=:hsts, `suexec_user`=:suexec_user, `server`=:server, logtype=:logtype, errorlog=:errorlog, certid=:cert, ipv4=:ipv4, autoipv6=:autoipv6, options=:options, stats=:stats WHERE id=:id", $args);
499
+        db_query("UPDATE vhosts.vhost SET hostname=:hostname, domain=:domain, docroot=:docroot, php=:php, cgi=:cgi, `ssl`=:ssl, hsts=:hsts, `suexec_user`=:suexec_user, `server`=:server, logtype=:logtype, errorlog=:errorlog, certid=:cert, ipv4=:ipv4, autoipv6=:autoipv6, options=:options WHERE id=:id", $args);
502 500
     } else {
503 501
         $args[":user"] = $_SESSION['userinfo']['uid'];
504 502
         unset($args[":id"]);
505 503
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
506
-        $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, hsts, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ".
507
-                       "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args, true);
504
+        $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, hsts, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options) VALUES ".
505
+                       "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options)", $args, true);
508 506
         $id = db_insert_id();
509 507
     }
510 508
     $oldvhost = get_vhost_details($id);
... ...
@@ -20,7 +20,6 @@ $role = $_SESSION['role'];
20 20
 
21 21
 if ($role & ROLE_SYSTEMUSER) {
22 22
     $menu["vhosts_vhosts"] = array("label" => "Websites", "file" => "vhosts", "weight" => 2);
23
-    $menu["vhosts_stats"] = array("label" => "Zugriffs-Statistiken", "file" => "stats", "weight" => 12, "submenu" => "vhosts_vhosts");
24 23
 
25 24
     if (user_has_manual_certs() or ($section == 'vhosts_certs')) {
26 25
         $menu["vhosts_certs"] = array("label" => "TLS-Zertifikate", "file" => "certs", "weight" => 10, "submenu" => "vhosts_vhosts");
... ...
@@ -196,18 +196,6 @@ if ($_GET['action'] == 'edit') {
196 196
     }
197 197
 
198 198
 
199
-    if (isset($_POST['stats']) && $_POST['stats'] == 1) {
200
-        if ($vhost['stats'] == null) {
201
-            $vhost['stats'] = 'private';
202
-        }
203
-    } else {
204
-        $vhost['stats'] = null;
205
-    }
206
-
207
-    if ($logtype == '') {
208
-        $vhost['stats'] = null;
209
-    }
210
-
211 199
     DEBUG("PHP: {$php} / Logging: {$logtype}");
212 200
 
213 201
     $old_options = explode(',', $vhost['options']);
... ...
@@ -1,86 +0,0 @@
1
-<?php
2
-/*
3
-This file belongs to the Webinterface of schokokeks.org Hosting
4
-
5
-Written 2008-2018 by schokokeks.org Hosting, namely
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
-*/
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
-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
-
26
-// Stellt sicher, dass der angegebene VHost dem User gehört
27
-$vhost = get_vhost_details($_REQUEST['vhost']);
28
-
29
-if (! isset($_REQUEST['file'])) {
30
-    $_REQUEST['file'] = 'index.html';
31
-}
32
-
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'])."«");
35
-}
36
-
37
-$path = '/home/stats/webalizer/data/' . idn_to_ascii($vhost['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
38
-$file = $path . '/' . $_REQUEST['file'];
39
-
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");
47
-
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);
78
-
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.");
86
-}
... ...
@@ -1,86 +0,0 @@
1
-<?php
2
-/*
3
-This file belongs to the Webinterface of schokokeks.org Hosting
4
-
5
-Written 2008-2018 by schokokeks.org Hosting, namely
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
-*/
16
-
17
-require_once("inc/icons.php");
18
-
19
-require_once("vhosts.php");
20
-
21
-require_role(ROLE_SYSTEMUSER);
22
-
23
-title("Zugriffs-Statistiken");
24
-
25
-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.');
26
-
27
-if (isset($_REQUEST['vhost'])) {
28
-    $v = get_vhost_details($_REQUEST['vhost']);
29
-
30
-    if (isset($_REQUEST['public'])) {
31
-        $v['stats'] = ($_REQUEST['public'] == 1) ? 'public' : 'private';
32
-    }
33
-    if (isset($_REQUEST['action'])) {
34
-        if ($_REQUEST['action'] == 'delete') {
35
-            $v['stats'] = null;
36
-        } elseif ($_REQUEST['action'] == 'new') {
37
-            check_form_token('stats_new');
38
-        }
39
-    }
40
-    save_vhost($v);
41
-    redirect('stats');
42
-} else {
43
-    $all_vhosts = list_vhosts();
44
-    $stats_vhosts = array();
45
-
46
-    foreach ($all_vhosts as $v) {
47
-        if ($v['stats']) {
48
-            $stats_vhosts[] = $v;
49
-        }
50
-    }
51
-
52
-
53
-    output('<p>Um die Reichweite und das Publikum Ihrer Internet-Seiten besser einschätzen zu können, besteht die Möglichkeit aus den ggf. vorhandenen Webserver-Logfiles grafisch aufbereitete Statistiken erstellen zu lassen.</p>
54
-
55
-<h3>Statistiken für Ihre Seiten</h3>
56
-');
57
-
58
-    if (count($stats_vhosts) > 0) {
59
-        output('
60
-  <table><tr><th>Für Website</th><th>Öffentlich abrufbar?</th><th>Operationen</th></tr>
61
-  ');
62
-
63
-        foreach ($stats_vhosts as $v) {
64
-            output("<tr>");
65
-            output("<td>".internal_link('showstats', $v['fqdn'], "vhost={$v['id']}")."</td>");
66
-
67
-            if ($v['stats'] == 'public') {
68
-                output("<td><a href=\"http://".config('stats_hostname')."/{$v['fqdn']}\">".icon_enabled("Diese Statistiken können von jedermann aufgerufen werden. Klicken Sie hier um die öffentliche Version zu sehen.")."</a></td>");
69
-            } else {
70
-                output("<td>".icon_disabled("Diese Statistiken können nur hier im Webinterface betrachtet werden.")."</td>");
71
-            }
72
-
73
-            output("<td>");
74
-            if ($v['stats'] == 'public') {
75
-                output(internal_link("", other_icon("lock.png", "Statistiken nicht mehr öffentlich anzeigen"), "vhost={$v['id']}&public=0"));
76
-            } else {
77
-                output(internal_link("", other_icon("world.png", "Statistiken veröffentlichen"), "vhost={$v['id']}&public=1"));
78
-            }
79
-            output(" &#160; ".internal_link("", icon_delete("Diese Statistiken löschen"), "vhost={$v['id']}&action=delete")."</td>");
80
-            output("</tr>");
81
-        }
82
-        output('</table>');
83
-    } else {
84
-        output('<em>Für Ihre Seiten werden bisher keine Statistiken erzeugt</em>');
85
-    }
86
-}
... ...
@@ -109,8 +109,6 @@ if (count($vhosts) > 0) {
109 109
                 $logfiles .= ' + Fehler';
110 110
             }
111 111
         }
112
-        $stats = $vhost['stats'] ? internal_link("showstats", other_icon("chart_bar.png", "Statistiken anzeigen"), "vhost={$vhost['id']}").' ' : '';
113
-        output("<td>{$stats}{$logfiles}</td>");
114 112
 
115 113
         if ($vhost['ssl'] == 'http') {
116 114
             output("<td>".icon_disabled('HTTPS ausgeschaltet')."</td>");
117 115