f12aba6daa6e2848a8ed60ea57b26874d6675f52
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 Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 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) 
17) require_once('inc/db_connect.php');
bernd Neue Token-Mail, Erstellung...

bernd authored 16 years ago

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

bernd authored 16 years ago

19) 
20) function customer_with_email($email)
21) {
22)   $email = mysql_real_escape_string($email);
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

23)   $result = db_query("SELECT id FROM kundendaten.kunden WHERE email='{$email}' OR email_rechnung='{$email}' OR email_extern='{$email}' LIMIT 1;");
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

24)   if (mysql_num_rows($result) == 0)
25)     return NULL;
26)   else
bernd Tabelle 'kundenkontakt' kom...

bernd authored 14 years ago

27)     return mysql_fetch_object($result)->id;
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

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

bernd authored 14 years ago

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

38)     return NULL;
39)   }
40) 
41)   $anrede = mysql_escape_string($data['anrede']);
42)   $firma = mysql_escape_string($data['firma']);
43)   $vorname = mysql_escape_string($data['vorname']);
44)   $nachname = mysql_escape_string($data['nachname']);
45)   $email = mysql_escape_string($data['email']);
46) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 14 years ago

55)   db_query("INSERT INTO kundendaten.kunden (firma, nachname, vorname, anrede, email, erstellungsdatum,status) VALUES ({$firma}, {$nachname}, {$vorname}, {$anrede}, {$email}, CURDATE(), 3)");
bernd Neues Modul für "Kunde werden"

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

152) }
153) 
154) 
155) 
156) 
157)