Browse Source

More prepared queries, friends feature, etc.

biotorrents 3 years ago
parent
commit
51f318ea42

+ 2
- 2
classes/wiki.class.php View File

22
         $Aliases = G::$Cache->get_value('wiki_aliases');
22
         $Aliases = G::$Cache->get_value('wiki_aliases');
23
         if (!$Aliases) {
23
         if (!$Aliases) {
24
             $QueryID = G::$DB->get_query_id();
24
             $QueryID = G::$DB->get_query_id();
25
-            G::$DB->query("
25
+            G::$DB->prepared_query("
26
             SELECT Alias, ArticleID
26
             SELECT Alias, ArticleID
27
             FROM wiki_aliases");
27
             FROM wiki_aliases");
28
             $Aliases = G::$DB->to_pair('Alias', 'ArticleID');
28
             $Aliases = G::$DB->to_pair('Alias', 'ArticleID');
67
         $Contents = G::$Cache->get_value('wiki_article_'.$ArticleID);
67
         $Contents = G::$Cache->get_value('wiki_article_'.$ArticleID);
68
         if (!$Contents) {
68
         if (!$Contents) {
69
             $QueryID = G::$DB->get_query_id();
69
             $QueryID = G::$DB->get_query_id();
70
-            G::$DB->query("
70
+            G::$DB->prepared_query("
71
             SELECT
71
             SELECT
72
               w.Revision,
72
               w.Revision,
73
               w.Title,
73
               w.Title,

+ 4
- 4
sections/forums/take_warn.php View File

35
   Tools::update_user_notes($UserID, $AdminComment);
35
   Tools::update_user_notes($UserID, $AdminComment);
36
 }
36
 }
37
 
37
 
38
-$DB->query("
38
+$DB->prepared_query("
39
   INSERT INTO users_warnings_forums
39
   INSERT INTO users_warnings_forums
40
     (UserID, Comment)
40
     (UserID, Comment)
41
   VALUES
41
   VALUES
45
 Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
45
 Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage);
46
 
46
 
47
 //edit the post
47
 //edit the post
48
-$DB->query("
48
+$DB->prepared_query("
49
   SELECT
49
   SELECT
50
     p.Body,
50
     p.Body,
51
     p.AuthorID,
51
     p.AuthorID,
66
 list($OldBody, $AuthorID, $TopicID, $ForumID, $Page) = $DB->next_record();
66
 list($OldBody, $AuthorID, $TopicID, $ForumID, $Page) = $DB->next_record();
67
 
67
 
68
 // Perform the update
68
 // Perform the update
69
-$DB->query("
69
+$DB->prepared_query("
70
   UPDATE forums_posts
70
   UPDATE forums_posts
71
   SET Body = '" . db_string($Body) . "',
71
   SET Body = '" . db_string($Body) . "',
72
     EditedUserID = '$UserID',
72
     EditedUserID = '$UserID',
101
   $Cache->cache_value("thread_$TopicID" . '_info', $ThreadInfo, 0);
101
   $Cache->cache_value("thread_$TopicID" . '_info', $ThreadInfo, 0);
102
 }
102
 }
103
 
103
 
104
-$DB->query("
104
+$DB->prepared_query("
105
   INSERT INTO comments_edits
105
   INSERT INTO comments_edits
106
     (Page, PostID, EditUser, EditTime, Body)
106
     (Page, PostID, EditUser, EditTime, Body)
107
   VALUES
107
   VALUES

+ 11
- 11
sections/forums/thread.php View File

22
     if (isset($_GET['topicid']) && is_number($_GET['topicid'])) {
22
     if (isset($_GET['topicid']) && is_number($_GET['topicid'])) {
23
         $ThreadID = $_GET['topicid'];
23
         $ThreadID = $_GET['topicid'];
24
     } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) {
24
     } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) {
25
-        $DB->query("
25
+        $DB->prepared_query("
26
       SELECT TopicID
26
       SELECT TopicID
27
       FROM forums_posts
27
       FROM forums_posts
28
       WHERE ID = $_GET[postid]");
28
       WHERE ID = $_GET[postid]");
78
         if ($ThreadInfo['StickyPostID'] < $_GET['postid']) {
78
         if ($ThreadInfo['StickyPostID'] < $_GET['postid']) {
79
             $SQL .= " AND ID != $ThreadInfo[StickyPostID]";
79
             $SQL .= " AND ID != $ThreadInfo[StickyPostID]";
80
         }
80
         }
81
-        $DB->query($SQL);
81
+        $DB->prepared_query($SQL);
82
         list($PostNum) = $DB->next_record();
82
         list($PostNum) = $DB->next_record();
83
     } else {
83
     } else {
84
         $PostNum = 1;
84
         $PostNum = 1;
94
 
94
 
95
 // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
95
 // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
96
 if (!$Catalogue = $Cache->get_value("thread_{$ThreadID}_catalogue_$CatalogueID")) {
96
 if (!$Catalogue = $Cache->get_value("thread_{$ThreadID}_catalogue_$CatalogueID")) {
97
-    $DB->query("
97
+    $DB->prepared_query("
98
     SELECT
98
     SELECT
99
       p.ID,
99
       p.ID,
100
       p.AuthorID,
100
       p.AuthorID,
127
 //Why would we skip this on locked or stickied threads?
127
 //Why would we skip this on locked or stickied threads?
128
 //if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
128
 //if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
129
 
129
 
130
-  $DB->query("
130
+  $DB->prepared_query("
131
     SELECT PostID
131
     SELECT PostID
132
     FROM forums_last_read_topics
132
     FROM forums_last_read_topics
133
     WHERE UserID = '$LoggedUser[ID]'
133
     WHERE UserID = '$LoggedUser[ID]'
134
       AND TopicID = '$ThreadID'");
134
       AND TopicID = '$ThreadID'");
135
   list($LastRead) = $DB->next_record();
135
   list($LastRead) = $DB->next_record();
136
   if ($LastRead < $LastPost) {
136
   if ($LastRead < $LastPost) {
137
-      $DB->query("
137
+      $DB->prepared_query("
138
       INSERT INTO forums_last_read_topics
138
       INSERT INTO forums_last_read_topics
139
         (UserID, TopicID, PostID)
139
         (UserID, TopicID, PostID)
140
       VALUES
140
       VALUES
158
 
158
 
159
 $QuoteNotificationsCount = $Cache->get_value('notify_quoted_' . $LoggedUser['ID']);
159
 $QuoteNotificationsCount = $Cache->get_value('notify_quoted_' . $LoggedUser['ID']);
160
 if ($QuoteNotificationsCount === false || $QuoteNotificationsCount > 0) {
160
 if ($QuoteNotificationsCount === false || $QuoteNotificationsCount > 0) {
161
-    $DB->query("
161
+    $DB->prepared_query("
162
     UPDATE users_notify_quoted
162
     UPDATE users_notify_quoted
163
     SET UnRead = false
163
     SET UnRead = false
164
     WHERE UserID = '$LoggedUser[ID]'
164
     WHERE UserID = '$LoggedUser[ID]'
243
 
243
 
244
 if ($ThreadInfo['NoPoll'] == 0) {
244
 if ($ThreadInfo['NoPoll'] == 0) {
245
     if (!list($Question, $Answers, $Votes, $Featured, $Closed) = $Cache->get_value("polls_$ThreadID")) {
245
     if (!list($Question, $Answers, $Votes, $Featured, $Closed) = $Cache->get_value("polls_$ThreadID")) {
246
-        $DB->query("
246
+        $DB->prepared_query("
247
       SELECT Question, Answers, Featured, Closed
247
       SELECT Question, Answers, Featured, Closed
248
       FROM forums_polls
248
       FROM forums_polls
249
       WHERE TopicID = '$ThreadID'");
249
       WHERE TopicID = '$ThreadID'");
250
         list($Question, $Answers, $Featured, $Closed) = $DB->next_record(MYSQLI_NUM, array(1));
250
         list($Question, $Answers, $Featured, $Closed) = $DB->next_record(MYSQLI_NUM, array(1));
251
         $Answers = unserialize($Answers);
251
         $Answers = unserialize($Answers);
252
-        $DB->query("
252
+        $DB->prepared_query("
253
       SELECT Vote, COUNT(UserID)
253
       SELECT Vote, COUNT(UserID)
254
       FROM forums_polls_votes
254
       FROM forums_polls_votes
255
       WHERE TopicID = '$ThreadID'
255
       WHERE TopicID = '$ThreadID'
281
     #$RevealVoters = in_array($ForumID, FORUMS_TO_REVEAL_VOTERS);
281
     #$RevealVoters = in_array($ForumID, FORUMS_TO_REVEAL_VOTERS);
282
 
282
 
283
     // Polls lose the you voted arrow thingy
283
     // Polls lose the you voted arrow thingy
284
-    $DB->query("
284
+    $DB->prepared_query("
285
     SELECT Vote
285
     SELECT Vote
286
     FROM forums_polls_votes
286
     FROM forums_polls_votes
287
     WHERE UserID = '".$LoggedUser['ID']."'
287
     WHERE UserID = '".$LoggedUser['ID']."'
349
             $StaffNames[] = $Staffer['Username'];
349
             $StaffNames[] = $Staffer['Username'];
350
         }
350
         }
351
 
351
 
352
-        $DB->query("
352
+        $DB->prepared_query("
353
         SELECT
353
         SELECT
354
           fpv.Vote AS Vote,
354
           fpv.Vote AS Vote,
355
           GROUP_CONCAT(um.Username SEPARATOR ', ')
355
           GROUP_CONCAT(um.Username SEPARATOR ', ')
636
   }
636
   }
637
 
637
 
638
 if (check_perms('site_moderate_forums')) {
638
 if (check_perms('site_moderate_forums')) {
639
-    G::$DB->query("
639
+    G::$DB->prepared_query("
640
       SELECT ID, AuthorID, AddedTime, Body
640
       SELECT ID, AuthorID, AddedTime, Body
641
       FROM forums_topic_notes
641
       FROM forums_topic_notes
642
       WHERE TopicID = $ThreadID
642
       WHERE TopicID = $ThreadID

+ 3
- 3
sections/forums/warn.php View File

11
 $Key = (int) $_POST['key'];
11
 $Key = (int) $_POST['key'];
12
 $UserInfo = Users::user_info($UserID);
12
 $UserInfo = Users::user_info($UserID);
13
 
13
 
14
-$DB->query("
14
+$DB->prepared_query("
15
   SELECT p.Body, t.ForumID
15
   SELECT p.Body, t.ForumID
16
   FROM forums_posts AS p
16
   FROM forums_posts AS p
17
     JOIN forums_topics AS t ON p.TopicID = t.ID
17
     JOIN forums_topics AS t ON p.TopicID = t.ID
18
   WHERE p.ID = '$PostID'");
18
   WHERE p.ID = '$PostID'");
19
 list($PostBody, $ForumID) = $DB -> next_record();
19
 list($PostBody, $ForumID) = $DB -> next_record();
20
 
20
 
21
-View::show_header('Warn User');
21
+View::show_header('Warn');
22
 ?>
22
 ?>
23
 
23
 
24
 <div>
24
 <div>
75
             <textarea id="body" style="width: 95%;" tabindex="1" onkeyup="resize('body');" name="body" cols="90"
75
             <textarea id="body" style="width: 95%;" tabindex="1" onkeyup="resize('body');" name="body" cols="90"
76
               rows="8"><?=$PostBody?></textarea>
76
               rows="8"><?=$PostBody?></textarea>
77
             <br />
77
             <br />
78
-            <input type="submit" id="submit_button" value="Warn user" tabindex="1" />
78
+            <input type="submit" id="submit_button" class="button-primary" value="Warn user" tabindex="1" />
79
           </td>
79
           </td>
80
         </tr>
80
         </tr>
81
       </table>
81
       </table>

+ 17
- 13
sections/friends/add.php View File

1
 <?php
1
 <?php
2
+declare(strict_types = 1);
3
+
2
 authorize();
4
 authorize();
3
-if (!is_number($_GET['friendid'])) {
4
-  error(404);
5
-}
6
-$FriendID = db_string($_GET['friendid']);
5
+
6
+$FriendID = (int) $_GET['friendid'];
7
+Security::checkInt($FriendID);
7
 
8
 
8
 // Check if the user $FriendID exists
9
 // Check if the user $FriendID exists
9
-$DB->query("
10
-  SELECT 1
11
-  FROM users_main
12
-  WHERE ID = '$FriendID'");
10
+$DB->prepared_query("
11
+SELECT 1
12
+FROM `users_main`
13
+WHERE `ID` = '$FriendID'
14
+");
15
+
13
 if (!$DB->has_results()) {
16
 if (!$DB->has_results()) {
14
-  error(404);
17
+    error(404);
15
 }
18
 }
16
 
19
 
17
-$DB->query("
18
-  INSERT IGNORE INTO friends
19
-    (UserID, FriendID)
20
+$DB->prepared_query("
21
+  INSERT IGNORE INTO `friends`
22
+    (`UserID`, `FriendID`)
20
   VALUES
23
   VALUES
21
-    ('$LoggedUser[ID]', '$FriendID')");
24
+    ('$LoggedUser[ID]', '$FriendID')
25
+");
22
 
26
 
23
 header('Location: friends.php');
27
 header('Location: friends.php');

+ 9
- 7
sections/friends/comment.php View File

1
-<?
2
-$DB->query("
3
-  UPDATE friends
4
-  SET Comment='$P[comment]'
5
-  WHERE UserID='$LoggedUser[ID]'
6
-    AND FriendID='$P[friendid]'");
1
+<?php
2
+declare(strict_types = 1);
3
+
4
+$DB->prepared_query("
5
+  UPDATE `friends`
6
+  SET `Comment`='$P[comment]'
7
+  WHERE `UserID`='$LoggedUser[ID]'
8
+    AND `FriendID`='$P[friendid]'
9
+");
7
 
10
 
8
 header('Location: friends.php');
11
 header('Location: friends.php');
9
-?>

+ 4
- 4
sections/friends/friends.php View File

3
 
3
 
4
 /**
4
 /**
5
  * Main friends page
5
  * Main friends page
6
- * 
6
+ *
7
  * This page lists a user's friends.
7
  * This page lists a user's friends.
8
  * There's no real point in caching this page.
8
  * There's no real point in caching this page.
9
  * I doubt users load it that much.
9
  * I doubt users load it that much.
21
 list($Page, $Limit) = Format::page_limit(FRIENDS_PER_PAGE);
21
 list($Page, $Limit) = Format::page_limit(FRIENDS_PER_PAGE);
22
 
22
 
23
 // Main query
23
 // Main query
24
-$DB->query("
24
+$DB->prepared_query("
25
   SELECT
25
   SELECT
26
     SQL_CALC_FOUND_ROWS
26
     SQL_CALC_FOUND_ROWS
27
     f.`FriendID`,
27
     f.`FriendID`,
42
 $Friends = $DB->to_array(false, MYSQLI_BOTH, array(6, 'Paranoia'));
42
 $Friends = $DB->to_array(false, MYSQLI_BOTH, array(6, 'Paranoia'));
43
 
43
 
44
 // Number of results (for pagination)
44
 // Number of results (for pagination)
45
-$DB->query('SELECT FOUND_ROWS()');
45
+$DB->prepared_query('SELECT FOUND_ROWS()');
46
 list($Results) = $DB->next_record();
46
 list($Results) = $DB->next_record();
47
 
47
 
48
-// Start printing stuff ?>
48
+// Start printing stuff?>
49
 
49
 
50
 <div>
50
 <div>
51
   <div class="header">
51
   <div class="header">

+ 17
- 15
sections/friends/index.php View File

1
-<?
2
-$P = db_array($_POST);
1
+<?php
2
+declare(strict_types = 1);
3
+
3
 enforce_login();
4
 enforce_login();
4
-if (!empty($_REQUEST['friendid']) && !is_number($_REQUEST['friendid'])) {
5
-  error(404);
6
-}
5
+$P = db_array($_POST);
6
+
7
+$FriendID = (int) $_REQUEST['friendid'];
8
+Security::checkInt($FriendID);
7
 
9
 
8
 if (!empty($_REQUEST['action'])) {
10
 if (!empty($_REQUEST['action'])) {
9
-  switch ($_REQUEST['action']) {
11
+    switch ($_REQUEST['action']) {
10
     case 'add':
12
     case 'add':
11
-      include(SERVER_ROOT.'/sections/friends/add.php');
13
+      require_once "$ENV->SERVER_ROOT/sections/friends/add.php";
12
       break;
14
       break;
15
+
13
     case 'Remove friend':
16
     case 'Remove friend':
14
       authorize();
17
       authorize();
15
-      include(SERVER_ROOT.'/sections/friends/remove.php');
18
+      require_once "$ENV->SERVER_ROOT/sections/friends/remove.php";
16
       break;
19
       break;
20
+
17
     case 'Update':
21
     case 'Update':
18
       authorize();
22
       authorize();
19
-      include(SERVER_ROOT.'/sections/friends/comment.php');
20
-      break;
21
-    case 'whois':
22
-      include(SERVER_ROOT.'/sections/friends/whois.php');
23
+      require_once "$ENV->SERVER_ROOT/sections/friends/comment.php";
23
       break;
24
       break;
25
+
24
     case 'Contact':
26
     case 'Contact':
25
-      header('Location: inbox.php?action=compose&to='.$_POST['friendid']);
27
+      header("Location: inbox.php?action=compose&to=$FriendID");
26
       break;
28
       break;
29
+      
27
     default:
30
     default:
28
       error(404);
31
       error(404);
29
   }
32
   }
30
 } else {
33
 } else {
31
-  include(SERVER_ROOT.'/sections/friends/friends.php');
34
+    require_once "$ENV->SERVER_ROOT/sections/friends/friends.php";
32
 }
35
 }
33
-?>

+ 8
- 6
sections/friends/remove.php View File

1
-<?
2
-$DB->query("
3
-  DELETE FROM friends
4
-  WHERE UserID='$LoggedUser[ID]'
5
-    AND FriendID='$P[friendid]'");
1
+<?php
2
+declare(strict_types = 1);
3
+
4
+$DB->prepared_query("
5
+  DELETE FROM `friends`
6
+  WHERE `UserID`='$LoggedUser[ID]'
7
+    AND `FriendID`='$P[friendid]'
8
+");
6
 
9
 
7
 header('Location: friends.php');
10
 header('Location: friends.php');
8
-?>

+ 2
- 2
sections/inbox/compose.php View File

19
     error(403);
19
     error(403);
20
 }
20
 }
21
 
21
 
22
-$DB->query("
22
+$DB->prepared_query("
23
   SELECT Username
23
   SELECT Username
24
   FROM users_main
24
   FROM users_main
25
   WHERE ID='$ToID'");
25
   WHERE ID='$ToID'");
60
       <div id="preview" class="hidden"></div>
60
       <div id="preview" class="hidden"></div>
61
       <div id="buttons" class="center">
61
       <div id="buttons" class="center">
62
         <input type="button" value="Preview" onclick="Quick_Preview();" />
62
         <input type="button" value="Preview" onclick="Quick_Preview();" />
63
-        <input type="submit" value="Send message" />
63
+        <input type="submit" class="button-primary" value="Send message" />
64
       </div>
64
       </div>
65
     </div>
65
     </div>
66
   </form>
66
   </form>

+ 4
- 4
sections/tools/misc/create_user.php View File

24
     $torrent_pass = Users::make_secret();
24
     $torrent_pass = Users::make_secret();
25
 
25
 
26
     //Create the account
26
     //Create the account
27
-    $DB->query("
27
+    $DB->prepared_query("
28
       INSERT INTO users_main
28
       INSERT INTO users_main
29
         (Username, Email, PassHash, torrent_pass, Enabled, PermissionID)
29
         (Username, Email, PassHash, torrent_pass, Enabled, PermissionID)
30
       VALUES
30
       VALUES
39
     Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
39
     Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $torrent_pass));
40
 
40
 
41
     //Default stylesheet
41
     //Default stylesheet
42
-    $DB->query("
42
+    $DB->prepared_query("
43
       SELECT ID
43
       SELECT ID
44
       FROM stylesheets");
44
       FROM stylesheets");
45
     list($StyleID) = $DB->next_record();
45
     list($StyleID) = $DB->next_record();
48
     $AuthKey = Users::make_secret();
48
     $AuthKey = Users::make_secret();
49
 
49
 
50
     //Give them a row in users_info
50
     //Give them a row in users_info
51
-    $DB->query("
51
+    $DB->prepared_query("
52
       INSERT INTO users_info
52
       INSERT INTO users_info
53
         (UserID, StyleID, AuthKey, JoinDate)
53
         (UserID, StyleID, AuthKey, JoinDate)
54
       VALUES
54
       VALUES
55
         ('".db_string($UserID)."', '".db_string($StyleID)."', '".db_string($AuthKey)."', NOW())");
55
         ('".db_string($UserID)."', '".db_string($StyleID)."', '".db_string($AuthKey)."', NOW())");
56
 
56
 
57
     // Give the notification settings
57
     // Give the notification settings
58
-    $DB->query("INSERT INTO users_notifications_settings (UserID) VALUES ('$UserID')");
58
+    $DB->prepared_query("INSERT INTO users_notifications_settings (UserID) VALUES ('$UserID')");
59
 
59
 
60
     //Redirect to users profile
60
     //Redirect to users profile
61
     header ("Location: user.php?id=$UserID");
61
     header ("Location: user.php?id=$UserID");

+ 1
- 1
sections/top10/donors.php View File

15
 $Limit = in_array($Limit, array(10, 100, 250)) ? $Limit : 10;
15
 $Limit = in_array($Limit, array(10, 100, 250)) ? $Limit : 10;
16
 
16
 
17
 $IsMod = check_perms("users_mod");
17
 $IsMod = check_perms("users_mod");
18
-$DB->query("
18
+$DB->prepared_query("
19
 SELECT
19
 SELECT
20
   `UserID`,
20
   `UserID`,
21
   `TotalRank`,
21
   `TotalRank`,

+ 1
- 1
sections/top10/history.php View File

66
 
66
 
67
     $Details = $Cache->get_value("top10_history_$SQLTime");
67
     $Details = $Cache->get_value("top10_history_$SQLTime");
68
     if ($Details === false) {
68
     if ($Details === false) {
69
-        $DB->query("
69
+        $DB->prepared_query("
70
         SELECT
70
         SELECT
71
           tht.`Rank`,
71
           tht.`Rank`,
72
           tht.`TitleString`,
72
           tht.`TitleString`,

+ 2
- 2
sections/top10/tags.php View File

28
 
28
 
29
 if ($Details == 'all' || $Details == 'ut') {
29
 if ($Details == 'all' || $Details == 'ut') {
30
     if (!$TopUsedTags = $Cache->get_value('topusedtag_'.$Limit)) {
30
     if (!$TopUsedTags = $Cache->get_value('topusedtag_'.$Limit)) {
31
-        $DB->query("
31
+        $DB->prepared_query("
32
         SELECT
32
         SELECT
33
           t.ID,
33
           t.ID,
34
           t.Name,
34
           t.Name,
47
 
47
 
48
 if ($Details == 'all' || $Details == 'ur') {
48
 if ($Details == 'all' || $Details == 'ur') {
49
     if (!$TopRequestTags = $Cache->get_value('toprequesttag_'.$Limit)) {
49
     if (!$TopRequestTags = $Cache->get_value('toprequesttag_'.$Limit)) {
50
-        $DB->query("
50
+        $DB->prepared_query("
51
         SELECT
51
         SELECT
52
           t.ID,
52
           t.ID,
53
           t.Name,
53
           t.Name,

+ 8
- 8
sections/top10/torrents.php View File

208
               ORDER BY (t.Seeders + t.Leechers) DESC
208
               ORDER BY (t.Seeders + t.Leechers) DESC
209
               LIMIT $Limit;";
209
               LIMIT $Limit;";
210
 
210
 
211
-            $DB->query($Query);
211
+            $DB->prepared_query($Query);
212
             $TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
212
             $TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
213
             $Cache->cache_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastDay, 3600 * 2);
213
             $Cache->cache_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastDay, 3600 * 2);
214
             $Cache->clear_query_lock('top10');
214
             $Cache->clear_query_lock('top10');
235
               ORDER BY (t.Seeders + t.Leechers) DESC
235
               ORDER BY (t.Seeders + t.Leechers) DESC
236
               LIMIT $Limit;";
236
               LIMIT $Limit;";
237
 
237
 
238
-            $DB->query($Query);
238
+            $DB->prepared_query($Query);
239
             $TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
239
             $TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
240
             $Cache->cache_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastWeek, 3600 * 6);
240
             $Cache->cache_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastWeek, 3600 * 6);
241
             $Cache->clear_query_lock('top10');
241
             $Cache->clear_query_lock('top10');
262
               ORDER BY (t.Seeders + t.Leechers) DESC
262
               ORDER BY (t.Seeders + t.Leechers) DESC
263
               LIMIT $Limit;";
263
               LIMIT $Limit;";
264
 
264
 
265
-            $DB->query($Query);
265
+            $DB->prepared_query($Query);
266
             $TopTorrentsActiveLastMonth = $DB->to_array(false, MYSQLI_NUM);
266
             $TopTorrentsActiveLastMonth = $DB->to_array(false, MYSQLI_NUM);
267
             $Cache->cache_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastMonth, 3600 * 6);
267
             $Cache->cache_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastMonth, 3600 * 6);
268
             $Cache->clear_query_lock('top10');
268
             $Cache->clear_query_lock('top10');
294
               ORDER BY (t.Seeders + t.Leechers) DESC
294
               ORDER BY (t.Seeders + t.Leechers) DESC
295
               LIMIT $Limit;";
295
               LIMIT $Limit;";
296
 
296
 
297
-            $DB->query($Query);
297
+            $DB->prepared_query($Query);
298
             $TopTorrentsActiveLastYear = $DB->to_array(false, MYSQLI_NUM);
298
             $TopTorrentsActiveLastYear = $DB->to_array(false, MYSQLI_NUM);
299
             $Cache->cache_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastYear, 3600 * 6);
299
             $Cache->cache_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastYear, 3600 * 6);
300
             $Cache->clear_query_lock('top10');
300
             $Cache->clear_query_lock('top10');
325
               ORDER BY (t.Seeders + t.Leechers) DESC
325
               ORDER BY (t.Seeders + t.Leechers) DESC
326
               LIMIT $Limit;";
326
               LIMIT $Limit;";
327
 
327
 
328
-            $DB->query($Query);
328
+            $DB->prepared_query($Query);
329
             $TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
329
             $TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
330
             $Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveAllTime, 3600 * 6);
330
             $Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveAllTime, 3600 * 6);
331
             $Cache->clear_query_lock('top10');
331
             $Cache->clear_query_lock('top10');
351
               ORDER BY t.Snatched DESC
351
               ORDER BY t.Snatched DESC
352
               LIMIT $Limit;";
352
               LIMIT $Limit;";
353
 
353
 
354
-            $DB->query($Query);
354
+            $DB->prepared_query($Query);
355
             $TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
355
             $TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
356
             $Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSnatched, 3600 * 6);
356
             $Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSnatched, 3600 * 6);
357
             $Cache->clear_query_lock('top10');
357
             $Cache->clear_query_lock('top10');
380
               ORDER BY Data DESC
380
               ORDER BY Data DESC
381
               LIMIT $Limit;";
381
               LIMIT $Limit;";
382
 
382
 
383
-            $DB->query($Query);
383
+            $DB->prepared_query($Query);
384
             $TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
384
             $TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
385
             $Cache->cache_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsTransferred, 3600 * 6);
385
             $Cache->cache_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsTransferred, 3600 * 6);
386
             $Cache->clear_query_lock('top10');
386
             $Cache->clear_query_lock('top10');
405
               ORDER BY t.Seeders DESC
405
               ORDER BY t.Seeders DESC
406
               LIMIT $Limit;";
406
               LIMIT $Limit;";
407
 
407
 
408
-            $DB->query($Query);
408
+            $DB->prepared_query($Query);
409
             $TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
409
             $TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
410
             $Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSeeded, 3600 * 6);
410
             $Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSeeded, 3600 * 6);
411
             $Cache->clear_query_lock('top10');
411
             $Cache->clear_query_lock('top10');

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

48
 
48
 
49
   if ($Details == 'all' || $Details == 'ul') {
49
   if ($Details == 'all' || $Details == 'ul') {
50
       if (!$TopUserUploads = $Cache->get_value('topuser_ul_'.$Limit)) {
50
       if (!$TopUserUploads = $Cache->get_value('topuser_ul_'.$Limit)) {
51
-          $DB->query("$BaseQuery ORDER BY u.Uploaded DESC LIMIT $Limit;");
51
+          $DB->prepared_query("$BaseQuery ORDER BY u.Uploaded DESC LIMIT $Limit;");
52
           $TopUserUploads = $DB->to_array();
52
           $TopUserUploads = $DB->to_array();
53
           $Cache->cache_value('topuser_ul_'.$Limit, $TopUserUploads, 3600 * 12);
53
           $Cache->cache_value('topuser_ul_'.$Limit, $TopUserUploads, 3600 * 12);
54
       }
54
       }
57
 
57
 
58
   if ($Details == 'all' || $Details == 'dl') {
58
   if ($Details == 'all' || $Details == 'dl') {
59
       if (!$TopUserDownloads = $Cache->get_value('topuser_dl_'.$Limit)) {
59
       if (!$TopUserDownloads = $Cache->get_value('topuser_dl_'.$Limit)) {
60
-          $DB->query("$BaseQuery ORDER BY u.Downloaded DESC LIMIT $Limit;");
60
+          $DB->prepared_query("$BaseQuery ORDER BY u.Downloaded DESC LIMIT $Limit;");
61
           $TopUserDownloads = $DB->to_array();
61
           $TopUserDownloads = $DB->to_array();
62
           $Cache->cache_value('topuser_dl_'.$Limit, $TopUserDownloads, 3600 * 12);
62
           $Cache->cache_value('topuser_dl_'.$Limit, $TopUserDownloads, 3600 * 12);
63
       }
63
       }
66
 
66
 
67
   if ($Details == 'all' || $Details == 'numul') {
67
   if ($Details == 'all' || $Details == 'numul') {
68
       if (!$TopUserNumUploads = $Cache->get_value('topuser_numul_'.$Limit)) {
68
       if (!$TopUserNumUploads = $Cache->get_value('topuser_numul_'.$Limit)) {
69
-          $DB->query("$BaseQuery ORDER BY NumUploads DESC LIMIT $Limit;");
69
+          $DB->prepared_query("$BaseQuery ORDER BY NumUploads DESC LIMIT $Limit;");
70
           $TopUserNumUploads = $DB->to_array();
70
           $TopUserNumUploads = $DB->to_array();
71
           $Cache->cache_value('topuser_numul_'.$Limit, $TopUserNumUploads, 3600 * 12);
71
           $Cache->cache_value('topuser_numul_'.$Limit, $TopUserNumUploads, 3600 * 12);
72
       }
72
       }
75
 
75
 
76
   if ($Details == 'all' || $Details == 'uls') {
76
   if ($Details == 'all' || $Details == 'uls') {
77
       if (!$TopUserUploadSpeed = $Cache->get_value('topuser_ulspeed_'.$Limit)) {
77
       if (!$TopUserUploadSpeed = $Cache->get_value('topuser_ulspeed_'.$Limit)) {
78
-          $DB->query("$BaseQuery ORDER BY UpSpeed DESC LIMIT $Limit;");
78
+          $DB->prepared_query("$BaseQuery ORDER BY UpSpeed DESC LIMIT $Limit;");
79
           $TopUserUploadSpeed = $DB->to_array();
79
           $TopUserUploadSpeed = $DB->to_array();
80
           $Cache->cache_value('topuser_ulspeed_'.$Limit, $TopUserUploadSpeed, 3600 * 12);
80
           $Cache->cache_value('topuser_ulspeed_'.$Limit, $TopUserUploadSpeed, 3600 * 12);
81
       }
81
       }
84
 
84
 
85
   if ($Details == 'all' || $Details == 'dls') {
85
   if ($Details == 'all' || $Details == 'dls') {
86
       if (!$TopUserDownloadSpeed = $Cache->get_value('topuser_dlspeed_'.$Limit)) {
86
       if (!$TopUserDownloadSpeed = $Cache->get_value('topuser_dlspeed_'.$Limit)) {
87
-          $DB->query("$BaseQuery ORDER BY DownSpeed DESC LIMIT $Limit;");
87
+          $DB->prepared_query("$BaseQuery ORDER BY DownSpeed DESC LIMIT $Limit;");
88
           $TopUserDownloadSpeed = $DB->to_array();
88
           $TopUserDownloadSpeed = $DB->to_array();
89
           $Cache->cache_value('topuser_dlspeed_'.$Limit, $TopUserDownloadSpeed, 3600 * 12);
89
           $Cache->cache_value('topuser_dlspeed_'.$Limit, $TopUserDownloadSpeed, 3600 * 12);
90
       }
90
       }

Loading…
Cancel
Save