90da2da308dae512eb32794cd8d9c91095c87b73
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 Ermögliche das Speichern de...

Bernd Wurst authored 5 years ago

89)     $c['salutation'] = null;
90)     if ($_REQUEST['salutation'] == 'Herr') {
91)         $c['salutation'] = 'Herr';
92)     } elseif ($_REQUEST['salutation'] == 'Frau') {
93)         $c['salutation'] = 'Frau';
94)     }
Bernd Wurst Security

Bernd Wurst authored 6 years ago

95)     $c['company'] = verify_input_general(maybe_null($_REQUEST['firma']));
96)     $c['name'] = verify_input_general(maybe_null($_REQUEST['name']));
97)     $c['address'] = verify_input_general(maybe_null($_REQUEST['adresse']));
98)     $c['country'] = verify_input_general(maybe_null(strtoupper($_REQUEST['land'])));
99)     $c['zip'] = verify_input_general(maybe_null($_REQUEST['plz']));
100)     $c['city'] = verify_input_general(maybe_null($_REQUEST['ort']));
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

102)         $c['email'] = verify_input_general(maybe_null($_REQUEST['email']));
103)         if (!check_emailaddr($c['email'])) {
104)             system_failure("Ungültige E-Mail-Adresse!");
105)         }
106)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

107) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

108) 
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

111)         if ($num) {
112)             $c['phone'] = $num;
113)         } else {
114)             system_failure('Die eingegebene Telefonnummer scheint nicht gültig zu sein!');
115)         }
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

121)         if ($num) {
122)             $c['mobile'] = $num;
123)         } else {
124)             system_failure('Die eingegebene Mobiltelefonnummer scheint nicht gültig zu sein!');
125)         }
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

131)         if ($num) {
132)             $c['fax'] = $num;
133)         } else {
134)             system_failure('Die eingegebene Faxnummer scheint nicht gültig zu sein!');
135)         }
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

139) 
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

142)         $pgpid = preg_replace('/[^0-9a-fA-F]/', '', $_REQUEST['pgpid']);
Bernd Wurst Prüfe die Verwendbarkeit vo...

Bernd Wurst authored 5 years ago

143)         DEBUG('PGP-ID: '.$pgpid);
144)         if (isset($_REQUEST['pgpkey']) && $_REQUEST['pgpkey']) {
145)             DEBUG('Key angegeben, wird importiert');
146)             $c['pgp_id'] = $pgpid;
147)             import_pgp_key($_REQUEST['pgpkey']);
148)             $c['pgp_key'] = $_REQUEST['pgpkey'];
Bernd Wurst Ermögliche das Setzen des P...

Bernd Wurst authored 6 years ago

149)         } else {
Bernd Wurst Prüfe die Verwendbarkeit vo...

Bernd Wurst authored 5 years ago

150)             DEBUG('Kein Key, wird vom Keyserver geholt!');
151)             $c['pgp_id'] = fetch_pgp_key($pgpid);
152)         }
153)         if (!test_pgp_key($c['pgp_id'])) {
154)             $c['pgp_id'] = null;
155)             $c['pgp_key'] = null;
156)             warning('Ihr PGP-Key wurde nicht übernommen, da er nicht gültig zu sein scheint. Bitte geben Sie im Zweifel die vollständige Key-ID (Fingerprint) und einen Key in der ASCII-Form ein.');
Bernd Wurst Ermögliche das Setzen des P...

Bernd Wurst authored 6 years ago

157)         }
Bernd Wurst Suche PGP-Key nur wenn der...

Bernd Wurst authored 6 years ago

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

Hanno authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

163) 
164)     if (isset($_REQUEST['domainholder']) && $_REQUEST['domainholder'] == 1) {
165)         if (!possible_domainholder($c)) {
166)             DEBUG("Kein möglicher Domaininhaber:");
167)             DEBUG($c);
168)             warning('Zur Verwendung als Domaininhaber fehlen noch Angaben.');
169)             redirect('edit?id='.$_REQUEST['id'].'&back='.$_REQUEST['back'].'&domainholder=1');
170)         }
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

174)     }
175) 
Bernd Wurst Frage die Zustimmung des Do...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

178)         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

179)             system_failure("Sie müssen die explizite Zustimmung des Domaininhabers bestätigen um diese Änderungen zu speichern.");
180)         }
181)     }
182) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

183)     // 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

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

187) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

190) 
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

194)         } else {
195)             send_emailchange_token($c['id'], $_REQUEST['email']);
196)         }
197)     }
198)     if ($c['nic_id']) {
199)         $c = get_contact($c['id']);
200)         upload_contact($c);
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

202) 
203) 
Bernd Wurst Suche PGP-Key nur wenn der...

Bernd Wurst authored 6 years ago

204)     redirect($back);