96f5f24fd7fe712b7c9e9a2c221c46ecc227b1a9
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) 
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('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']);
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();
38)     if ($sure === NULL)
39)     {
Bernd Wurst Ermögliche das Ändern eines...

Bernd Wurst authored 6 years ago

40)        are_you_sure("action=delete&id={$contact['id']}&back=".urlencode($back), "Möchten Sie diese Adresse wirklich löschen? {$contact_string}");
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

41)     }
42)     elseif ($sure === true)
43)     {
44)        delete_contact($contact['id']);
45)        if (! $debugmode)
Bernd Wurst Ermögliche das Ändern eines...

Bernd Wurst authored 6 years ago

46)            header("Location: ".$back);
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

47)     }
48)     elseif ($sure === false)
49)     {
50)         if (! $debugmode)
Bernd Wurst Ermögliche das Ändern eines...

Bernd Wurst authored 6 years ago

51)             header("Location: ".$back);
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

52)     }
53) 
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

54) 
55) } else {
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

57) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

58)     $new = False;
59)     if ($_REQUEST['id'] == 'new') {
60)         title("Adresse anlegen");
61)         $new = True;
62)     } else {
63)         title("Adresse bearbeiten");
64)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

65) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

66)     $c = new_contact();
67)     if (! $new) {
68)         $c = get_contact($_REQUEST['id']);
69)     }
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

70) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

71)     if (!isset($_REQUEST['firma'])) {
72)         $_REQUEST['firma'] = $c['company'];
73)     }
74)     if (!isset($_REQUEST['name'])) {
75)         $_REQUEST['name'] = $c['name'];
76)     }
77)     if (!isset($_REQUEST['land'])) {
78)         $_REQUEST['land'] = $c['country'];
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

79)     }
80) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

81)     if ($c['nic_handle'] != NULL) {
82)         if ($c['name'] != $_REQUEST['name'] || $c['company'] != $_REQUEST['firma'] || $c['country'] != $_REQUEST['land']) {
83)             system_failure('Name/Firma/Land kann bei diesem Kontakt nicht geändert werden.');
84)         }
85)     }
Bernd Wurst Speichern der Eingaben (unv...

Bernd Wurst authored 6 years ago

86) 
Bernd Wurst Abstrahieren der Anzeigefun...

Bernd Wurst authored 6 years ago

87)     $kundenkontakte = get_kundenkontakte();
88)     if ($c['id'] == $kundenkontakte['kunde']) {
89)         if (!$_REQUEST['name'] && !$_REQUEST['firma']) {
90)             system_failure('Beim Inhaber darf nicht Firmenname und Name leer sein.');
91)         }
92)     }
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

93) 
Bernd Wurst Security

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

101)         $c['email'] = verify_input_general(maybe_null($_REQUEST['email']));
102)         if (!check_emailaddr($c['email'])) {
103)             system_failure("Ungültige E-Mail-Adresse!");
104)         }
105)     }
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

106)         
107) 
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

116)         $c['phone'] = NULL;
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

126)         $c['mobile'] = NULL;
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

136)         $c['fax'] = NULL;
Bernd Wurst Nummercheck ausgelagert und...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

138) 
Bernd Wurst Ermögliche das Setzen des P...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

151)     } else {
152)         $c['pgp_id'] = NULL;
153)         $c['pgp_key'] = NULL;
Bernd Wurst Ermögliche das Setzen des P...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

167)     }
168) 
Bernd Wurst Frage die Zustimmung des Do...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

172)             system_failure("Sie müssen die explizite Zustimmung des Domaininhabers bestätigen um diese Änderungen zu speichern.");
173)         }
174)     }
175) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

176)     // Zuerst Kontakt speichern und wenn eine Änderung der E-Mail gewünscht war,
177)     // dann hinterher das Token erzeugen und senden. Weil wir für das Token die 
178)     // Contact-ID brauchen und die bekommen wir bei einer Neueintragung erst nach 
179)     // dem Speichern.
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

180) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

183) 
Bernd Wurst möglicherweise undefinierte...

Bernd Wurst authored 5 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

187)         } else {
188)             send_emailchange_token($c['id'], $_REQUEST['email']);
189)         }
190)     }
191)     if ($c['nic_id']) {
192)         $c = get_contact($c['id']);
193)         upload_contact($c);
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

195) 
196) 
Bernd Wurst Suche PGP-Key nur wenn der...

Bernd Wurst authored 6 years ago

197)     redirect($back);