dcc202fb249a446ac15c7cf413b9f1b4a3f31b58
bernd Neues Modul: Kann greylisti...

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 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 Neues Modul: Kann greylisti...

bernd authored 16 years ago

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

Hanno authored 6 years ago

14) function whitelist_entries()
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

15) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

16)     $uid = (int) $_SESSION['userinfo']['uid'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

17)     $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=?", [$uid]);
18)     $return = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

19)     while ($line = $res->fetch()) {
20)         array_push($return, $line);
21)     }
22)     return $return;
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

23) }
24) 
25) 
26) function get_whitelist_details($id)
27) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

28)     $args = [":id" => $id,
29)                 ":uid" => $_SESSION['userinfo']['uid'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

30)     $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=:uid AND id=:id", $args);
31)     if ($res->rowCount() != 1) {
32)         system_failure('Kann diesen Eintrag nicht finden');
33)     }
34)     return $res->fetch();
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

35) }
36) 
37) 
38) function delete_from_whitelist($id)
39) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

40)     $id = (int) $id;
41)     // Check if the ID is valid: This will die if not.
42)     $entry = get_whitelist_details($id);
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

43) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

44)     db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id=?", [$id]);
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

45) }
46) 
47) 
48) function valid_entry($local, $domain)
49) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

50)     if ($domain == 'schokokeks.org') {
51)         if (($local != $_SESSION['userinfo']['username']) &&
52)             (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0)) {
53)             system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
54)         }
55)         return true;
56)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

57)     $args = [":domain" => $domain,
58)                 ":uid" => $_SESSION['userinfo']['uid'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

59)     $res = db_query("SELECT id FROM mail.v_domains WHERE domainname=:domain AND user=:uid", $args);
60)     if ($res->rowCount() != 1) {
61)         system_failure('Diese domain gehört Ihnen nicht!');
62)     }
63)     return true;
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

64) }
65) 
66) 
67) function new_whitelist_entry($local, $domain, $minutes)
68) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

69)     valid_entry($local, $domain);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

70)     $args = [":uid" => $_SESSION['userinfo']['uid'],
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

71)                 ":local" => $local,
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

72)                 ":domain" => $domain, ];
Hanno remove whitespace in empty...

Hanno authored 6 years ago

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

Hanno authored 6 years ago

74)     $expire = 'NULL';
75)     if ($minutes == 'none') {
76)         $expire = 'NULL';
77)     } else {
78)         $args[':minutes'] = $minutes;
79)         $expire = "NOW() + INTERVAL :minutes MINUTE";
80)     }
81)     db_query("INSERT INTO mail.greylisting_manual_whitelist (local,domain,date,expire,uid) VALUES ".
82)              "(:local, :domain, NOW(), {$expire}, :uid)", $args);