9086c9ad77db90633e0629e9e86a88366265ded0
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) 
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 Fix coding style with php-c...

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

19)     $uid = (int) $_SESSION['userinfo']['uid'];
20)     $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=?", array($uid));
21)     $return = array();
22)     while ($line = $res->fetch()) {
23)         array_push($return, $line);
24)     }
25)     return $return;
bernd Neues Modul: Kann greylisti...

bernd authored 16 years ago

26) }
27) 
28) 
29) function get_whitelist_details($id)
30) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

31)     $args = array(":id" => $id,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

32)                 ":uid" => $_SESSION['userinfo']['uid']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

38) }
39) 
40) 
41) function delete_from_whitelist($id)
42) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

48) }
49) 
50) 
51) function valid_entry($local, $domain)
52) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

53)     if ($domain == 'schokokeks.org') {
54)         if (($local != $_SESSION['userinfo']['username']) &&
55)             (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0)) {
56)             system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
57)         }
58)         return true;
59)     }
60)     $args = array(":domain" => $domain,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

61)                 ":uid" => $_SESSION['userinfo']['uid']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

67) }
68) 
69) 
70) function new_whitelist_entry($local, $domain, $minutes)
71) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

72)     valid_entry($local, $domain);
73)     $args = array(":uid" => $_SESSION['userinfo']['uid'],
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

74)                 ":local" => $local,
75)                 ":domain" => $domain);
Hanno remove whitespace in empty...

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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