Browse Source

Security::checkInt()

biotorrents 4 years ago
parent
commit
6396b797d2

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

17
      * Makes sure a number ID is valid,
17
      * Makes sure a number ID is valid,
18
      * e.g., a page ID requested by GET.
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
             if (!ID || !is_int($ID) || $ID < 1) {
23
             if (!ID || !is_int($ID) || $ID < 1) {
31
                 error(400);
24
                 error(400);
32
             }
25
             }

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

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

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

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

Loading…
Cancel
Save