Browse code

Codingstyle PSR12 + array syntax

Hanno Böck authored on 30/10/2021 21:18:17
Showing 1 changed files
... ...
@@ -17,8 +17,8 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 function whitelist_entries()
18 18
 {
19 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();
20
+    $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=?", [$uid]);
21
+    $return = [];
22 22
     while ($line = $res->fetch()) {
23 23
         array_push($return, $line);
24 24
     }
... ...
@@ -28,8 +28,8 @@ function whitelist_entries()
28 28
 
29 29
 function get_whitelist_details($id)
30 30
 {
31
-    $args = array(":id" => $id,
32
-                ":uid" => $_SESSION['userinfo']['uid']);
31
+    $args = [":id" => $id,
32
+                ":uid" => $_SESSION['userinfo']['uid'], ];
33 33
     $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=:uid AND id=:id", $args);
34 34
     if ($res->rowCount() != 1) {
35 35
         system_failure('Kann diesen Eintrag nicht finden');
... ...
@@ -44,7 +44,7 @@ function delete_from_whitelist($id)
44 44
     // Check if the ID is valid: This will die if not.
45 45
     $entry = get_whitelist_details($id);
46 46
 
47
-    db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id=?", array($id));
47
+    db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id=?", [$id]);
48 48
 }
49 49
 
50 50
 
... ...
@@ -57,8 +57,8 @@ function valid_entry($local, $domain)
57 57
         }
58 58
         return true;
59 59
     }
60
-    $args = array(":domain" => $domain,
61
-                ":uid" => $_SESSION['userinfo']['uid']);
60
+    $args = [":domain" => $domain,
61
+                ":uid" => $_SESSION['userinfo']['uid'], ];
62 62
     $res = db_query("SELECT id FROM mail.v_domains WHERE domainname=:domain AND user=:uid", $args);
63 63
     if ($res->rowCount() != 1) {
64 64
         system_failure('Diese domain gehört Ihnen nicht!');
... ...
@@ -70,9 +70,9 @@ function valid_entry($local, $domain)
70 70
 function new_whitelist_entry($local, $domain, $minutes)
71 71
 {
72 72
     valid_entry($local, $domain);
73
-    $args = array(":uid" => $_SESSION['userinfo']['uid'],
73
+    $args = [":uid" => $_SESSION['userinfo']['uid'],
74 74
                 ":local" => $local,
75
-                ":domain" => $domain);
75
+                ":domain" => $domain, ];
76 76
 
77 77
     $expire = 'NULL';
78 78
     if ($minutes == 'none') {
Browse code

remove whitespace in empty lines

Hanno authored on 26/06/2018 23:36:40
Showing 1 changed files
... ...
@@ -73,7 +73,7 @@ function new_whitelist_entry($local, $domain, $minutes)
73 73
     $args = array(":uid" => $_SESSION['userinfo']['uid'],
74 74
                 ":local" => $local,
75 75
                 ":domain" => $domain);
76
-    
76
+
77 77
     $expire = 'NULL';
78 78
     if ($minutes == 'none') {
79 79
         $expire = 'NULL';
Browse code

Fix coding style with php-cs-checker, see https://cs.sensiolabs.org/

Hanno authored on 26/06/2018 13:58:19
Showing 1 changed files
... ...
@@ -8,79 +8,79 @@ Written 2008-2018 by schokokeks.org Hosting, namely
8 8
 
9 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 10
 
11
-You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
12 12
 http://creativecommons.org/publicdomain/zero/1.0/
13 13
 
14 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 15
 */
16 16
 
17
-function whitelist_entries() 
17
+function whitelist_entries()
18 18
 {
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
-	return $return;
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;
25 26
 }
26 27
 
27 28
 
28 29
 function get_whitelist_details($id)
29 30
 {
30
-  $args = array(":id" => $id,
31
+    $args = array(":id" => $id,
31 32
                 ":uid" => $_SESSION['userinfo']['uid']);
32
-	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=:uid AND id=:id", $args);
33
-	if ($res->rowCount() != 1)
34
-		system_failure('Kann diesen Eintrag nicht finden');
35
-	return $res->fetch();
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();
36 38
 }
37 39
 
38 40
 
39 41
 function delete_from_whitelist($id)
40 42
 {
41
-	$id = (int) $id;
42
-	// Check if the ID is valid: This will die if not.
43
-	$entry = get_whitelist_details($id);
43
+    $id = (int) $id;
44
+    // Check if the ID is valid: This will die if not.
45
+    $entry = get_whitelist_details($id);
44 46
 
45
-	db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id=?", array($id));
47
+    db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id=?", array($id));
46 48
 }
47 49
 
48 50
 
49 51
 function valid_entry($local, $domain)
50 52
 {
51
-	if ($domain == 'schokokeks.org')
52
-	{
53
-		if (($local != $_SESSION['userinfo']['username']) && 
54
-		    (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0))
55
-			system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
56
-		return true;
57
-	}
58
-  $args = array(":domain" => $domain,
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,
59 61
                 ":uid" => $_SESSION['userinfo']['uid']);
60
-	$res = db_query("SELECT id FROM mail.v_domains WHERE domainname=:domain AND user=:uid", $args);
61
-	if ($res->rowCount() != 1)
62
-		system_failure('Diese domain gehört Ihnen nicht!');
63
-	return true;
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;
64 67
 }
65 68
 
66 69
 
67 70
 function new_whitelist_entry($local, $domain, $minutes)
68 71
 {
69
-	valid_entry($local, $domain);
70
-  $args = array(":uid" => $_SESSION['userinfo']['uid'],
72
+    valid_entry($local, $domain);
73
+    $args = array(":uid" => $_SESSION['userinfo']['uid'],
71 74
                 ":local" => $local,
72 75
                 ":domain" => $domain);
73
-	
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);
76
+    
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);
83 86
 }
84
-
85
-
86
-?>
Browse code

Copyright year update

Bernd Wurst authored on 13/01/2018 06:07:05
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2014 by schokokeks.org Hosting, namely
5
+Written 2008-2018 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Lizenzinfos in eigenes Modul ausgelagert und Copyright auf 2014 angepasst

Bernd Wurst authored on 08/02/2014 05:45:07
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2013 by schokokeks.org Hosting, namely
5
+Written 2008-2014 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Weitere Umstellungen auf prepared statements

Bernd Wurst authored on 03/02/2014 20:49:24
Showing 1 changed files
... ...
@@ -17,7 +17,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 function whitelist_entries() 
18 18
 {
19 19
 	$uid = (int) $_SESSION['userinfo']['uid'];
20
-	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid};");
20
+	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=?", array($uid));
21 21
 	$return = array();
22 22
 	while ($line = $res->fetch())
23 23
 		array_push($return, $line);
... ...
@@ -27,9 +27,9 @@ function whitelist_entries()
27 27
 
28 28
 function get_whitelist_details($id)
29 29
 {
30
-	$id = (int) $id;
31
-	$uid = (int) $_SESSION['userinfo']['uid'];
32
-	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid} AND id={$id};");
30
+  $args = array(":id" => $id,
31
+                ":uid" => $_SESSION['userinfo']['uid']);
32
+	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=:uid AND id=:id", $args);
33 33
 	if ($res->rowCount() != 1)
34 34
 		system_failure('Kann diesen Eintrag nicht finden');
35 35
 	return $res->fetch();
... ...
@@ -42,7 +42,7 @@ function delete_from_whitelist($id)
42 42
 	// Check if the ID is valid: This will die if not.
43 43
 	$entry = get_whitelist_details($id);
44 44
 
45
-	db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id={$id} LIMIT 1;");
45
+	db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id=?", array($id));
46 46
 }
47 47
 
48 48
 
... ...
@@ -55,8 +55,9 @@ function valid_entry($local, $domain)
55 55
 			system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
56 56
 		return true;
57 57
 	}
58
-	$d = db_escape_string($domain);
59
-	$res = db_query("SELECT id FROM mail.v_domains WHERE domainname='{$d}' AND user={$_SESSION['userinfo']['uid']} LIMIT 1");
58
+  $args = array(":domain" => $domain,
59
+                ":uid" => $_SESSION['userinfo']['uid']);
60
+	$res = db_query("SELECT id FROM mail.v_domains WHERE domainname=:domain AND user=:uid", $args);
60 61
 	if ($res->rowCount() != 1)
61 62
 		system_failure('Diese domain gehört Ihnen nicht!');
62 63
 	return true;
... ...
@@ -66,17 +67,19 @@ function valid_entry($local, $domain)
66 67
 function new_whitelist_entry($local, $domain, $minutes)
67 68
 {
68 69
 	valid_entry($local, $domain);
69
-	$uid = (int) $_SESSION['userinfo']['uid'];
70
-	$local = maybe_null($local);
71
-	$domain = db_escape_string($domain);
70
+  $args = array(":uid" => $_SESSION['userinfo']['uid'],
71
+                ":local" => $local,
72
+                ":domain" => $domain);
72 73
 	
73
-	$expire = '';
74
-	if ($minutes == 'none')
74
+	$expire = 'NULL';
75
+	if ($minutes == 'none') {
75 76
 		$expire = 'NULL';
76
-	else
77
-		$expire = "NOW() + INTERVAL ". (int) $minutes ." MINUTE";
77
+  }	else {
78
+    $args[':minutes'] = $minutes;
79
+		$expire = "NOW() + INTERVAL :minutes MINUTE";
80
+  }
78 81
 	db_query("INSERT INTO mail.greylisting_manual_whitelist (local,domain,date,expire,uid) VALUES ".
79
-	         "({$local}, '{$domain}', NOW(), {$expire}, $uid);");
82
+	         "(:local, :domain, NOW(), {$expire}, :uid)", $args);
80 83
 }
81 84
 
82 85
 
Browse code

Umstellung auf PDO-Datenbankverbindung

Bernd Wurst authored on 01/02/2014 18:38:23
Showing 1 changed files
... ...
@@ -19,7 +19,7 @@ function whitelist_entries()
19 19
 	$uid = (int) $_SESSION['userinfo']['uid'];
20 20
 	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid};");
21 21
 	$return = array();
22
-	while ($line = mysql_fetch_assoc($res))
22
+	while ($line = $res->fetch())
23 23
 		array_push($return, $line);
24 24
 	return $return;
25 25
 }
... ...
@@ -30,9 +30,9 @@ function get_whitelist_details($id)
30 30
 	$id = (int) $id;
31 31
 	$uid = (int) $_SESSION['userinfo']['uid'];
32 32
 	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid} AND id={$id};");
33
-	if (mysql_num_rows($res) != 1)
33
+	if ($res->rowCount() != 1)
34 34
 		system_failure('Kann diesen Eintrag nicht finden');
35
-	return mysql_fetch_assoc($res);
35
+	return $res->fetch();
36 36
 }
37 37
 
38 38
 
... ...
@@ -55,9 +55,9 @@ function valid_entry($local, $domain)
55 55
 			system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
56 56
 		return true;
57 57
 	}
58
-	$d = mysql_real_escape_string($domain);
58
+	$d = db_escape_string($domain);
59 59
 	$res = db_query("SELECT id FROM mail.v_domains WHERE domainname='{$d}' AND user={$_SESSION['userinfo']['uid']} LIMIT 1");
60
-	if (mysql_num_rows($res) != 1)
60
+	if ($res->rowCount() != 1)
61 61
 		system_failure('Diese domain gehört Ihnen nicht!');
62 62
 	return true;
63 63
 }
... ...
@@ -68,7 +68,7 @@ function new_whitelist_entry($local, $domain, $minutes)
68 68
 	valid_entry($local, $domain);
69 69
 	$uid = (int) $_SESSION['userinfo']['uid'];
70 70
 	$local = maybe_null($local);
71
-	$domain = mysql_real_escape_string($domain);
71
+	$domain = db_escape_string($domain);
72 72
 	
73 73
 	$expire = '';
74 74
 	if ($minutes == 'none')
Browse code

Updated copyright notice (2012 => 2013)

Bernd Wurst authored on 19/01/2013 10:49:50
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2012 by schokokeks.org Hosting, namely
5
+Written 2008-2013 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Added license tags for CC0, README and COPYING

Bernd Wurst authored on 11/03/2012 15:40:04
Showing 1 changed files
... ...
@@ -1,4 +1,18 @@
1 1
 <?php
2
+/*
3
+This file belongs to the Webinterface of schokokeks.org Hosting
4
+
5
+Written 2008-2012 by schokokeks.org Hosting, namely
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
+*/
2 16
 
3 17
 function whitelist_entries() 
4 18
 {
Browse code

Neues Modul: Kann greylisting-Whitelist-einträge verwalten.

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@985 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 11/03/2008 11:04:59
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,69 @@
1
+<?php
2
+
3
+function whitelist_entries() 
4
+{
5
+	$uid = (int) $_SESSION['userinfo']['uid'];
6
+	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid};");
7
+	$return = array();
8
+	while ($line = mysql_fetch_assoc($res))
9
+		array_push($return, $line);
10
+	return $return;
11
+}
12
+
13
+
14
+function get_whitelist_details($id)
15
+{
16
+	$id = (int) $id;
17
+	$uid = (int) $_SESSION['userinfo']['uid'];
18
+	$res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid} AND id={$id};");
19
+	if (mysql_num_rows($res) != 1)
20
+		system_failure('Kann diesen Eintrag nicht finden');
21
+	return mysql_fetch_assoc($res);
22
+}
23
+
24
+
25
+function delete_from_whitelist($id)
26
+{
27
+	$id = (int) $id;
28
+	// Check if the ID is valid: This will die if not.
29
+	$entry = get_whitelist_details($id);
30
+
31
+	db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id={$id} LIMIT 1;");
32
+}
33
+
34
+
35
+function valid_entry($local, $domain)
36
+{
37
+	if ($domain == 'schokokeks.org')
38
+	{
39
+		if (($local != $_SESSION['userinfo']['username']) && 
40
+		    (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0))
41
+			system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
42
+		return true;
43
+	}
44
+	$d = mysql_real_escape_string($domain);
45
+	$res = db_query("SELECT id FROM mail.v_domains WHERE domainname='{$d}' AND user={$_SESSION['userinfo']['uid']} LIMIT 1");
46
+	if (mysql_num_rows($res) != 1)
47
+		system_failure('Diese domain gehört Ihnen nicht!');
48
+	return true;
49
+}
50
+
51
+
52
+function new_whitelist_entry($local, $domain, $minutes)
53
+{
54
+	valid_entry($local, $domain);
55
+	$uid = (int) $_SESSION['userinfo']['uid'];
56
+	$local = maybe_null($local);
57
+	$domain = mysql_real_escape_string($domain);
58
+	
59
+	$expire = '';
60
+	if ($minutes == 'none')
61
+		$expire = 'NULL';
62
+	else
63
+		$expire = "NOW() + INTERVAL ". (int) $minutes ." MINUTE";
64
+	db_query("INSERT INTO mail.greylisting_manual_whitelist (local,domain,date,expire,uid) VALUES ".
65
+	         "({$local}, '{$domain}', NOW(), {$expire}, $uid);");
66
+}
67
+
68
+
69
+?>