Browse Source

Use prepared queries on stats and store

biotorrents 3 years ago
parent
commit
abbdd7612d

+ 3
- 3
sections/stats/torrents.php View File

7
 LIMIT 1, 12
7
 LIMIT 1, 12
8
 */
8
 */
9
 if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('torrents_timeline')) {
9
 if (!list($Labels, $InFlow, $OutFlow, $Max) = $Cache->get_value('torrents_timeline')) {
10
-    $DB->query("
10
+    $DB->prepared_query("
11
     SELECT
11
     SELECT
12
       DATE_FORMAT(`Time`, '%b %Y') AS Month,
12
       DATE_FORMAT(`Time`, '%b %Y') AS Month,
13
       COUNT(`ID`)
13
       COUNT(`ID`)
23
     ");
23
     ");
24
     $TimelineIn = array_reverse($DB->to_array());
24
     $TimelineIn = array_reverse($DB->to_array());
25
 
25
 
26
-    $DB->query("
26
+    $DB->prepared_query("
27
     SELECT
27
     SELECT
28
       DATE_FORMAT(`Time`, '%b %Y') AS Month,
28
       DATE_FORMAT(`Time`, '%b %Y') AS Month,
29
       COUNT(`ID`)
29
       COUNT(`ID`)
51
 }
51
 }
52
 
52
 
53
 if (!$CategoryDistribution = $Cache->get_value('category_distribution')) {
53
 if (!$CategoryDistribution = $Cache->get_value('category_distribution')) {
54
-    $DB->query("
54
+    $DB->prepared_query("
55
     SELECT
55
     SELECT
56
       tg.`category_id`,
56
       tg.`category_id`,
57
       COUNT(t.`ID`) AS Torrents
57
       COUNT(t.`ID`) AS Torrents

+ 5
- 5
sections/stats/users.php View File

3
 
3
 
4
 
4
 
5
 if (!$ClassDistribution = $Cache->get_value('class_distribution')) {
5
 if (!$ClassDistribution = $Cache->get_value('class_distribution')) {
6
-    $DB->query("
6
+    $DB->prepared_query("
7
       SELECT p.Name, COUNT(m.ID) AS Users
7
       SELECT p.Name, COUNT(m.ID) AS Users
8
       FROM users_main AS m
8
       FROM users_main AS m
9
         JOIN permissions AS p ON m.PermissionID = p.ID
9
         JOIN permissions AS p ON m.PermissionID = p.ID
16
 }
16
 }
17
 
17
 
18
 if (!$PlatformDistribution = $Cache->get_value('platform_distribution')) {
18
 if (!$PlatformDistribution = $Cache->get_value('platform_distribution')) {
19
-    $DB->query("
19
+    $DB->prepared_query("
20
       SELECT OperatingSystem, COUNT(DISTINCT UserID) AS Users
20
       SELECT OperatingSystem, COUNT(DISTINCT UserID) AS Users
21
       FROM users_sessions
21
       FROM users_sessions
22
       GROUP BY OperatingSystem
22
       GROUP BY OperatingSystem
27
 }
27
 }
28
 
28
 
29
 if (!$BrowserDistribution = $Cache->get_value('browser_distribution')) {
29
 if (!$BrowserDistribution = $Cache->get_value('browser_distribution')) {
30
-    $DB->query("
30
+    $DB->prepared_query("
31
       SELECT Browser, COUNT(DISTINCT UserID) AS Users
31
       SELECT Browser, COUNT(DISTINCT UserID) AS Users
32
       FROM users_sessions
32
       FROM users_sessions
33
       GROUP BY Browser
33
       GROUP BY Browser
39
 
39
 
40
 // Timeline generation
40
 // Timeline generation
41
 if (!list($Labels, $InFlow, $OutFlow) = $Cache->get_value('users_timeline')) {
41
 if (!list($Labels, $InFlow, $OutFlow) = $Cache->get_value('users_timeline')) {
42
-    $DB->query("
42
+    $DB->prepared_query("
43
       SELECT DATE_FORMAT(JoinDate,\"%b %Y\") AS Month, COUNT(UserID)
43
       SELECT DATE_FORMAT(JoinDate,\"%b %Y\") AS Month, COUNT(UserID)
44
       FROM users_info
44
       FROM users_info
45
       GROUP BY Month
45
       GROUP BY Month
47
       LIMIT 1, 11");
47
       LIMIT 1, 11");
48
     $TimelineIn = array_reverse($DB->to_array());
48
     $TimelineIn = array_reverse($DB->to_array());
49
 
49
 
50
-    $DB->query("
50
+    $DB->prepared_query("
51
       SELECT DATE_FORMAT(BanDate,\"%b %Y\") AS Month, COUNT(UserID)
51
       SELECT DATE_FORMAT(BanDate,\"%b %Y\") AS Month, COUNT(UserID)
52
       FROM users_info
52
       FROM users_info
53
       WHERE BanDate > 0
53
       WHERE BanDate > 0

+ 3
- 3
sections/store/badge.php View File

29
 
29
 
30
 if (isset($_GET['confirm']) && $_GET['confirm'] === '1') {
30
 if (isset($_GET['confirm']) && $_GET['confirm'] === '1') {
31
     if (!isset($Err)) {
31
     if (!isset($Err)) {
32
-        $DB->query("
32
+        $DB->prepared_query("
33
           SELECT BonusPoints
33
           SELECT BonusPoints
34
           FROM users_main
34
           FROM users_main
35
           WHERE ID = $UserID");
35
           WHERE ID = $UserID");
42
                 if (!Badges::award_badge($UserID, $BadgeID)) {
42
                 if (!Badges::award_badge($UserID, $BadgeID)) {
43
                     $Err = 'Could not award badge, unknown error occurred.';
43
                     $Err = 'Could not award badge, unknown error occurred.';
44
                 } else {
44
                 } else {
45
-                    $DB->query("
45
+                    $DB->prepared_query("
46
                       UPDATE users_main
46
                       UPDATE users_main
47
                       SET BonusPoints = BonusPoints - " . $Prices[$BadgeID] ."
47
                       SET BonusPoints = BonusPoints - " . $Prices[$BadgeID] ."
48
                       WHERE ID = $UserID");
48
                       WHERE ID = $UserID");
49
 
49
 
50
-                    $DB->query("
50
+                    $DB->prepared_query("
51
                       UPDATE users_info
51
                       UPDATE users_info
52
                       SET AdminComment = CONCAT('".sqltime()." - Purchased badge $BadgeID from store\n\n', AdminComment)
52
                       SET AdminComment = CONCAT('".sqltime()." - Purchased badge $BadgeID from store\n\n', AdminComment)
53
                       WHERE UserID = $UserID");
53
                       WHERE UserID = $UserID");

+ 6
- 6
sections/store/coinbadge.php View File

2
 #declare(strict_types=1);
2
 #declare(strict_types=1);
3
 
3
 
4
 $UserID = $LoggedUser['ID'];
4
 $UserID = $LoggedUser['ID'];
5
-$DB->query("
5
+$DB->prepared_query("
6
   SELECT First, Second
6
   SELECT First, Second
7
   FROM misc
7
   FROM misc
8
   WHERE Name='CoinBadge'");
8
   WHERE Name='CoinBadge'");
10
 if ($DB->has_results()) {
10
 if ($DB->has_results()) {
11
     list($Purchases, $Price) = $DB->next_record();
11
     list($Purchases, $Price) = $DB->next_record();
12
 } else {
12
 } else {
13
-    $DB->query("
13
+    $DB->prepared_query("
14
     INSERT INTO misc
14
     INSERT INTO misc
15
       (Name, First, Second)
15
       (Name, First, Second)
16
     VALUES ('CoinBadge', 0, 1000)");
16
     VALUES ('CoinBadge', 0, 1000)");
24
   if (isset($_GET['confirm'])
24
   if (isset($_GET['confirm'])
25
    && $_GET['confirm'] === 1
25
    && $_GET['confirm'] === 1
26
    && !Badges::has_badge($UserID, 255)) {
26
    && !Badges::has_badge($UserID, 255)) {
27
-      $DB->query("
27
+      $DB->prepared_query("
28
       SELECT BonusPoints
28
       SELECT BonusPoints
29
       FROM users_main
29
       FROM users_main
30
       WHERE ID = $UserID");
30
       WHERE ID = $UserID");
34
           if (!Badges::award_badge($UserID, 255)) {
34
           if (!Badges::award_badge($UserID, 255)) {
35
               $Err = 'Could not award badge, unknown error occurred.';
35
               $Err = 'Could not award badge, unknown error occurred.';
36
           } else {
36
           } else {
37
-              $DB->query("
37
+              $DB->prepared_query("
38
               UPDATE users_main
38
               UPDATE users_main
39
               SET BonusPoints = BonusPoints - $Price
39
               SET BonusPoints = BonusPoints - $Price
40
               WHERE ID = $UserID");
40
               WHERE ID = $UserID");
41
 
41
 
42
-              $DB->query("
42
+              $DB->prepared_query("
43
               UPDATE users_info
43
               UPDATE users_info
44
               SET AdminComment = CONCAT('".sqltime()." - Purchased badge 255 from store\n\n', AdminComment)
44
               SET AdminComment = CONCAT('".sqltime()." - Purchased badge 255 from store\n\n', AdminComment)
45
               WHERE UserID = $UserID");
45
               WHERE UserID = $UserID");
50
               $x = $Purchases;
50
               $x = $Purchases;
51
               $Price = 1000+$x*(10000+1400*((sin($x/1.3)+cos($x/4.21))+(sin($x/2.6)+cos(2*$x/4.21))/2));
51
               $Price = 1000+$x*(10000+1400*((sin($x/1.3)+cos($x/4.21))+(sin($x/2.6)+cos(2*$x/4.21))/2));
52
 
52
 
53
-              $DB->query("
53
+              $DB->prepared_query("
54
               UPDATE misc
54
               UPDATE misc
55
               SET First  = $Purchases,
55
               SET First  = $Purchases,
56
                 Second = $Price
56
                 Second = $Price

+ 7
- 7
sections/store/freeleechize.php View File

26
     $UserID = $LoggedUser['ID'];
26
     $UserID = $LoggedUser['ID'];
27
 
27
 
28
     // Make sure torrent exists
28
     // Make sure torrent exists
29
-    $DB->query("
29
+    $DB->prepared_query("
30
       SELECT FreeTorrent, FreeLeechType
30
       SELECT FreeTorrent, FreeLeechType
31
       FROM torrents
31
       FROM torrents
32
       WHERE ID = $TorrentID");
32
       WHERE ID = $TorrentID");
42
         error('Torrent does not exist');
42
         error('Torrent does not exist');
43
     }
43
     }
44
 
44
 
45
-    $DB->query("
45
+    $DB->prepared_query("
46
       SELECT BonusPoints
46
       SELECT BonusPoints
47
       FROM users_main
47
       FROM users_main
48
       WHERE ID = $UserID");
48
       WHERE ID = $UserID");
51
         list($Points) = $DB->next_record();
51
         list($Points) = $DB->next_record();
52
 
52
 
53
         if ($Points >= $Cost) {
53
         if ($Points >= $Cost) {
54
-            $DB->query("
54
+            $DB->prepared_query("
55
               SELECT TorrentID
55
               SELECT TorrentID
56
               FROM shop_freeleeches
56
               FROM shop_freeleeches
57
               WHERE TorrentID = $TorrentID");
57
               WHERE TorrentID = $TorrentID");
58
 
58
 
59
             if ($DB->has_results()) {
59
             if ($DB->has_results()) {
60
-                $DB->query("
60
+                $DB->prepared_query("
61
                   UPDATE shop_freeleeches
61
                   UPDATE shop_freeleeches
62
                   SET ExpiryTime = ExpiryTime + INTERVAL 1 DAY
62
                   SET ExpiryTime = ExpiryTime + INTERVAL 1 DAY
63
                   WHERE TorrentID = $TorrentID");
63
                   WHERE TorrentID = $TorrentID");
64
             } else {
64
             } else {
65
-                $DB->query("
65
+                $DB->prepared_query("
66
                   INSERT INTO shop_freeleeches
66
                   INSERT INTO shop_freeleeches
67
                     (TorrentID, ExpiryTime)
67
                     (TorrentID, ExpiryTime)
68
                   VALUES($TorrentID, NOW() + INTERVAL 1 DAY)");
68
                   VALUES($TorrentID, NOW() + INTERVAL 1 DAY)");
69
                 Torrents::freeleech_torrents($TorrentID, 1, 3);
69
                 Torrents::freeleech_torrents($TorrentID, 1, 3);
70
             }
70
             }
71
 
71
 
72
-            $DB->query("
72
+            $DB->prepared_query("
73
               UPDATE users_main
73
               UPDATE users_main
74
               SET BonusPoints = BonusPoints - $Cost
74
               SET BonusPoints = BonusPoints - $Cost
75
               WHERE ID = $UserID");
75
               WHERE ID = $UserID");
76
 
76
 
77
-            $DB->query("
77
+            $DB->prepared_query("
78
               UPDATE users_info
78
               UPDATE users_info
79
               SET AdminComment = CONCAT('".sqltime()." - Made TorrentID $TorrentID freeleech for 24 more hours via the store\n\n', AdminComment)
79
               SET AdminComment = CONCAT('".sqltime()." - Made TorrentID $TorrentID freeleech for 24 more hours via the store\n\n', AdminComment)
80
               WHERE UserID = $UserID");
80
               WHERE UserID = $UserID");

+ 8
- 8
sections/store/freeleechpool.php View File

10
     }
10
     }
11
 
11
 
12
     $UserID = $LoggedUser['ID'];
12
     $UserID = $LoggedUser['ID'];
13
-    $DB->query("
13
+    $DB->prepared_query("
14
       SELECT BonusPoints
14
       SELECT BonusPoints
15
       FROM users_main
15
       FROM users_main
16
       WHERE ID = $UserID");
16
       WHERE ID = $UserID");
21
         if ($Points >= $Donation) {
21
         if ($Points >= $Donation) {
22
             $PoolTipped = false;
22
             $PoolTipped = false;
23
 
23
 
24
-            $DB->query("
24
+            $DB->prepared_query("
25
               UPDATE users_main
25
               UPDATE users_main
26
               SET BonusPoints = BonusPoints - $Donation
26
               SET BonusPoints = BonusPoints - $Donation
27
               WHERE ID = $UserID");
27
               WHERE ID = $UserID");
28
 
28
 
29
-            $DB->query("
29
+            $DB->prepared_query("
30
               UPDATE misc
30
               UPDATE misc
31
               SET First = First + $Donation
31
               SET First = First + $Donation
32
               WHERE Name = 'FreeleechPool'");
32
               WHERE Name = 'FreeleechPool'");
33
             $Cache->delete_value('user_info_heavy_'.$UserID);
33
             $Cache->delete_value('user_info_heavy_'.$UserID);
34
 
34
 
35
             // Check to see if we're now over the target pool size
35
             // Check to see if we're now over the target pool size
36
-            $DB->query("
36
+            $DB->prepared_query("
37
               SELECT First, Second
37
               SELECT First, Second
38
               FROM misc
38
               FROM misc
39
               WHERE Name = 'FreeleechPool'");
39
               WHERE Name = 'FreeleechPool'");
48
 
48
 
49
                     for ($i = 0; $i < $NumTorrents; $i++) {
49
                     for ($i = 0; $i < $NumTorrents; $i++) {
50
                         $TorrentSize = intval($Pool * (($i===$NumTorrents-1)?1:(rand(10, 80)/100)) * 100000); # todo
50
                         $TorrentSize = intval($Pool * (($i===$NumTorrents-1)?1:(rand(10, 80)/100)) * 100000); # todo
51
-                        $DB->query("
51
+                        $DB->prepared_query("
52
                           SELECT ID, Size
52
                           SELECT ID, Size
53
                           FROM torrents
53
                           FROM torrents
54
                           WHERE Size < $TorrentSize
54
                           WHERE Size < $TorrentSize
61
                         if ($DB->has_results()) {
61
                         if ($DB->has_results()) {
62
                             list($TorrentID, $Size) = $DB->next_record();
62
                             list($TorrentID, $Size) = $DB->next_record();
63
 
63
 
64
-                            $DB->query("
64
+                            $DB->prepared_query("
65
                               INSERT INTO shop_freeleeches
65
                               INSERT INTO shop_freeleeches
66
                                 (TorrentID, ExpiryTime)
66
                                 (TorrentID, ExpiryTime)
67
                               VALUES($TorrentID, NOW() + INTERVAL 2 DAY)");
67
                               VALUES($TorrentID, NOW() + INTERVAL 2 DAY)");
77
                     }
77
                     }
78
 
78
 
79
                     $Target = rand(10000, 100000);
79
                     $Target = rand(10000, 100000);
80
-                    $DB->query("
80
+                    $DB->prepared_query("
81
                       UPDATE misc
81
                       UPDATE misc
82
                       SET First = 0,
82
                       SET First = 0,
83
                         Second = $Target
83
                         Second = $Target
116
 <?php
116
 <?php
117
 View::show_footer();
117
 View::show_footer();
118
 } else {
118
 } else {
119
-    $DB->query("
119
+    $DB->prepared_query("
120
       SELECT First
120
       SELECT First
121
       FROM misc
121
       FROM misc
122
       WHERE Name = 'FreeleechPool'");
122
       WHERE Name = 'FreeleechPool'");

+ 3
- 3
sections/store/invite.php View File

6
 $Purchase = "1 invite";
6
 $Purchase = "1 invite";
7
 $UserID = $LoggedUser['ID'];
7
 $UserID = $LoggedUser['ID'];
8
 
8
 
9
-$DB->query("
9
+$DB->prepared_query("
10
   SELECT BonusPoints
10
   SELECT BonusPoints
11
   FROM users_main
11
   FROM users_main
12
   WHERE ID = $UserID");
12
   WHERE ID = $UserID");
15
     list($Points) = $DB->next_record();
15
     list($Points) = $DB->next_record();
16
 
16
 
17
     if ($Points >= $Cost) {
17
     if ($Points >= $Cost) {
18
-        $DB->query("
18
+        $DB->prepared_query("
19
           UPDATE users_main
19
           UPDATE users_main
20
           SET BonusPoints = BonusPoints - $Cost,
20
           SET BonusPoints = BonusPoints - $Cost,
21
             Invites = Invites + 1
21
             Invites = Invites + 1
22
           WHERE ID = $UserID");
22
           WHERE ID = $UserID");
23
 
23
 
24
-        $DB->query("
24
+        $DB->prepared_query("
25
           UPDATE users_info
25
           UPDATE users_info
26
           SET AdminComment = CONCAT('".sqltime()." - Purchased an invite from the store\n\n', AdminComment)
26
           SET AdminComment = CONCAT('".sqltime()." - Purchased an invite from the store\n\n', AdminComment)
27
           WHERE UserID = $UserID");
27
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/points_1.php View File

9
 $GiB = 1024 * 1024 * 1024;
9
 $GiB = 1024 * 1024 * 1024;
10
 $Cost = intval(0.15 * $GiB);
10
 $Cost = intval(0.15 * $GiB);
11
 
11
 
12
-$DB->query("
12
+$DB->prepared_query("
13
   SELECT Uploaded
13
   SELECT Uploaded
14
   FROM users_main
14
   FROM users_main
15
   WHERE ID = $UserID");
15
   WHERE ID = $UserID");
18
     list($Upload) = $DB->next_record();
18
     list($Upload) = $DB->next_record();
19
 
19
 
20
     if ($Upload >= $Cost) {
20
     if ($Upload >= $Cost) {
21
-        $DB->query("
21
+        $DB->prepared_query("
22
           UPDATE users_main
22
           UPDATE users_main
23
           SET BonusPoints = BonusPoints + 10,
23
           SET BonusPoints = BonusPoints + 10,
24
             Uploaded = Uploaded - $Cost
24
             Uploaded = Uploaded - $Cost
25
           WHERE ID = $UserID");
25
           WHERE ID = $UserID");
26
 
26
 
27
-        $DB->query("
27
+        $DB->prepared_query("
28
           UPDATE users_info
28
           UPDATE users_info
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
30
           WHERE UserID = $UserID");
30
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/points_10.php View File

9
 $GiB = 1024 * 1024 * 1024;
9
 $GiB = 1024 * 1024 * 1024;
10
 $Cost = 1.5 * $GiB;
10
 $Cost = 1.5 * $GiB;
11
 
11
 
12
-$DB->query("
12
+$DB->prepared_query("
13
   SELECT Uploaded
13
   SELECT Uploaded
14
   FROM users_main
14
   FROM users_main
15
   WHERE ID = $UserID");
15
   WHERE ID = $UserID");
18
     list($Upload) = $DB->next_record();
18
     list($Upload) = $DB->next_record();
19
 
19
 
20
     if ($Upload >= $Cost) {
20
     if ($Upload >= $Cost) {
21
-        $DB->query("
21
+        $DB->prepared_query("
22
           UPDATE users_main
22
           UPDATE users_main
23
           SET BonusPoints = BonusPoints + 100,
23
           SET BonusPoints = BonusPoints + 100,
24
             Uploaded = Uploaded - $Cost
24
             Uploaded = Uploaded - $Cost
25
           WHERE ID = $UserID");
25
           WHERE ID = $UserID");
26
 
26
 
27
-        $DB->query("
27
+        $DB->prepared_query("
28
           UPDATE users_info
28
           UPDATE users_info
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
30
           WHERE UserID = $UserID");
30
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/points_100.php View File

9
 $GiB = 1024 * 1024 * 1024;
9
 $GiB = 1024 * 1024 * 1024;
10
 $Cost = 15.0 * $GiB;
10
 $Cost = 15.0 * $GiB;
11
 
11
 
12
-$DB->query("
12
+$DB->prepared_query("
13
   SELECT Uploaded
13
   SELECT Uploaded
14
   FROM users_main
14
   FROM users_main
15
   WHERE ID = $UserID");
15
   WHERE ID = $UserID");
18
     list($Upload) = $DB->next_record();
18
     list($Upload) = $DB->next_record();
19
 
19
 
20
     if ($Upload >= $Cost) {
20
     if ($Upload >= $Cost) {
21
-        $DB->query("
21
+        $DB->prepared_query("
22
           UPDATE users_main
22
           UPDATE users_main
23
           SET BonusPoints = BonusPoints + 1000,
23
           SET BonusPoints = BonusPoints + 1000,
24
             Uploaded = Uploaded - $Cost
24
             Uploaded = Uploaded - $Cost
25
           WHERE ID = $UserID");
25
           WHERE ID = $UserID");
26
 
26
 
27
-        $DB->query("
27
+        $DB->prepared_query("
28
           UPDATE users_info
28
           UPDATE users_info
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
30
           WHERE UserID = $UserID");
30
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/points_1000.php View File

9
 $GiB = 1024*1024*1024;
9
 $GiB = 1024*1024*1024;
10
 $Cost = 150.0 * $GiB;
10
 $Cost = 150.0 * $GiB;
11
 
11
 
12
-$DB->query("
12
+$DB->prepared_query("
13
   SELECT Uploaded
13
   SELECT Uploaded
14
   FROM users_main
14
   FROM users_main
15
   WHERE ID = $UserID");
15
   WHERE ID = $UserID");
18
     list($Upload) = $DB->next_record();
18
     list($Upload) = $DB->next_record();
19
 
19
 
20
     if ($Upload >= $Cost) {
20
     if ($Upload >= $Cost) {
21
-        $DB->query("
21
+        $DB->prepared_query("
22
           UPDATE users_main
22
           UPDATE users_main
23
           SET BonusPoints = BonusPoints + 10000,
23
           SET BonusPoints = BonusPoints + 10000,
24
             Uploaded = Uploaded - $Cost
24
             Uploaded = Uploaded - $Cost
25
           WHERE ID = $UserID");
25
           WHERE ID = $UserID");
26
 
26
 
27
-        $DB->query("
27
+        $DB->prepared_query("
28
           UPDATE users_info
28
           UPDATE users_info
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
29
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
30
           WHERE UserID = $UserID");
30
           WHERE UserID = $UserID");

+ 4
- 4
sections/store/promotion.php View File

64
 );
64
 );
65
 
65
 
66
 $To = -1;
66
 $To = -1;
67
-$DB->query("
67
+$DB->prepared_query("
68
   SELECT PermissionID, BonusPoints, Warned, Uploaded, Downloaded, (Uploaded / Downloaded) AS Ratio, Enabled, COUNT(torrents.ID) AS Uploads, COUNT(DISTINCT torrents.GroupID) AS Groups
68
   SELECT PermissionID, BonusPoints, Warned, Uploaded, Downloaded, (Uploaded / Downloaded) AS Ratio, Enabled, COUNT(torrents.ID) AS Uploads, COUNT(DISTINCT torrents.GroupID) AS Groups
69
   FROM users_main
69
   FROM users_main
70
     JOIN users_info ON users_main.ID = users_info.UserID
70
     JOIN users_info ON users_main.ID = users_info.UserID
100
         $Err[] = "This account is disabled, how did you get here?";
100
         $Err[] = "This account is disabled, how did you get here?";
101
     } else {
101
     } else {
102
         if ($Classes[$To]['NonSmall'] > 0) {
102
         if ($Classes[$To]['NonSmall'] > 0) {
103
-            $DB->query("
103
+            $DB->prepared_query("
104
               SELECT COUNT(torrents.ID)
104
               SELECT COUNT(torrents.ID)
105
               FROM torrents
105
               FROM torrents
106
               JOIN torrents_group ON torrents.GroupID = torrents_group.ID
106
               JOIN torrents_group ON torrents.GroupID = torrents_group.ID
159
         }
159
         }
160
 
160
 
161
         if (!isset($Err)) {
161
         if (!isset($Err)) {
162
-            $DB->query("
162
+            $DB->prepared_query("
163
               UPDATE users_main
163
               UPDATE users_main
164
               SET
164
               SET
165
                 BonusPoints = BonusPoints - ".$Classes[$To]['Price'].",
165
                 BonusPoints = BonusPoints - ".$Classes[$To]['Price'].",
166
                 PermissionID = $To
166
                 PermissionID = $To
167
               WHERE ID = $UserID");
167
               WHERE ID = $UserID");
168
 
168
 
169
-            $DB->query("
169
+            $DB->prepared_query("
170
               UPDATE users_info
170
               UPDATE users_info
171
               SET AdminComment = CONCAT('".sqltime()." - Class changed to ".Users::make_class_string($To)." via store purchase\n\n', AdminComment)
171
               SET AdminComment = CONCAT('".sqltime()." - Class changed to ".Users::make_class_string($To)." via store purchase\n\n', AdminComment)
172
               WHERE UserID = $UserID");
172
               WHERE UserID = $UserID");

+ 2
- 2
sections/store/store.php View File

6
 
6
 
7
 if (!$LoggedUser['DisablePoints']) {
7
 if (!$LoggedUser['DisablePoints']) {
8
     $PointsRate = 0;
8
     $PointsRate = 0;
9
-    $getTorrents = $DB->query("
9
+    $getTorrents = $DB->prepared_query("
10
       SELECT um.BonusPoints,
10
       SELECT um.BonusPoints,
11
         COUNT(DISTINCT x.fid) AS Torrents,
11
         COUNT(DISTINCT x.fid) AS Torrents,
12
         SUM(t.Size) AS Size,
12
         SUM(t.Size) AS Size,
271
       </tr>
271
       </tr>
272
 
272
 
273
       <?php
273
       <?php
274
-$DB->query("
274
+$DB->prepared_query("
275
   SELECT ID AS BadgeID, Name, Description
275
   SELECT ID AS BadgeID, Name, Description
276
   FROM badges
276
   FROM badges
277
   WHERE ID IN (40, 41, 42, 43, 44, 45, 46, 47, 48)
277
   WHERE ID IN (40, 41, 42, 43, 44, 45, 46, 47, 48)

+ 3
- 3
sections/store/title.php View File

11
     $Title = htmlspecialchars($_POST['title'], ENT_QUOTES);
11
     $Title = htmlspecialchars($_POST['title'], ENT_QUOTES);
12
     $UserID = $LoggedUser['ID'];
12
     $UserID = $LoggedUser['ID'];
13
 
13
 
14
-    $DB->query("
14
+    $DB->prepared_query("
15
       SELECT BonusPoints
15
       SELECT BonusPoints
16
       FROM users_main
16
       FROM users_main
17
       WHERE ID = $UserID");
17
       WHERE ID = $UserID");
20
         list($Points) = $DB->next_record();
20
         list($Points) = $DB->next_record();
21
 
21
 
22
         if ($Points >= $Cost) {
22
         if ($Points >= $Cost) {
23
-            $DB->query("
23
+            $DB->prepared_query("
24
               UPDATE users_main
24
               UPDATE users_main
25
               SET BonusPoints = BonusPoints - $Cost,
25
               SET BonusPoints = BonusPoints - $Cost,
26
                 Title = ?
26
                 Title = ?
27
               WHERE ID = ?", $Title, $UserID);
27
               WHERE ID = ?", $Title, $UserID);
28
 
28
 
29
-            $DB->query("
29
+            $DB->prepared_query("
30
               UPDATE users_info
30
               UPDATE users_info
31
               SET AdminComment = CONCAT(NOW(), ' - Changed title to ', ?, ' via the store\n\n', AdminComment)
31
               SET AdminComment = CONCAT(NOW(), ' - Changed title to ', ?, ' via the store\n\n', AdminComment)
32
               WHERE UserID = ?", $Title, $UserID);
32
               WHERE UserID = ?", $Title, $UserID);

+ 3
- 3
sections/store/token.php View File

6
 $Purchase = "1 freeleech token";
6
 $Purchase = "1 freeleech token";
7
 $UserID = $LoggedUser['ID'];
7
 $UserID = $LoggedUser['ID'];
8
 
8
 
9
-$DB->query("
9
+$DB->prepared_query("
10
   SELECT BonusPoints
10
   SELECT BonusPoints
11
   FROM users_main
11
   FROM users_main
12
   WHERE ID = $UserID");
12
   WHERE ID = $UserID");
15
     list($Points) = $DB->next_record();
15
     list($Points) = $DB->next_record();
16
 
16
 
17
     if ($Points >= $Cost) {
17
     if ($Points >= $Cost) {
18
-        $DB->query("
18
+        $DB->prepared_query("
19
           UPDATE users_main
19
           UPDATE users_main
20
           SET BonusPoints = BonusPoints - $Cost,
20
           SET BonusPoints = BonusPoints - $Cost,
21
             FLTokens = FLTokens + 1
21
             FLTokens = FLTokens + 1
22
           WHERE ID = $UserID");
22
           WHERE ID = $UserID");
23
 
23
 
24
-        $DB->query("
24
+        $DB->prepared_query("
25
           UPDATE users_info
25
           UPDATE users_info
26
           SET AdminComment = CONCAT('".sqltime()." - Purchased a freeleech token from the store\n\n', AdminComment)
26
           SET AdminComment = CONCAT('".sqltime()." - Purchased a freeleech token from the store\n\n', AdminComment)
27
           WHERE UserID = $UserID");
27
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/upload_1.php View File

7
 $GiB = 1024*1024*1024;
7
 $GiB = 1024*1024*1024;
8
 $Cost = 15;
8
 $Cost = 15;
9
 
9
 
10
-$DB->query("
10
+$DB->prepared_query("
11
   SELECT BonusPoints
11
   SELECT BonusPoints
12
   FROM users_main
12
   FROM users_main
13
   WHERE ID = $UserID");
13
   WHERE ID = $UserID");
16
     list($Points) = $DB->next_record();
16
     list($Points) = $DB->next_record();
17
 
17
 
18
     if ($Points >= $Cost) {
18
     if ($Points >= $Cost) {
19
-        $DB->query("
19
+        $DB->prepared_query("
20
           UPDATE users_main
20
           UPDATE users_main
21
           SET BonusPoints = BonusPoints - $Cost,
21
           SET BonusPoints = BonusPoints - $Cost,
22
             Uploaded = Uploaded + ($GiB * 0.1)
22
             Uploaded = Uploaded + ($GiB * 0.1)
23
           WHERE ID = $UserID");
23
           WHERE ID = $UserID");
24
 
24
 
25
-        $DB->query("
25
+        $DB->prepared_query("
26
           UPDATE users_info
26
           UPDATE users_info
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
28
           WHERE UserID = $UserID");
28
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/upload_10.php View File

7
 $GiB = 1024*1024*1024;
7
 $GiB = 1024*1024*1024;
8
 $Cost = 150;
8
 $Cost = 150;
9
 
9
 
10
-$DB->query("
10
+$DB->prepared_query("
11
   SELECT BonusPoints
11
   SELECT BonusPoints
12
   FROM users_main
12
   FROM users_main
13
   WHERE ID = $UserID");
13
   WHERE ID = $UserID");
16
     list($Points) = $DB->next_record();
16
     list($Points) = $DB->next_record();
17
 
17
 
18
     if ($Points >= $Cost) {
18
     if ($Points >= $Cost) {
19
-        $DB->query("
19
+        $DB->prepared_query("
20
           UPDATE users_main
20
           UPDATE users_main
21
           SET BonusPoints = BonusPoints - $Cost,
21
           SET BonusPoints = BonusPoints - $Cost,
22
             Uploaded = Uploaded + ($GiB * 1)
22
             Uploaded = Uploaded + ($GiB * 1)
23
           WHERE ID = $UserID");
23
           WHERE ID = $UserID");
24
 
24
 
25
-        $DB->query("
25
+        $DB->prepared_query("
26
           UPDATE users_info
26
           UPDATE users_info
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
28
           WHERE UserID = $UserID");
28
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/upload_100.php View File

7
 $GiB = 1024*1024*1024;
7
 $GiB = 1024*1024*1024;
8
 $Cost = 1500;
8
 $Cost = 1500;
9
 
9
 
10
-$DB->query("
10
+$DB->prepared_query("
11
   SELECT BonusPoints
11
   SELECT BonusPoints
12
   FROM users_main
12
   FROM users_main
13
   WHERE ID = $UserID");
13
   WHERE ID = $UserID");
16
     list($Points) = $DB->next_record();
16
     list($Points) = $DB->next_record();
17
 
17
 
18
     if ($Points >= $Cost) {
18
     if ($Points >= $Cost) {
19
-        $DB->query("
19
+        $DB->prepared_query("
20
           UPDATE users_main
20
           UPDATE users_main
21
           SET BonusPoints = BonusPoints - $Cost,
21
           SET BonusPoints = BonusPoints - $Cost,
22
             Uploaded = Uploaded + ($GiB * 10)
22
             Uploaded = Uploaded + ($GiB * 10)
23
           WHERE ID = $UserID");
23
           WHERE ID = $UserID");
24
 
24
 
25
-        $DB->query("
25
+        $DB->prepared_query("
26
           UPDATE users_info
26
           UPDATE users_info
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
28
           WHERE UserID = $UserID");
28
           WHERE UserID = $UserID");

+ 3
- 3
sections/store/upload_1000.php View File

7
 $GiB = 1024*1024*1024;
7
 $GiB = 1024*1024*1024;
8
 $Cost = 15000;
8
 $Cost = 15000;
9
 
9
 
10
-$DB->query("
10
+$DB->prepared_query("
11
   SELECT BonusPoints
11
   SELECT BonusPoints
12
   FROM users_main
12
   FROM users_main
13
   WHERE ID = $UserID");
13
   WHERE ID = $UserID");
16
     list($Points) = $DB->next_record();
16
     list($Points) = $DB->next_record();
17
 
17
 
18
     if ($Points >= $Cost) {
18
     if ($Points >= $Cost) {
19
-        $DB->query("
19
+        $DB->prepared_query("
20
           UPDATE users_main
20
           UPDATE users_main
21
           SET BonusPoints = BonusPoints - $Cost,
21
           SET BonusPoints = BonusPoints - $Cost,
22
             Uploaded = Uploaded + ($GiB * 100)
22
             Uploaded = Uploaded + ($GiB * 100)
23
           WHERE ID = $UserID");
23
           WHERE ID = $UserID");
24
 
24
 
25
-        $DB->query("
25
+        $DB->prepared_query("
26
           UPDATE users_info
26
           UPDATE users_info
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
27
           SET AdminComment = CONCAT('".sqltime()." - $Purchase from the store\n\n', AdminComment)
28
           WHERE UserID = $UserID");
28
           WHERE UserID = $UserID");

Loading…
Cancel
Save