5effc2bd7685822df276c1372dab480cff321941
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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) */
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

16) 
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

17) require_once('mail.php');
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

18) 
19) function customer_with_email($email)
20) {
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

21)   $email = db_escape_string($email);
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

22)   $result = db_query("SELECT id FROM kundendaten.kunden WHERE email='{$email}' OR email_rechnung='{$email}' OR email_extern='{$email}' LIMIT 1;");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

23)   if ($result->rowCount() == 0)
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

24)     return NULL;
25)   else
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

26)     return $result->fetch(PDO::FETCH_OBJ)->id;
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

27) }
28) 
29) 
30) 
31) function create_customer($data)
32) {
33) 
34)   if (customer_with_email($data['email']) !== NULL)
35)   {
bernd Logger mit Logleveln

bernd authored 14 years ago

36)     logger(LOG_WARNING, 'modules/register/include/register', 'register', "Attempt to create customer with duplicate email »{$data['email']}«");
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

37)     return NULL;
38)   }
39) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

40)   $anrede = db_escape_string($data['anrede']);
41)   $firma = db_escape_string($data['firma']);
42)   $vorname = db_escape_string($data['vorname']);
43)   $nachname = db_escape_string($data['nachname']);
44)   $email = db_escape_string($data['email']);
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

45) 
bernd Logger mit Logleveln

bernd authored 14 years ago

46)   logger(LOG_INFO, 'modules/register/include/register', 'register', "Creating new account: {$anrede} / {$firma} / {$vorname} / {$nachname} / {$email}");
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

47)   
48)   $anrede = maybe_null($anrede);
49)   $firma = maybe_null($firma);
50)   $vorname = maybe_null($vorname);
51)   $nachname = maybe_null($nachname);
52) 
53)   db_query("BEGIN");
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

54)   db_query("INSERT INTO kundendaten.kunden (firma, nachname, vorname, anrede, email, erstellungsdatum,status) VALUES ({$firma}, {$nachname}, {$vorname}, {$anrede}, {$email}, CURDATE(), 3)");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

55)   $customerno = db_insert_id();
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

56)   db_query("COMMIT");
57)   return $customerno;
58) 
59) }
60) 
61) 
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

62) function send_initial_customer_token($customerno)
63) {
64)   $customerno = (int) $customerno;
65)   $token = get_customer_token($customerno);
66)   $customer = get_customer_info($customerno);
67)   $anrede = "Sehr geehrte Damen und Herren";
68)   if ($customer['title'] == 'Herr')
69)     $anrede = "Sehr geehrter Herr {$customer['name']}";
70)   elseif ($customer['title'] == 'Frau')
71)     $anrede = "Sehr geehrte Frau {$customer['name']}";
72)   $msg = "{$anrede},
73) 
74) wir freuen uns, Sie bei schokokeks.org begrüßen zu dürfen.
75) 
76) 
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

77) Sie haben sich als Kunde von schokokeks.org Webhosting 
78) angemeldet. Diese E-Mail ist ein Zwischenschritt um die Gültigkeit 
79) Ihrer E-Mail-Adresse zu überprüfen.
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

80) 
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

81) Um ein Passwort für Ihren Kunden-Zugang festzulegen, rufen Sie 
82) bitte die folgende Adresse auf:
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

83)  https://config.schokokeks.org/go/index/validate_token.php?customerno={$customer['customerno']}&token={$token}
84) 
85) Sollte Ihr E-Mail-Programm diesen Link nicht korrekt an den Browser
86) übertragen, rufen Sie bitte die Seite
87)  https://config.schokokeks.org/go/index/validate_token.php
88) auf und geben Sie die folgenden Daten ein:
89)  Kundennummer: {$customer['customerno']}
90)  Code:         {$token}
91) 
92) Diese Prozedur müssen Sie bis spätestens 24 Stunden nach Erhalt
93) dieser Nachricht durchführen, sonst verliert der Code seine
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

94) Gültigkeit und der Zugang wird wieder gelöscht.
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

95) 
96) Sofern Sie keinen Account bei schokokeks.org angemeldet haben, 
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

97) können Sie diese Nachricht ignorieren.
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

98) ";
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

99)   send_mail($customer['email'], "Willkommen bei schokokeks.org Webhosting", $msg);
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

100) }
101) 
102) 
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

103) function notify_admins_about_new_customer($customerno)
104) {
105)   $customerno = (int) $customerno;
106)   $customer = get_customer_info($customerno);
107)   $msg = "Folgender Kunde hat sich gerade über's Webinterface neu angemeldet:
108) 
109) Kundennummer: {$customerno}
110) Name: {$customer['name']}
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

111) E-mail: {$customer['email']}
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

112) 
113) Registriert von IP-Adresse {$_SERVER['REMOTE_ADDR']}.
114) ";
115)   send_mail("root@schokokeks.org", "[Webinterface] Neuer Kunde", $msg);
116)   
117)   
118) }
119) 
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

120) function welcome_customer($customerno)
121) {
122)   $customerno = (int) $customerno;
123)   $customer = get_customer_info($customerno);
124)   $anrede = "Sehr geehrte Damen und Herren";
125)   if ($customer['title'] == 'Herr')
126)     $anrede = "Sehr geehrter Herr {$customer['name']}";
127)   elseif ($customer['title'] == 'Frau')
128)     $anrede = "Sehr geehrte Frau {$customer['name']}";
129)   $msg = "{$anrede}.
130) 
131) Herzlich willkommen bei schokokeks.org!
132) 
133) Wir freuen uns, dass Sie sich für schokokeks.org entschieden haben.
134) 
135) Um Ihnen den Einstieg besonders angenehm zu gestalten, haben wir in 
136) unserem Wiki eine Seite eingerichtet, die Ihnen die ersten Schritte 
137) erläutern soll.
138) Rufen Sie dazu bitte die Adresse 
139)  https://wiki.schokokeks.org/Erste_Schritte
140) auf.
141) 
142) Auch die anderen Bereiche des Wikis stecken voller Tipps und 
143) Informationen. Schauen Sie sich um, es lohnt sich!
144) 
145) ";
146)  /*
147)   * FIXME: Diese Mail muss noch überarbeitet werden!
148)   */
149) 
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

150)   send_mail($customer['email'], "Willkommen bei schokokeks.org", $msg);
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

151) }
152) 
153) 
154) 
155) 
156)