Browse Source

Housekeeping and bug fixes

biotorrents 4 years ago
parent
commit
8058498b34

+ 56
- 58
classes/config.template View File

73
 ENV::setPub('CRUMB', '›'); # e.g., Forums › Board › Thread
73
 ENV::setPub('CRUMB', '›'); # e.g., Forums › Board › Thread
74
 
74
 
75
 # The FQDN of your site, e.g., dev.biotorrents.de
75
 # The FQDN of your site, e.g., dev.biotorrents.de
76
-( # Old format: ternary
76
+( # Old format
77
     !$ENV->DEV
77
     !$ENV->DEV
78
         ? define('SITE_DOMAIN', 'biotorrents.de') # Production
78
         ? define('SITE_DOMAIN', 'biotorrents.de') # Production
79
         : define('SITE_DOMAIN', 'dev.biotorrents.de') # Development
79
         : define('SITE_DOMAIN', 'dev.biotorrents.de') # Development
90
 ENV::setPub('IMAGE_DOMAIN', 'pics.biotorrents.de');
90
 ENV::setPub('IMAGE_DOMAIN', 'pics.biotorrents.de');
91
 
91
 
92
 # The root of the server, used for includes, e.g., /var/www/html/dev.biotorrents.de/
92
 # The root of the server, used for includes, e.g., /var/www/html/dev.biotorrents.de/
93
-( # Old format: ternary
93
+( # Old format
94
     !$ENV->DEV
94
     !$ENV->DEV
95
         ? define('SERVER_ROOT', '/var/www/html/biotorrents.de/') # Production
95
         ? define('SERVER_ROOT', '/var/www/html/biotorrents.de/') # Production
96
         : define('SERVER_ROOT', '/var/www/html/dev.biotorrents.de/') # Development
96
         : define('SERVER_ROOT', '/var/www/html/dev.biotorrents.de/') # Development
104
 );
104
 );
105
 
105
 
106
 # Where torrent files are stored, e.g., /var/www/torrents-dev/
106
 # Where torrent files are stored, e.g., /var/www/torrents-dev/
107
-( # Old format: ternary
107
+( # Old format
108
     !$ENV->DEV
108
     !$ENV->DEV
109
         ? define('TORRENT_STORE', '/var/www/torrents/') # Production
109
         ? define('TORRENT_STORE', '/var/www/torrents/') # Production
110
         : define('TORRENT_STORE', '/var/www/torrents-dev/') # Development
110
         : define('TORRENT_STORE', '/var/www/torrents-dev/') # Development
125
 ENV::setPub('SRI', 'sha384');
125
 ENV::setPub('SRI', 'sha384');
126
 
126
 
127
 
127
 
128
+/**
129
+ * Tech support
130
+ */
131
+
132
+$TechSupport = [
133
+  'Email' => 'help@biotorrents.de',
134
+  'Subject' => '[TxID '.strtoupper(bin2hex(random_bytes(2))).'] Specific subject line with TxID intact',
135
+  'Body' => 'A detailed description of how you reach the error and the full text of any site messages you may receive.'
136
+];
137
+ENV::setPub(
138
+    'HELP',
139
+    new RecursiveArrayObject($TechSupport)
140
+);
141
+
142
+
128
 /**
143
 /**
129
  * App keys
144
  * App keys
130
  *
145
  *
141
     ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
156
     ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
142
   
157
   
143
     # Alphanumeric random key. This key must be the argument to schedule.php for the schedule to work
158
     # Alphanumeric random key. This key must be the argument to schedule.php for the schedule to work
144
-    define('SCHEDULE_KEY', '00000000000000000000000000000000');
145
     ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
159
     ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
146
   
160
   
147
     # Random key. Used for generating unique RSS auth key
161
     # Random key. Used for generating unique RSS auth key
148
-    define('RSS_HASH', '00000000000000000000000000000000');
149
     ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
162
     ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
150
 }
163
 }
151
 
164
 
152
 # Development
165
 # Development
153
 else {
166
 else {
154
     ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
167
     ENV::setPriv('ENCKEY', '00000000000000000000000000000000');
155
-
156
-    define('SCHEDULE_KEY', '00000000000000000000000000000000');
157
     ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
168
     ENV::setPriv('SCHEDULE_KEY', '00000000000000000000000000000000');
158
-    
159
-    define('RSS_HASH', '00000000000000000000000000000000');
160
     ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
169
     ENV::setPriv('RSS_HASH', '00000000000000000000000000000000');
161
 }
170
 }
162
 
171
 
190
  */
199
  */
191
 
200
 
192
 # Ocelot connection, e.g., 0.0.0.0
201
 # Ocelot connection, e.g., 0.0.0.0
193
-define('TRACKER_HOST', '0.0.0.0');
194
 ENV::setPriv('TRACKER_HOST', '0.0.0.0');
202
 ENV::setPriv('TRACKER_HOST', '0.0.0.0');
195
 
203
 
196
  # Production
204
  # Production
197
- if (!$ENV->DEV) {
198
-     define('TRACKER_PORT', 34000);
199
-     ENV::setPriv('TRACKER_PORT', 34000);
205
+if (!$ENV->DEV) {
206
+    ENV::setPriv('TRACKER_PORT', 34000);
200
   
207
   
201
-     # Must be 32 alphanumeric characters and match site_password in ocelot.conf
202
-     define('TRACKER_SECRET', '00000000000000000000000000000000');
203
-     ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
208
+    # Must be 32 alphanumeric characters and match site_password in ocelot.conf
209
+    ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
204
 
210
 
205
-     # Must be 32 alphanumeric characters and match report_password in ocelot.conf
206
-     define('TRACKER_REPORTKEY', '00000000000000000000000000000000');
207
-     ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
208
- }
211
+    # Must be 32 alphanumeric characters and match report_password in ocelot.conf
212
+    ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
213
+}
209
 
214
 
210
 # Development
215
 # Development
211
 else {
216
 else {
212
-    define('TRACKER_PORT', 34001);
213
     ENV::setPriv('TRACKER_PORT', 34001);
217
     ENV::setPriv('TRACKER_PORT', 34001);
214
-  
215
-    define('TRACKER_SECRET', '00000000000000000000000000000000');
216
     ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
218
     ENV::setPriv('TRACKER_SECRET', '00000000000000000000000000000000');
217
-  
218
-    define('TRACKER_REPORTKEY', '00000000000000000000000000000000');
219
     ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
219
     ENV::setPriv('TRACKER_REPORTKEY', '00000000000000000000000000000000');
220
 }
220
 }
221
 
221
 
254
 else {
254
 else {
255
     define('ANNOUNCE_URLS', [
255
     define('ANNOUNCE_URLS', [
256
       [ # Tier 1
256
       [ # Tier 1
257
-        'https://devtr.biotorrents.de:443',
257
+        'https://trx.biotorrents.de:443',
258
       ], [] # Tier 2
258
       ], [] # Tier 2
259
     ]);
259
     ]);
260
 
260
 
261
     $AnnounceURLs = [
261
     $AnnounceURLs = [
262
       [ # Tier 1
262
       [ # Tier 1
263
-        'https://devtr.biotorrents.de:443',
263
+        'https://trx.biotorrents.de:443',
264
       ], [], # Tier 2
264
       ], [], # Tier 2
265
     ];
265
     ];
266
     ENV::setPub(
266
     ENV::setPub(
398
 ENV::setPub('STARTING_INVITES', 2);
398
 ENV::setPub('STARTING_INVITES', 2);
399
 ENV::setPub('STARTING_TOKENS', 2);
399
 ENV::setPub('STARTING_TOKENS', 2);
400
 ENV::setPub('STARTING_UPLOAD', 5368709120);
400
 ENV::setPub('STARTING_UPLOAD', 5368709120);
401
-
402
-define('DONOR_INVITES', 2);
403
 ENV::setPub('DONOR_INVITES', 2);
401
 ENV::setPub('DONOR_INVITES', 2);
404
 
402
 
405
 # Bonus Points
403
 # Bonus Points
426
     'PASSWORD_ADVICE',
424
     'PASSWORD_ADVICE',
427
     <<<HTML
425
     <<<HTML
428
     <p>
426
     <p>
429
-      Any password of 15 characters or longer will be accepted, but a strong password
427
+      Any password 15 characters or longer is accepted, but a strong password
430
       <ul>
428
       <ul>
431
-        <li>is really a pass<em>phrase</em> with uppercase and lowercase letters and many small words,</li>
432
-        <li>that contains numbers and symbols, including complex Unicode characters like emoji.</li>
429
+        <li>is a pass<em>phrase</em> of mixed case with many small words,</li>
430
+        <li>that contains complex characters including Unicode and emoji.</li>
433
       </ul>
431
       </ul>
434
     </p>
432
     </p>
435
 HTML
433
 HTML
470
  */
468
  */
471
 
469
 
472
 #       Name of class     Class ID (not level)
470
 #       Name of class     Class ID (not level)
473
-define('ADMIN',          '1');
474
-define('USER',           '2');
475
-define('MEMBER',         '3');
476
-define('POWER',          '4');
477
-define('ELITE',          '5');
478
-define('LEGEND',         '8');
479
-define('MOD',            '11');
480
-define('SYSOP',          '15');
481
-define('ARTIST',         '19');
482
-define('DONOR',          '20');
483
-define('VIP',            '21');
471
+define('ADMIN', '1');
472
+define('USER', '2');
473
+define('MEMBER', '3');
474
+define('POWER', '4');
475
+define('ELITE', '5');
476
+define('LEGEND', '8');
477
+define('MOD', '11');
478
+define('SYSOP', '15');
479
+define('ARTIST', '19');
480
+define('DONOR', '20');
481
+define('VIP', '21');
484
 define('TORRENT_MASTER', '23');
482
 define('TORRENT_MASTER', '23');
485
-define('POWER_TM',       '24');
486
-define('FLS_TEAM',       '33');
487
-define('FORUM_MOD',      '9001');
483
+define('POWER_TM', '24');
484
+define('FLS_TEAM', '33');
485
+define('FORUM_MOD', '9001');
488
 
486
 
489
 
487
 
490
 /**
488
 /**
563
   ],
561
   ],
564
 
562
 
565
   'Posts' => [
563
   'Posts' => [
566
-    '5'    => 60,
567
-    '10'   => 61,
568
-    '25'   => 62,
569
-    '50'   => 63,
570
-    '100'  => 64,
571
-    '250'  => 65,
572
-    '500'  => 66,
573
-    '1000' => 67,
574
-    '2500' => 68,
564
+    '5'    => 30,
565
+    '10'   => 31,
566
+    '25'   => 32,
567
+    '50'   => 33,
568
+    '100'  => 34,
569
+    '250'  => 35,
570
+    '500'  => 36,
571
+    '1000' => 37,
572
+    '2500' => 38,
575
   ]
573
   ]
576
 ];
574
 ];
577
 ENV::setPub(
575
 ENV::setPub(
608
  *     . $InstanceID;
606
  *     . $InstanceID;
609
  */
607
  */
610
 
608
 
611
-$DatabaseFields = [
609
+$DB = [
612
   'AccessionNumber' => [
610
   'AccessionNumber' => [
613
     'Label' => 'Accession Number',
611
     'Label' => 'Accession Number',
614
     'Selector' => ['DOI' => 'javdb', 'RefSeq' => 'anidb', 'UniProt' => 'ehentai'],
612
     'Selector' => ['DOI' => 'javdb', 'RefSeq' => 'anidb', 'UniProt' => 'ehentai'],
639
   # etc.
637
   # etc.
640
 ];
638
 ];
641
 ENV::setPub(
639
 ENV::setPub(
642
-    'DBMAP',
643
-    new RecursiveArrayObject($DatabaseFields)
640
+    'META',
641
+    new RecursiveArrayObject($DB)
644
 );
642
 );
645
 
643
 
646
 
644
 

+ 1
- 1
classes/script_start.php View File

303
 
303
 
304
     // Create LoggedUser array
304
     // Create LoggedUser array
305
     $LoggedUser = array_merge($HeavyInfo, $LightInfo, $UserStats);
305
     $LoggedUser = array_merge($HeavyInfo, $LightInfo, $UserStats);
306
-    $LoggedUser['RSS_Auth'] = md5($LoggedUser['ID'] . RSS_HASH . $LoggedUser['torrent_pass']);
306
+    $LoggedUser['RSS_Auth'] = md5($LoggedUser['ID'] . $ENV->getPriv('RSS_HASH') . $LoggedUser['torrent_pass']);
307
 
307
 
308
     // $LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
308
     // $LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
309
     $LoggedUser['RatioWatch'] = (
309
     $LoggedUser['RatioWatch'] = (

+ 1
- 1
classes/torrent_form.class.php View File

355
                   <p id="category_description" class="">
355
                   <p id="category_description" class="">
356
                   <!-- $Cat->Description will live here -->
356
                   <!-- $Cat->Description will live here -->
357
                   Please see the
357
                   Please see the
358
-                  <a href="https://dev.biotorrents.de/wiki.php?action=article&name=categories">Categories Wiki</a>
358
+                  <a href="/wiki.php?action=article&name=categories">Categories Wiki</a>
359
                   for details
359
                   for details
360
                   </p>
360
                   </p>
361
                 </td>
361
                 </td>

+ 30
- 10
classes/tracker.class.php View File

20
      */
20
      */
21
     public static function update_tracker($Action, $Updates, $ToIRC = false)
21
     public static function update_tracker($Action, $Updates, $ToIRC = false)
22
     {
22
     {
23
+        $ENV = ENV::go();
24
+
23
         // Build request
25
         // Build request
24
-        $Get = TRACKER_SECRET . "/update?action=$Action";
26
+        $Get = $ENV->getPriv('TRACKER_SECRET') . "/update?action=$Action";
25
         foreach ($Updates as $Key => $Value) {
27
         foreach ($Updates as $Key => $Value) {
26
             $Get .= "&$Key=$Value";
28
             $Get .= "&$Key=$Value";
27
         }
29
         }
102
      */
104
      */
103
     private static function get_stats($Type, $Params = false)
105
     private static function get_stats($Type, $Params = false)
104
     {
106
     {
105
-        if (!defined('TRACKER_REPORTKEY')) {
107
+        $ENV = ENV::go();
108
+
109
+        if (!defined($ENV->getPriv('TRACKER_REPORTKEY'))) {
106
             return false;
110
             return false;
107
         }
111
         }
108
-        $Get = TRACKER_REPORTKEY . '/report?';
112
+
113
+        $Get = $ENV->getPriv('TRACKER_REPORTKEY') . '/report?';
109
         if ($Type === self::STATS_MAIN) {
114
         if ($Type === self::STATS_MAIN) {
110
             $Get .= 'get=stats';
115
             $Get .= 'get=stats';
111
         } elseif ($Type === self::STATS_USER && !empty($Params['key'])) {
116
         } elseif ($Type === self::STATS_USER && !empty($Params['key'])) {
113
         } else {
118
         } else {
114
             return false;
119
             return false;
115
         }
120
         }
121
+
116
         $Response = self::send_request($Get);
122
         $Response = self::send_request($Get);
117
         if ($Response === false) {
123
         if ($Response === false) {
118
             return false;
124
             return false;
119
         }
125
         }
126
+
120
         $Stats = [];
127
         $Stats = [];
121
         foreach (explode("\n", $Response) as $Stat) {
128
         foreach (explode("\n", $Response) as $Stat) {
122
             list($Val, $Key) = explode(" ", $Stat, 2);
129
             list($Val, $Key) = explode(" ", $Stat, 2);
125
         return $Stats;
132
         return $Stats;
126
     }
133
     }
127
 
134
 
135
+
128
     /**
136
     /**
129
      * Send a request to the tracker
137
      * Send a request to the tracker
130
      *
138
      *
135
      */
143
      */
136
     private static function send_request($Get, $MaxAttempts = 1, &$Err = false)
144
     private static function send_request($Get, $MaxAttempts = 1, &$Err = false)
137
     {
145
     {
146
+        $ENV = ENV::go();
147
+
138
         $Header = "GET /$Get HTTP/1.1\r\nConnection: Close\r\n\r\n";
148
         $Header = "GET /$Get HTTP/1.1\r\nConnection: Close\r\n\r\n";
139
         $Attempts = 0;
149
         $Attempts = 0;
140
         $Sleep = 0;
150
         $Sleep = 0;
152
             }
162
             }
153
 
163
 
154
             // Send request
164
             // Send request
155
-            $File = fsockopen(TRACKER_HOST, TRACKER_PORT, $ErrorNum, $ErrorString);
165
+            $File = fsockopen(
166
+                $ENV->getPriv('TRACKER_HOST'),
167
+                $ENV->getPriv('TRACKER_PORT'),
168
+                $ErrorNum,
169
+                $ErrorString
170
+            );
171
+            
156
             if ($File) {
172
             if ($File) {
157
                 if (fwrite($File, $Header) === false) {
173
                 if (fwrite($File, $Header) === false) {
158
                     $Err = "Failed to fwrite()";
174
                     $Err = "Failed to fwrite()";
169
             while (!feof($File)) {
185
             while (!feof($File)) {
170
                 $Response .= fread($File, 1024);
186
                 $Response .= fread($File, 1024);
171
             }
187
             }
188
+
172
             $DataStart = strpos($Response, "\r\n\r\n") + 4;
189
             $DataStart = strpos($Response, "\r\n\r\n") + 4;
173
             $DataEnd = strrpos($Response, "\n");
190
             $DataEnd = strrpos($Response, "\n");
174
             if ($DataEnd > $DataStart) {
191
             if ($DataEnd > $DataStart) {
176
             } else {
193
             } else {
177
                 $Data = "";
194
                 $Data = "";
178
             }
195
             }
196
+
179
             $Status = substr($Response, $DataEnd + 1);
197
             $Status = substr($Response, $DataEnd + 1);
180
             if ($Status == "success") {
198
             if ($Status == "success") {
181
                 $Success = true;
199
                 $Success = true;
182
             }
200
             }
183
         }
201
         }
184
-        $Request = array(
185
-      'path' => substr($Get, strpos($Get, '/')),
186
-      'response' => ($Success ? $Data : $Response),
187
-      'status' => ($Success ? 'ok' : 'failed'),
188
-      'time' => 1000 * (microtime(true) - $StartTime)
189
-    );
202
+
203
+        $Request = [
204
+            'path' => substr($Get, strpos($Get, '/')),
205
+            'response' => ($Success ? $Data : $Response),
206
+            'status' => ($Success ? 'ok' : 'failed'),
207
+            'time' => 1000 * (microtime(true) - $StartTime)
208
+        ];
209
+
190
         self::$Requests[] = $Request;
210
         self::$Requests[] = $Request;
191
         if ($Success) {
211
         if ($Success) {
192
             return $Data;
212
             return $Data;

+ 2
- 1
sections/feeds/index.php View File

23
     error(400, $NoHTML = true);
23
     error(400, $NoHTML = true);
24
 }
24
 }
25
 
25
 
26
+# Initialize
26
 require_once 'classes/env.class.php';
27
 require_once 'classes/env.class.php';
27
 $ENV = ENV::go();
28
 $ENV = ENV::go();
28
 
29
 
45
 }
46
 }
46
 
47
 
47
 # Check for RSS auth
48
 # Check for RSS auth
48
-if (md5($User.RSS_HASH.$_GET['passkey']) !== $_GET['auth'] || (int) $Enabled !== 1) {
49
+if (md5($User.$ENV->getPriv('RSS_HASH').$_GET['passkey']) !== $_GET['auth'] || (int) $Enabled !== 1) {
49
     $Feed->open_feed();
50
     $Feed->open_feed();
50
     $Feed->channel('Blocked', 'RSS feed.');
51
     $Feed->channel('Blocked', 'RSS feed.');
51
     $Feed->close_feed();
52
     $Feed->close_feed();

+ 9
- 1
sections/peerupdate/index.php View File

1
 <?php
1
 <?php
2
+#declare(strict_types=1);
3
+
4
+$ENV = ENV::go();
2
 
5
 
3
 // We keep torrent groups cached. However, the peer counts change often, so our solutions are to not cache them for long, or to update them. Here is where we updated them.
6
 // We keep torrent groups cached. However, the peer counts change often, so our solutions are to not cache them for long, or to update them. Here is where we updated them.
4
-if ((!isset($argv[1]) || $argv[1]!=SCHEDULE_KEY) && !check_perms('admin_schedule')) { // authorization, Fix to allow people with perms hit this page.
7
+if ((!isset($argv[1]) || $argv[1]!== $ENV->getPriv('SCHEDULE_KEY'))
8
+&& !check_perms('admin_schedule')) { // auth fix to let people with perms hit this page
5
     error(403);
9
     error(403);
6
 }
10
 }
7
 
11
 
50
 $LastGroupID = 0;
54
 $LastGroupID = 0;
51
 $UpdatedKeys = $UncachedGroups = 0;
55
 $UpdatedKeys = $UncachedGroups = 0;
52
 list($TorrentID, $GroupID, $Seeders, $Leechers, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
56
 list($TorrentID, $GroupID, $Seeders, $Leechers, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
57
+
53
 while ($TorrentID) {
58
 while ($TorrentID) {
54
     if ($LastGroupID != $GroupID) {
59
     if ($LastGroupID != $GroupID) {
55
         $CachedData = $Cache->get_value("torrent_group_$GroupID");
60
         $CachedData = $Cache->get_value("torrent_group_$GroupID");
62
         }
67
         }
63
         $LastGroupID = $GroupID;
68
         $LastGroupID = $GroupID;
64
     }
69
     }
70
+
65
     while ($LastGroupID == $GroupID) {
71
     while ($LastGroupID == $GroupID) {
66
         $RowNum++;
72
         $RowNum++;
67
         if (isset($CachedStats) && is_array($CachedStats[$TorrentID])) {
73
         if (isset($CachedStats) && is_array($CachedStats[$TorrentID])) {
72
             $Changed = true;
78
             $Changed = true;
73
             unset($OldValues);
79
             unset($OldValues);
74
         }
80
         }
81
+
75
         if (!($RowNum % $StepSize)) {
82
         if (!($RowNum % $StepSize)) {
76
             $DB->query("
83
             $DB->query("
77
         SELECT *
84
         SELECT *
84
         $LastGroupID = $GroupID;
91
         $LastGroupID = $GroupID;
85
         list($TorrentID, $GroupID, $Seeders, $Leechers, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
92
         list($TorrentID, $GroupID, $Seeders, $Leechers, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
86
     }
93
     }
94
+    
87
     if ($Changed) {
95
     if ($Changed) {
88
         $Cache->cache_value("torrent_group_$LastGroupID", $CachedData, 0);
96
         $Cache->cache_value("torrent_group_$LastGroupID", $CachedData, 0);
89
         unset($CachedStats);
97
         unset($CachedStats);

+ 1
- 1
sections/requests/take_new_edit.php View File

190
       TitleJP = '".db_string($TitleJP??"")."',
190
       TitleJP = '".db_string($TitleJP??"")."',
191
       Image = '".db_string($Image)."',
191
       Image = '".db_string($Image)."',
192
       Description = '".db_string($Description)."',
192
       Description = '".db_string($Description)."',
193
-      CatalogueNumber = '".db_string($CatalogueNumber)."',
193
+      CatalogueNumber = '".db_string($CatalogueNumber)."'
194
     WHERE ID = $RequestID");
194
     WHERE ID = $RequestID");
195
 
195
 
196
     // We need to be able to delete artists/tags
196
     // We need to be able to delete artists/tags

+ 5
- 2
sections/schedule/index.php View File

1
 <?php
1
 <?php
2
+#declare(strict_types=1);
3
+
4
+$ENV = ENV::go();
2
 
5
 
3
 // This page is run every 15 minutes by cron
6
 // This page is run every 15 minutes by cron
4
 // todo: See if strict equality will break everything
7
 // todo: See if strict equality will break everything
31
     }
34
     }
32
 }
35
 }
33
 
36
 
34
-if ((!isset($_REQUEST['key']) || $_REQUEST['key'] !== SCHEDULE_KEY)
35
-    #&& (!isset($argv[1]) || $argv[1] !== SCHEDULE_KEY)
37
+if ((!isset($_REQUEST['key']) || $_REQUEST['key'] !== $ENV->getPriv('SCHEDULE_KEY'))
38
+    #|| (!isset($argv[1]) || $argv[1] !== $ENV->getPriv('SCHEDULE_KEY'))
36
     && !$AS) {
39
     && !$AS) {
37
     error(403);
40
     error(403);
38
 }
41
 }

+ 33
- 30
sections/tools/managers/ocelot.php View File

1
-<?
1
+<?php
2
+#declare(strict_types=1);
3
+
4
+$ENV = ENV::go();
5
+
2
 $Key = $_REQUEST['key'];
6
 $Key = $_REQUEST['key'];
3
 $Type = $_REQUEST['type'];
7
 $Type = $_REQUEST['type'];
4
 
8
 
5
-if (($Key != TRACKER_SECRET) || $_SERVER['REMOTE_ADDR'] != TRACKER_HOST) {
6
-  send_irc(DEBUG_CHAN, 'Ocelot Auth Failure '.$_SERVER['REMOTE_ADDR']);
7
-  error(403);
9
+if (($Key !== $ENV->getPriv('TRACKER_SECRET')) || $_SERVER['REMOTE_ADDR'] !== $ENV->getPriv('TRACKER_HOST')) {
10
+    send_irc(DEBUG_CHAN, 'Ocelot Auth Failure '.$_SERVER['REMOTE_ADDR']);
11
+    error(403);
8
 }
12
 }
9
 
13
 
10
 switch ($Type) {
14
 switch ($Type) {
11
   case 'expiretoken':
15
   case 'expiretoken':
12
     if (isset($_GET['tokens'])) {
16
     if (isset($_GET['tokens'])) {
13
-      $Tokens = explode(',', $_GET['tokens']);
14
-      if (empty($Tokens)) {
15
-        error(0);
16
-      }
17
-      $Cond = $UserIDs = [];
18
-      foreach ($Tokens as $Key => $Token) {
19
-        list($UserID, $TorrentID) = explode(':', $Token);
20
-        if (!is_number($UserID) || !is_number($TorrentID)) {
21
-          continue;
17
+        $Tokens = explode(',', $_GET['tokens']);
18
+        if (empty($Tokens)) {
19
+            error(0);
22
         }
20
         }
23
-        $Cond[] = "(UserID = $UserID AND TorrentID = $TorrentID)";
24
-        $UserIDs[] = $UserID;
25
-      }
26
-      if (!empty($Cond)) {
27
-        $Query = "
21
+        $Cond = $UserIDs = [];
22
+        foreach ($Tokens as $Key => $Token) {
23
+            list($UserID, $TorrentID) = explode(':', $Token);
24
+            if (!is_number($UserID) || !is_number($TorrentID)) {
25
+                continue;
26
+            }
27
+            $Cond[] = "(UserID = $UserID AND TorrentID = $TorrentID)";
28
+            $UserIDs[] = $UserID;
29
+        }
30
+        if (!empty($Cond)) {
31
+            $Query = "
28
           UPDATE users_freeleeches
32
           UPDATE users_freeleeches
29
           SET Expired = TRUE
33
           SET Expired = TRUE
30
           WHERE ".implode(" OR ", $Cond);
34
           WHERE ".implode(" OR ", $Cond);
31
-        $DB->query($Query);
32
-        foreach ($UserIDs as $UserID) {
33
-          $Cache->delete_value("users_tokens_$UserID");
35
+            $DB->query($Query);
36
+            foreach ($UserIDs as $UserID) {
37
+                $Cache->delete_value("users_tokens_$UserID");
38
+            }
34
         }
39
         }
35
-      }
36
     } else {
40
     } else {
37
-      $TorrentID = $_REQUEST['torrentid'];
38
-      $UserID = $_REQUEST['userid'];
39
-      if (!is_number($TorrentID) || !is_number($UserID)) {
40
-        error(403);
41
-      }
42
-      $DB->query("
41
+        $TorrentID = $_REQUEST['torrentid'];
42
+        $UserID = $_REQUEST['userid'];
43
+        if (!is_number($TorrentID) || !is_number($UserID)) {
44
+            error(403);
45
+        }
46
+        $DB->query("
43
         UPDATE users_freeleeches
47
         UPDATE users_freeleeches
44
         SET Expired = TRUE
48
         SET Expired = TRUE
45
         WHERE UserID = $UserID
49
         WHERE UserID = $UserID
46
           AND TorrentID = $TorrentID");
50
           AND TorrentID = $TorrentID");
47
-      $Cache->delete_value("users_tokens_$UserID");
51
+        $Cache->delete_value("users_tokens_$UserID");
48
     }
52
     }
49
     break;
53
     break;
50
 }
54
 }
51
-?>

+ 2
- 2
sections/upload/upload_handle.php View File

256
             'resolution',
256
             'resolution',
257
             '1',
257
             '1',
258
             'string',
258
             'string',
259
-            'Scope must be between 5 and 20 characters.',
260
-            array('maxlength' => 20, 'minlength' => 5)
259
+            'Scope must be between 4 and 20 characters.',
260
+            array('maxlength' => 20, 'minlength' => 4)
261
         );
261
         );
262
         
262
         
263
         # torrents_group.TagList
263
         # torrents_group.TagList

+ 0
- 13
static/styles/bookish/scss/fonts.scss View File

27
     text-align: center;
27
     text-align: center;
28
 }
28
 }
29
 
29
 
30
-.torrent_form {
31
-    label {
32
-        font-weight: bold;
33
-    }
34
-
35
-    .required {
36
-        &:after {
37
-            color: red;
38
-            content: "*";
39
-        }
40
-    }
41
-}
42
-
43
 /* Links */
30
 /* Links */
44
 a {
31
 a {
45
     color: black;
32
     color: black;

+ 18
- 1
static/styles/global/scss/fonts.scss View File

5
 }
5
 }
6
 
6
 
7
 /*
7
 /*
8
- * Classes
8
+ * Spacing classes
9
  */
9
  */
10
 
10
 
11
 .center {
11
 .center {
54
     display: none;
54
     display: none;
55
 }
55
 }
56
 
56
 
57
+/*
58
+ * Torrent form
59
+*/
60
+
61
+.torrent_form {
62
+    label {
63
+        font-weight: bold;
64
+    }
65
+
66
+    .required {
67
+        &:after {
68
+            color: red;
69
+            content: "*";
70
+        }
71
+    }
72
+}
73
+
57
 /* Good/bad examples on rules pages */
74
 /* Good/bad examples on rules pages */
58
 .important_text {
75
 .important_text {
59
     color: red;
76
     color: red;

Loading…
Cancel
Save