dcc202fb249a446ac15c7cf413b9f1b4a3f31b58
bernd Entities repariert

bernd authored 17 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 2 years 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 2 years 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 Entities repariert

bernd authored 17 years ago

13) 
14) require_once('session/checkuser.php');
15) 
16) function customer_has_email($customerno, $email)
17) {
Hanno verbleibende syntaxfehler u...

Hanno authored 6 years ago

18)     $customerno = (int) $customerno;
19)     $email = db_escape_string($email);
20)     $result = db_query("SELECT NULL FROM kundendaten.kunden WHERE id=".$customerno." AND (email='".$email."' OR email_extern='{$email}' OR email_rechnung='{$email}');");
21)     return ($result->rowCount() > 0);
bernd Entities repariert

bernd authored 17 years ago

22) }
23) 
24) 
25) function validate_token($customerno, $token)
26) {
Hanno verbleibende syntaxfehler u...

Hanno authored 6 years ago

27)     expire_tokens();
28)     $customerno = (int) $customerno;
29)     $token = db_escape_string($token);
30)     $result = db_query("SELECT NULL FROM kundendaten.kunden WHERE id={$customerno} AND token='{$token}';");
31)     return ($result->rowCount() > 0);
bernd Entities repariert

bernd authored 17 years ago

32) }
33) 
34) 
35) function expire_tokens()
36) {
Hanno verbleibende syntaxfehler u...

Hanno authored 6 years ago

37)     $expire = "1 DAY";
38)     db_query("UPDATE kundendaten.kunden SET token=NULL, token_create=NULL WHERE token_create < NOW() - INTERVAL {$expire};");
bernd Entities repariert

bernd authored 17 years ago

39) }
40) 
41) function invalidate_customer_token($customerno)
42) {
Hanno verbleibende syntaxfehler u...

Hanno authored 6 years ago

43)     $customerno = (int) $customerno;
44)     db_query("UPDATE kundendaten.kunden SET token=NULL, token_create=NULL WHERE id={$customerno} LIMIT 1;");
bernd Entities repariert

bernd authored 17 years ago

45) }
Hanno remove whitespace in empty...

Hanno authored 6 years ago

46) 
bernd Entities repariert

bernd authored 17 years ago

47) function create_token($customerno)
48) {
Hanno verbleibende syntaxfehler u...

Hanno authored 6 years ago

49)     $customerno = (int) $customerno;
50)     expire_tokens();
51)     $result = db_query("SELECT token_create FROM kundendaten.kunden WHERE id={$customerno} AND token_create IS NOT NULL;");
52)     if ($result->rowCount() > 0) {
53)         $res = $result->fetch(PDO::FETCH_OBJ)->token_create;
54)         input_error("Sie haben diese Funktion kürzlich erst benutzt, an Ihre E-Mail-Adresse wurde bereits am {$res} eine Nachricht verschickt. Sie können diese Funktion erst nach Ablauf von 24 Stunden erneut benutzen.");
55)         return false;
56)     }
57)     $token = random_string(10);
58)     db_query("UPDATE kundendaten.kunden SET token='{$token}', token_create=now() WHERE id={$customerno} LIMIT 1;");
59)     return true;
bernd Entities repariert

bernd authored 17 years ago

60) }
61) 
62) 
63) function get_customer_token($customerno)
64) {
Hanno verbleibende syntaxfehler u...

Hanno authored 6 years ago

65)     $customerno = (int) $customerno;
66)     expire_tokens();
67)     $result = db_query("SELECT token FROM kundendaten.kunden WHERE id={$customerno} AND token IS NOT NULL;");
68)     if ($result->rowCount() < 1) {
69)         system_failure("Kann das Token nicht auslesen!");
70)     }
71)     return $result->fetch(PDO::FETCH_OBJ)->token;