Browse code

Erste Vorbereitungen für Domainregistrierung

Bernd Wurst authored on02/02/2018 05:25:41
Showing9 changed files
... ...
@@ -80,8 +80,16 @@ function get_server_by_id($id) {
80 80
 function redirect($target)
81 81
 {
82 82
   global $debugmode;
83
-  if (! $debugmode)
83
+  if (! $debugmode) {
84 84
     header("Location: {$target}");
85
+  } else {
86
+      if (strpos($target, '?') === false) {
87
+        print 'REDIRECT: '.internal_link($target, $target);
88
+      } else {
89
+          list($file, $qs) = explode('?', $target, 2);
90
+          print 'REDIRECT: '.internal_link($file, $target, $qs);
91
+      }
92
+  }
85 93
   die();
86 94
 }
87 95
 
... ...
@@ -308,7 +316,6 @@ function encode_querystring($querystring)
308 316
   global $debugmode;
309 317
   if ($debugmode)
310 318
     $querystring = 'debug&'.$querystring;
311
-  DEBUG($querystring);
312 319
   $query = explode('&', $querystring);
313 320
   $new_query = array();
314 321
   foreach ($query AS $item)
... ...
@@ -323,7 +330,6 @@ function encode_querystring($querystring)
323 330
   $querystring = implode('&', $new_query);
324 331
   if ($querystring)
325 332
     $querystring = '?'.$querystring;
326
-  DEBUG($querystring);
327 333
   return $querystring;
328 334
 }
329 335
 
... ...
@@ -60,16 +60,6 @@ if (isset($_REQUEST['domain'])) {
60 60
             <tr><td>Domainname:</td><td><strong>'.$data['domainname'].'</strong></td></tr>
61 61
             <tr><td>Jahresgebühr:</td><td style="text-align: right;">'.$data['gebuehr'].' €</td></tr>
62 62
             <tr><td>Setup-Gebühr (einmalig):</td><td style="text-align: right;">'.$data['setup'].' €</td></tr>';
63
-        $users = list_useraccounts();
64
-        if (count($users) > 1) {
65
-            $userselect = array();
66
-            foreach ($users as $u) {
67
-                $userselect[$u['uid']] = $u['username'].' / '.$u['name'];
68
-            }
69
-
70
-
71
-            $form .= '<tr><td>Benutzeraccount:</td><td>'.html_select('uid', $userselect).'</td></tr>';
72
-        }
73 63
         $form .='</table>';
74 64
 
75 65
 
... ...
@@ -15,10 +15,16 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
15 15
 */
16 16
 
17 17
 if (isset($_GET['type'])) {
18
+    $caller = 'detail';
19
+    if (isset($_REQUEST['backto'])) {
20
+        $caller = $_REQUEST['backto'];
21
+    }
22
+    $_SESSION['domains_choose_redirect'] = $caller;
23
+
18 24
     $function = 'owner';
19 25
     if ($_GET['type'] == 'admin_c') {
20 26
         if (isset($_GET['detach'])) {
21
-            $_SESSION['domains_update_detach'] = $_GET['detach'];
27
+            $_SESSION['domains_'.$caller.'_detach'] = $_GET['detach'];
22 28
         }
23 29
         $function = 'admin_c';
24 30
     }
... ...
@@ -26,15 +32,17 @@ if (isset($_GET['type'])) {
26 32
     if ($function == 'admin_c') {
27 33
         $t = 'Verwalter';
28 34
     }
29
-    $_SESSION['contacts_choose_header'] = 'Wählen Sie einen neuen '.$t.' für die Domain '.$_SESSION['domains_update_domainname'];
30
-    $_SESSION['contacts_choose_key'] = 'domains_update_'.$function;
31
-    $_SESSION['contacts_choose_redirect'] = '../domains/detail';
35
+    $_SESSION['contacts_choose_header'] = 'Wählen Sie einen neuen '.$t.' für die Domain '.$_SESSION['domains_'.$caller.'_domainname'];
36
+    $_SESSION['contacts_choose_key'] = 'domains_'.$caller.'_'.$function;
37
+    $_SESSION['contacts_choose_redirect'] = '../domains/choose';
32 38
     redirect('../contacts/choose');
33 39
 } else {
34 40
     unset($_SESSION['contacts_choose_key']);
35 41
     unset($_SESSION['contacts_choose_header']);
36 42
     unset($_SESSION['contacts_choose_redirect']);
37
-    redirect("detail");
43
+    $backto = $_SESSION['domains_choose_redirect'];
44
+    unset($_SESSION['domains_choose_redirect']);
45
+    redirect($backto);
38 46
 }
39 47
 
40 48
 
... ...
@@ -26,9 +26,9 @@ require_role(ROLE_CUSTOMER);
26 26
 $dom = NULL;
27 27
 if (isset($_REQUEST['id'])) {
28 28
     $dom = new Domain( (int) $_REQUEST['id']);
29
-    $_SESSION['domains_update_domainname'] = $dom->fqdn;
30
-} elseif (isset($_SESSION['domains_update_domainname'])) {
31
-    $dom = new Domain($_SESSION['domains_update_domainname']);
29
+    $_SESSION['domains_detail_domainname'] = $dom->fqdn;
30
+} elseif (isset($_SESSION['domains_detail_domainname'])) {
31
+    $dom = new Domain($_SESSION['domains_detail_domainname']);
32 32
 } else {
33 33
     system_failure("Keine Domain angegeben");
34 34
 }
... ...
@@ -69,29 +69,29 @@ if ($dom->provider == 'terions' && ($dom->cancel_date === NULL || $dom->cancel_d
69 69
 
70 70
     if (isset($_REQUEST['id'])) {
71 71
         api_download_domain($_REQUEST['id']);
72
-        $_SESSION['domains_update_domainname'] = $dom->fqdn;
73
-        $_SESSION['domains_update_owner'] = $dom->owner;
74
-        $_SESSION['domains_update_admin_c'] = $dom->admin_c;
72
+        $_SESSION['domains_detail_domainname'] = $dom->fqdn;
73
+        $_SESSION['domains_detail_owner'] = $dom->owner;
74
+        $_SESSION['domains_detail_admin_c'] = $dom->admin_c;
75 75
     }
76 76
     if (!update_possible($dom->id)) {
77 77
         warning("Diese Domain verwendet eine unübliche Endung. Daher kann der Inhaber nicht auf diesem Weg verändert werden. Bitte kontaktieren Sie den Support.");
78 78
     } else {
79 79
 
80
-        if ($_SESSION['domains_update_admin_c'] == $dom->admin_c && 
81
-                $_SESSION['domains_update_owner'] != $dom->owner && 
82
-                (!isset($_SESSION['domains_update_detach']) || $_SESSION['domains_update_detach'] == 0)) {
80
+        if ($_SESSION['domains_detail_admin_c'] == $dom->admin_c && 
81
+                $_SESSION['domains_detail_owner'] != $dom->owner && 
82
+                (!isset($_SESSION['domains_detail_detach']) || $_SESSION['domains_detail_detach'] == 0)) {
83 83
             // Wenn der Owner geändert wurde, der Admin aber nicht und das detach-Flag 
84 84
             // nicht gesetzt ist, dann wird der Admin gleich dem Owner gesetzt
85
-            $_SESSION['domains_update_admin_c'] = $_SESSION['domains_update_owner'];
85
+            $_SESSION['domains_detail_admin_c'] = $_SESSION['domains_detail_owner'];
86 86
         }
87 87
 
88 88
         if (isset($_GET['admin_c']) && $_GET['admin_c'] == 'none') {
89
-            $_SESSION['domains_update_admin_c'] = $_SESSION['domains_update_owner'];
90
-            unset($_SESSION['domains_update_detach']);
89
+            $_SESSION['domains_detail_admin_c'] = $_SESSION['domains_detail_owner'];
90
+            unset($_SESSION['domains_detail_detach']);
91 91
         }
92 92
 
93
-        $owner = get_contact($_SESSION['domains_update_owner']);
94
-        $admin_c = get_contact($_SESSION['domains_update_admin_c']);
93
+        $owner = get_contact($_SESSION['domains_detail_owner']);
94
+        $admin_c = get_contact($_SESSION['domains_detail_admin_c']);
95 95
         $function = 'Inhaber';
96 96
         if ($owner['id'] == $admin_c['id']) {
97 97
             $function .= ' und Verwalter';
... ...
@@ -109,7 +109,7 @@ if ($dom->provider == 'terions' && ($dom->cancel_date === NULL || $dom->cancel_d
109 109
             }
110 110
             output('<p><strong>Verwalter:</strong></p>'.display_contact($admin_c, '', $cssclass));
111 111
             addnew('choose', 'Neuen Verwalter wählen', "type=admin_c");
112
-            output('<p class="delete">'.internal_link('update', 'Keinen separaten Verwalter festlegen', 'admin_c=none').'</p>');
112
+            output('<p class="delete">'.internal_link('', 'Keinen separaten Verwalter festlegen', 'admin_c=none').'</p>');
113 113
         } else {
114 114
             addnew('choose', 'Einen separaten Verwalter wählen', "type=admin_c&detach=1");
115 115
         }
... ...
@@ -131,14 +131,20 @@ if ($dom->provider == 'terions' && ($dom->cancel_date === NULL || $dom->cancel_d
131 131
 
132 132
 // Block Externe Domain umziehen
133 133
 
134
-if ($dom->provider != 'terions') {
134
+if ($dom->status == 'prereg') {
135
+    output('<h4>Domain-Registrierung abschließen</h4>
136
+            <p>'.internal_link('domainreg', 'Domain registrieren', "domain={$dom->fqdn}").'</p>');
137
+} elseif ($dom->status == 'pretransfer') {
138
+    output('<h4>Domain-Umzug ausführen</h4>
139
+            <p>'.internal_link('domainreg', 'Umzugsautrag (ggf. nochmals) erteilen', "domain={$dom->fqdn}").'</p>');
140
+} elseif ($dom->provider != 'terions') {
135 141
     output('<h4>Domain-Transfer ausführen</h4>
136 142
             <p>'.internal_link('domainreg', 'Domain-Transfer ausführen', "domain={$dom->fqdn}").'</p>');
137 143
 }
138 144
 
139 145
 // Block Domain bestätigen
140 146
 
141
-if ($dom->mailserver_lock == 1) {
147
+if ($dom->mailserver_lock == 1 && $dom->status != 'prereg') {
142 148
     if (has_own_ns($dom->domainname, $dom->tld)) {
143 149
         unset_mailserver_lock($dom);
144 150
         success_msg("Die Domain {$dom->fqdn} wurde erfolgreich bestätigt und kann nun in vollem Umfang verwendet werden.");
145 151
new file mode 100644
... ...
@@ -0,0 +1,122 @@
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/security.php');
18
+require_once('inc/icons.php');
19
+require_once('class/domain.php');
20
+
21
+require_once('domains.php');
22
+require_once('domainapi.php');
23
+require_role(ROLE_CUSTOMER);
24
+use_module('contacts');
25
+require_once('contacts.php');
26
+
27
+
28
+$dom = NULL;
29
+if (isset($_REQUEST['domain'])) {
30
+    $domain = $_REQUEST['domain'];
31
+    if (strpos($domain, ' ') !== false) {
32
+        system_failure('Leerzeichen sind in Domainnamen nicht erlaubt.');
33
+    }
34
+    $dom = new Domain();
35
+    if ($dom->loadByName($domain) === false) {
36
+        // Eintragen mit DNS und Mail
37
+        $id = insert_domain_external($domain, true, true);
38
+        $dom->loadByName($domain);
39
+    } 
40
+    $dom->ensure_customerdomain();
41
+    if ($dom->provider == 'terions') {
42
+        system_failure("Diese Domain ist bereits auf Ihr Kundenkonto registriert.");
43
+    }
44
+    
45
+    // An diesem Punkt ist die Domain eingetragen als extern und ggf. mit Mailserver-Lock
46
+    // Bei der Reg-Bestätigung wird das Lock entfernt und die Daten entsprechend gesetzt, inklusive Preise.
47
+
48
+    $_SESSION['domains_domainreg_owner'] = NULL;
49
+    $_SESSION['domains_domainreg_admin_c'] = NULL;
50
+    $_SESSION['domains_domainreg_domainname'] = $domain;
51
+    $_SESSION['domains_domainreg_detach'] = 0;
52
+    
53
+} elseif (isset($_SESSION['domains_domainreg_domainname'])) {
54
+    $domain = $_SESSION['domains_domainreg_domainname'];
55
+    $dom = new Domain($domain);
56
+    $dom->ensure_customerdomain();
57
+}
58
+
59
+if (!$dom) {
60
+    system_failure("Keine Domain");
61
+}
62
+
63
+$mode=NULL;
64
+
65
+$avail = api_domain_available($dom->fqdn);
66
+if ($avail == 'available') {
67
+    set_domain_prereg($dom->id);
68
+    $mode = 'reg';
69
+    title("Domain registrieren");
70
+} elseif ($avail == 'registered' || $avail == 'alreadyRegistered') {
71
+    // FIXME: alreadyRegistered bedeutet, dass die Domain bereits über uns verwaltet wird. Das wird dann hier nicht funktionieren
72
+    set_domain_pretransfer($dom->id);
73
+    $mode = 'transfer';
74
+    title("Domain-Transfer vornehmen");
75
+}
76
+
77
+
78
+output("<p>Domainname: <strong>".$dom->fqdn."</strong></p>");
79
+
80
+$section='domains_domains';
81
+
82
+
83
+output('<h4>Inhaber der Domain</h4>');
84
+output('<p>Legen Sie hier einen neuen Inhaber für diese Domain fest.</p>');
85
+
86
+if ($_SESSION['domains_domainreg_detach'] == 0) {
87
+    $_SESSION['domains_domainreg_admin_c'] = $_SESSION['domains_domainreg_owner'];
88
+} 
89
+
90
+// Behandlung für "keinen extra Verwalter"
91
+if (isset($_GET['admin_c']) && $_GET['admin_c'] == 'none') {
92
+    $_SESSION['domains_domainreg_admin_c'] = $_SESSION['domains_domainreg_owner'];
93
+    $_SESSION['domains_domainreg_detach'] = 0;
94
+}
95
+
96
+if ($_SESSION['domains_domainreg_owner']) {
97
+    $owner = get_contact($_SESSION['domains_domainreg_owner']);
98
+
99
+    $function = 'Inhaber';
100
+    if ($_SESSION['domains_domainreg_admin_c'] == $_SESSION['domains_domainreg_owner']) {
101
+        $function .= ' und Verwalter';
102
+    }
103
+    output('<p><strong>'.$function.':</strong></p>'.display_contact($owner, ''));
104
+} else {
105
+    output('<p><strong>Inhaber und Verwalter:</strong></p><p><em>Bisher kein Inhaber ausgewählt</em>');
106
+}
107
+addnew('choose', 'Neuen Inhaber wählen', "type=owner&backto=domainreg");
108
+if ($_SESSION['domains_domainreg_admin_c'] != $_SESSION['domains_domainreg_owner']) {
109
+    $admin_c = get_contact($_SESSION['domains_domainreg_admin_c']);
110
+    output('<p><strong>Verwalter:</strong></p>'.display_contact($admin_c, ''));
111
+    addnew('choose', 'Neuen Verwalter wählen', "type=admin_c&backto=domainreg");
112
+    output('<p class="delete">'.internal_link('', 'Keinen separaten Verwalter festlegen', 'admin_c=none').'</p>');
113
+} else {
114
+    addnew('choose', 'Einen separaten Verwalter wählen', "type=admin_c&detach=1&backto=domainreg");
115
+}
116
+
117
+
118
+
119
+
120
+
121
+
122
+
... ...
@@ -43,7 +43,10 @@ foreach ($user_domains as $domain)
43 43
       $mailserver_lock = '<br><strong>Mail-Verarbeitung eingeschränkt!</strong>'.footnote('Diese Domain ist extern registriert und wurde noch nicht bestätigt. Momentan ist daher der Mail-Empfang auf dieser Domain nicht möglich.');
44 44
   }
45 45
   $regdate = $domain->reg_date;
46
-  if ($domain->provider != 'terions') {
46
+  if ($domain->status == 'prereg') {
47
+      $status = 'prereg';
48
+      $regdate = '<em>Registrierung nicht abgeschlossen</em>';
49
+  } elseif ($domain->provider != 'terions') {
47 50
     $status = 'external';
48 51
     $regdate = '<em>Extern registriert</em>';
49 52
   } elseif ($domain->reg_date == NULL) {
... ...
@@ -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
 
... ...
@@ -36,6 +36,7 @@ if ($_REQUEST['action'] == 'ownerchange') {
36 36
     if (!(isset($_POST['accept']) && $_POST['accept'] == '1')) {
37 37
         redirect('detail?error=1');
38 38
     }
39
+    check_form_token('domains_update');
39 40
     $dom = new Domain($_SESSION['domains_update_domainname']);
40 41
     if (!$dom) {
41 42
         system_failure("Keine Domain gewählt!");
... ...
@@ -29,6 +29,6 @@ if (!isset($_REQUEST['domain'])) {
29 29
 
30 30
 $id = insert_domain_external($_REQUEST['domain'], ($_REQUEST['dns'] === 'enable'), ($_REQUEST['email'] === 'enable'));
31 31
 
32
-redirect('verify?id='.$id);
32
+redirect('detail?id='.$id);
33 33
 
34 34