Browse Source

Use prepared queries on classes/script_start.php

biotorrents 4 years ago
parent
commit
d1ca9c6f18
2 changed files with 13 additions and 13 deletions
  1. 4
    4
      classes/mysql.class.php
  2. 9
    9
      classes/script_start.php

+ 4
- 4
classes/mysql.class.php View File

@@ -22,7 +22,7 @@ $DB = NEW DB_MYSQL;
22 22
 
23 23
 * Making a query
24 24
 
25
-$DB->query("
25
+$DB->prepared_query("
26 26
   SELECT *
27 27
   FROM table...");
28 28
 
@@ -92,14 +92,14 @@ set_query_id($ResultSet)
92 92
   This class can only hold one result set at a time. Using set_query_id allows
93 93
   you to set the result set that the class is using to the result set in
94 94
   $ResultSet. This result set should have been obtained earlier by using
95
-  $DB->query().
95
+  $DB->prepared_query().
96 96
 
97 97
   Example:
98 98
 
99
-  $FoodRS = $DB->query("
99
+  $FoodRS = $DB->prepared_query("
100 100
       SELECT *
101 101
       FROM food");
102
-  $DB->query("
102
+  $DB->prepared_query("
103 103
     SELECT *
104 104
     FROM drink");
105 105
   $Drinks = $DB->next_record();

+ 9
- 9
classes/script_start.php View File

@@ -225,7 +225,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
225 225
 
226 226
     $UserSessions = $Cache->get_value("users_sessions_$UserID");
227 227
     if (!is_array($UserSessions)) {
228
-        $DB->query(
228
+        $DB->prepared_query(
229 229
             "
230 230
         SELECT
231 231
           SessionID,
@@ -250,7 +250,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
250 250
     // Check if user is enabled
251 251
     $Enabled = $Cache->get_value('enabled_'.$LoggedUser['ID']);
252 252
     if ($Enabled === false) {
253
-        $DB->query("
253
+        $DB->prepared_query("
254 254
         SELECT Enabled
255 255
           FROM users_main
256 256
           WHERE ID = '$LoggedUser[ID]'");
@@ -267,7 +267,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
267 267
     // Up/Down stats
268 268
     $UserStats = $Cache->get_value('user_stats_'.$LoggedUser['ID']);
269 269
     if (!is_array($UserStats)) {
270
-        $DB->query("
270
+        $DB->prepared_query("
271 271
         SELECT Uploaded AS BytesUploaded, Downloaded AS BytesDownloaded, RequiredRatio
272 272
         FROM users_main
273 273
           WHERE ID = '$LoggedUser[ID]'");
@@ -321,7 +321,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
321 321
 
322 322
     // Update LastUpdate every 10 minutes
323 323
     if (strtotime($UserSessions[$SessionID]['LastUpdate']) + 600 < time()) {
324
-        $DB->query("
324
+        $DB->prepared_query("
325 325
         UPDATE users_main
326 326
         SET LastAccess = NOW()
327 327
         WHERE ID = '$LoggedUser[ID]'
@@ -343,7 +343,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
343 343
         WHERE UserID = '$LoggedUser[ID]'
344 344
         AND SessionID = '".db_string($SessionID)."'";
345 345
 
346
-        $DB->query($SessionQuery);
346
+        $DB->prepared_query($SessionQuery);
347 347
         $Cache->begin_transaction("users_sessions_$UserID");
348 348
         $Cache->delete_row($SessionID);
349 349
 
@@ -362,7 +362,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
362 362
     if (isset($LoggedUser['Permissions']['site_torrents_notify'])) {
363 363
         $LoggedUser['Notify'] = $Cache->get_value('notify_filters_'.$LoggedUser['ID']);
364 364
         if (!is_array($LoggedUser['Notify'])) {
365
-            $DB->query("
365
+            $DB->prepared_query("
366 366
             SELECT ID, Label
367 367
             FROM users_notify_filters
368 368
               WHERE UserID = '$LoggedUser[ID]'");
@@ -394,7 +394,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
394 394
     // Get stylesheets
395 395
     $Stylesheets = $Cache->get_value('stylesheets');
396 396
     if (!is_array($Stylesheets)) {
397
-        $DB->query('
397
+        $DB->prepared_query('
398 398
         SELECT
399 399
           ID,
400 400
           LOWER(REPLACE(Name, " ", "_")) AS Name,
@@ -429,7 +429,7 @@ function logout()
429 429
     setcookie('keeplogged', '', time() - 60 * 60 * 24 * 365, '/', '', false);
430 430
 
431 431
     if ($SessionID) {
432
-        G::$DB->query("
432
+        G::$DB->prepared_query("
433 433
         DELETE FROM users_sessions
434 434
           WHERE UserID = '" . G::$LoggedUser['ID'] . "'
435 435
           AND SessionID = '".db_string($SessionID)."'");
@@ -451,7 +451,7 @@ function logout_all_sessions()
451 451
 {
452 452
     $UserID = G::$LoggedUser['ID'];
453 453
 
454
-    G::$DB->query("
454
+    G::$DB->prepared_query("
455 455
     DELETE FROM users_sessions
456 456
       WHERE UserID = '$UserID'");
457 457
 

Loading…
Cancel
Save