Browse Source

Please don't let this break the site schedules

pjc 5 years ago
parent
commit
c0984f9245
33 changed files with 357 additions and 342 deletions
  1. 4
    3
      sections/schedule/biweekly/cycle_auth_keys.php
  2. 27
    28
      sections/schedule/biweekly/grant_invites.php
  3. 2
    2
      sections/schedule/daily/class_demotions.php
  4. 3
    0
      sections/schedule/daily/delete_dead_torrents.php
  5. 13
    13
      sections/schedule/daily/disable_inactive_users.php
  6. 6
    6
      sections/schedule/daily/disable_unconfirmed_users.php
  7. 2
    2
      sections/schedule/daily/donations.php
  8. 5
    1
      sections/schedule/daily/ratio_reqs.php
  9. 34
    33
      sections/schedule/daily/ratio_watch.php
  10. 2
    2
      sections/schedule/daily/resolve_staff_pms.php
  11. 33
    32
      sections/schedule/daily/top10_daily.php
  12. 10
    10
      sections/schedule/every/expire_tokens.php
  13. 4
    4
      sections/schedule/every/freeleech.php
  14. 10
    10
      sections/schedule/every/shop_freeleech.php
  15. 12
    11
      sections/schedule/every/update_recently_uploaded_torrents_swarms.php
  16. 30
    30
      sections/schedule/hourly/badges.php
  17. 14
    12
      sections/schedule/hourly/bonus_points.php
  18. 6
    5
      sections/schedule/hourly/class_promotion.php
  19. 9
    9
      sections/schedule/hourly/disable_leech.php
  20. 11
    11
      sections/schedule/hourly/expire_invites.php
  21. 5
    5
      sections/schedule/hourly/expire_warnings.php
  22. 2
    2
      sections/schedule/hourly/hide_old_requests.php
  23. 2
    2
      sections/schedule/hourly/hit_n_runs.php
  24. 2
    2
      sections/schedule/hourly/record_seeding.php
  25. 2
    2
      sections/schedule/hourly/remove_dead_peers.php
  26. 5
    5
      sections/schedule/hourly/remove_dead_sessions.php
  27. 2
    2
      sections/schedule/hourly/seed_times.php
  28. 4
    4
      sections/schedule/hourly/sphinx_min_max_matches.php
  29. 41
    40
      sections/schedule/index.php
  30. 4
    4
      sections/schedule/manually/update_geodist.php
  31. 2
    2
      sections/schedule/monthly/update_top_snatchers.php
  32. 17
    16
      sections/schedule/weekly/deletion_warning.php
  33. 32
    32
      sections/schedule/weekly/top10_weekly.php

+ 4
- 3
sections/schedule/biweekly/cycle_auth_keys.php View File

@@ -1,7 +1,9 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Cycle auth keys -----------------------------------------//
3 4
 
4
-$DB->query("
5
+$DB->query(
6
+    "
5 7
   UPDATE users_info
6 8
   SET AuthKey =
7 9
     MD5(
@@ -15,4 +17,3 @@ $DB->query("
15 17
       )
16 18
     );"
17 19
 );
18
-?>

+ 27
- 28
sections/schedule/biweekly/grant_invites.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Give out invites! ---------------------------------------//
3 4
 
4 5
 /*
@@ -14,7 +15,6 @@ Every TORRENT_MASTER whose total invitee ratio is above 3.0 and total invitee up
14 15
 This cascades, so if you qualify for the last bonus group, you also qualify for the first two and will receive three bonus invites.
15 16
 
16 17
 The bonus invites cannot put a user over their cap.
17
-
18 18
 */
19 19
 
20 20
 $DB->query("
@@ -32,12 +32,12 @@ $DB->query("
32 32
 
33 33
 $UserIDs = $DB->collect('ID');
34 34
 if (count($UserIDs) > 0) {
35
-  foreach ($UserIDs as $UserID) {
36
-      $Cache->begin_transaction("user_info_heavy_$UserID");
37
-      $Cache->update_row(false, array('Invites' => '+1'));
38
-      $Cache->commit_transaction(0);
39
-  }
40
-  $DB->query('
35
+    foreach ($UserIDs as $UserID) {
36
+        $Cache->begin_transaction("user_info_heavy_$UserID");
37
+        $Cache->update_row(false, array('Invites' => '+1'));
38
+        $Cache->commit_transaction(0);
39
+    }
40
+    $DB->query('
41 41
     UPDATE users_main
42 42
     SET Invites = Invites + 1
43 43
     WHERE ID IN ('.implode(',', $UserIDs).')');
@@ -48,7 +48,7 @@ $BonusReqs = array(
48 48
   array(2.0, 10 * 1024 * 1024 * 1024),
49 49
   array(3.0, 20 * 1024 * 1024 * 1024));
50 50
 
51
-// Since MySQL doesn't like subselecting from the target table during an update, we must create a temporary table.
51
+// Since MySQL doesn't like subselecting from the target table during an update, we must create a temporary table
52 52
 
53 53
 $DB->query("
54 54
   CREATE TEMPORARY TABLE temp_sections_schedule_index
@@ -75,12 +75,12 @@ $DB->query("
75 75
 
76 76
 $UserIDs = $DB->collect('ID');
77 77
 if (count($UserIDs) > 0) {
78
-  foreach ($UserIDs as $UserID) {
79
-      $Cache->begin_transaction("user_info_heavy_$UserID");
80
-      $Cache->update_row(false, array('Invites' => '+1'));
81
-      $Cache->commit_transaction(0);
82
-  }
83
-  $DB->query('
78
+    foreach ($UserIDs as $UserID) {
79
+        $Cache->begin_transaction("user_info_heavy_$UserID");
80
+        $Cache->update_row(false, array('Invites' => '+1'));
81
+        $Cache->commit_transaction(0);
82
+    }
83
+    $DB->query('
84 84
     UPDATE users_main
85 85
     SET Invites = Invites + 1
86 86
     WHERE ID IN ('.implode(',', $UserIDs).')');
@@ -103,12 +103,12 @@ $DB->query("
103 103
 
104 104
 $UserIDs = $DB->collect('ID');
105 105
 if (count($UserIDs) > 0) {
106
-  foreach ($UserIDs as $UserID) {
107
-      $Cache->begin_transaction("user_info_heavy_$UserID");
108
-      $Cache->update_row(false, array('Invites' => '+1'));
109
-      $Cache->commit_transaction(0);
110
-  }
111
-  $DB->query('
106
+    foreach ($UserIDs as $UserID) {
107
+        $Cache->begin_transaction("user_info_heavy_$UserID");
108
+        $Cache->update_row(false, array('Invites' => '+1'));
109
+        $Cache->commit_transaction(0);
110
+    }
111
+    $DB->query('
112 112
     UPDATE users_main
113 113
     SET Invites = Invites + 1
114 114
     WHERE ID IN ('.implode(',', $UserIDs).')');
@@ -128,14 +128,13 @@ $DB->query("
128 128
 
129 129
 $UserIDs = $DB->collect('ID');
130 130
 if (count($UserIDs) > 0) {
131
-  foreach ($UserIDs as $UserID) {
132
-      $Cache->begin_transaction("user_info_heavy_$UserID");
133
-      $Cache->update_row(false, array('Invites' => '+1'));
134
-      $Cache->commit_transaction(0);
135
-  }
136
-  $DB->query('
131
+    foreach ($UserIDs as $UserID) {
132
+        $Cache->begin_transaction("user_info_heavy_$UserID");
133
+        $Cache->update_row(false, array('Invites' => '+1'));
134
+        $Cache->commit_transaction(0);
135
+    }
136
+    $DB->query('
137 137
     UPDATE users_main
138 138
     SET Invites = Invites + 1
139 139
     WHERE ID IN ('.implode(',', $UserIDs).')');
140 140
 }
141
-?>

+ 2
- 2
sections/schedule/daily/class_demotions.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Demote users --------------------------------------------//
3 4
 
4 5
 // Disabled in favor of store-based promotions
@@ -52,4 +53,3 @@ while (list($UserID) = $DB->next_record()) {*/
52 53
 }
53 54
 echo "demoted 4\n";
54 55
 */
55
-?>

+ 3
- 0
sections/schedule/daily/delete_dead_torrents.php View File

@@ -1,4 +1,7 @@
1 1
 <?php
2
+
3
+# todo: Make this 4 months
4
+
2 5
 //------------- Delete dead torrents ------------------------------------//
3 6
 
4 7
 /*

+ 13
- 13
sections/schedule/daily/disable_inactive_users.php View File

@@ -1,9 +1,10 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Disable inactive user accounts --------------------------//
3 4
 
4 5
 if (apcu_exists('DBKEY')) {
5
-  // Send email
6
-  $DB->query("
6
+    // Send email
7
+    $DB->query("
7 8
     SELECT um.Username, um.Email
8 9
     FROM users_info AS ui
9 10
       JOIN users_main AS um ON um.ID = ui.UserID
@@ -16,13 +17,13 @@ if (apcu_exists('DBKEY')) {
16 17
       AND um.Enabled != '2'
17 18
       AND ul.UserID IS NULL
18 19
     GROUP BY um.ID");
19
-  while (list($Username, $Email) = $DB->next_record()) {
20
-    $Email = Crypto::decrypt($Email);
21
-    $Body = "Hi $Username,\n\nIt has been almost 4 months since you used your account at ".site_url().". This is an automated email to inform you that your account will be disabled in 10 days if you do not sign in.";
22
-    Misc::send_email($Email, 'Your '.SITE_NAME.' account is about to be disabled', $Body);
23
-  }
20
+    while (list($Username, $Email) = $DB->next_record()) {
21
+        $Email = Crypto::decrypt($Email);
22
+        $Body = "Hi $Username,\n\nIt has been almost 4 months since you used your account at ".site_url().". This is an automated email to inform you that your account will be disabled in 10 days if you do not sign in.";
23
+        Misc::send_email($Email, 'Your '.SITE_NAME.' account is about to be disabled', $Body);
24
+    }
24 25
 
25
-  $DB->query("
26
+    $DB->query("
26 27
     SELECT um.ID
27 28
     FROM users_info AS ui
28 29
       JOIN users_main AS um ON um.ID = ui.UserID
@@ -34,8 +35,7 @@ if (apcu_exists('DBKEY')) {
34 35
       AND um.Enabled != '2'
35 36
       AND ul.UserID IS NULL
36 37
     GROUP BY um.ID");
37
-  if ($DB->has_results()) {
38
-    Tools::disable_users($DB->collect('ID'), 'Disabled for inactivity.', 3);
39
-  }
38
+    if ($DB->has_results()) {
39
+        Tools::disable_users($DB->collect('ID'), 'Disabled for inactivity.', 3);
40
+    }
40 41
 }
41
-?>

+ 6
- 6
sections/schedule/daily/disable_unconfirmed_users.php View File

@@ -1,7 +1,8 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Disable unconfirmed users ------------------------------//
3 4
 
4
-// get a list of user IDs for clearing cache keys
5
+// Get a list of user IDs for clearing cache keys
5 6
 $DB->query("
6 7
   SELECT UserID
7 8
   FROM users_info AS ui
@@ -11,7 +12,7 @@ $DB->query("
11 12
     AND um.Enabled != '2'");
12 13
 $UserIDs = $DB->collect('UserID');
13 14
 
14
-// disable the users
15
+// Disable the users
15 16
 $DB->query("
16 17
   UPDATE users_info AS ui
17 18
     JOIN users_main AS um ON um.ID = ui.UserID
@@ -24,10 +25,9 @@ $DB->query("
24 25
     AND um.Enabled != '2'");
25 26
 $Cache->decrement('stats_user_count', $DB->affected_rows());
26 27
 
27
-// clear the appropriate cache keys
28
+// Clear the appropriate cache keys
28 29
 foreach ($UserIDs as $UserID) {
29
-  $Cache->delete_value("user_info_$UserID");
30
+    $Cache->delete_value("user_info_$UserID");
30 31
 }
31 32
 
32 33
 echo "disabled unconfirmed\n";
33
-?>

+ 2
- 2
sections/schedule/daily/donations.php View File

@@ -1,3 +1,3 @@
1
-<?
1
+<?php
2
+
2 3
 Donations::schedule();
3
-?>

+ 5
- 1
sections/schedule/daily/ratio_reqs.php View File

@@ -1,4 +1,8 @@
1 1
 <?php
2
+
3
+# todo: Set the HnR time long (4 months) anddo something to incentivize seeding,
4
+# e.g., you don't start getting BP until the HnR time passes
5
+
2 6
 //------------------- Ratio requirements -----------------------//
3 7
 
4 8
 // Clear old seed time history
@@ -30,7 +34,7 @@ $DB->query("
30 34
   SET Weight = NumTorrents * Time");
31 35
 
32 36
 // Calculate average time spent seeding each of the currently active torrents.
33
-// This rounds the results to the nearest integer because SeedingAvg is an int column.
37
+// This rounds the results to the nearest integer because SeedingAvg is an int column
34 38
 $DB->query("TRUNCATE TABLE users_torrent_history_temp");
35 39
 $DB->query("
36 40
   INSERT INTO users_torrent_history_temp

+ 34
- 33
sections/schedule/daily/ratio_watch.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //----------------------- Manage Ratio Watch ----------------------//
3 4
 
4 5
 $OffRatioWatch = [];
@@ -17,7 +18,7 @@ $UserQuery = $DB->query("
17 18
       AND m.Enabled = '1'");
18 19
 $OffRatioWatch = $DB->collect('ID');
19 20
 if (count($OffRatioWatch) > 0) {
20
-  $DB->query("
21
+    $DB->query("
21 22
     UPDATE users_info AS ui
22 23
       JOIN users_main AS um ON um.ID = ui.UserID
23 24
     SET ui.RatioWatchEnds = NULL,
@@ -28,16 +29,16 @@ if (count($OffRatioWatch) > 0) {
28 29
 }
29 30
 
30 31
 foreach ($OffRatioWatch as $UserID) {
31
-  $Cache->begin_transaction("user_info_heavy_$UserID");
32
-  $Cache->update_row(false, array('RatioWatchEnds' => NULL, 'RatioWatchDownload' => '0', 'CanLeech' => 1));
33
-  $Cache->commit_transaction(0);
34
-  Misc::send_pm($UserID, 0, 'You have been taken off Ratio Watch', "Congratulations! Feel free to begin downloading again.\n To ensure that you do not get put on ratio watch again, please read the rules located [url=".site_url()."rules.php?p=ratio]here[/url].\n");
35
-  echo "Ratio watch off: $UserID\n";
32
+    $Cache->begin_transaction("user_info_heavy_$UserID");
33
+    $Cache->update_row(false, array('RatioWatchEnds' => null, 'RatioWatchDownload' => '0', 'CanLeech' => 1));
34
+    $Cache->commit_transaction(0);
35
+    Misc::send_pm($UserID, 0, 'You have been taken off Ratio Watch', "Congratulations! Feel free to begin downloading again.\n To ensure that you do not get put on ratio watch again, please read the rules located [url=".site_url()."rules.php?p=ratio]here[/url].\n");
36
+    echo "Ratio watch off: $UserID\n";
36 37
 }
37 38
 $DB->set_query_id($UserQuery);
38 39
 $Passkeys = $DB->collect('torrent_pass');
39 40
 foreach ($Passkeys as $Passkey) {
40
-  Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1'));
41
+    Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1'));
41 42
 }
42 43
 
43 44
 // Take users off ratio watch
@@ -50,7 +51,7 @@ $UserQuery = $DB->query("
50 51
         AND m.Enabled = '1'");
51 52
 $OffRatioWatch = $DB->collect('ID');
52 53
 if (count($OffRatioWatch) > 0) {
53
-  $DB->query("
54
+    $DB->query("
54 55
     UPDATE users_info AS ui
55 56
       JOIN users_main AS um ON um.ID = ui.UserID
56 57
     SET ui.RatioWatchEnds = NULL,
@@ -60,16 +61,16 @@ if (count($OffRatioWatch) > 0) {
60 61
 }
61 62
 
62 63
 foreach ($OffRatioWatch as $UserID) {
63
-  $Cache->begin_transaction("user_info_heavy_$UserID");
64
-  $Cache->update_row(false, array('RatioWatchEnds' => NULL, 'RatioWatchDownload' => '0', 'CanLeech' => 1));
65
-  $Cache->commit_transaction(0);
66
-  Misc::send_pm($UserID, 0, "You have been taken off Ratio Watch", "Congratulations! Feel free to begin downloading again.\n To ensure that you do not get put on ratio watch again, please read the rules located [url=".site_url()."rules.php?p=ratio]here[/url].\n");
67
-  echo "Ratio watch off: $UserID\n";
64
+    $Cache->begin_transaction("user_info_heavy_$UserID");
65
+    $Cache->update_row(false, array('RatioWatchEnds' => null, 'RatioWatchDownload' => '0', 'CanLeech' => 1));
66
+    $Cache->commit_transaction(0);
67
+    Misc::send_pm($UserID, 0, "You have been taken off Ratio Watch", "Congratulations! Feel free to begin downloading again.\n To ensure that you do not get put on ratio watch again, please read the rules located [url=".site_url()."rules.php?p=ratio]here[/url].\n");
68
+    echo "Ratio watch off: $UserID\n";
68 69
 }
69 70
 $DB->set_query_id($UserQuery);
70 71
 $Passkeys = $DB->collect('torrent_pass');
71 72
 foreach ($Passkeys as $Passkey) {
72
-  Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1'));
73
+    Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '1'));
73 74
 }
74 75
 
75 76
 // Put user on ratio watch if he doesn't meet the standards
@@ -86,12 +87,13 @@ $OnRatioWatch = $DB->collect('ID');
86 87
 
87 88
 $WatchList = [];
88 89
 foreach ($OnRatioWatch as $UserID) {
89
-  if (!Permissions::get_permissions_for_user($UserID)['site_ratio_watch_immunity'])
90
-    $WatchList[] = $UserID;
90
+    if (!Permissions::get_permissions_for_user($UserID)['site_ratio_watch_immunity']) {
91
+        $WatchList[] = $UserID;
92
+    }
91 93
 }
92 94
 
93 95
 if (!empty($WatchList)) {
94
-  $DB->query("
96
+    $DB->query("
95 97
     UPDATE users_info AS i
96 98
       JOIN users_main AS m ON m.ID = i.UserID
97 99
     SET i.RatioWatchEnds = '".time_plus(60 * 60 * 24 * 14)."',
@@ -101,15 +103,15 @@ if (!empty($WatchList)) {
101 103
 }
102 104
 
103 105
 foreach ($WatchList as $UserID) {
104
-  $Cache->begin_transaction("user_info_heavy_$UserID");
105
-  $Cache->update_row(false, array('RatioWatchEnds' => time_plus(60 * 60 * 24 * 14), 'RatioWatchDownload' => 0));
106
-  $Cache->commit_transaction(0);
107
-  Misc::send_pm($UserID, 0, 'You have been put on Ratio Watch', "This happens when your ratio falls below the requirements we have outlined in the rules located [url=".site_url()."rules.php?p=ratio]here[/url].\n For information about ratio watch, click the link above.");
108
-  echo "Ratio watch on: $UserID\n";
106
+    $Cache->begin_transaction("user_info_heavy_$UserID");
107
+    $Cache->update_row(false, array('RatioWatchEnds' => time_plus(60 * 60 * 24 * 14), 'RatioWatchDownload' => 0));
108
+    $Cache->commit_transaction(0);
109
+    Misc::send_pm($UserID, 0, 'You have been put on Ratio Watch', "This happens when your ratio falls below the requirements we have outlined in the rules located [url=".site_url()."rules.php?p=ratio]here[/url].\n For information about ratio watch, click the link above.");
110
+    echo "Ratio watch on: $UserID\n";
109 111
 }
110 112
 
111 113
 
112
-//------------- Disable downloading ability of users on ratio watch
114
+// Disable downloading ability of users on ratio watch
113 115
 $UserQuery = $DB->query("
114 116
     SELECT ID, torrent_pass
115 117
     FROM users_info AS i
@@ -121,7 +123,7 @@ $UserQuery = $DB->query("
121 123
 
122 124
 $UserIDs = $DB->collect('ID');
123 125
 if (count($UserIDs) > 0) {
124
-  $DB->query("
126
+    $DB->query("
125 127
     UPDATE users_info AS i
126 128
       JOIN users_main AS m ON m.ID = i.UserID
127 129
     SET m.can_leech = '0',
@@ -129,22 +131,21 @@ if (count($UserIDs) > 0) {
129 131
     WHERE m.ID IN(".implode(',', $UserIDs).')');
130 132
 
131 133
 
132
-  $DB->query("
134
+    $DB->query("
133 135
     DELETE FROM users_torrent_history
134 136
     WHERE UserID IN (".implode(',', $UserIDs).')');
135 137
 }
136 138
 
137 139
 foreach ($UserIDs as $UserID) {
138
-  $Cache->begin_transaction("user_info_heavy_$UserID");
139
-  $Cache->update_row(false, array('RatioWatchDownload' => 0, 'CanLeech' => 0));
140
-  $Cache->commit_transaction(0);
141
-  Misc::send_pm($UserID, 0, 'Your downloading privileges have been disabled', "As you did not raise your ratio in time, your downloading privileges have been revoked. You will not be able to download any torrents until your ratio is above your new required ratio.");
142
-  echo "Ratio watch disabled: $UserID\n";
140
+    $Cache->begin_transaction("user_info_heavy_$UserID");
141
+    $Cache->update_row(false, array('RatioWatchDownload' => 0, 'CanLeech' => 0));
142
+    $Cache->commit_transaction(0);
143
+    Misc::send_pm($UserID, 0, 'Your downloading privileges have been disabled', "As you did not raise your ratio in time, your downloading privileges have been revoked. You will not be able to download any torrents until your ratio is above your new required ratio.");
144
+    echo "Ratio watch disabled: $UserID\n";
143 145
 }
144 146
 
145 147
 $DB->set_query_id($UserQuery);
146 148
 $Passkeys = $DB->collect('torrent_pass');
147 149
 foreach ($Passkeys as $Passkey) {
148
-  Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '0'));
150
+    Tracker::update_tracker('update_user', array('passkey' => $Passkey, 'can_leech' => '0'));
149 151
 }
150
-?>

+ 2
- 2
sections/schedule/daily/resolve_staff_pms.php View File

@@ -1,8 +1,8 @@
1
-<?
1
+<?php
2
+
2 3
 $DB->query("
3 4
   UPDATE staff_pm_conversations
4 5
   SET Status = 'Resolved', ResolverID = '0'
5 6
   WHERE Date < NOW() - INTERVAL 1 MONTH
6 7
     AND Status = 'Open'
7 8
     AND AssignedToUser IS NULL");
8
-?>

+ 33
- 32
sections/schedule/daily/top10_daily.php View File

@@ -1,5 +1,7 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Daily Top 10 History -------------//
4
+
3 5
 $DB->query("
4 6
   INSERT INTO top10_history (Date, Type)
5 7
   VALUES ('$sqltime', 'Daily')");
@@ -7,7 +9,7 @@ $HistoryID = $DB->inserted_id();
7 9
 
8 10
 $Top10 = $Cache->get_value('top10tor_day_10');
9 11
 if ($Top10 === false) {
10
-  $DB->query("
12
+    $DB->query("
11 13
     SELECT
12 14
       t.ID,
13 15
       g.ID,
@@ -28,53 +30,52 @@ if ($Top10 === false) {
28 30
     ORDER BY (t.Seeders + t.Leechers) DESC
29 31
     LIMIT 10;");
30 32
 
31
-  $Top10 = $DB->to_array();
33
+    $Top10 = $DB->to_array();
32 34
 }
33 35
 
34 36
 $i = 1;
35 37
 foreach ($Top10 as $Torrent) {
36
-  list($TorrentID, $GroupID, $GroupName, $GroupCategoryID,
38
+    list($TorrentID, $GroupID, $GroupName, $GroupCategoryID,
37 39
     $WikiImage, $TorrentTags, $Media, $Year,
38 40
     $Snatched, $Seeders, $Leechers, $Data) = $Torrent;
39 41
 
40
-  $DisplayName = '';
42
+    $DisplayName = '';
41 43
 
42
-  $Artists = Artists::get_artist($GroupID);
44
+    $Artists = Artists::get_artist($GroupID);
43 45
 
44
-  if (!empty($Artists)) {
45
-    $DisplayName = Artists::display_artists($Artists, false, true);
46
-  }
46
+    if (!empty($Artists)) {
47
+        $DisplayName = Artists::display_artists($Artists, false, true);
48
+    }
47 49
 
48
-  $DisplayName .= $GroupName;
50
+    $DisplayName .= $GroupName;
49 51
 
50
-  if ($GroupCategoryID == 1 && $GroupYear > 0) {
51
-    $DisplayName .= " [$GroupYear]";
52
-  }
52
+    if ($GroupCategoryID === 1 && $GroupYear > 0) {
53
+        $DisplayName .= " [$GroupYear]";
54
+    }
53 55
 
54
-  // append extra info to torrent title
55
-  $ExtraInfo = '';
56
-  $AddExtra = '';
57
-  if ($Media) {
58
-    $ExtraInfo .= $AddExtra.$Media;
59
-    $AddExtra = ' / ';
60
-  }
61
-  if ($Year > 0) {
62
-    $ExtraInfo .= $AddExtra.$Year;
63
-    $AddExtra = ' ';
64
-  }
65
-  if ($ExtraInfo != '') {
66
-    $ExtraInfo = "- [$ExtraInfo]";
67
-  }
56
+    // append extra info to torrent title
57
+    $ExtraInfo = '';
58
+    $AddExtra = '';
59
+    if ($Media) {
60
+        $ExtraInfo .= $AddExtra.$Media;
61
+        $AddExtra = ' / ';
62
+    }
63
+    if ($Year > 0) {
64
+        $ExtraInfo .= $AddExtra.$Year;
65
+        $AddExtra = ' ';
66
+    }
67
+    if ($ExtraInfo !== '') {
68
+        $ExtraInfo = "- [$ExtraInfo]";
69
+    }
68 70
 
69
-  $TitleString = "$DisplayName $ExtraInfo";
71
+    $TitleString = "$DisplayName $ExtraInfo";
70 72
 
71
-  $TagString = str_replace('|', ' ', $TorrentTags);
73
+    $TagString = str_replace('|', ' ', $TorrentTags);
72 74
 
73
-  $DB->query("
75
+    $DB->query("
74 76
     INSERT INTO top10_history_torrents
75 77
       (HistoryID, Rank, TorrentID, TitleString, TagString)
76 78
     VALUES
77 79
       ($HistoryID, $i, $TorrentID, '".db_string($TitleString)."', '".db_string($TagString)."')");
78
-  $i++;
80
+    $i++;
79 81
 }
80
-?>

+ 10
- 10
sections/schedule/every/expire_tokens.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Expire old FL Tokens and clear cache where needed ------//
3 4
 
4 5
 $DB->query("
@@ -7,23 +8,22 @@ $DB->query("
7 8
   WHERE Expired = FALSE
8 9
     AND Time < (NOW() - INTERVAL 4 DAY)");
9 10
 if ($DB->has_results()) {
10
-  while (list($UserID) = $DB->next_record()) {
11
-    $Cache->delete_value("users_tokens_$UserID");
12
-  }
11
+    while (list($UserID) = $DB->next_record()) {
12
+        $Cache->delete_value("users_tokens_$UserID");
13
+    }
13 14
 
14
-  $DB->query("
15
+    $DB->query("
15 16
     SELECT uf.UserID, HEX(t.info_hash)
16 17
     FROM users_freeleeches AS uf
17 18
       JOIN torrents AS t ON uf.TorrentID = t.ID
18 19
     WHERE uf.Expired = FALSE
19 20
       AND uf.Time < (NOW() - INTERVAL 4 DAY)");
20
-  while (list($UserID, $InfoHash) = $DB->next_record(MYSQLI_NUM, false)) {
21
-    Tracker::update_tracker('remove_token', ['info_hash' => substr('%'.chunk_split($InfoHash,2,'%'),0,-1), 'userid' => $UserID]);
22
-  }
23
-  $DB->query("
21
+    while (list($UserID, $InfoHash) = $DB->next_record(MYSQLI_NUM, false)) {
22
+        Tracker::update_tracker('remove_token', ['info_hash' => substr('%'.chunk_split($InfoHash, 2, '%'), 0, -1), 'userid' => $UserID]);
23
+    }
24
+    $DB->query("
24 25
     UPDATE users_freeleeches
25 26
     SET Expired = TRUE
26 27
     WHERE Time < (NOW() - INTERVAL 4 DAY)
27 28
       AND Expired = FALSE");
28 29
 }
29
-?>

+ 4
- 4
sections/schedule/every/freeleech.php View File

@@ -1,9 +1,10 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Freeleech -----------------------------------------------//
3 4
 
4
-//We use this to control 6 hour freeleeches. They're actually 7 hours, but don't tell anyone.
5
-/*
5
+// We use this to control 6 hour freeleeches. They're actually 7 hours, but don't tell anyone
6 6
 
7
+/*
7 8
 $TimeMinus = time_minus(3600 * 7);
8 9
 
9 10
 $DB->query("
@@ -25,4 +26,3 @@ $DB->query("
25 26
     AND Time < '$TimeMinus'");
26 27
 
27 28
 */
28
-?>

+ 10
- 10
sections/schedule/every/shop_freeleech.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- BP Shop Freeleeches -------------------------------------//
3 4
 
4 5
 $date = date('Y-m-d H:i:s');
@@ -12,16 +13,16 @@ $DB->query("
12 13
 
13 14
 $TorrentIDs = [];
14 15
 if ($DB->has_results()) {
15
-  while (list($GroupID, $TorrentID) = $DB->next_record()) {
16
-    $TorrentIDs[] = $TorrentID;
17
-    $Cache->delete_value("torrents_details_$GroupID");
18
-    $Cache->delete_value("torrent_group_$GroupID");
19
-  }
20
-  Torrents::freeleech_torrents($TorrentIDs, 0, 0);
21
-  $DB->query("
16
+    while (list($GroupID, $TorrentID) = $DB->next_record()) {
17
+        $TorrentIDs[] = $TorrentID;
18
+        $Cache->delete_value("torrents_details_$GroupID");
19
+        $Cache->delete_value("torrent_group_$GroupID");
20
+    }
21
+    Torrents::freeleech_torrents($TorrentIDs, 0, 0);
22
+    $DB->query("
22 23
     DELETE FROM shop_freeleeches
23 24
     WHERE ExpiryTime < '".$date."'");
24
-  $Cache->delete_value('shop_freeleech_list');
25
+    $Cache->delete_value('shop_freeleech_list');
25 26
 }
26 27
 
27 28
 // Also clear misc table for expired freeleech
@@ -29,4 +30,3 @@ $DB->query("
29 30
   DELETE FROM misc
30 31
   WHERE Second = 'freeleech'
31 32
     AND CAST(First AS UNSIGNED INTEGER) < " . date('U'));
32
-?>

+ 12
- 11
sections/schedule/every/update_recently_uploaded_torrents_swarms.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 // peerupdate.php is apparently shit so this is a crappy bandaid to fix the problem of
3 4
 // all the cached "0 seeds" on the first search page from peerupdate missing the changes.
4 5
 // It used to be in a sandbox that I just ran whenever I saw something wrong with
@@ -13,22 +14,22 @@ $Results = $FrontPageQ->query()->to_array('id');
13 14
 $IDs = [];
14 15
 $Seeds = [];
15 16
 foreach ($Results as $i) {
16
-  $GroupCache = $Cache->get_value('torrent_group_'.$i['groupid']);
17
-  if (!$GroupCache) continue;
18
-  $IDs = array_merge($IDs, array_column($GroupCache['d']['Torrents'], 'ID'));
19
-  $Seeds = array_merge($Seeds, array_column($GroupCache['d']['Torrents'], 'Seeders'));
17
+    $GroupCache = $Cache->get_value('torrent_group_'.$i['groupid']);
18
+    if (!$GroupCache) {
19
+        continue;
20
+    }
21
+    $IDs = array_merge($IDs, array_column($GroupCache['d']['Torrents'], 'ID'));
22
+    $Seeds = array_merge($Seeds, array_column($GroupCache['d']['Torrents'], 'Seeders'));
20 23
 }
21 24
 $QueryParts = [];
22 25
 for ($i = 0; $i < sizeof($IDs); $i++) {
23
-  $QueryParts[] = '(ID='.$IDs[$i].' AND Seeders!='.$Seeds[$i].')';
26
+    $QueryParts[] = '(ID='.$IDs[$i].' AND Seeders!='.$Seeds[$i].')';
24 27
 }
25 28
 $query = 'SELECT GroupID FROM torrents WHERE '.implode(' OR ', $QueryParts);
26 29
 
27 30
 $DB->query($query);
28 31
 if ($DB->has_results()) {
29
-  foreach($DB->collect('GroupID') as $GID) {
30
-    $Cache->delete_value('torrent_group_'.$GID);
31
-  }
32
+    foreach ($DB->collect('GroupID') as $GID) {
33
+        $Cache->delete_value('torrent_group_'.$GID);
34
+    }
32 35
 }
33
-
34
-?>

+ 30
- 30
sections/schedule/hourly/badges.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //----------- Award Automated Badges -----------------------//
3 4
 
4 5
 $GiB = 1024*1024*1024;
@@ -7,63 +8,62 @@ $ModifiedIDs = [];
7 8
 
8 9
 // Download Badges
9 10
 foreach (AUTOMATED_BADGE_IDS['DL'] as $DL=>$Badge) {
10
-  $DB->query("
11
+    $DB->query("
11 12
     SELECT ID
12 13
     FROM users_main
13 14
     WHERE Downloaded >= ".($DL*$GiB)."
14 15
       AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = $Badge)");
15 16
 
16
-  if ($DB->has_results()) {
17
-    $IDs = $DB->collect('ID');
18
-    foreach ($IDs as $ID) {
19
-      if (Badges::award_badge($ID, $Badge)) {
20
-        Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading ".$DL."GiB of data.\n\nIt can be enabled from your user settings.");
21
-      }
17
+    if ($DB->has_results()) {
18
+        $IDs = $DB->collect('ID');
19
+        foreach ($IDs as $ID) {
20
+            if (Badges::award_badge($ID, $Badge)) {
21
+                Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for downloading ".$DL."GiB of data.\n\nIt can be enabled from your user settings.");
22
+            }
23
+        }
24
+        $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
22 25
     }
23
-    $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
24
-  }
25 26
 }
26 27
 
27 28
 // Upload Badges
28 29
 foreach (AUTOMATED_BADGE_IDS['UL'] as $UL=>$Badge) {
29
-  $DB->query("
30
+    $DB->query("
30 31
     SELECT ID
31 32
     FROM users_main
32 33
     WHERE Uploaded >= ".($UL*$GiB)."
33 34
       AND ID NOT IN (SELECT UserID FROM users_badges WHERE BadgeID = $Badge)");
34 35
 
35
-  if ($DB->has_results()) {
36
-    $IDs = $DB->collect('ID');
37
-    foreach ($IDs as $ID) {
38
-      if (Badges::award_badge($ID, $Badge)) {
39
-        Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for uploading ".$UL."GiB of data.\n\nIt can be enabled from your user settings.");
40
-      }
36
+    if ($DB->has_results()) {
37
+        $IDs = $DB->collect('ID');
38
+        foreach ($IDs as $ID) {
39
+            if (Badges::award_badge($ID, $Badge)) {
40
+                Misc::send_pm($ID, 0, 'You have received a badge!', "You have received a badge for uploading ".$UL."GiB of data.\n\nIt can be enabled from your user settings.");
41
+            }
42
+        }
43
+        $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
41 44
     }
42
-    $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
43
-  }
44 45
 }
45 46
 
46 47
 // Tag Badges
47 48
 foreach (AUTOMATED_BADGE_IDS['Tags'] as $Tag=>$Badge) {
48
-  $DB->query("
49
+    $DB->query("
49 50
     SELECT DISTINCT x.uid
50 51
     FROM xbt_snatched AS x
51 52
     JOIN torrents AS t ON t.ID = x.fid
52 53
     JOIN torrents_group AS tg ON t.GroupID = tg.ID
53 54
     WHERE tg.TagList LIKE '%" . $Tag . "%'");
54 55
 
55
-  if ($DB->has_results()) {
56
-    $IDs = $DB->collect('uid');
57
-    foreach ($IDs as $ID) {
58
-      if (Badges::award_badge($ID, $Badge)) {
59
-        Misc::send_pm($ID, 0, 'You have recieved a badge!', "You have received a badge for mysterious reasons.\n\nIt can be enabled from your user settings.");
60
-      }
56
+    if ($DB->has_results()) {
57
+        $IDs = $DB->collect('uid');
58
+        foreach ($IDs as $ID) {
59
+            if (Badges::award_badge($ID, $Badge)) {
60
+                Misc::send_pm($ID, 0, 'You have recieved a badge!', "You have received a badge for mysterious reasons.\n\nIt can be enabled from your user settings.");
61
+            }
62
+        }
63
+        $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
61 64
     }
62
-    $ModifiedIDs = array_merge($ModifiedIDs, $IDs);
63
-  }
64 65
 }
65 66
 
66 67
 foreach (array_unique($ModifiedIDs) as $ID) {
67
-  $Cache->delete_value('user_badges_'.$ID);
68
+    $Cache->delete_value('user_badges_'.$ID);
68 69
 }
69
-?>

+ 14
- 12
sections/schedule/hourly/bonus_points.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------------------ Update Bonus Points -------------------------//
3 4
 
4 5
 $getUsers = $DB->query("
@@ -21,21 +22,22 @@ $getUsers = $DB->query("
21 22
     AND x.Remaining = 0
22 23
   GROUP BY um.ID");
23 24
 if ($DB->has_results()) {
24
-  $QueryPart = '';
25
-  while (list($UserID, $BonusPoints, $NumTorr, $TSize, $TTime, $TSeeds) = $DB->next_record()) {
26
-    $Points = (0.5 + (0.55*($NumTorr * (sqrt(($TSize/$NumTorr)/1073741824) * pow(1.5,($TTime/$NumTorr)/(24*365))))) / (max(1, sqrt(($TSeeds/$NumTorr)+4)/3)))**0.95;
27
-    $Points = intval(max(min($Points, ($Points * 2) - ($BonusPoints/1440)), 0));
28
-    if ($Points > 100000) $Points = 0;
29
-    if ($Points > 0) {
30
-      $QueryPart .= "WHEN $UserID THEN BonusPoints+$Points ";
31
-      $Cache->delete_value('user_info_heavy_'.$UserID);
25
+    $QueryPart = '';
26
+    while (list($UserID, $BonusPoints, $NumTorr, $TSize, $TTime, $TSeeds) = $DB->next_record()) {
27
+        $Points = (0.5 + (0.55*($NumTorr * (sqrt(($TSize/$NumTorr)/1073741824) * pow(1.5, ($TTime/$NumTorr)/(24*365))))) / (max(1, sqrt(($TSeeds/$NumTorr)+4)/3)))**0.95;
28
+        $Points = intval(max(min($Points, ($Points * 2) - ($BonusPoints/1440)), 0));
29
+        if ($Points > 100000) {
30
+            $Points = 0;
31
+        }
32
+        if ($Points > 0) {
33
+            $QueryPart .= "WHEN $UserID THEN BonusPoints+$Points ";
34
+            $Cache->delete_value('user_info_heavy_'.$UserID);
35
+        }
32 36
     }
33
-  }
34 37
 
35
-  $DB->query("
38
+    $DB->query("
36 39
     UPDATE users_main
37 40
     SET BonusPoints = CASE ID "
38 41
     .$QueryPart.
39 42
     "ELSE BonusPoints END");
40 43
 }
41
-?>

+ 6
- 5
sections/schedule/hourly/class_promotion.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Promote users -------------------------------------------//
3 4
 
4 5
 // Disabled in favor of store-based promotions
@@ -51,7 +52,8 @@ $Criteria[] = array(
51 52
         FROM torrents
52 53
         WHERE UserID = users_main.ID
53 54
       ) >= 300');
54
-/*$Criteria[] = array(
55
+
56
+$Criteria[] = array(
55 57
   'From' => POWER_TM,
56 58
   'To' => ELITE_TM,
57 59
   'MinUpload' => 2 * 1024 * 1024 * 1024 * 1024,
@@ -111,7 +113,7 @@ $Criteria[] = array(
111 113
       SET PermissionID = ".$L['To']."
112 114
       WHERE ID IN(".implode(',', $UserIDs).')');
113 115
     foreach ($UserIDs as $UserID) {
114
-      /*$Cache->begin_transaction("user_info_$UserID");
116
+      $Cache->begin_transaction("user_info_$UserID");
115 117
       $Cache->update_row(false, array('PermissionID' => $L['To']));
116 118
       $Cache->commit_transaction(0);
117 119
       $Cache->delete_value("user_info_$UserID");
@@ -155,7 +157,7 @@ $Criteria[] = array(
155 157
       SET PermissionID = ".$L['From']."
156 158
       WHERE ID IN(".implode(',', $UserIDs).')');
157 159
     foreach ($UserIDs as $UserID) {
158
-      /*$Cache->begin_transaction("user_info_$UserID");
160
+      $Cache->begin_transaction("user_info_$UserID");
159 161
       $Cache->update_row(false, array('PermissionID' => $L['From']));
160 162
       $Cache->commit_transaction(0);
161 163
       $Cache->delete_value("user_info_$UserID");
@@ -171,4 +173,3 @@ $Criteria[] = array(
171 173
   }
172 174
  }
173 175
 */
174
-?>

+ 9
- 9
sections/schedule/hourly/disable_leech.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 // If a user has downloaded more than 10 GiBs while on ratio watch, disable leeching privileges, and send the user a message
3 4
 
4 5
 $DB->query("
@@ -12,18 +13,17 @@ $DB->query("
12 13
 $Users = $DB->to_pair('torrent_pass', 'ID');
13 14
 
14 15
 if (count($Users) > 0) {
15
-  $Subject = 'Leeching Disabled';
16
-  $Message = 'You have downloaded more than 10 GB while on Ratio Watch. Your leeching privileges have been disabled. Please reread the rules and refer to this guide on how to improve your ratio ' . site_url() . 'wiki.php?action=article&amp;id=110';
17
-  foreach ($Users as $TorrentPass => $UserID) {
18
-    Misc::send_pm($UserID, 0, $Subject, $Message);
19
-    Tracker::update_tracker('update_user', array('passkey' => $TorrentPass, 'can_leech' => '0'));
20
-  }
16
+    $Subject = 'Leeching Disabled';
17
+    $Message = 'You have downloaded more than 10 GB while on Ratio Watch. Your leeching privileges have been disabled. Please reread the rules and refer to this guide on how to improve your ratio ' . site_url() . 'wiki.php?action=article&amp;id=110';
18
+    foreach ($Users as $TorrentPass => $UserID) {
19
+        Misc::send_pm($UserID, 0, $Subject, $Message);
20
+        Tracker::update_tracker('update_user', array('passkey' => $TorrentPass, 'can_leech' => '0'));
21
+    }
21 22
 
22
-  $DB->query("
23
+    $DB->query("
23 24
     UPDATE users_info AS i
24 25
       JOIN users_main AS m ON m.ID = i.UserID
25 26
     SET m.can_leech = '0',
26 27
       i.AdminComment = CONCAT('$sqltime - Leeching privileges disabled by ratio watch system for downloading more than 10 GBs on ratio watch. - required ratio: ', m.RequiredRatio, '\n\n', i.AdminComment)
27 28
     WHERE m.ID IN(" . implode(',', $Users) . ')');
28 29
 }
29
-?>

+ 11
- 11
sections/schedule/hourly/expire_invites.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Expire invites ------------------------------------------//
3 4
 
4 5
 $DB->query("
@@ -7,23 +8,22 @@ $DB->query("
7 8
   WHERE Expires < '$sqltime'");
8 9
 $Users = $DB->to_array();
9 10
 foreach ($Users as $UserID) {
10
-  list($UserID) = $UserID;
11
-  $DB->query("
11
+    list($UserID) = $UserID;
12
+    $DB->query("
12 13
     SELECT Invites, PermissionID
13 14
     FROM users_main
14 15
     WHERE ID = $UserID");
15
-  list($Invites, $PermID) = $DB->next_record();
16
-  if (($Invites < 2 && $Classes[$PermID]['Level'] <= $Classes[POWER]['Level']) || ($Invites < 4 && $PermID == ELITE)) {
17
-    $DB->query("
16
+    list($Invites, $PermID) = $DB->next_record();
17
+    if (($Invites < 2 && $Classes[$PermID]['Level'] <= $Classes[POWER]['Level']) || ($Invites < 4 && $PermID == ELITE)) {
18
+        $DB->query("
18 19
       UPDATE users_main
19 20
       SET Invites = Invites + 1
20 21
       WHERE ID = $UserID");
21
-    $Cache->begin_transaction("user_info_heavy_$UserID");
22
-    $Cache->update_row(false, array('Invites' => '+1'));
23
-    $Cache->commit_transaction(0);
24
-  }
22
+        $Cache->begin_transaction("user_info_heavy_$UserID");
23
+        $Cache->update_row(false, array('Invites' => '+1'));
24
+        $Cache->commit_transaction(0);
25
+    }
25 26
 }
26 27
 $DB->query("
27 28
   DELETE FROM invites
28 29
   WHERE Expires < '$sqltime'");
29
-?>

+ 5
- 5
sections/schedule/hourly/expire_warnings.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Remove expired warnings ---------------------------------//
3 4
 
4 5
 $DB->query("
@@ -6,13 +7,12 @@ $DB->query("
6 7
   FROM users_info
7 8
   WHERE Warned < '$sqltime'");
8 9
 while (list($UserID) = $DB->next_record()) {
9
-  $Cache->begin_transaction("user_info_$UserID");
10
-  $Cache->update_row(false, array('Warned' => NULL));
11
-  $Cache->commit_transaction(2592000);
10
+    $Cache->begin_transaction("user_info_$UserID");
11
+    $Cache->update_row(false, array('Warned' => null));
12
+    $Cache->commit_transaction(2592000);
12 13
 }
13 14
 
14 15
 $DB->query("
15 16
   UPDATE users_info
16 17
   SET Warned = NULL
17 18
   WHERE Warned < '$sqltime'");
18
-?>

+ 2
- 2
sections/schedule/hourly/hide_old_requests.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Hide old requests ---------------------------------------//
3 4
 
4 5
 $DB->query("
@@ -6,4 +7,3 @@ $DB->query("
6 7
   SET Visible = 0
7 8
   WHERE TimeFilled < (NOW() - INTERVAL 7 DAY)
8 9
     AND TimeFilled IS NOT NULL");
9
-?>

+ 2
- 2
sections/schedule/hourly/hit_n_runs.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Update Hit 'n Runs --------------------------------------//
3 4
 
4 5
 // This will never work until we start keeping track of upload/download stats
@@ -30,4 +31,3 @@ while(list($UserID, $HnR) = $DB->next_record()) {
30 31
     $DB->set_query_id($getUsers);
31 32
   }
32 33
 } */
33
-?>

+ 2
- 2
sections/schedule/hourly/record_seeding.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Record who's seeding how much, used for ratio watch
3 4
 
4 5
 $DB->query("TRUNCATE TABLE users_torrent_history_temp");
@@ -37,4 +38,3 @@ $DB->query("
37 38
   ON DUPLICATE KEY UPDATE
38 39
     Time = Time + UNIX_TIMESTAMP(NOW()) - LastTime,
39 40
     LastTime = UNIX_TIMESTAMP(NOW())");
40
-?>

+ 2
- 2
sections/schedule/hourly/remove_dead_peers.php View File

@@ -1,7 +1,7 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Remove dead peers ---------------------------------------//
3 4
 
4 5
 $DB->query("
5 6
   DELETE FROM xbt_files_users
6 7
   WHERE mtime < unix_timestamp(NOW() - INTERVAL 6 HOUR)");
7
-?>

+ 5
- 5
sections/schedule/hourly/remove_dead_sessions.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Remove dead sessions ---------------------------------------//
3 4
 
4 5
 $AgoMins = time_minus(60 * 30);
@@ -18,8 +19,7 @@ $DB->query("
18 19
 $DB->set_query_id($SessionQuery);
19 20
 
20 21
 while (list($UserID, $SessionID) = $DB->next_record()) {
21
-  $Cache->begin_transaction("users_sessions_$UserID");
22
-  $Cache->delete_row($SessionID);
23
-  $Cache->commit_transaction(0);
22
+    $Cache->begin_transaction("users_sessions_$UserID");
23
+    $Cache->delete_row($SessionID);
24
+    $Cache->commit_transaction(0);
24 25
 }
25
-?>

+ 2
- 2
sections/schedule/hourly/seed_times.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------- Update seed times ---------------------------------------//
3 4
 
4 5
 $DB->query("
@@ -6,4 +7,3 @@ $DB->query("
6 7
   INNER JOIN xbt_files_users AS xfu
7 8
     ON xs.uid = xfu.uid AND xs.fid = xfu.fid
8 9
   SET xs.seedtime = xs.seedtime + (xfu.active & ~xfu.completed)");
9
-?>

+ 4
- 4
sections/schedule/hourly/sphinx_min_max_matches.php View File

@@ -1,11 +1,11 @@
1
-<?
1
+<?php
2
+
2 3
 $SphQL = new SphinxqlQuery();
3 4
 $SphQL->where_match('_all', 'fake', false);
4
-$SphQL->select('id')->from('torrents, delta')->limit(0,0,10000);
5
+$SphQL->select('id')->from('torrents, delta')->limit(0, 0, 10000);
5 6
 $TTorrents = $SphQL->query()->get_meta('total_found');
6 7
 
7
-$SphQL->select('groupid')->group_by('groupid')->from('torrents, delta')->limit(0,0,10000);
8
+$SphQL->select('groupid')->group_by('groupid')->from('torrents, delta')->limit(0, 0, 10000);
8 9
 $TGroups = $SphQL->query()->get_meta('total_found');
9 10
 
10 11
 $Cache->cache_value('sphinx_min_max_matches', 2*($TTorrents-$TGroups));
11
-?>

+ 41
- 40
sections/schedule/index.php View File

@@ -1,6 +1,7 @@
1
-<?
1
+<?php
2
+
2 3
 //--------------Schedule page -------------------------------------------//
3
-// This page is run every 15 minutes by cron.
4
+// This page is run every 15 minutes by cron
4 5
 
5 6
 set_time_limit(50000);
6 7
 ob_end_flush();
@@ -10,31 +11,32 @@ $ScheduleDebug = false;
10 11
 
11 12
 $PCount = chop(shell_exec("/usr/bin/pgrep -cf schedule.php"));
12 13
 if ($PCount > 3) {  // 3 because the cron job starts two processes and pgrep finds itself
13
-  die("schedule.php is already running. Exiting ($PCount)\n");
14
+    die("schedule.php is already running. Exiting ($PCount)\n");
14 15
 }
15 16
 
16 17
 $AS = check_perms('admin_schedule');
17 18
 
18
-function run_all_in($Dir) {
19
-  $Tasks = array_diff(scandir(SERVER_ROOT.'/sections/schedule/'.$Dir, 1), ['.', '..']);
20
-  extract($GLOBALS);
21
-  foreach ($Tasks as $Task) {
22
-    $TimeStart = microtime(true);
23
-    include($Dir.'/'.$Task);
24
-    if ($ScheduleDebug) {
25
-      echo $Dir.'/'.$Task.': '.number_format(microtime(true)-$TimeStart,3).($AS?"<br>":"\n");
19
+function run_all_in($Dir)
20
+{
21
+    $Tasks = array_diff(scandir(SERVER_ROOT.'/sections/schedule/'.$Dir, 1), ['.', '..']);
22
+    extract($GLOBALS);
23
+    foreach ($Tasks as $Task) {
24
+        $TimeStart = microtime(true);
25
+        include($Dir.'/'.$Task);
26
+        if ($ScheduleDebug) {
27
+            echo $Dir.'/'.$Task.': '.number_format(microtime(true)-$TimeStart, 3).($AS?"<br>":"\n");
28
+        }
26 29
     }
27
-  }
28 30
 }
29 31
 
30
-if ((!isset($_REQUEST['key']) || $_REQUEST['key'] != SCHEDULE_KEY) && (!isset($argv[1]) || $argv[1] != SCHEDULE_KEY) && !$AS) {
31
-  error(403);
32
+if ((!isset($_REQUEST['key']) || $_REQUEST['key'] !== SCHEDULE_KEY) && (!isset($argv[1]) || $argv[1] !== SCHEDULE_KEY) && !$AS) {
33
+    error(403);
32 34
 }
33 35
 
34 36
 if ($AS) {
35
-  authorize();
36
-  View::show_header();
37
-  echo '<div class="box">';
37
+    authorize();
38
+    View::show_header();
39
+    echo '<div class="box">';
38 40
 }
39 41
 
40 42
 $ASBreak = $AS ? "<br>" : "\n";
@@ -57,50 +59,49 @@ echo $sqltime.$ASBreak;
57 59
 
58 60
 //-------------- Run every time ------------------------------------------//
59 61
 if (!(isset($_GET['notevery']) && $_GET['notevery'])) {
60
-  run_all_in('every');
61
-  echo "Ran every-time functions".$ASBreak;
62
+    run_all_in('every');
63
+    echo "Ran every-time functions".$ASBreak;
62 64
 }
63 65
 
64 66
 //-------------- Run every hour ------------------------------------------//
65
-if ($Hour != $NextHour || (isset($_GET['runhour']) && $_GET['runhour'])) {
66
-  run_all_in('hourly');
67
-  echo "Ran hourly functions".$ASBreak;
67
+if ($Hour !== $NextHour || (isset($_GET['runhour']) && $_GET['runhour'])) {
68
+    run_all_in('hourly');
69
+    echo "Ran hourly functions".$ASBreak;
68 70
 }
69 71
 
70 72
 //-------------- Run every day -------------------------------------------//
71
-if ($Day != $NextDay || (isset($_GET['runday']) && $_GET['runday'])) {
72
-  run_all_in('daily');
73
-  echo "Ran daily functions".$ASBreak;
73
+if ($Day !== $NextDay || (isset($_GET['runday']) && $_GET['runday'])) {
74
+    run_all_in('daily');
75
+    echo "Ran daily functions".$ASBreak;
74 76
 }
75 77
 
76 78
 //-------------- Run every week -------------------------------------------//
77
-if (($Day != $NextDay && date('w') == 0) || (isset($_GET['runweek']) && $_GET['runweek'])) {
78
-  run_all_in('weekly');
79
-  echo "Ran weekly functions".$ASBreak;
79
+if (($Day !== $NextDay && date('w') === 0) || (isset($_GET['runweek']) && $_GET['runweek'])) {
80
+    run_all_in('weekly');
81
+    echo "Ran weekly functions".$ASBreak;
80 82
 }
81 83
 
82 84
 //--------------- Run twice per month -------------------------------------//
83
-if ($BiWeek != $NextBiWeek || (isset($_GET['runbiweek']) && $_GET['runbiweek'])) {
84
-  run_all_in('biweekly');
85
-  echo "Ran bi-weekly functions".$ASBreak;
85
+if ($BiWeek !== $NextBiWeek || (isset($_GET['runbiweek']) && $_GET['runbiweek'])) {
86
+    run_all_in('biweekly');
87
+    echo "Ran bi-weekly functions".$ASBreak;
86 88
 }
87 89
 
88 90
 //---------------- Run every month -----------------------------------------//
89
-if (($BiWeek != $NextBiWeek && $BiWeek == 8) || (isset($_GET['runmonth']) && $_GET['runmonth'])) {
90
-  run_all_in('monthly');
91
-  echo "Ran monthly functions".$ASBreak;
91
+if (($BiWeek !== $NextBiWeek && $BiWeek === 8) || (isset($_GET['runmonth']) && $_GET['runmonth'])) {
92
+    run_all_in('monthly');
93
+    echo "Ran monthly functions".$ASBreak;
92 94
 }
93 95
 
94 96
 //---------------- Run on request ------------------------------------------//
95 97
 if (isset($_GET['runmanual']) && $_GET['runmanual']) {
96
-  run_all_in('manually');
97
-  echo "Ran manual functions".$ASBreak;
98
+    run_all_in('manually');
99
+    echo "Ran manual functions".$ASBreak;
98 100
 }
99 101
 
100 102
 if ($AS) {
101
-  echo '</div>';
102
-  View::show_footer();
103
+    echo '</div>';
104
+    View::show_footer();
103 105
 } else {
104
-  echo "-------------------------\n\n";
106
+    echo "-------------------------\n\n";
105 107
 }
106
-?>

+ 4
- 4
sections/schedule/manually/update_geodist.php View File

@@ -1,8 +1,9 @@
1
-<?
1
+<?php
2
+
2 3
 $IPs = [];
3 4
 $DB->query("SELECT IP FROM users_main WHERE Enabled = '1'");
4
-while(list($EncIP) = $DB->next_record()) {
5
-  $IPs[] = Crypto::decrypt($EncIP);
5
+while (list($EncIP) = $DB->next_record()) {
6
+    $IPs[] = Crypto::decrypt($EncIP);
6 7
 }
7 8
 $DB->query("CREATE TEMPORARY TABLE users_ips_decrypted (IP VARCHAR(45) NOT NULL)");
8 9
 $DB->query("INSERT INTO users_ips_decrypted (IP) VALUES('".implode("'),('", $IPs)."')");
@@ -17,4 +18,3 @@ $DB->query("
17 18
   ORDER BY Users DESC");
18 19
 $DB->query("DROP TABLE users_ips_decrypted");
19 20
 $Cache->delete_value('geodistribution');
20
-?>

+ 2
- 2
sections/schedule/monthly/update_top_snatchers.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 $DB->query('TRUNCATE TABLE top_snatchers;');
3 4
 $DB->query("
4 5
   INSERT INTO top_snatchers (UserID)
@@ -7,4 +8,3 @@ $DB->query("
7 8
   GROUP BY uid
8 9
   ORDER BY COUNT(uid) DESC
9 10
   LIMIT 100;");
10
-?>

+ 17
- 16
sections/schedule/weekly/deletion_warning.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 // Send warnings to uploaders of torrents that will be deleted this week
3 4
 $DB->query("
4 5
   SELECT
@@ -16,23 +17,23 @@ $DB->query("
16 17
 $TorrentIDs = $DB->to_array();
17 18
 $TorrentAlerts = [];
18 19
 foreach ($TorrentIDs as $TorrentID) {
19
-  list($ID, $GroupID, $Name, $UserID) = $TorrentID;
20
+    list($ID, $GroupID, $Name, $UserID) = $TorrentID;
20 21
 
21
-  if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) {
22
-    // don't notify exceptions
23
-    continue;
24
-  }
22
+    if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) {
23
+        // Don't notify exceptions
24
+        continue;
25
+    }
25 26
 
26
-  if (!array_key_exists($UserID, $TorrentAlerts))
27
-    $TorrentAlerts[$UserID] = array('Count' => 0, 'Msg' => '');
28
-  $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false);
29
-  if ($ArtistName) {
30
-    $Name = "$ArtistName - $Name";
31
-  }
32
-  $TorrentAlerts[$UserID]['Msg'] .= "\n[url=".site_url()."torrents.php?torrentid=$ID]".$Name."[/url]";
33
-  $TorrentAlerts[$UserID]['Count']++;
27
+    if (!array_key_exists($UserID, $TorrentAlerts)) {
28
+        $TorrentAlerts[$UserID] = array('Count' => 0, 'Msg' => '');
29
+    }
30
+    $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false);
31
+    if ($ArtistName) {
32
+        $Name = "$ArtistName - $Name";
33
+    }
34
+    $TorrentAlerts[$UserID]['Msg'] .= "\n[url=".site_url()."torrents.php?torrentid=$ID]".$Name."[/url]";
35
+    $TorrentAlerts[$UserID]['Count']++;
34 36
 }
35 37
 foreach ($TorrentAlerts as $UserID => $MessageInfo) {
36
-  Misc::send_pm($UserID, 0, 'Unseeded torrent notification', $MessageInfo['Count']." of your uploads will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=".site_url()."wiki.php?action=article&amp;id=663]here[/url].\n\nThe following torrent".($MessageInfo['Count'] > 1 ? 's' : '').' will be removed for inactivity:'.$MessageInfo['Msg']."\n\nIf you no longer wish to receive these notifications, please disable them in your profile settings.");
38
+    Misc::send_pm($UserID, 0, 'Unseeded torrent notification', $MessageInfo['Count']." of your uploads will be deleted for inactivity soon. Unseeded torrents are deleted after 4 weeks. If you still have the files, you can seed your uploads by ensuring the torrents are in your client and that they aren't stopped. You can view the time that a torrent has been unseeded by clicking on the torrent description line and looking for the \"Last active\" time. For more information, please go [url=".site_url()."wiki.php?action=article&amp;id=663]here[/url].\n\nThe following torrent".($MessageInfo['Count'] > 1 ? 's' : '').' will be removed for inactivity:'.$MessageInfo['Msg']."\n\nIf you no longer wish to receive these notifications, please disable them in your profile settings.");
37 39
 }
38
-?>

+ 32
- 32
sections/schedule/weekly/top10_weekly.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 //------------------- Weekly Top 10 History -----------------//
3 4
 
4 5
 $DB->query("
@@ -8,7 +9,7 @@ $HistoryID = $DB->inserted_id();
8 9
 
9 10
 $Top10 = $Cache->get_value('top10tor_week_10');
10 11
 if ($Top10 === false) {
11
-  $DB->query("
12
+    $DB->query("
12 13
     SELECT
13 14
       t.ID,
14 15
       g.ID,
@@ -29,53 +30,52 @@ if ($Top10 === false) {
29 30
     ORDER BY (t.Seeders + t.Leechers) DESC
30 31
     LIMIT 10;");
31 32
 
32
-  $Top10 = $DB->to_array();
33
+    $Top10 = $DB->to_array();
33 34
 }
34 35
 
35 36
 $i = 1;
36 37
 foreach ($Top10 as $Torrent) {
37
-  list($TorrentID, $GroupID, $GroupName, $GroupCategoryID,
38
+    list($TorrentID, $GroupID, $GroupName, $GroupCategoryID,
38 39
     $WikiImage, $TorrentTags, $Media, $Year, $GroupYear,
39 40
     $Snatched, $Seeders, $Leechers, $Data) = $Torrent;
40 41
 
41
-  $DisplayName = '';
42
+    $DisplayName = '';
42 43
 
43
-  $Artists = Artists::get_artist($GroupID);
44
+    $Artists = Artists::get_artist($GroupID);
44 45
 
45
-  if (!empty($Artists)) {
46
-    $DisplayName = Artists::display_artists($Artists, false, true);
47
-  }
46
+    if (!empty($Artists)) {
47
+        $DisplayName = Artists::display_artists($Artists, false, true);
48
+    }
48 49
 
49
-  $DisplayName .= $GroupName;
50
+    $DisplayName .= $GroupName;
50 51
 
51
-  if ($GroupCategoryID == 1 && $GroupYear > 0) {
52
-    $DisplayName .= " [$GroupYear]";
53
-  }
52
+    if ($GroupCategoryID === 1 && $GroupYear > 0) {
53
+        $DisplayName .= " [$GroupYear]";
54
+    }
54 55
 
55
-  // append extra info to torrent title
56
-  $ExtraInfo = '';
57
-  $AddExtra = '';
58
-  if ($Media) {
59
-    $ExtraInfo .= $AddExtra.$Media;
60
-    $AddExtra = ' / ';
61
-  }
62
-  if ($Year > 0) {
63
-    $ExtraInfo .= $AddExtra.$Year;
64
-    $AddExtra = ' ';
65
-  }
66
-  if ($ExtraInfo != '') {
67
-    $ExtraInfo = "- [$ExtraInfo]";
68
-  }
56
+    // Append extra info to torrent title
57
+    $ExtraInfo = '';
58
+    $AddExtra = '';
59
+    if ($Media) {
60
+        $ExtraInfo .= $AddExtra.$Media;
61
+        $AddExtra = ' / ';
62
+    }
63
+    if ($Year > 0) {
64
+        $ExtraInfo .= $AddExtra.$Year;
65
+        $AddExtra = ' ';
66
+    }
67
+    if ($ExtraInfo !== '') {
68
+        $ExtraInfo = "- [$ExtraInfo]";
69
+    }
69 70
 
70
-  $TitleString = "$DisplayName $ExtraInfo";
71
+    $TitleString = "$DisplayName $ExtraInfo";
71 72
 
72
-  $TagString = str_replace('|', ' ', $TorrentTags);
73
+    $TagString = str_replace('|', ' ', $TorrentTags);
73 74
 
74
-  $DB->query("
75
+    $DB->query("
75 76
     INSERT INTO top10_history_torrents
76 77
       (HistoryID, Rank, TorrentID, TitleString, TagString)
77 78
     VALUES
78 79
       ($HistoryID, $i, $TorrentID, '" . db_string($TitleString) . "', '" . db_string($TagString) . "')");
79
-  $i++;
80
+    $i++;
80 81
 }
81
-?>

Loading…
Cancel
Save