Wirkliche nutzung der Domains anzeigen
bernd

bernd commited on 2010-04-06 14:52:49
Zeige 2 geänderte Dateien mit 52 Einfügungen und 3 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1709 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -37,21 +37,25 @@ foreach ($user_domains as $domain)
37 37
 
38 38
   $features = array();
39 39
   if ($domain->dns == 1) {
40
+    if (dns_in_use($domain->id))
40 41
       $features[] = 'DNS';
41 42
     //if ($domain->autodns == 1)
42 43
     //  $features[] = 'AutoDNS';
43 44
   }
44 45
   $mailman = mailman_subdomains($domain->id);
45
-  if ($domain->mail != 'none')
46
+  if (mail_in_use($domain->id))
46 47
     $features[] = 'Mail';
47 48
   if ($mailman)
48 49
     $features[] = 'Mailinglisten';
49
-  if ($domain->webserver == 1)
50
+  if (web_in_use($domain->id))
50 51
     $features[] = 'Web';
51 52
   if ($domain->jabber == 1)
52 53
     $features[] = 'Jabber';
53 54
 
54
-    output("  <tr><td>{$domain->fqdn}</td><td>{$regdate}</td><td>".implode(', ', $features)."</td></tr>\n");
55
+  $features = implode(', ', $features);
56
+  if (! $features)
57
+    $features = '<em>unbenutzt</em>';
58
+  output("  <tr><td>{$domain->fqdn}</td><td>{$regdate}</td><td>{$features}</td></tr>\n");
55 59
 }
56 60
 output('</table>');
57 61
 output("<br />");
... ...
@@ -20,5 +20,50 @@ function mailman_subdomains($domain)
20 20
   return $ret;
21 21
 }
22 22
 
23
+function dns_in_use($domain)
24
+{
25
+  if ( ! in_array('dns', config('modules')))
26
+    return false;
27
+  $domain = (int) $domain;
28
+  $result = db_query("SELECT id FROM dns.custom_records WHERE domain={$domain}");
29
+  return (mysql_num_rows($result) > 0);
30
+}
31
+
32
+
33
+function mail_in_use($domain)
34
+{
35
+  if ( ! in_array('email', config('modules')))
36
+  {
37
+    return false;
38
+  }
39
+  $domain = (int) $domain;
40
+  $result = db_query("SELECT mail FROM kundendaten.domains WHERE id={$domain}");
41
+  if (mysql_num_rows($result) < 1)
42
+    system_failure("Domain not found");
43
+  $d = mysql_fetch_assoc($result);
44
+  if ($d['mail'] == 'none')
45
+    return false; // manually disabled
46
+  $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain={$domain}");
47
+  if (mysql_num_rows($result) < 1)
48
+    return true; // .courier
49
+  $result = db_query("SELECT acc.id FROM mail.vmail_accounts acc LEFT JOIN mail.virtual_mail_domains dom ON (acc.domain=dom.id) WHERE dom.domain={$domain}");
50
+  return (mysql_num_rows($result) > 0);
51
+}
52
+
53
+function web_in_use($domain)
54
+{
55
+  if ( ! in_array('vhosts', config('modules')))
56
+    return false;
57
+
58
+  $domain = (int) $domain;
59
+
60
+  $result = db_query("SELECT id FROM kundendaten.domains WHERE id={$domain} AND webserver=1");
61
+  if (mysql_num_rows($result) < 1)
62
+    return false;
63
+
64
+  $result = db_query("SELECT id FROM vhosts.vhost WHERE domain={$domain}");
65
+  $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain={$domain}");
66
+  return (mysql_num_rows($result) > 0 || mysql_num_rows($result2) > 0);
67
+}
23 68
 
24 69
 
25 70