Browse code

Update codingstyle according to latest PHP CS Fixer 2.14.2

Hanno authored on28/03/2019 18:56:56
Showing1 changed files
... ...
@@ -282,7 +282,7 @@ function set_domain_pretransfer($domain)
282 282
     $domain = (int) $domain;
283 283
     db_query(
284 284
         "UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?",
285
-            array($domain, $cid)
285
+        array($domain, $cid)
286 286
     );
287 287
 }
288 288
 
... ...
@@ -295,7 +295,7 @@ function set_domain_prereg($domain)
295 295
     $domain = (int) $domain;
296 296
     db_query(
297 297
         "UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?",
298
-            array($domain, $cid)
298
+        array($domain, $cid)
299 299
     );
300 300
 }
301 301
 
Browse code

remove whitespace in empty lines

Hanno authored on26/06/2018 23:36:40
Showing1 changed files
... ...
@@ -152,7 +152,7 @@ function get_auth_dns($domainname, $tld)
152 152
 
153 153
     $resp = shell_exec('dig @'.$NS.' -t ns '.$domain.'.');
154 154
     $lines = explode("\n", $resp);
155
-  
155
+
156 156
     $NS = null;
157 157
     $NS_IP = null;
158 158
     $sec = null;
... ...
@@ -271,7 +271,7 @@ function get_domain_offer($tld)
271 271
     $data["gebuehr"] = $temp["gebuehr"];
272 272
     $data["interval"] = $temp["interval"];
273 273
     $data["setup"] = ($temp["setup"] ? $temp["setup"] : 0.0);
274
-  
274
+
275 275
     return $data;
276 276
 }
277 277
 
... ...
@@ -312,7 +312,7 @@ function insert_domain_external($domain, $dns = false, $mail = true)
312 312
     $tld = $info['domainSuffix'];
313 313
     $domainname = str_replace(".$tld", "", $info['domainNameUnicode']);
314 314
     logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Inserting external domain '.$info['domainNameUnicode']." DNS:{$dns} / Mail:{$mail}");
315
-    
315
+
316 316
     db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
317 317
         ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, 1)", array($cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none')));
318 318
     $id = db_insert_id();
Browse code

Fix coding style with php-cs-checker, see https://cs.sensiolabs.org/

Hanno authored on26/06/2018 13:58:19
Showing1 changed files
... ...
@@ -8,7 +8,7 @@ Written 2008-2018 by schokokeks.org Hosting, namely
8 8
 
9 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 10
 
11
-You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
12 12
 http://creativecommons.org/publicdomain/zero/1.0/
13 13
 
14 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.
... ...
@@ -19,51 +19,53 @@ require_once('inc/debug.php');
19 19
 
20 20
 function mailman_subdomains($domain)
21 21
 {
22
-  if ( ! in_array('mailman', config('modules')))
23
-  {
24
-    return array();
25
-  }
26
-  $domain = (int) $domain;
27
-  $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain=?", array($domain));
28
-  $ret = array();
29
-  while ($line = $result->fetch())
30
-  {
31
-    $ret[] = $line;
32
-  }
33
-  return $ret;
22
+    if (! in_array('mailman', config('modules'))) {
23
+        return array();
24
+    }
25
+    $domain = (int) $domain;
26
+    $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain=?", array($domain));
27
+    $ret = array();
28
+    while ($line = $result->fetch()) {
29
+        $ret[] = $line;
30
+    }
31
+    return $ret;
34 32
 }
35 33
 
36 34
 function dns_in_use($domain)
37 35
 {
38
-  if ( ! in_array('dns', config('modules')))
39
-    return false;
40
-  $domain = (int) $domain;
41
-  $result = db_query("SELECT id FROM dns.custom_records WHERE domain=?", array($domain));
42
-  return ($result->rowCount() > 0);
36
+    if (! in_array('dns', config('modules'))) {
37
+        return false;
38
+    }
39
+    $domain = (int) $domain;
40
+    $result = db_query("SELECT id FROM dns.custom_records WHERE domain=?", array($domain));
41
+    return ($result->rowCount() > 0);
43 42
 }
44 43
 
45 44
 
46 45
 function mail_in_use($domain)
47 46
 {
48
-  if ( ! in_array('email', config('modules')))
49
-  {
50
-    return false;
51
-  }
52
-  $domain = (int) $domain;
53
-  $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", array($domain));
54
-  if ($result->rowCount() < 1)
55
-    system_failure("Domain not found");
56
-  $d = $result->fetch();
57
-  if ($d['mail'] == 'none')
58
-    return false; // manually disabled
59
-  $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain=?", array($domain));
60
-  if ($result->rowCount() < 1)
61
-    return true; // .courier
62
-  $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=?", array($domain));
63
-  return ($result->rowCount() > 0);
47
+    if (! in_array('email', config('modules'))) {
48
+        return false;
49
+    }
50
+    $domain = (int) $domain;
51
+    $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", array($domain));
52
+    if ($result->rowCount() < 1) {
53
+        system_failure("Domain not found");
54
+    }
55
+    $d = $result->fetch();
56
+    if ($d['mail'] == 'none') {
57
+        return false;
58
+    } // manually disabled
59
+    $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain=?", array($domain));
60
+    if ($result->rowCount() < 1) {
61
+        return true;
62
+    } // .courier
63
+    $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=?", array($domain));
64
+    return ($result->rowCount() > 0);
64 65
 }
65 66
 
66
-function count_vmail($domain) {
67
+function count_vmail($domain)
68
+{
67 69
     $domain = (int) $domain;
68 70
     $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=?", array($domain));
69 71
     return $result->rowCount();
... ...
@@ -71,24 +73,26 @@ function count_vmail($domain) {
71 73
 
72 74
 function web_in_use($domain)
73 75
 {
74
-  if ( ! in_array('vhosts', config('modules')))
75
-    return false;
76
+    if (! in_array('vhosts', config('modules'))) {
77
+        return false;
78
+    }
76 79
 
77
-  $domain = (int) $domain;
80
+    $domain = (int) $domain;
78 81
 
79
-  $result = db_query("SELECT id FROM kundendaten.domains WHERE id=? AND webserver=1", array($domain));
80
-  if ($result->rowCount() < 1)
81
-    return false;
82
+    $result = db_query("SELECT id FROM kundendaten.domains WHERE id=? AND webserver=1", array($domain));
83
+    if ($result->rowCount() < 1) {
84
+        return false;
85
+    }
82 86
 
83
-  $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=?", array($domain));
84
-  $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain=?", array($domain));
85
-  return ($result->rowCount() > 0 || $result2->rowCount() > 0);
87
+    $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=?", array($domain));
88
+    $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain=?", array($domain));
89
+    return ($result->rowCount() > 0 || $result2->rowCount() > 0);
86 90
 }
87 91
 
88
-function domain_ownerchange($fqdn, $owner, $admin_c) 
92
+function domain_ownerchange($fqdn, $owner, $admin_c)
89 93
 {
90 94
     $cid = (int) $_SESSION['customerinfo']['customerno'];
91
-    $dom = new Domain( $fqdn );
95
+    $dom = new Domain($fqdn);
92 96
     db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE id=? AND kunde=?", array($owner, $admin_c, $dom->id, $cid));
93 97
     if (update_possible($dom->id)) {
94 98
         require_once('domainapi.php');
... ...
@@ -98,7 +102,8 @@ function domain_ownerchange($fqdn, $owner, $admin_c)
98 102
 }
99 103
 
100 104
 
101
-function update_possible($domain) {
105
+function update_possible($domain)
106
+{
102 107
     $dom = new Domain((int) $domain);
103 108
     if ($dom->provider != 'terions' || $dom->billing=='external') {
104 109
         // Domain nicht über uns verwaltet
... ...
@@ -112,7 +117,7 @@ function update_possible($domain) {
112 117
         return false;
113 118
     }
114 119
     $data = $result->fetch();
115
-    if ($data['aenderung_eigentuemer'] != NULL || $data['ruecksprache'] == 'Y') {
120
+    if ($data['aenderung_eigentuemer'] != null || $data['ruecksprache'] == 'Y') {
116 121
         DEBUG("Endung hat Eigenheiten (ruecksprache=Y)");
117 122
         // Endung mit speziellen Eigenheiten
118 123
         return false;
... ...
@@ -121,12 +126,14 @@ function update_possible($domain) {
121 126
     return true;
122 127
 }
123 128
 
124
-function unset_mailserver_lock($dom) {
129
+function unset_mailserver_lock($dom)
130
+{
125 131
     $id = $dom->id;
126 132
     db_query("UPDATE kundendaten.domains SET secret=NULL, mailserver_lock=0 WHERE id=?", array($id));
127 133
 }
128 134
 
129
-function create_domain_secret($dom) {
135
+function create_domain_secret($dom)
136
+{
130 137
     $id = $dom->id;
131 138
     $secret = md5(random_string(20));
132 139
     db_query("UPDATE kundendaten.domains SET secret=? WHERE id=?", array($secret, $id));
... ...
@@ -135,44 +142,46 @@ function create_domain_secret($dom) {
135 142
 }
136 143
 
137 144
 
138
-function get_auth_dns($domainname, $tld) {
139
-  $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
145
+function get_auth_dns($domainname, $tld)
146
+{
147
+    $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
140 148
 
141
-  $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
142
-  $line = explode("\n", $resp, 2)[0];
143
-  $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $line);
149
+    $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
150
+    $line = explode("\n", $resp, 2)[0];
151
+    $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $line);
144 152
 
145
-  $resp = shell_exec('dig @'.$NS.' -t ns '.$domain.'.');
146
-  $lines = explode("\n", $resp);
153
+    $resp = shell_exec('dig @'.$NS.' -t ns '.$domain.'.');
154
+    $lines = explode("\n", $resp);
147 155
   
148
-  $NS = NULL;
149
-  $NS_IP = NULL;
150
-  $sec = NULL;
151
-  foreach ($lines as $l) {
152
-      if (preg_match("/;; AUTHORITY SECTION:.*/", $l)) {
153
-          $sec = 'auth';
154
-      } elseif (preg_match("/;; ADDITIONAL SECTION:.*/", $l)) {
155
-          $sec = 'add';
156
-      }
157
-      if ($sec == 'auth' && preg_match("/^.*\\sIN\\s+NS\\s+\\S+$/", $l)) {
158
-          $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)\\.$/", '\1', $l);
159
-      }
160
-      if ($sec == 'add' && $NS && preg_match("/^.*\\sIN\\s+A\\s+\\S+$/", $l)) {
161
-          $NS_IP = preg_replace("/^.*\\sIN\\s+A\\s+(\\S+)$/", '\1', $l);
162
-      }
163
-  }
164
-  return array("$NS" => $NS_IP);
156
+    $NS = null;
157
+    $NS_IP = null;
158
+    $sec = null;
159
+    foreach ($lines as $l) {
160
+        if (preg_match("/;; AUTHORITY SECTION:.*/", $l)) {
161
+            $sec = 'auth';
162
+        } elseif (preg_match("/;; ADDITIONAL SECTION:.*/", $l)) {
163
+            $sec = 'add';
164
+        }
165
+        if ($sec == 'auth' && preg_match("/^.*\\sIN\\s+NS\\s+\\S+$/", $l)) {
166
+            $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)\\.$/", '\1', $l);
167
+        }
168
+        if ($sec == 'add' && $NS && preg_match("/^.*\\sIN\\s+A\\s+\\S+$/", $l)) {
169
+            $NS_IP = preg_replace("/^.*\\sIN\\s+A\\s+(\\S+)$/", '\1', $l);
170
+        }
171
+    }
172
+    return array("$NS" => $NS_IP);
165 173
 }
166 174
 
167 175
 
168
-function own_ns() {
176
+function own_ns()
177
+{
169 178
     $auth = dns_get_record(config('masterdomain'), DNS_NS);
170 179
     $own_ns = array();
171 180
     foreach ($auth as $ns) {
172 181
         $own_ns[] = $ns['target'];
173 182
     }
174 183
 
175
-    return $own_ns;  
184
+    return $own_ns;
176 185
 }
177 186
 
178 187
 
... ...
@@ -180,56 +189,56 @@ function own_ns() {
180 189
 
181 190
 function has_own_ns($domainname, $tld)
182 191
 {
183
-  $nsdata = get_auth_dns($domainname, $tld);
184
-  $NS = NULL;
185
-  foreach ($nsdata as $host => $ip) {
186
-      $NS=$host;
187
-  }
188
-  if (in_array($NS, own_ns())) {
189
-      DEBUG('Domain hat unsere DNS-Server!');
190
-      return true;
191
-  }
192
-  return false;
192
+    $nsdata = get_auth_dns($domainname, $tld);
193
+    $NS = null;
194
+    foreach ($nsdata as $host => $ip) {
195
+        $NS=$host;
196
+    }
197
+    if (in_array($NS, own_ns())) {
198
+        DEBUG('Domain hat unsere DNS-Server!');
199
+        return true;
200
+    }
201
+    return false;
193 202
 }
194 203
 
195 204
 
196
-function get_txt_record($hostname, $domainname, $tld) {
197
-  $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
198
-  $nsdata = get_auth_dns($domainname, $tld);
199
-  $NS = NULL;
200
-  foreach ($nsdata as $host => $ip) {
201
-      $NS = $host;
202
-      if ($ip) {
203
-          $NS = $ip;
204
-      }
205
-  }
206
-  DEBUG('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
207
-  $resp = shell_exec('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
208
-  $TXT = trim($resp, "\n \"");
209
-  DEBUG($TXT);
210
-  return $TXT;
205
+function get_txt_record($hostname, $domainname, $tld)
206
+{
207
+    $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
208
+    $nsdata = get_auth_dns($domainname, $tld);
209
+    $NS = null;
210
+    foreach ($nsdata as $host => $ip) {
211
+        $NS = $host;
212
+        if ($ip) {
213
+            $NS = $ip;
214
+        }
215
+    }
216
+    DEBUG('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
217
+    $resp = shell_exec('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
218
+    $TXT = trim($resp, "\n \"");
219
+    DEBUG($TXT);
220
+    return $TXT;
211 221
 }
212 222
 
213 223
 
214 224
 function list_useraccounts()
215 225
 {
216
-  $customerno = (int) $_SESSION['customerinfo']['customerno'];
217
-  $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde=?", array($customerno));
218
-  $ret = array();
219
-  while ($item = $result->fetch())
220
-  {
221
-    $ret[] = $item;
222
-  }
223
-  DEBUG($ret);
224
-  return $ret;
226
+    $customerno = (int) $_SESSION['customerinfo']['customerno'];
227
+    $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde=?", array($customerno));
228
+    $ret = array();
229
+    while ($item = $result->fetch()) {
230
+        $ret[] = $item;
231
+    }
232
+    DEBUG($ret);
233
+    return $ret;
225 234
 }
226 235
 
227 236
 
228
-function change_user($domain, $uid) 
237
+function change_user($domain, $uid)
229 238
 {
230 239
     $domain = new Domain($domain);
231 240
     $domain->ensure_customerdomain();
232
-    $targetuser = NULL;
241
+    $targetuser = null;
233 242
     $useraccounts = list_useraccounts();
234 243
     foreach ($useraccounts as $u) {
235 244
         if ($u['uid'] == $uid) {
... ...
@@ -244,26 +253,26 @@ function change_user($domain, $uid)
244 253
 }
245 254
 
246 255
 
247
-function get_domain_offer($tld) 
256
+function get_domain_offer($tld)
248 257
 {
249
-  $tld = filter_input_hostname($tld);
250
-  $cid = (int) $_SESSION['customerinfo']['customerno'];
258
+    $tld = filter_input_hostname($tld);
259
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
251 260
 
252
-  $data = array("tld" => $tld);
261
+    $data = array("tld" => $tld);
253 262
 
254
-  $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
255
-  if ($result->rowCount() != 1) {
256
-    $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", array(":tld" => $tld));
257
-  }
258
-  if ($result->rowCount() != 1) {
259
-    return false;
260
-  }
261
-  $temp = $result->fetch();
262
-  $data["gebuehr"] = $temp["gebuehr"];
263
-  $data["interval"] = $temp["interval"];
264
-  $data["setup"] = ($temp["setup"] ? $temp["setup"] : 0.0);
263
+    $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
264
+    if ($result->rowCount() != 1) {
265
+        $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", array(":tld" => $tld));
266
+    }
267
+    if ($result->rowCount() != 1) {
268
+        return false;
269
+    }
270
+    $temp = $result->fetch();
271
+    $data["gebuehr"] = $temp["gebuehr"];
272
+    $data["interval"] = $temp["interval"];
273
+    $data["setup"] = ($temp["setup"] ? $temp["setup"] : 0.0);
265 274
   
266
-  return $data;
275
+    return $data;
267 276
 }
268 277
 
269 278
 function set_domain_pretransfer($domain)
... ...
@@ -271,8 +280,10 @@ function set_domain_pretransfer($domain)
271 280
     $cid = (int) $_SESSION['customerinfo']['customerno'];
272 281
     $uid = (int) $_SESSION['userinfo']['uid'];
273 282
     $domain = (int) $domain;
274
-    db_query("UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?", 
275
-            array($domain, $cid));
283
+    db_query(
284
+        "UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?",
285
+            array($domain, $cid)
286
+    );
276 287
 }
277 288
 
278 289
 
... ...
@@ -282,8 +293,10 @@ function set_domain_prereg($domain)
282 293
     $cid = (int) $_SESSION['customerinfo']['customerno'];
283 294
     $uid = (int) $_SESSION['userinfo']['uid'];
284 295
     $domain = (int) $domain;
285
-    db_query("UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?", 
286
-            array($domain, $cid));
296
+    db_query(
297
+        "UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?",
298
+            array($domain, $cid)
299
+    );
287 300
 }
288 301
 
289 302
 
... ...
@@ -317,7 +330,5 @@ function delete_domain($id)
317 330
 {
318 331
     $cid = (int) $_SESSION['customerinfo']['customerno'];
319 332
     logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Deleting domain '.$id);
320
-    db_query("DELETE FROM kundendaten.domains WHERE id=? AND kunde=?", array($id, $cid)); 
333
+    db_query("DELETE FROM kundendaten.domains WHERE id=? AND kunde=?", array($id, $cid));
321 334
 }
322
-
323
-
Browse code

Logging beim Eintragen und Löschen externer Domains

Bernd Wurst authored on18/02/2018 20:44:33
Showing1 changed files
... ...
@@ -298,6 +298,7 @@ function insert_domain_external($domain, $dns = false, $mail = true)
298 298
     }
299 299
     $tld = $info['domainSuffix'];
300 300
     $domainname = str_replace(".$tld", "", $info['domainNameUnicode']);
301
+    logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Inserting external domain '.$info['domainNameUnicode']." DNS:{$dns} / Mail:{$mail}");
301 302
     
302 303
     db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
303 304
         ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, 1)", array($cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none')));
... ...
@@ -315,6 +316,7 @@ function insert_domain_external($domain, $dns = false, $mail = true)
315 316
 function delete_domain($id)
316 317
 {
317 318
     $cid = (int) $_SESSION['customerinfo']['customerno'];
319
+    logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Deleting domain '.$id);
318 320
     db_query("DELETE FROM kundendaten.domains WHERE id=? AND kunde=?", array($id, $cid)); 
319 321
 }
320 322
 
Browse code

Zuverlässigeres Logging bei API-Aktionen

Bernd Wurst authored on17/02/2018 17:04:40
Showing1 changed files
... ...
@@ -88,10 +88,12 @@ function web_in_use($domain)
88 88
 function domain_ownerchange($fqdn, $owner, $admin_c) 
89 89
 {
90 90
     $cid = (int) $_SESSION['customerinfo']['customerno'];
91
-    db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE CONCAT_WS('.', domainname, tld)=? AND kunde=?", array($owner, $admin_c, $fqdn, $cid));
92
-    if (update_possible($fqdn)) {
91
+    $dom = new Domain( $fqdn );
92
+    db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE id=? AND kunde=?", array($owner, $admin_c, $dom->id, $cid));
93
+    if (update_possible($dom->id)) {
93 94
         require_once('domainapi.php');
94
-        api_upload_domain($fqdn);
95
+        DEBUG("Rufe Domain-API auf!");
96
+        api_upload_domain($dom->fqdn);
95 97
     }
96 98
 }
97 99
 
... ...
@@ -100,18 +102,22 @@ function update_possible($domain) {
100 102
     $dom = new Domain((int) $domain);
101 103
     if ($dom->provider != 'terions' || $dom->billing=='external') {
102 104
         // Domain nicht über uns verwaltet
105
+        DEBUG("Domain nicht über uns verwaltet!");
103 106
         return false;
104 107
     }
105 108
     $result = db_query("SELECT aenderung_eigentuemer, ruecksprache FROM misc.domainpreise WHERE tld=?", array($dom->tld));
106 109
     if ($result->rowCount() < 1) {
107 110
         // Endung nicht bei uns in der Liste erfasst
111
+        DEBUG("Endung nicht in der Preisliste!");
108 112
         return false;
109 113
     }
110 114
     $data = $result->fetch();
111 115
     if ($data['aenderung_eigentuemer'] != NULL || $data['ruecksprache'] == 'Y') {
116
+        DEBUG("Endung hat Eigenheiten (ruecksprache=Y)");
112 117
         // Endung mit speziellen Eigenheiten
113 118
         return false;
114 119
     }
120
+    DEBUG("Änderungen sollten möglich sein: {$dom->fqdn}");
115 121
     return true;
116 122
 }
117 123
 
Browse code

Zeige Mail-Deeplink korrekt an bei manueller Konfiguration

Bernd Wurst authored on16/02/2018 05:39:11
Showing1 changed files
... ...
@@ -63,6 +63,12 @@ function mail_in_use($domain)
63 63
   return ($result->rowCount() > 0);
64 64
 }
65 65
 
66
+function count_vmail($domain) {
67
+    $domain = (int) $domain;
68
+    $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=?", array($domain));
69
+    return $result->rowCount();
70
+}
71
+
66 72
 function web_in_use($domain)
67 73
 {
68 74
   if ( ! in_array('vhosts', config('modules')))
Browse code

Fehlermeldung bei nicht automatisch möglicher Eintragung freundlicher. Preishinweis auf USt.

Bernd Wurst authored on08/02/2018 15:36:32
Showing1 changed files
... ...
@@ -244,8 +244,7 @@ function get_domain_offer($tld)
244 244
     $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", array(":tld" => $tld));
245 245
   }
246 246
   if ($result->rowCount() != 1) {
247
-    warning('Die Endung »'.$tld.'« steht zur automatischen Eintragung nicht zur Verfügung.');
248
-    return;
247
+    return false;
249 248
   }
250 249
   $temp = $result->fetch();
251 250
   $data["gebuehr"] = $temp["gebuehr"];
Browse code

hardening domain input (II)

Bernd Wurst authored on06/02/2018 17:55:49
Showing1 changed files
... ...
@@ -239,9 +239,9 @@ function get_domain_offer($tld)
239 239
 
240 240
   $data = array("tld" => $tld);
241 241
 
242
-  $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
242
+  $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
243 243
   if ($result->rowCount() != 1) {
244
-    $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", array(":tld" => $tld));
244
+    $result = db_query("SELECT tld, gebuehr, `interval`, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", array(":tld" => $tld));
245 245
   }
246 246
   if ($result->rowCount() != 1) {
247 247
     warning('Die Endung »'.$tld.'« steht zur automatischen Eintragung nicht zur Verfügung.');
... ...
@@ -249,6 +249,7 @@ function get_domain_offer($tld)
249 249
   }
250 250
   $temp = $result->fetch();
251 251
   $data["gebuehr"] = $temp["gebuehr"];
252
+  $data["interval"] = $temp["interval"];
252 253
   $data["setup"] = ($temp["setup"] ? $temp["setup"] : 0.0);
253 254
   
254 255
   return $data;
Browse code

Entferne Punkt am Ende der Nameserver

Bernd Wurst authored on06/02/2018 13:05:21
Showing1 changed files
... ...
@@ -143,7 +143,7 @@ function get_auth_dns($domainname, $tld) {
143 143
           $sec = 'add';
144 144
       }
145 145
       if ($sec == 'auth' && preg_match("/^.*\\sIN\\s+NS\\s+\\S+$/", $l)) {
146
-          $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $l);
146
+          $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)\\.$/", '\1', $l);
147 147
       }
148 148
       if ($sec == 'add' && $NS && preg_match("/^.*\\sIN\\s+A\\s+\\S+$/", $l)) {
149 149
           $NS_IP = preg_replace("/^.*\\sIN\\s+A\\s+(\\S+)$/", '\1', $l);
... ...
@@ -173,7 +173,6 @@ function has_own_ns($domainname, $tld)
173 173
   foreach ($nsdata as $host => $ip) {
174 174
       $NS=$host;
175 175
   }
176
-  DEBUG($NS);
177 176
   if (in_array($NS, own_ns())) {
178 177
       DEBUG('Domain hat unsere DNS-Server!');
179 178
       return true;
Browse code

Transfer-Freigabe und Kündigung implementiert

Bernd Wurst authored on05/02/2018 16:34:38
Showing1 changed files
... ...
@@ -301,4 +301,10 @@ function insert_domain_external($domain, $dns = false, $mail = true)
301 301
     return $id;
302 302
 }
303 303
 
304
+function delete_domain($id)
305
+{
306
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
307
+    db_query("DELETE FROM kundendaten.domains WHERE id=? AND kunde=?", array($id, $cid)); 
308
+}
309
+
304 310
 
Browse code

Lasse die API bestimmen was bei einer Domain die Endung ist und ob der Domainname gültig ist

Bernd Wurst authored on05/02/2018 09:04:50
Showing1 changed files
... ...
@@ -233,18 +233,12 @@ function change_user($domain, $uid)
233 233
 }
234 234
 
235 235
 
236
-function get_domain_offer($domainname) 
236
+function get_domain_offer($tld) 
237 237
 {
238
-  $domainname = filter_input_hostname($domainname);
239
-  $domainname = preg_replace('/^www\./', '', $domainname);
240
-
241
-  $basename = preg_replace('/([^\.]+)\..*$/', '\1', $domainname);
242
-  DEBUG('Found Basename: '.$basename);
243
-  $tld = preg_replace('/^[^\.]*\./', '', $domainname);
244
-  DEBUG('Found TLD: '.$tld);
238
+  $tld = filter_input_hostname($tld);
245 239
   $cid = (int) $_SESSION['customerinfo']['customerno'];
246 240
 
247
-  $data = array("domainname" => $domainname, "basename" => $basename, "tld" => $tld);
241
+  $data = array("tld" => $tld);
248 242
 
249 243
   $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
250 244
   if ($result->rowCount() != 1) {
... ...
@@ -286,15 +280,14 @@ function insert_domain_external($domain, $dns = false, $mail = true)
286 280
 {
287 281
     $cid = (int) $_SESSION['customerinfo']['customerno'];
288 282
     $uid = (int) $_SESSION['userinfo']['uid'];
289
-    if (strpos($domain, ' ') !== false) {
290
-        system_failure("Ungültige Zeichen im Domainname");
291
-    }
292
-    $parts = explode('.', $domain);
293
-    if (count($parts) !== 2) {
294
-        system_failure("Ungültiger Domainname");
283
+    require_once("domainapi.php");
284
+    $info = api_domain_available($domain);
285
+    if (in_array($info['status'], array('nameContainsForbiddenCharacter', 'suffixDoesNotExist'))) {
286
+        system_failure("Diese Domain scheint ungültig zu sein!");
295 287
     }
296
-    $domainname = $parts[0];
297
-    $tld = $parts[1];
288
+    $tld = $info['domainSuffix'];
289
+    $domainname = str_replace(".$tld", "", $info['domainNameUnicode']);
290
+    
298 291
     db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
299 292
         ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, 1)", array($cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none')));
300 293
     $id = db_insert_id();
Browse code

Domain-Transfer und -Registrierung eingebaut (braucht Überprüfung)

Bernd Wurst authored on03/02/2018 15:39:25
Showing1 changed files
... ...
@@ -81,10 +81,12 @@ function web_in_use($domain)
81 81
 
82 82
 function domain_ownerchange($fqdn, $owner, $admin_c) 
83 83
 {
84
-    require_once('domainapi.php');
85 84
     $cid = (int) $_SESSION['customerinfo']['customerno'];
86 85
     db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE CONCAT_WS('.', domainname, tld)=? AND kunde=?", array($owner, $admin_c, $fqdn, $cid));
87
-    api_upload_domain($fqdn);
86
+    if (update_possible($fqdn)) {
87
+        require_once('domainapi.php');
88
+        api_upload_domain($fqdn);
89
+    }
88 90
 }
89 91
 
90 92
 
... ...
@@ -240,15 +242,8 @@ function get_domain_offer($domainname)
240 242
   DEBUG('Found Basename: '.$basename);
241 243
   $tld = preg_replace('/^[^\.]*\./', '', $domainname);
242 244
   DEBUG('Found TLD: '.$tld);
243
-
244 245
   $cid = (int) $_SESSION['customerinfo']['customerno'];
245 246
 
246
-  $result = db_query("SELECT id FROM kundendaten.domains WHERE domainname=:domainname AND tld=:tld", array("domainname" => $basename, "tld" => $tld));
247
-  if ($result->rowCount() != 0) {
248
-    warning('Diese Domain ist in unserem System bereits vorhanden und kann daher nicht noch einmal eingetragen werden.');
249
-    return;
250
-  }
251
-
252 247
   $data = array("domainname" => $domainname, "basename" => $basename, "tld" => $tld);
253 248
 
254 249
   $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
Browse code

Erste Vorbereitungen für Domainregistrierung

Bernd Wurst authored on02/02/2018 05:25:41
Showing1 changed files
... ...
@@ -266,30 +266,24 @@ function get_domain_offer($domainname)
266 266
   return $data;
267 267
 }
268 268
 
269
+function set_domain_pretransfer($domain)
270
+{
271
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
272
+    $uid = (int) $_SESSION['userinfo']['uid'];
273
+    $domain = (int) $domain;
274
+    db_query("UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?", 
275
+            array($domain, $cid));
276
+}
277
+
269 278
 
270
-function insert_domain_prereg($domain, $transfer=false)
279
+
280
+function set_domain_prereg($domain)
271 281
 {
272 282
     $cid = (int) $_SESSION['customerinfo']['customerno'];
273 283
     $uid = (int) $_SESSION['userinfo']['uid'];
274
-    if (strpos($domain, ' ') !== false) {
275
-        system_failure("Ungültige Zeichen im Domainname");
276
-    }
277
-    $parts = explode('.', $domain);
278
-    if (count($parts) !== 2) {
279
-        system_failure("Ungültiger Domainname");
280
-    }
281
-    $domainname = $parts[0];
282
-    $tld = $parts[1];
283
-    $status = 'prereg';
284
-    if ($transfer) {
285
-        $status = 'pretransfer';
286
-    }
287
-    db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
288
-        (?, ?, ?, ?, ?, 'regular', 'other', 1, 'auto', 1)", array($status, $cid, $uid, $domainname, $tld));
289
-    $id = db_insert_id();
290
-    $vmailserver = (int) $_SESSION['userinfo']['server'];
291
-    db_query("INSERT INTO mail.virtual_mail_domains (domain, server) VALUES (?, ?)", array($id, $vmailserver));
292
-    return $id;
284
+    $domain = (int) $domain;
285
+    db_query("UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?", 
286
+            array($domain, $cid));
293 287
 }
294 288
 
295 289
 
Browse code

Änderung des betreffenden Useraccounts eingebaut

Bernd Wurst authored on31/01/2018 16:12:26
Showing1 changed files
... ...
@@ -212,6 +212,24 @@ function list_useraccounts()
212 212
 }
213 213
 
214 214
 
215
+function change_user($domain, $uid) 
216
+{
217
+    $domain = new Domain($domain);
218
+    $domain->ensure_customerdomain();
219
+    $targetuser = NULL;
220
+    $useraccounts = list_useraccounts();
221
+    foreach ($useraccounts as $u) {
222
+        if ($u['uid'] == $uid) {
223
+            $targetuser = $u['uid'];
224
+            break;
225
+        }
226
+    }
227
+    if (! $targetuser) {
228
+        system_failure("Ungültiger Useraccount!");
229
+    }
230
+    db_query("UPDATE kundendaten.domains SET useraccount=? WHERE id=?", array($targetuser, $domain->id));
231
+}
232
+
215 233
 
216 234
 function get_domain_offer($domainname) 
217 235
 {
Browse code

Wenn die E-Mail-Funktion komplett abgeschaltet ist, wird die Domain nicht mehr als unbestätigt markiert.

Bernd Wurst authored on30/01/2018 09:12:00
Showing1 changed files
... ...
@@ -212,6 +212,7 @@ function list_useraccounts()
212 212
 }
213 213
 
214 214
 
215
+
215 216
 function get_domain_offer($domainname) 
216 217
 {
217 218
   $domainname = filter_input_hostname($domainname);
... ...
@@ -248,7 +249,33 @@ function get_domain_offer($domainname)
248 249
 }
249 250
 
250 251
 
251
-function insert_domain_external($domain, $dns)
252
+function insert_domain_prereg($domain, $transfer=false)
253
+{
254
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
255
+    $uid = (int) $_SESSION['userinfo']['uid'];
256
+    if (strpos($domain, ' ') !== false) {
257
+        system_failure("Ungültige Zeichen im Domainname");
258
+    }
259
+    $parts = explode('.', $domain);
260
+    if (count($parts) !== 2) {
261
+        system_failure("Ungültiger Domainname");
262
+    }
263
+    $domainname = $parts[0];
264
+    $tld = $parts[1];
265
+    $status = 'prereg';
266
+    if ($transfer) {
267
+        $status = 'pretransfer';
268
+    }
269
+    db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
270
+        (?, ?, ?, ?, ?, 'regular', 'other', 1, 'auto', 1)", array($status, $cid, $uid, $domainname, $tld));
271
+    $id = db_insert_id();
272
+    $vmailserver = (int) $_SESSION['userinfo']['server'];
273
+    db_query("INSERT INTO mail.virtual_mail_domains (domain, server) VALUES (?, ?)", array($id, $vmailserver));
274
+    return $id;
275
+}
276
+
277
+
278
+function insert_domain_external($domain, $dns = false, $mail = true)
252 279
 {
253 280
     $cid = (int) $_SESSION['customerinfo']['customerno'];
254 281
     $uid = (int) $_SESSION['userinfo']['uid'];
... ...
@@ -261,12 +288,16 @@ function insert_domain_external($domain, $dns)
261 288
     }
262 289
     $domainname = $parts[0];
263 290
     $tld = $parts[1];
264
-    db_query("INSERT INTO kundendaten.domains (kunde, useraccount, domainname, tld, billing, provider, dns, mailserver_lock) VALUES 
265
-        (?, ?, ?, ?, 'external', 'other', 0, 1)", array($cid, $uid, $domainname, $tld));
291
+    db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
292
+        ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, 1)", array($cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none')));
266 293
     $id = db_insert_id();
267 294
     if ($dns) {
268 295
         db_query("UPDATE kundendaten.domains SET dns=1 WHERE id=?", array($id));
269 296
     }
297
+    if ($mail) {
298
+        $vmailserver = (int) $_SESSION['userinfo']['server'];
299
+        db_query("INSERT INTO mail.virtual_mail_domains (domain, server) VALUES (?, ?)", array($id, $vmailserver));
300
+    }
270 301
     return $id;
271 302
 }
272 303
 
Browse code

Zeige die Optionen zur Prüfung der Inhaberschaft (WIP)

Bernd Wurst authored on28/01/2018 08:11:14
Showing1 changed files
... ...
@@ -151,6 +151,19 @@ function get_auth_dns($domainname, $tld) {
151 151
 }
152 152
 
153 153
 
154
+function own_ns() {
155
+    $auth = dns_get_record(config('masterdomain'), DNS_NS);
156
+    $own_ns = array();
157
+    foreach ($auth as $ns) {
158
+        $own_ns[] = $ns['target'];
159
+    }
160
+
161
+    return $own_ns;  
162
+}
163
+
164
+
165
+
166
+
154 167
 function has_own_ns($domainname, $tld)
155 168
 {
156 169
   $nsdata = get_auth_dns($domainname, $tld);
... ...
@@ -159,7 +172,7 @@ function has_own_ns($domainname, $tld)
159 172
       $NS=$host;
160 173
   }
161 174
   DEBUG($NS);
162
-  if (in_array($NS, array('ns1.schokokeks-dns.de.', 'ns2.schokokeks-dns.de.', 'ns3.schokokeks-dns.de.'))) {
175
+  if (in_array($NS, own_ns())) {
163 176
       DEBUG('Domain hat unsere DNS-Server!');
164 177
       return true;
165 178
   }
... ...
@@ -238,6 +251,7 @@ function get_domain_offer($domainname)
238 251
 function insert_domain_external($domain, $dns)
239 252
 {
240 253
     $cid = (int) $_SESSION['customerinfo']['customerno'];
254
+    $uid = (int) $_SESSION['userinfo']['uid'];
241 255
     if (strpos($domain, ' ') !== false) {
242 256
         system_failure("Ungültige Zeichen im Domainname");
243 257
     }
... ...
@@ -247,8 +261,8 @@ function insert_domain_external($domain, $dns)
247 261
     }
248 262
     $domainname = $parts[0];
249 263
     $tld = $parts[1];
250
-    db_query("INSERT INTO kundendaten.domains (kunde, domainname, tld, billing, provider, dns, mailserver_lock) VALUES 
251
-        (?, ?, ?, 'external', 'other', 0, 1)", array($cid, $domainname, $tld));
264
+    db_query("INSERT INTO kundendaten.domains (kunde, useraccount, domainname, tld, billing, provider, dns, mailserver_lock) VALUES 
265
+        (?, ?, ?, ?, 'external', 'other', 0, 1)", array($cid, $uid, $domainname, $tld));
252 266
     $id = db_insert_id();
253 267
     if ($dns) {
254 268
         db_query("UPDATE kundendaten.domains SET dns=1 WHERE id=?", array($id));
Browse code

Ermögliche das Hinzufügen externer Domains

Bernd Wurst authored on28/01/2018 07:23:10
Showing1 changed files
... ...
@@ -185,4 +185,75 @@ function get_txt_record($hostname, $domainname, $tld) {
185 185
 }
186 186
 
187 187
 
188
+function list_useraccounts()
189
+{
190
+  $customerno = (int) $_SESSION['customerinfo']['customerno'];
191
+  $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde=?", array($customerno));
192
+  $ret = array();
193
+  while ($item = $result->fetch())
194
+  {
195
+    $ret[] = $item;
196
+  }
197
+  DEBUG($ret);
198
+  return $ret;
199
+}
200
+
201
+
202
+function get_domain_offer($domainname) 
203
+{
204
+  $domainname = filter_input_hostname($domainname);
205
+  $domainname = preg_replace('/^www\./', '', $domainname);
206
+
207
+  $basename = preg_replace('/([^\.]+)\..*$/', '\1', $domainname);
208
+  DEBUG('Found Basename: '.$basename);
209
+  $tld = preg_replace('/^[^\.]*\./', '', $domainname);
210
+  DEBUG('Found TLD: '.$tld);
211
+
212
+  $cid = (int) $_SESSION['customerinfo']['customerno'];
213
+
214
+  $result = db_query("SELECT id FROM kundendaten.domains WHERE domainname=:domainname AND tld=:tld", array("domainname" => $basename, "tld" => $tld));
215
+  if ($result->rowCount() != 0) {
216
+    warning('Diese Domain ist in unserem System bereits vorhanden und kann daher nicht noch einmal eingetragen werden.');
217
+    return;
218
+  }
219
+
220
+  $data = array("domainname" => $domainname, "basename" => $basename, "tld" => $tld);
221
+
222
+  $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", array(":cid" => $cid, ":tld" => $tld));
223
+  if ($result->rowCount() != 1) {
224
+    $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", array(":tld" => $tld));
225
+  }
226
+  if ($result->rowCount() != 1) {
227
+    warning('Die Endung »'.$tld.'« steht zur automatischen Eintragung nicht zur Verfügung.');
228
+    return;
229
+  }
230
+  $temp = $result->fetch();
231
+  $data["gebuehr"] = $temp["gebuehr"];
232
+  $data["setup"] = ($temp["setup"] ? $temp["setup"] : 0.0);
233
+  
234
+  return $data;
235
+}
236
+
237
+
238
+function insert_domain_external($domain, $dns)
239
+{
240
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
241
+    if (strpos($domain, ' ') !== false) {
242
+        system_failure("Ungültige Zeichen im Domainname");
243
+    }
244
+    $parts = explode('.', $domain);
245
+    if (count($parts) !== 2) {
246
+        system_failure("Ungültiger Domainname");
247
+    }
248
+    $domainname = $parts[0];
249
+    $tld = $parts[1];
250
+    db_query("INSERT INTO kundendaten.domains (kunde, domainname, tld, billing, provider, dns, mailserver_lock) VALUES 
251
+        (?, ?, ?, 'external', 'other', 0, 1)", array($cid, $domainname, $tld));
252
+    $id = db_insert_id();
253
+    if ($dns) {
254
+        db_query("UPDATE kundendaten.domains SET dns=1 WHERE id=?", array($id));
255
+    }
256
+    return $id;
257
+}
258
+
188 259
 
Browse code

Bestätige eine Domain ohne weiteres, wenn die DNS-Server auf uns gesetzt sind.

Bernd Wurst authored on27/01/2018 07:50:30
Showing1 changed files
... ...
@@ -120,7 +120,8 @@ function create_domain_secret($dom) {
120 120
     return $secret;
121 121
 }
122 122
 
123
-function get_txt_record($hostname, $domainname, $tld) {
123
+
124
+function get_auth_dns($domainname, $tld) {
124 125
   $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
125 126
 
126 127
   $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
... ...
@@ -146,11 +147,36 @@ function get_txt_record($hostname, $domainname, $tld) {
146 147
           $NS_IP = preg_replace("/^.*\\sIN\\s+A\\s+(\\S+)$/", '\1', $l);
147 148
       }
148 149
   }
150
+  return array("$NS" => $NS_IP);
151
+}
152
+
149 153
 
150
-  if ($NS_IP) {
151
-      $NS = $NS_IP;
154
+function has_own_ns($domainname, $tld)
155
+{
156
+  $nsdata = get_auth_dns($domainname, $tld);
157
+  $NS = NULL;
158
+  foreach ($nsdata as $host => $ip) {
159
+      $NS=$host;
160
+  }
161
+  DEBUG($NS);
162
+  if (in_array($NS, array('ns1.schokokeks-dns.de.', 'ns2.schokokeks-dns.de.', 'ns3.schokokeks-dns.de.'))) {
163
+      DEBUG('Domain hat unsere DNS-Server!');
164
+      return true;
152 165
   }
166
+  return false;
167
+}
168
+
153 169
 
170
+function get_txt_record($hostname, $domainname, $tld) {
171
+  $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
172
+  $nsdata = get_auth_dns($domainname, $tld);
173
+  $NS = NULL;
174
+  foreach ($nsdata as $host => $ip) {
175
+      $NS = $host;
176
+      if ($ip) {
177
+          $NS = $ip;
178
+      }
179
+  }
154 180
   DEBUG('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
155 181
   $resp = shell_exec('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
156 182
   $TXT = trim($resp, "\n \"");
Browse code

verify-Funktion um via DNS-Record die Inhaberschaft zu bestätigen.

Bernd Wurst authored on27/01/2018 07:20:38
Showing1 changed files
... ...
@@ -107,4 +107,56 @@ function update_possible($domain) {
107 107
     return true;
108 108
 }
109 109
 
110
+function unset_mailserver_lock($dom) {
111
+    $id = $dom->id;
112
+    db_query("UPDATE kundendaten.domains SET secret=NULL, mailserver_lock=0 WHERE id=?", array($id));
113
+}
114
+
115
+function create_domain_secret($dom) {
116
+    $id = $dom->id;
117
+    $secret = md5(random_string(20));
118
+    db_query("UPDATE kundendaten.domains SET secret=? WHERE id=?", array($secret, $id));
119
+    $dom->secret = $secret;
120
+    return $secret;
121
+}
122
+
123
+function get_txt_record($hostname, $domainname, $tld) {
124
+  $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
125
+
126
+  $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
127
+  $line = explode("\n", $resp, 2)[0];
128
+  $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $line);
129
+
130
+  $resp = shell_exec('dig @'.$NS.' -t ns '.$domain.'.');
131
+  $lines = explode("\n", $resp);
132
+  
133
+  $NS = NULL;
134
+  $NS_IP = NULL;
135
+  $sec = NULL;
136
+  foreach ($lines as $l) {
137
+      if (preg_match("/;; AUTHORITY SECTION:.*/", $l)) {
138
+          $sec = 'auth';
139
+      } elseif (preg_match("/;; ADDITIONAL SECTION:.*/", $l)) {
140
+          $sec = 'add';
141
+      }
142
+      if ($sec == 'auth' && preg_match("/^.*\\sIN\\s+NS\\s+\\S+$/", $l)) {
143
+          $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $l);
144
+      }
145
+      if ($sec == 'add' && $NS && preg_match("/^.*\\sIN\\s+A\\s+\\S+$/", $l)) {
146
+          $NS_IP = preg_replace("/^.*\\sIN\\s+A\\s+(\\S+)$/", '\1', $l);
147
+      }
148
+  }
149
+
150
+  if ($NS_IP) {
151
+      $NS = $NS_IP;
152
+  }
153
+
154
+  DEBUG('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
155
+  $resp = shell_exec('dig @'.$NS.' +short -t txt '.$hostname.'.'.$domain.'.');
156
+  $TXT = trim($resp, "\n \"");
157
+  DEBUG($TXT);
158
+  return $TXT;
159
+}
160
+
161
+
110 162
 
Browse code

Abhängigkeit von contacts-Modul reduziert

Bernd Wurst authored on30/01/2018 09:19:02
Showing1 changed files
... ...
@@ -15,7 +15,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
15 15
 */
16 16
 
17 17
 require_once('inc/debug.php');
18
-require_once('domainapi.php');
19 18
 
20 19
 
21 20
 function mailman_subdomains($domain)
... ...
@@ -82,6 +81,7 @@ function web_in_use($domain)
82 81
 
83 82
 function domain_ownerchange($fqdn, $owner, $admin_c) 
84 83
 {
84
+    require_once('domainapi.php');
85 85
     $cid = (int) $_SESSION['customerinfo']['customerno'];
86 86
     db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE CONCAT_WS('.', domainname, tld)=? AND kunde=?", array($owner, $admin_c, $fqdn, $cid));
87 87
     api_upload_domain($fqdn);
Browse code

Domain-Update (Ownerchange) funktionsfähig

Bernd Wurst authored on23/01/2018 15:44:46
Showing1 changed files
... ...
@@ -14,8 +14,8 @@ http://creativecommons.org/publicdomain/zero/1.0/
14 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 15
 */
16 16
 
17
-require_once('inc/base.php');
18 17
 require_once('inc/debug.php');
18
+require_once('domainapi.php');
19 19
 
20 20
 
21 21
 function mailman_subdomains($domain)
... ...
@@ -80,6 +80,13 @@ function web_in_use($domain)
80 80
   return ($result->rowCount() > 0 || $result2->rowCount() > 0);
81 81
 }
82 82
 
83
+function domain_ownerchange($fqdn, $owner, $admin_c) 
84
+{
85
+    $cid = (int) $_SESSION['customerinfo']['customerno'];
86
+    db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE CONCAT_WS('.', domainname, tld)=? AND kunde=?", array($owner, $admin_c, $fqdn, $cid));
87
+    api_upload_domain($fqdn);
88
+}
89
+
83 90
 
84 91
 function update_possible($domain) {
85 92
     $dom = new Domain((int) $domain);
Browse code

Aktualisiere Domain- und Inhaberdaten beim Aufrufen der update-Seite

Bernd Wurst authored on23/01/2018 15:18:38
Showing1 changed files
... ...
@@ -81,3 +81,23 @@ function web_in_use($domain)
81 81
 }
82 82
 
83 83
 
84
+function update_possible($domain) {
85
+    $dom = new Domain((int) $domain);
86
+    if ($dom->provider != 'terions' || $dom->billing=='external') {
87
+        // Domain nicht über uns verwaltet
88
+        return false;
89
+    }
90
+    $result = db_query("SELECT aenderung_eigentuemer, ruecksprache FROM misc.domainpreise WHERE tld=?", array($dom->tld));
91
+    if ($result->rowCount() < 1) {
92
+        // Endung nicht bei uns in der Liste erfasst
93
+        return false;
94
+    }
95
+    $data = $result->fetch();
96
+    if ($data['aenderung_eigentuemer'] != NULL || $data['ruecksprache'] == 'Y') {
97
+        // Endung mit speziellen Eigenheiten
98
+        return false;
99
+    }
100
+    return true;
101
+}
102
+
103
+
Browse code

Copyright year update

Bernd Wurst authored on13/01/2018 06:07:05
Showing1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2014 by schokokeks.org Hosting, namely
5
+Written 2008-2018 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Lizenzinfos in eigenes Modul ausgelagert und Copyright auf 2014 angepasst

Bernd Wurst authored on08/02/2014 05:45:07
Showing1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2013 by schokokeks.org Hosting, namely
5
+Written 2008-2014 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Einige Statements auf Prepared-statements umgestellt

Bernd Wurst authored on02/02/2014 16:31:00
Showing1 changed files
... ...
@@ -25,7 +25,7 @@ function mailman_subdomains($domain)
25 25
     return array();
26 26
   }
27 27
   $domain = (int) $domain;
28
-  $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain={$domain}");
28
+  $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain=?", array($domain));
29 29
   $ret = array();
30 30
   while ($line = $result->fetch())
31 31
   {
... ...
@@ -39,7 +39,7 @@ function dns_in_use($domain)
39 39
   if ( ! in_array('dns', config('modules')))
40 40
     return false;
41 41
   $domain = (int) $domain;
42
-  $result = db_query("SELECT id FROM dns.custom_records WHERE domain={$domain}");
42
+  $result = db_query("SELECT id FROM dns.custom_records WHERE domain=?", array($domain));
43 43
   return ($result->rowCount() > 0);
44 44
 }
45 45
 
... ...
@@ -51,16 +51,16 @@ function mail_in_use($domain)
51 51
     return false;
52 52
   }
53 53
   $domain = (int) $domain;
54
-  $result = db_query("SELECT mail FROM kundendaten.domains WHERE id={$domain}");
54
+  $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", array($domain));
55 55
   if ($result->rowCount() < 1)
56 56
     system_failure("Domain not found");
57 57
   $d = $result->fetch();
58 58
   if ($d['mail'] == 'none')
59 59
     return false; // manually disabled
60
-  $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain={$domain}");
60
+  $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain=?", array($domain));
61 61
   if ($result->rowCount() < 1)
62 62
     return true; // .courier
63
-  $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}");
63
+  $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=?", array($domain));
64 64
   return ($result->rowCount() > 0);
65 65
 }
66 66
 
... ...
@@ -71,12 +71,12 @@ function web_in_use($domain)
71 71
 
72 72
   $domain = (int) $domain;
73 73
 
74
-  $result = db_query("SELECT id FROM kundendaten.domains WHERE id={$domain} AND webserver=1");
74
+  $result = db_query("SELECT id FROM kundendaten.domains WHERE id=? AND webserver=1", array($domain));
75 75
   if ($result->rowCount() < 1)
76 76
     return false;
77 77
 
78
-  $result = db_query("SELECT id FROM vhosts.vhost WHERE domain={$domain}");
79
-  $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain={$domain}");
78
+  $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=?", array($domain));
79
+  $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain=?", array($domain));
80 80
   return ($result->rowCount() > 0 || $result2->rowCount() > 0);
81 81
 }
82 82
 
Browse code

Umstellung auf PDO-Datenbankverbindung

Bernd Wurst authored on01/02/2014 18:38:23
Showing1 changed files
... ...
@@ -27,7 +27,7 @@ function mailman_subdomains($domain)
27 27
   $domain = (int) $domain;
28 28
   $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain={$domain}");
29 29
   $ret = array();
30
-  while ($line = mysql_fetch_assoc($result))
30
+  while ($line = $result->fetch())
31 31
   {
32 32
     $ret[] = $line;
33 33
   }
... ...
@@ -40,7 +40,7 @@ function dns_in_use($domain)
40 40
     return false;
41 41
   $domain = (int) $domain;
42 42
   $result = db_query("SELECT id FROM dns.custom_records WHERE domain={$domain}");
43
-  return (mysql_num_rows($result) > 0);
43
+  return ($result->rowCount() > 0);
44 44
 }
45 45
 
46 46
 
... ...
@@ -52,16 +52,16 @@ function mail_in_use($domain)
52 52
   }
53 53
   $domain = (int) $domain;
54 54
   $result = db_query("SELECT mail FROM kundendaten.domains WHERE id={$domain}");
55
-  if (mysql_num_rows($result) < 1)
55
+  if ($result->rowCount() < 1)
56 56
     system_failure("Domain not found");
57
-  $d = mysql_fetch_assoc($result);
57
+  $d = $result->fetch();
58 58
   if ($d['mail'] == 'none')
59 59
     return false; // manually disabled
60 60
   $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain={$domain}");
61
-  if (mysql_num_rows($result) < 1)
61
+  if ($result->rowCount() < 1)
62 62
     return true; // .courier
63 63
   $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}");
64
-  return (mysql_num_rows($result) > 0);
64
+  return ($result->rowCount() > 0);
65 65
 }
66 66
 
67 67
 function web_in_use($domain)
... ...
@@ -72,12 +72,12 @@ function web_in_use($domain)
72 72
   $domain = (int) $domain;
73 73
 
74 74
   $result = db_query("SELECT id FROM kundendaten.domains WHERE id={$domain} AND webserver=1");
75
-  if (mysql_num_rows($result) < 1)
75
+  if ($result->rowCount() < 1)
76 76
     return false;
77 77
 
78 78
   $result = db_query("SELECT id FROM vhosts.vhost WHERE domain={$domain}");
79 79
   $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain={$domain}");
80
-  return (mysql_num_rows($result) > 0 || mysql_num_rows($result2) > 0);
80
+  return ($result->rowCount() > 0 || $result2->rowCount() > 0);
81 81
 }
82 82
 
83 83
 
Browse code

Updated copyright notice (2012 => 2013)

Bernd Wurst authored on19/01/2013 10:49:50
Showing1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2012 by schokokeks.org Hosting, namely
5
+Written 2008-2013 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Added license tags for CC0, README and COPYING

Bernd Wurst authored on11/03/2012 15:40:04
Showing1 changed files
... ...
@@ -1,4 +1,18 @@
1 1
 <?php
2
+/*
3
+This file belongs to the Webinterface of schokokeks.org Hosting
4
+
5
+Written 2008-2012 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
+*/
2 16
 
3 17
 require_once('inc/base.php');
4 18
 require_once('inc/debug.php');
Browse code

Wirkliche nutzung der Domains anzeigen

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1709 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on06/04/2010 14:52:49
Showing1 changed files
... ...
@@ -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
 
Browse code

Mailman-Domains nur auslesen wenn Mailman-Modul aktiviert ist

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1631 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on26/01/2010 16:48:59
Showing1 changed files
... ...
@@ -3,8 +3,13 @@
3 3
 require_once('inc/base.php');
4 4
 require_once('inc/debug.php');
5 5
 
6
+
6 7
 function mailman_subdomains($domain)
7 8
 {
9
+  if ( ! in_array('mailman', config('modules')))
10
+  {
11
+    return array();
12
+  }
8 13
   $domain = (int) $domain;
9 14
   $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain={$domain}");
10 15
   $ret = array();
Browse code

Bessere Darstellung des Domain-Status

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1532 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on08/12/2009 15:25:06
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('inc/debug.php');
5
+
6
+function mailman_subdomains($domain)
7
+{
8
+  $domain = (int) $domain;
9
+  $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain={$domain}");
10
+  $ret = array();
11
+  while ($line = mysql_fetch_assoc($result))
12
+  {
13
+    $ret[] = $line;
14
+  }
15
+  return $ret;
16
+}
17
+
18
+
19
+
Browse code

Domain-Klasse benutzen

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@536 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on05/07/2007 18:43:18
Showing1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,66 +0,0 @@
1
-<?php
2
-
3
-require_once('inc/db_connect.php');
4
-require_once('inc/debug.php');
5
-
6
-function get_domain_names($customerno, $uid = NULL)
7
-{
8
-  $customerno = (int) $customerno;
9
-  $query = "SELECT id,CONCAT_WS('.', domainname, tld) AS domainname, registrierungsdatum, kuendigungsdatum FROM kundendaten.domains WHERE";
10
-  if ($uid !== NULL)
11
-  {
12
-    $uid = (int) $uid;
13
-    $query .= " useraccount={$uid};";
14
-  }
15
-  else
16
-  {
17
-    $query .= " kunde={$customerno};";
18
-  }
19
-  $result = db_query($query);
20
-  $domains = array();
21
-  DEBUG('Result set is '.mysql_num_rows($result)." rows.<br />\n");
22
-  if (mysql_num_rows($result) > 0)
23
-    while ($domain = mysql_fetch_object($result))
24
-      array_push($domains, array('id' => $domain->id,
25
-                              'domainname'  => $domain->domainname,
26
-                              'reg_date' => $domain->registrierungsdatum,
27
-                              'cancel_date' => $domain->kuendigungsdatum));
28
-
29
-	return $domains;	
30
-}
31
-
32
-
33
-
34
-function get_domain_name($domid)
35