Browse Source

Security::checkInt()

biotorrents 4 years ago
parent
commit
6396b797d2

+ 2
- 9
classes/security.class.php View File

@@ -17,16 +17,9 @@ class Security
17 17
      * Makes sure a number ID is valid,
18 18
      * e.g., a page ID requested by GET.
19 19
      */
20
-    public function checkInt($ID)
21
-    #public function checkInt(int|array $ID) # Union types need PHP 8 - unbelievable!
20
+    public function checkInt(...$IDs)
22 21
     {
23
-        # Cast single ID to array
24
-        if (!is_array($ID)) {
25
-            $ID = [$ID];
26
-        }
27
-
28
-        # Check each ID supplied
29
-        foreach ($ID as $ID) {
22
+        foreach ($IDs as $ID) {
30 23
             if (!ID || !is_int($ID) || $ID < 1) {
31 24
                 error(400);
32 25
             }

+ 3
- 1
sections/torrents/nonwikiedit.php View File

@@ -1,9 +1,11 @@
1 1
 <?php
2 2
 declare(strict_types=1);
3 3
 
4
-Security::checkInt($_POST['groupid']);
5 4
 authorize();
6 5
 
6
+$GroupID = (int) $_GET['groupid'];
7
+Security::checkInt($GroupID);
8
+
7 9
 // Usual perm checks
8 10
 if (!check_perms('torrents_edit')) {
9 11
     $DB->query("

+ 1
- 1
sections/torrents/takegroupedit.php View File

@@ -15,7 +15,7 @@ if (!check_perms('site_edit_wiki')) {
15 15
 # Variables for database input
16 16
 $user_id = (int) $LoggedUser['ID'];
17 17
 $group_id = (int) $_REQUEST['groupid'];
18
-Security::checkInt([$user_id, $group_id]);
18
+Security::checkInt($user_id, $group_id);
19 19
 
20 20
 # If we're reverting to a previous revision
21 21
 if (!empty($_GET['action']) && $_GET['action'] === 'revert') {

Loading…
Cancel
Save