9086c9ad77db90633e0629e9e86a88366265ded0
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

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) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

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('contacts.php');
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

18) require_once('numbers.php');
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

19) require_once('inc/debug.php');
20) 
21) require_once('session/start.php');
22) 
23) 
24) require_role(array(ROLE_CUSTOMER));
25) $section = 'contacts_list';
26) 
Bernd Wurst Ermögliche das Ändern eines...

Bernd Wurst authored 6 years ago

27) $back = 'list';
28) if (isset($_REQUEST['back'])) {
29)     $back = urldecode($_REQUEST['back']);
30) }
31) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

32) if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
33)     $contact = get_contact($_REQUEST['id']);
Hanno remove whitespace in empty...

Hanno authored 5 years ago

34) 
Bernd Wurst Abstrahieren der Anzeigefun...

Bernd Wurst authored 6 years ago

35)     $contact_string = display_contact($contact);
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

36) 
37)     $sure = user_is_sure();
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

38)     if ($sure === null) {
39)         are_you_sure("action=delete&id={$contact['id']}&back=".urlencode($back), "Möchten Sie diese Adresse wirklich löschen? {$contact_string}");
40)     } elseif ($sure === true) {
41)         delete_contact($contact['id']);
42)         if (! $debugmode) {
Bernd Wurst Ermögliche das Ändern eines...

Bernd Wurst authored 6 years ago

43)             header("Location: ".$back);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

44)         }
45)     } elseif ($sure === false) {
46)         if (! $debugmode) {
47)             header("Location: ".$back);
48)         }
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

49)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

50) } else {
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

51)     check_form_token('contacts_edit');
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

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

Hanno authored 5 years ago

53)     $new = false;
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

54)     if ($_REQUEST['id'] == 'new') {
55)         title("Adresse anlegen");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

56)         $new = true;
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

57)     } else {
58)         title("Adresse bearbeiten");
59)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

60) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

61)     $c = new_contact();
62)     if (! $new) {
63)         $c = get_contact($_REQUEST['id']);
64)     }
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

65) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

66)     if (!isset($_REQUEST['firma'])) {
67)         $_REQUEST['firma'] = $c['company'];
68)     }
69)     if (!isset($_REQUEST['name'])) {
70)         $_REQUEST['name'] = $c['name'];
71)     }
72)     if (!isset($_REQUEST['land'])) {
73)         $_REQUEST['land'] = $c['country'];
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

74)     }
75) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

76)     if ($c['nic_handle'] != null) {
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

77)         if ($c['name'] != $_REQUEST['name'] || $c['company'] != $_REQUEST['firma'] || $c['country'] != $_REQUEST['land']) {
78)             system_failure('Name/Firma/Land kann bei diesem Kontakt nicht geändert werden.');
79)         }
80)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

81) 
Bernd Wurst Abstrahieren der Anzeigefun...

Bernd Wurst authored 6 years ago

82)     $kundenkontakte = get_kundenkontakte();
83)     if ($c['id'] == $kundenkontakte['kunde']) {
84)         if (!$_REQUEST['name'] && !$_REQUEST['firma']) {
85)             system_failure('Beim Inhaber darf nicht Firmenname und Name leer sein.');
86)         }
87)     }
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

88) 
Bernd Wurst Security

Bernd Wurst authored 6 years ago

89)     $c['company'] = verify_input_general(maybe_null($_REQUEST['firma']));
90)     $c['name'] = verify_input_general(maybe_null($_REQUEST['name']));
91)     $c['address'] = verify_input_general(maybe_null($_REQUEST['adresse']));
92)     $c['country'] = verify_input_general(maybe_null(strtoupper($_REQUEST['land'])));
93)     $c['zip'] = verify_input_general(maybe_null($_REQUEST['plz']));
94)     $c['city'] = verify_input_general(maybe_null($_REQUEST['ort']));
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

95)     if ($new && isset($_REQUEST['email'])) {
Bernd Wurst Ermögliche das Erstellen ei...

Bernd Wurst authored 6 years ago

96)         $c['email'] = verify_input_general(maybe_null($_REQUEST['email']));
97)         if (!check_emailaddr($c['email'])) {
98)             system_failure("Ungültige E-Mail-Adresse!");
99)         }
100)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

101) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

102) 
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

103)     if (isset($_REQUEST['telefon']) && $_REQUEST['telefon'] != '') {
Bernd Wurst Security

Bernd Wurst authored 6 years ago

104)         $num = format_number(verify_input_general($_REQUEST['telefon']), $_REQUEST['land']);
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

105)         if ($num) {
106)             $c['phone'] = $num;
107)         } else {
108)             system_failure('Die eingegebene Telefonnummer scheint nicht gültig zu sein!');
109)         }
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

110)     } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

111)         $c['phone'] = null;
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

112)     }
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

113)     if (isset($_REQUEST['mobile']) && $_REQUEST['mobile'] != '') {
Bernd Wurst Security

Bernd Wurst authored 6 years ago

114)         $num = format_number(verify_input_general($_REQUEST['mobile']), $_REQUEST['land']);
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

115)         if ($num) {
116)             $c['mobile'] = $num;
117)         } else {
118)             system_failure('Die eingegebene Mobiltelefonnummer scheint nicht gültig zu sein!');
119)         }
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

120)     } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

121)         $c['mobile'] = null;
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

122)     }
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

123)     if (isset($_REQUEST['telefax']) && $_REQUEST['telefax'] != '') {
Bernd Wurst Security

Bernd Wurst authored 6 years ago

124)         $num = format_number(verify_input_general($_REQUEST['telefax']), $_REQUEST['land']);
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

125)         if ($num) {
126)             $c['fax'] = $num;
127)         } else {
128)             system_failure('Die eingegebene Faxnummer scheint nicht gültig zu sein!');
129)         }
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

130)     } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

131)         $c['fax'] = null;
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

132)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

133) 
Hanno remove whitespace in empty...

Hanno authored 5 years ago

134) 
Bernd Wurst Suche PGP-Key nur wenn der...

Bernd Wurst authored 6 years ago

135)     if (isset($_REQUEST['usepgp']) && $_REQUEST['usepgp'] == 'yes' && isset($_REQUEST['pgpid'])) {
Bernd Wurst Ermögliche das Setzen des P...

Bernd Wurst authored 6 years ago

136)         $pgpid = preg_replace('/[^0-9a-fA-F]/', '', $_REQUEST['pgpid']);
137)         DEBUG('PGP-ID: '.$pgpid.' / Länge: '.strlen($pgpid));
138)         if (strlen($pgpid) == 8 || strlen($pgpid) == 16 || strlen($pgpid) == 40) {
139)             $c['pgp_id'] = $_REQUEST['pgpid'];
140)             if (isset($_REQUEST['pgpkey']) && $_REQUEST['pgpkey']) {
141)                 $c['pgp_key'] = $_REQUEST['pgpkey'];
142)             }
143)         } else {
144)             warning('Ihre PGP-ID wurde nicht übernommen, da sie syntaktisch falsch erscheint');
145)         }
Bernd Wurst Suche PGP-Key nur wenn der...

Bernd Wurst authored 6 years ago

146)     } else {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

147)         $c['pgp_id'] = null;
148)         $c['pgp_key'] = null;
Bernd Wurst Ermögliche das Setzen des P...

Bernd Wurst authored 6 years ago

149)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

150) 
Bernd Wurst Ermögliche das Erstellen ei...

Bernd Wurst authored 6 years ago

151) 
152)     if (isset($_REQUEST['domainholder']) && $_REQUEST['domainholder'] == 1) {
153)         if (!possible_domainholder($c)) {
154)             DEBUG("Kein möglicher Domaininhaber:");
155)             DEBUG($c);
156)             warning('Zur Verwendung als Domaininhaber fehlen noch Angaben.');
157)             redirect('edit?id='.$_REQUEST['id'].'&back='.$_REQUEST['back'].'&domainholder=1');
158)         }
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

159)         if (isset($_REQUEST['email']) && !have_mailaddress($_REQUEST['email'])) {
Bernd Wurst Zeige eine Warnung an, dass...

Bernd Wurst authored 6 years ago

160)             warning("Die neu angelegte Adresse kann erst dann als Domaininhaber genutzt werden, wenn die E-Mail-Adresse bestätigt wurde.");
161)         }
Bernd Wurst Ermögliche das Erstellen ei...

Bernd Wurst authored 6 years ago

162)     }
163) 
Bernd Wurst Frage die Zustimmung des Do...

Bernd Wurst authored 6 years ago

164)     $domains = domainlist_by_contact($c);
165)     if ($domains) {
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

166)         if (isset($_REQUEST['email']) && $c['email'] != $_REQUEST['email'] && !(isset($_REQUEST['designated']) && $_REQUEST['designated'] == 'yes')) {
Bernd Wurst Frage die Zustimmung des Do...

Bernd Wurst authored 6 years ago

167)             system_failure("Sie müssen die explizite Zustimmung des Domaininhabers bestätigen um diese Änderungen zu speichern.");
168)         }
169)     }
170) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

171)     // Zuerst Kontakt speichern und wenn eine Änderung der E-Mail gewünscht war,
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

172)     // dann hinterher das Token erzeugen und senden. Weil wir für das Token die
173)     // Contact-ID brauchen und die bekommen wir bei einer Neueintragung erst nach
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

174)     // dem Speichern.
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

175) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

176)     $id = save_contact($c);
177)     $c['id'] = $id;
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

178) 
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

179)     if (isset($_REQUEST['email']) && ($new || $c['email'] != $_REQUEST['email'])) {
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

180)         if (have_mailaddress($_REQUEST['email'])) {
Bernd Wurst Security

Bernd Wurst authored 6 years ago

181)             save_emailaddress($c['id'], verify_input_general($_REQUEST['email']));
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

182)         } else {
183)             send_emailchange_token($c['id'], $_REQUEST['email']);
184)         }
185)     }
186)     if ($c['nic_id']) {
187)         $c = get_contact($c['id']);
188)         upload_contact($c);
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

189)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

190) 
191) 
Bernd Wurst Suche PGP-Key nur wenn der...

Bernd Wurst authored 6 years ago

192)     redirect($back);