747e001e4e56da6cde7784dc5c982ec1fdd331a4
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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

5) Written 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

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

bernd authored 16 years ago

13) 
14) function customer_with_email($email)
15) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

16)     $email = db_escape_string($email);
17)     $result = db_query("SELECT id FROM kundendaten.kunden WHERE email='{$email}' OR email_rechnung='{$email}' OR email_extern='{$email}' LIMIT 1;");
18)     if ($result->rowCount() == 0) {
19)         return null;
20)     } else {
21)         return $result->fetch(PDO::FETCH_OBJ)->id;
22)     }
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

23) }
24) 
25) 
26) 
27) function create_customer($data)
28) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

29)     if (customer_with_email($data['email']) !== null) {
30)         logger(LOG_WARNING, 'modules/register/include/register', 'register', "Attempt to create customer with duplicate email »{$data['email']}«");
31)         return null;
32)     }
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

33) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 6 months ago

34)     logger(LOG_INFO, 'modules/register/include/register', 'register', "Creating new account: " . print_r($data, true));
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

36)     db_query("INSERT INTO kundendaten.kunden (firma, nachname, vorname, anrede, email, erstellungsdatum,status) VALUES (:firma, :nachname, :vorname, :anrede, :email, CURDATE(), 3)", $data);
37)     $customerno = db_insert_id();
38)     return $customerno;
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

39) }
40) 
41) 
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

42) function send_initial_customer_token($customerno)
43) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

44)     $customerno = (int) $customerno;
45)     $token = get_customer_token($customerno);
46)     $customer = get_customer_info($customerno);
47)     $anrede = "Sehr geehrte Damen und Herren";
48)     if ($customer['title'] == 'Herr') {
49)         $anrede = "Sehr geehrter Herr {$customer['name']}";
50)     } elseif ($customer['title'] == 'Frau') {
51)         $anrede = "Sehr geehrte Frau {$customer['name']}";
52)     }
53)     $msg = "{$anrede},
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

54) 
55) wir freuen uns, Sie bei schokokeks.org begrüßen zu dürfen.
56) 
57) 
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

64)  https://config.schokokeks.org/go/index/validate_token.php?customerno={$customer['customerno']}&token={$token}
65) 
66) Sollte Ihr E-Mail-Programm diesen Link nicht korrekt an den Browser
67) übertragen, rufen Sie bitte die Seite
68)  https://config.schokokeks.org/go/index/validate_token.php
69) auf und geben Sie die folgenden Daten ein:
70)  Kundennummer: {$customer['customerno']}
71)  Code:         {$token}
72) 
73) Diese Prozedur müssen Sie bis spätestens 24 Stunden nach Erhalt
74) dieser Nachricht durchführen, sonst verliert der Code seine
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

79) ";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

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

bernd authored 16 years ago

81) }
82) 
83) 
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

84) function notify_admins_about_new_customer($customerno)
85) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

86)     $customerno = (int) $customerno;
87)     $customer = get_customer_info($customerno);
88)     $msg = "Folgender Kunde hat sich gerade über's Webinterface neu angemeldet:
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

89) 
90) Kundennummer: {$customerno}
91) Name: {$customer['name']}
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

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

bernd authored 16 years ago

93) 
94) Registriert von IP-Adresse {$_SERVER['REMOTE_ADDR']}.
95) ";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

96)     send_mail("root@schokokeks.org", "[Webinterface] Neuer Kunde", $msg);
bernd AGB muss man annehmen und A...

bernd authored 16 years ago

97) }
98) 
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

99) function welcome_customer($customerno)
100) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

101)     $customerno = (int) $customerno;
102)     $customer = get_customer_info($customerno);
103)     $anrede = "Sehr geehrte Damen und Herren";
104)     if ($customer['title'] == 'Herr') {
105)         $anrede = "Sehr geehrter Herr {$customer['name']}";
106)     } elseif ($customer['title'] == 'Frau') {
107)         $anrede = "Sehr geehrte Frau {$customer['name']}";
108)     }
109)     $msg = "{$anrede}.
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

110) 
111) Herzlich willkommen bei schokokeks.org!
112) 
113) Wir freuen uns, dass Sie sich für schokokeks.org entschieden haben.
114) 
115) Um Ihnen den Einstieg besonders angenehm zu gestalten, haben wir in 
116) unserem Wiki eine Seite eingerichtet, die Ihnen die ersten Schritte 
117) erläutern soll.
118) Rufen Sie dazu bitte die Adresse 
119)  https://wiki.schokokeks.org/Erste_Schritte
120) auf.
121) 
122) Auch die anderen Bereiche des Wikis stecken voller Tipps und 
123) Informationen. Schauen Sie sich um, es lohnt sich!
124) 
125) ";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

126)     /*
127)      * FIXME: Diese Mail muss noch überarbeitet werden!
128)      */
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

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

Hanno authored 5 years ago

130)     send_mail($customer['email'], "Willkommen bei schokokeks.org", $msg);