354c05a4ddd678c49bcbba458bffa7d13482139a
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

1) <?php
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

5) Written by schokokeks.org Hosting, namely
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

9) This code is published under a 0BSD license.
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

10) 
11) 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.
12) */
13) 
14) require_once('inc/debug.php');
15) require_once('inc/base.php');
16) require_once('inc/security.php');
17) require_once('inc/error.php');
18) 
Bernd Wurst Neue Version der http.net-P...

Bernd Wurst authored 8 years ago

19) require_once('httpnet.php');
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

20) 
Bernd Wurst Setze neu eingetragene Doma...

Bernd Wurst authored 9 years ago

21) require_once('modules/email/include/vmail.php');
22) 
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

23) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

24) function get_domain_offer($domainname)
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

25) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

26)     $domainname = filter_input_hostname($domainname);
27)     $domainname = preg_replace('/^www\./', '', $domainname);
28) 
29)     $basename = preg_replace('/([^\.]+)\..*$/', '\1', $domainname);
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

30)     DEBUG('Found Basename: ' . $basename);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

31)     $tld = preg_replace('/^[^\.]*\./', '', $domainname);
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

32)     DEBUG('Found TLD: ' . $tld);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

33) 
34)     $cid = (int) $_SESSION['customerinfo']['customerno'];
35) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

36)     $result = db_query("SELECT id FROM kundendaten.domains WHERE domainname=:domainname AND tld=:tld", ["domainname" => $basename, "tld" => $tld]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

37)     if ($result->rowCount() != 0) {
38)         warning('Diese Domain ist in unserem System bereits vorhanden und kann daher nicht noch einmal eingetragen werden.');
39)         return;
40)     }
41) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

42)     $data = ["domainname" => $domainname, "basename" => $basename, "tld" => $tld];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

43) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

44)     $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise_kunde WHERE kunde=:cid AND tld=:tld AND ruecksprache='N'", [":cid" => $cid, ":tld" => $tld]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

45)     if ($result->rowCount() != 1) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

46)         $result = db_query("SELECT tld, gebuehr, setup FROM misc.domainpreise WHERE tld=:tld AND ruecksprache='N'", [":tld" => $tld]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

47)     }
48)     if ($result->rowCount() != 1) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

49)         warning('Die Endung »' . $tld . '« steht zur automatischen Eintragung nicht zur Verfügung.');
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

50)         return;
51)     }
52)     $temp = $result->fetch();
53)     $data["gebuehr"] = $temp["gebuehr"];
54)     $data["setup"] = ($temp["setup"] ? $temp["setup"] : 0.0);
Hanno remove whitespace in empty...

Hanno authored 6 years ago

55) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

56)     $available = api_domain_available($domainname);
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

57)     if (!$available) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

58)         warning('Die Domain »' . $domainname . '« ist leider nicht verfügbar.');
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

59)         return;
60)     }
61)     return $data;
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

62) }
63) 
64) 
65) 
66) function register_domain($domainname, $uid)
67) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

68)     $data = get_domain_offer($domainname);
69) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

70)     if (!$data) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

71)         // Die Include-Datei setzt eine passende Warning-Nachricht
72)         show_warnings();
73)         system_failure('Interner Fehler');
74)     }
75) 
76)     $cid = (int) $_SESSION['customerinfo']['customerno'];
77)     $useraccount = null;
78)     $available_users = list_useraccounts();
79)     foreach ($available_users as $u) {
80)         if ($uid == $u['uid']) {
81)             $useraccount = (int) $uid;
82)             break;
83)         }
84)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

85)     if (!$useraccount) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

86)         system_failure('Kein User gesetzt');
87)     }
Hanno remove whitespace in empty...

Hanno authored 6 years ago

88) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

89)     $args = [":cid" => $cid,
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

90)                 ":useraccount" => $useraccount,
91)                 ":basename" => $data['basename'],
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

92)                 ":tld" => $data['tld'], ];
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

93)     db_query("INSERT INTO kundendaten.domains (kunde, useraccount, domainname, tld, billing, registrierungsdatum, dns,webserver, mail) VALUES " .
Bernd Wurst Beim Hinzufügen einer Domai...

Bernd Wurst authored 6 years ago

94)            "(:cid, :useraccount, :basename, :tld, 'regular', NULL, 1, 1, 'auto') ", $args);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

95)     $domid = db_insert_id();
96)     /*if ($data['setup']) {
97)       $args = array(":cid" => $cid, ":setup" => $data['setup'], ":text" => 'Einmalige Setup-Gebühren für Domain "'.$data['domainname'].'"');
98)       db_query("INSERT INTO kundendaten.leistungen (kunde,periodisch,datum,betrag,brutto,beschreibung,anzahl) VALUES (:cid, 0, CURDATE(), :setup, 1, :text, 1)", $args);
99)     }*/
100)     # Umstellen auf vmail
101)     change_domain($domid, 'virtual');
Bernd Wurst Neues Modul zum Prüfen der...

Bernd Wurst authored 10 years ago

102) }
103) 
104) function list_useraccounts()
105) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

106)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

107)     $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde=?", [$customerno]);
108)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

109)     while ($item = $result->fetch()) {
110)         $ret[] = $item;
111)     }
112)     DEBUG($ret);
113)     return $ret;