some updates
bernd

bernd commited on 2008-08-13 07:09:36
Zeige 4 geänderte Dateien mit 51 Einfügungen und 3 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1134 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -37,6 +37,7 @@ class Domain extends KeksData
37 37
 
38 38
   function parse($data)
39 39
   {
40
+    DEBUG($data);
40 41
     foreach (array_keys($this->data) as $key)
41 42
       if (array_key_exists($key, $data))
42 43
         $this->data[$key] = $data[$key];
... ...
@@ -8,7 +8,7 @@ function DEBUG($str)
8 8
 {
9 9
   global $debugmode;
10 10
   if ($debugmode)
11
-    if (is_array($str))
11
+    if (is_array($str) || is_object($str))
12 12
     {
13 13
       echo "<pre>".print_r($str, true)."</pre>\n";
14 14
     }
... ...
@@ -22,6 +22,8 @@ DEBUG($domains);
22 22
 
23 23
 foreach($domains AS $dom)
24 24
 {
25
+  if ($dom->dns == 0)
26
+    continue;
25 27
   $records = get_domain_records($dom->id);
26 28
 
27 29
   $autorec = ($dom->autodns == 1 ? 'Ja' : 'Nein');
... ...
@@ -45,6 +47,5 @@ foreach($domains AS $dom)
45 47
 }
46 48
 
47 49
 $output .= '</table><br />';
48
-$output .= '<p>'.internal_link('dns_edit', 'Neuen DNS-Record anlegen').'</p>';
49 50
 
50 51
 ?>
... ...
@@ -91,12 +91,46 @@ function get_dyndns_records($id)
91 91
   return $data;
92 92
 }
93 93
 
94
+$valid_record_types = array('a', 'aaaa', 'mx', 'ns', 'spf', 'txt', 'cname', 'ptr', 'srv', 'raw');
95
+
96
+
97
+function blank_dns_record($type)
98
+{ 
99
+  global $valid_record_types;
100
+  if (!in_array(strtolower($type), $valid_record_types))
101
+    system_failure('invalid type: '.$type);
102
+  $rec = array('hostname' => NULL,
103
+               'domain' => 0,
104
+               'type' => strtolower($type),
105
+               'ttl' => 3600,
106
+               'ip' => NULL,
107
+               'dyndns' => NULL,
108
+               'data' => NULL,
109
+               'spec' => NULL);
110
+  if (strtolower($type) == 'mx')
111
+  {
112
+    $rec['data'] = 'zucker.schokokeks.org';
113
+    $rec['spec'] = '5';
114
+  }
115
+  return $rec;
116
+}
117
+
118
+function get_dns_record($id)
119
+{
120
+  $id = (int) $id;
121
+  $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl FROM dns.custom_records WHERE id={$id}");
122
+  if (mysql_num_rows($result) != 1)
123
+    system_failure('illegal ID');
124
+  $data = mysql_fetch_assoc($result);
125
+  DEBUG($data);
126
+  return $data;
127
+}
94 128
 
95 129
 
96 130
 function get_domain_records($dom)
97 131
 {
98 132
   $dom = (int) $dom;
99
-  $result = db_query("SELECT hostname, domain, type, ip, dyndns, data, ttl, id FROM dns.custom_records WHERE domain={$dom}");
133
+  $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl, id FROM dns.custom_records WHERE domain={$dom}");
100 134
   $data = array();
101 135
   while ($entry = mysql_fetch_assoc($result)) {
102 136
     $dom = new Domain((int) $entry['domain']);
... ...
@@ -109,6 +143,18 @@ function get_domain_records($dom)
109 143
   return $data;
110 144
 }
111 145
 
146
+function get_domain_auto_records($domainname)
147
+{
148
+  $domainname = mysql_real_escape_string($domainname);
149
+  $result = db_query("SELECT hostname, domain, CONCAT_WS('.', hostname, domain) AS fqdn, type, ip, spec, data, ttl FROM dns.v_autogenerated_records WHERE domain='{$domainname}'");
150
+  $data = array();
151
+  while ($entry = mysql_fetch_assoc($result)) {
152
+    array_push($data, $entry);
153
+  }
154
+  DEBUG($data);
155
+  return $data;
156
+}
157
+
112 158
 
113 159
 
114 160
 ?>
115 161