Link auf Website / Ermögliche Filter auf Domainname
Bernd Wurst

Bernd Wurst commited on 2014-05-07 10:33:32
Zeige 3 geänderte Dateien mit 23 Einfügungen und 4 Löschungen.

... ...
@@ -50,10 +50,16 @@ function autoipv6_address($vhost_id, $mode = 1)
50 50
 }
51 51
 
52 52
 
53
-function list_vhosts()
53
+function list_vhosts($domainname=NULL)
54 54
 {
55 55
   $uid = (int) $_SESSION['userinfo']['uid'];
56
-  $result = db_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=? ORDER BY domain,hostname", array($uid));
56
+  $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";
57
+  $params = array(":uid" => $uid);
58
+  if ($domainname) {
59
+    $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 domain=:domain AND uid=:uid ORDER BY hostname";
60
+    $params[":domain"] = $domainname;
61
+  }
62
+  $result = db_query($query, $params);
57 63
   $ret = array();
58 64
   while ($item = $result->fetch())
59 65
     array_push($ret, $item);
... ...
@@ -32,7 +32,12 @@ output("<p>Mit dieser Funktion legen Sie fest, welche Domains und Subdomains als
32 32
 ");
33 33
 
34 34
 
35
-$vhosts = list_vhosts();
35
+$domain = NULL;
36
+if (isset($_REQUEST['domain']) && $_REQUEST['domain'] != '') {
37
+  $domain = $_REQUEST['domain'];
38
+  output('<p class="warning"><strong>Filter aktiv!</strong> Momentan werden nur Einstellungen für die Domain <strong>'.filter_input_general($domain).'</strong> angezeigt. Klicken Sie '.internal_link('', 'hier', 'domain=').' um alle Einstellungen anzuzeigen.</p>');
39
+}
40
+$vhosts = list_vhosts($domain);
36 41
 $traffic_sum = 0;
37 42
 
38 43
 if (count($vhosts) > 0)
... ...
@@ -51,7 +56,15 @@ if (count($vhosts) > 0)
51 56
     $fqdn = $vhost['fqdn'];
52 57
     $class = 'odd';
53 58
     if ($even) $class = 'even';
54
-    output("<tr class=\"{$class}\"><td>".internal_link('edit', $fqdn, "vhost={$vhost['id']}", 'title="Einstellungen bearbeiten"')."</td><td>".internal_link('save', icon_delete("»{$vhost['fqdn']}« löschen"), 'action=delete&vhost='.$vhost['id'] )."</td><td>");
59
+    $proto = 'http';
60
+    if ($vhost['ssl'] == 'https' || $vhost['ssl'] == 'forward') {
61
+      $proto = 'https';
62
+    }
63
+    $linkuri = $vhost['fqdn'];
64
+    if (strstr($vhost['options'], 'aliaswww')) {
65
+      $linkuri = "www.".$vhost['fqdn'];
66
+    }
67
+    output("<tr class=\"{$class}\"><td>".internal_link('edit', $fqdn, "vhost={$vhost['id']}", 'title="Einstellungen bearbeiten"')."</td><td><a href=\"{$proto}://{$linkuri}\">".other_icon('world_link.png', 'Website aufrufen')."</a> ".internal_link('save', icon_delete("»{$vhost['fqdn']}« löschen"), 'action=delete&vhost='.$vhost['id'] )."</td><td>");
55 68
     $aliases = get_all_aliases($vhost);
56 69
     $tmp = '';
57 70
     if (count($aliases) > 0)
58 71