9086c9ad77db90633e0629e9e86a88366265ded0
bernd Entities repariert

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 Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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 Entities repariert

bernd authored 16 years ago

16) 
17) require_once('session/checkuser.php');
18) 
19) function customer_has_email($customerno, $email)
20) {
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

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

bernd authored 16 years ago

25) }
26) 
27) 
28) function validate_token($customerno, $token)
29) {
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

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

bernd authored 16 years ago

35) }
36) 
37) 
38) function expire_tokens()
39) {
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

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

bernd authored 16 years ago

42) }
43) 
44) function invalidate_customer_token($customerno)
45) {
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

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

bernd authored 16 years ago

48) }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

49) 
bernd Entities repariert

bernd authored 16 years ago

50) function create_token($customerno)
51) {
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

52)     $customerno = (int) $customerno;
53)     expire_tokens();
54)     $result = db_query("SELECT token_create FROM kundendaten.kunden WHERE id={$customerno} AND token_create IS NOT NULL;");
55)     if ($result->rowCount() > 0) {
56)         $res = $result->fetch(PDO::FETCH_OBJ)->token_create;
57)         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.");
58)         return false;
59)     }
60)     $token = random_string(10);
61)     db_query("UPDATE kundendaten.kunden SET token='{$token}', token_create=now() WHERE id={$customerno} LIMIT 1;");
62)     return true;
bernd Entities repariert

bernd authored 16 years ago

63) }
64) 
65) 
66) function get_customer_token($customerno)
67) {
Hanno verbleibende syntaxfehler u...

Hanno authored 5 years ago

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