#61 Fix user settings page , undefined index PHP 7.2

Open
Stortebeker wants to merge 4 commits from Stortebeker/Gazelle:master into master

+ 0
- 0
classes/artist.class.php View File


+ 0
- 0
classes/artists.class.php View File


+ 23
- 14
classes/autoenable.class.php View File

@@ -11,10 +11,10 @@ class AutoEnable {
11 11
     const CACHE_KEY_NAME = 'num_enable_requests';
12 12
 
13 13
     // The default request rejected message
14
-    const REJECTED_MESSAGE = "Your request to re-enable your account has been rejected.<br />This may be because a request is already pending for your username, or because a recent request was denied.<br /><br />You are encouraged to discuss this with staff by visiting %s on %s";
14
+    const REJECTED_MESSAGE = "Your request to re-enable your account has been rejected.<br>This may be because a request is already pending for your username, or because a recent request was denied.<br><br>You are encouraged to discuss this with staff by visiting %s on %s";
15 15
 
16 16
     // The default request received message
17
-    const RECEIVED_MESSAGE = "Your request to re-enable your account has been received. You can expect a reply message in your email within 48 hours.<br />If you do not receive an email after 48 hours have passed, please visit us on IRC for assistance.";
17
+    const RECEIVED_MESSAGE = "Your request to re-enable your account has been received. Most requests are responded to within minutes. Remember to check your spam.<br>If you do not receive an email after 48 hours have passed, please visit us on IRC for assistance.";
18 18
 
19 19
     /**
20 20
      * Handle a new enable request
@@ -31,7 +31,7 @@ class AutoEnable {
31 31
 
32 32
         // Get the user's ID
33 33
         G::$DB->query("
34
-                SELECT um.ID
34
+                SELECT um.ID, ui.BanReason
35 35
                 FROM users_main AS um
36 36
                 JOIN users_info ui ON ui.UserID = um.ID
37 37
                 WHERE um.Username = '$Username'
@@ -39,7 +39,7 @@ class AutoEnable {
39 39
 
40 40
         if (G::$DB->has_results()) {
41 41
             // Make sure the user can make another request
42
-            list($UserID) = G::$DB->next_record();
42
+            list($UserID, $BanReason) = G::$DB->next_record();
43 43
             G::$DB->query("
44 44
             SELECT 1 FROM users_enable_requests
45 45
             WHERE UserID = '$UserID'
@@ -51,9 +51,8 @@ class AutoEnable {
51 51
                     OR
52 52
                     (
53 53
                       Timestamp > NOW() - INTERVAL 2 MONTH
54
-                        AND
55
-                          (Outcome = '".self::DENIED."'
56
-                             OR Outcome = '".self::DISCARDED."')
54
+                      AND
55
+                      Outcome = '".self::DENIED."'
57 56
                     )
58 57
                   )");
59 58
         }
@@ -75,12 +74,16 @@ class AutoEnable {
75 74
                 (UserID, Email, IP, UserAgent, Timestamp)
76 75
                 VALUES (?, ?, ?, ?, NOW())",
77 76
                 $UserID, Crypto::encrypt($Email), Crypto::encrypt($IP), $UserAgent);
77
+            $RequestID = G::$DB->inserted_id();
78 78
 
79 79
             // Cache the number of requests for the modbar
80 80
             G::$Cache->increment_value(self::CACHE_KEY_NAME);
81 81
             setcookie('username', '', time() - 60 * 60, '/', '', false);
82 82
             $Output = self::RECEIVED_MESSAGE;
83 83
             Tools::update_user_notes($UserID, sqltime() . " - Enable request " . G::$DB->inserted_id() . " received from $IP\n\n");
84
+            if ($BanReason == 3) {
85
+              //self::handle_requests([$RequestID], self::APPROVED, "Automatically approved (inactivity)");
86
+            }
84 87
         }
85 88
 
86 89
         return $Output;
@@ -140,8 +143,8 @@ class AutoEnable {
140 143
                     $Token = db_string(Users::make_secret());
141 144
                     G::$DB->query("
142 145
                         UPDATE users_enable_requests
143
-                        SET Token = '$Token'
144
-                        WHERE ID = '$ID'");
146
+                        SET Token = ?
147
+                        WHERE ID = ?", $Token, $ID);
145 148
                     $TPL->set('TOKEN', $Token);
146 149
                 }
147 150
 
@@ -159,11 +162,17 @@ class AutoEnable {
159 162
         }
160 163
 
161 164
         // User notes stuff
165
+        $StaffID = G::$LoggedUser['ID'] ?? 0;
162 166
         G::$DB->query("
163 167
             SELECT Username
164 168
             FROM users_main
165
-            WHERE ID = '" . G::$LoggedUser['ID'] . "'");
166
-        list($StaffUser) = G::$DB->next_record();
169
+            WHERE ID = ?", $StaffID);
170
+        if (G::$DB->has_results()) {
171
+          list($StaffUser) = G::$DB->next_record();
172
+        } else {
173
+          $StaffUser = "System";
174
+          $StaffID = 0;
175
+        }
167 176
 
168 177
         foreach ($UserInfo as $User) {
169 178
             list($ID, $UserID) = $User;
@@ -176,9 +185,9 @@ class AutoEnable {
176 185
         G::$DB->query("
177 186
                 UPDATE users_enable_requests
178 187
                 SET HandledTimestamp = NOW(),
179
-                    CheckedBy = '".G::$LoggedUser['ID']."',
180
-                    Outcome = '$Status'
181
-                WHERE ID IN (".implode(',', $IDs).")");
188
+                    CheckedBy = ?,
189
+                    Outcome = ?
190
+                WHERE ID IN (".implode(',', $IDs).")", $StaffID, $Status);
182 191
         G::$Cache->decrement_value(self::CACHE_KEY_NAME, count($IDs));
183 192
     }
184 193
 

+ 0
- 0
classes/badges.class.php View File


+ 0
- 0
classes/bencode.class.php View File


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

@@ -106,7 +106,7 @@ abstract class IRC_BOT {
106 106
 
107 107
   protected function get_word($Select = 1) {
108 108
     preg_match('/:.+ PRIVMSG [^:]+ :(.+)/', $this->Data, $Word);
109
-    $Word = split(' ', $Word[1]);
109
+    $Word = preg_split(' ', $Word[1]);
110 110
     return trim($Word[$Select]);
111 111
   }
112 112
 

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

@@ -296,7 +296,7 @@ class Tools {
296 296
   */
297 297
   public static function check_cidr_range($CheckIP, $Subnet) {
298 298
     $IP = ip2long($CheckIP);
299
-    $CIDR = split('/', $Subnet);
299
+    $CIDR = preg_split('/', $Subnet);
300 300
     $SubnetIP = ip2long($CIDR[0]);
301 301
     $SubnetMaskBits = 32 - $CIDR[1];
302 302
 

+ 27
- 27
sections/user/edit.php View File

@@ -207,11 +207,11 @@ echo $Val->GenerateJS('userform');
207 207
         <td>
208 208
           <ul class="options_list nobullet">
209 209
             <li>
210
-              <input type="radio" name="searchtype" id="search_type_simple" value="0"<?=$SiteOptions['SearchType'] == 0 ? ' checked="checked"' : ''?> />
210
+              <input type="radio" name="searchtype" id="search_type_simple" value="0"<?=$SiteOptions  ?? 'SearchType' == 0 ? ' checked="checked"' : ''?> />
211 211
               <label for="search_type_simple">Simple</label>
212 212
             </li>
213 213
             <li>
214
-              <input type="radio" name="searchtype" id="search_type_advanced" value="1"<?=$SiteOptions['SearchType'] == 1 ? ' checked="checked"' : ''?> />
214
+              <input type="radio" name="searchtype" id="search_type_advanced" value="1"<?=$SiteOptions ?? 'SearchType' == 1 ? ' checked="checked"' : ''?> />
215 215
               <label for="search_type_advanced">Advanced</label>
216 216
             </li>
217 217
           </ul>
@@ -222,7 +222,7 @@ echo $Val->GenerateJS('userform');
222 222
         <td class="label tooltip" title="Enabling torrent grouping will place multiple formats of the same torrent group together beneath a common header."><strong>Torrent grouping</strong></td>
223 223
         <td>
224 224
           <div class="option_group">
225
-            <input type="checkbox" name="disablegrouping" id="disablegrouping"<?=$SiteOptions['DisableGrouping2'] == 0 ? ' checked="checked"' : ''?> />
225
+            <input type="checkbox" name="disablegrouping" id="disablegrouping"<?=$SiteOptions ?? 'DisableGrouping2' == 0 ? ' checked="checked"' : ''?> />
226 226
             <label for="disablegrouping">Enable torrent grouping</label>
227 227
           </div>
228 228
         </td>
@@ -233,11 +233,11 @@ echo $Val->GenerateJS('userform');
233 233
           <div class="option_group">
234 234
             <ul class="options_list nobullet">
235 235
               <li>
236
-                <input type="radio" name="torrentgrouping" id="torrent_grouping_open" value="0"<?=$SiteOptions['TorrentGrouping'] == 0 ? ' checked="checked"' : ''?> />
236
+                <input type="radio" name="torrentgrouping" id="torrent_grouping_open" value="0"<?=$SiteOptions ?? 'TorrentGrouping' == 0 ? ' checked="checked"' : ''?> />
237 237
                 <label for="torrent_grouping_open">Open</label>
238 238
               </li>
239 239
               <li>
240
-                <input type="radio" name="torrentgrouping" id="torrent_grouping_closed" value="1"<?=$SiteOptions['TorrentGrouping'] == 1 ? ' checked="checked"' : ''?> />
240
+                <input type="radio" name="torrentgrouping" id="torrent_grouping_closed" value="1"<?=$SiteOptions ?? 'TorrentGrouping' == 1 ? ' checked="checked"' : ''?> />
241 241
                 <label for="torrent_grouping_closed">Closed</label>
242 242
               </li>
243 243
             </ul>
@@ -247,14 +247,14 @@ echo $Val->GenerateJS('userform');
247 247
       <tr id="tor_snatched_tr">
248 248
         <td class="label tooltip" title="Enabling the snatched torrents indicator will display &quot;Snatched!&quot; next to torrents you've snatched."><strong>Snatched torrents indicator</strong></td>
249 249
         <td>
250
-          <input type="checkbox" name="showsnatched" id="showsnatched"<?=!empty($SiteOptions['ShowSnatched']) ? ' checked="checked"' : ''?> />
250
+          <input type="checkbox" name="showsnatched" id="showsnatched"<?=!empty($SiteOptions ?? 'ShowSnatched') ? ' checked="checked"' : ''?> />
251 251
           <label for="showsnatched">Enable snatched torrents indicator</label>
252 252
         </td>
253 253
       </tr>
254 254
       <tr id="tor_magnet_tr">
255 255
         <td class="label tooltip" title="Magnet links should only be used on clients with DHT disabled globally"><strong>Magnet links</strong></td>
256 256
         <td>
257
-          <input type="checkbox" name="showmagnets" id="showmagnets"<?=!empty($SiteOptions['ShowMagnets']) ? ' checked="checked"' : '' ?> />
257
+          <input type="checkbox" name="showmagnets" id="showmagnets"<?=!empty($SiteOptions ?? 'ShowMagnets') ? ' checked="checked"' : '' ?> />
258 258
           <label for="showmagnets">Show magnet links</label>
259 259
         </td>
260 260
       </tr>
@@ -275,11 +275,11 @@ echo $Val->GenerateJS('userform');
275 275
           <ul class="options_list nobullet">
276 276
             <li>
277 277
               <input type="hidden" name="coverart" value="" />
278
-              <input type="checkbox" name="coverart" id="coverart"<?=!isset($SiteOptions['CoverArt']) || $SiteOptions['CoverArt'] ? ' checked="checked"' : ''?> />
278
+              <input type="checkbox" name="coverart" id="coverart"<?=!isset($SiteOptions['CoverArt']) || $SiteOptions ?? 'CoverArt' ? ' checked="checked"' : ''?> />
279 279
               <label for="coverart">Enable cover artwork</label>
280 280
             </li>
281 281
             <li>
282
-              <input type="checkbox" name="show_extra_covers" id="show_extra_covers"<?=$SiteOptions['ShowExtraCovers'] ? ' checked="checked"' : ''?> />
282
+              <input type="checkbox" name="show_extra_covers" id="show_extra_covers"<?=$SiteOptions ?? 'ShowExtraCovers' ? ' checked="checked"' : ''?> />
283 283
               <label for="show_extra_covers">Enable additional cover artwork</label>
284 284
             </li>
285 285
           </ul>
@@ -289,12 +289,12 @@ echo $Val->GenerateJS('userform');
289 289
         <td class="label tooltip" title="This option allows you to change the number of album covers to display within a single collection page."><strong>Cover art (collections)</strong></td>
290 290
         <td>
291 291
           <select name="collagecovers" id="collagecovers">
292
-            <option value="10"<?=$SiteOptions['CollageCovers'] == 10 ? ' selected="selected"' : ''?>>10</option>
293
-            <option value="25"<?=($SiteOptions['CollageCovers'] == 25 || !isset($SiteOptions['CollageCovers'])) ? ' selected="selected"' : ''?>>25 (default)</option>
294
-            <option value="50"<?=$SiteOptions['CollageCovers'] == 50 ? ' selected="selected"' : ''?>>50</option>
295
-            <option value="100"<?=$SiteOptions['CollageCovers'] == 100 ? ' selected="selected"' : ''?>>100</option>
296
-            <option value="1000000"<?=$SiteOptions['CollageCovers'] == 1000000 ? ' selected="selected"' : ''?>>All</option>
297
-            <option value="0"<?=($SiteOptions['CollageCovers'] === 0 || (!isset($SiteOptions['CollageCovers']) && $SiteOptions['HideCollage'])) ? ' selected="selected"' : ''?>>None</option>
292
+            <option value="10"<?=$SiteOptions ?? 'CollageCovers' == 10 ? ' selected="selected"' : ''?>>10</option>
293
+            <option value="25"<?=($SiteOptions ?? 'CollageCovers' == 25 || !isset($SiteOptions['CollageCovers'])) ? ' selected="selected"' : ''?>>25 (default)</option>
294
+            <option value="50"<?=$SiteOptions ?? 'CollageCovers' == 50 ? ' selected="selected"' : ''?>>50</option>
295
+            <option value="100"<?=$SiteOptions ?? 'CollageCovers' == 100 ? ' selected="selected"' : ''?>>100</option>
296
+            <option value="1000000"<?=$SiteOptions ?? 'CollageCovers' == 1000000 ? ' selected="selected"' : ''?>>All</option>
297
+            <option value="0"<?=($SiteOptions ?? 'CollageCovers' === 0 || (!isset($SiteOptions['CollageCovers']) && $SiteOptions['HideCollage'])) ? ' selected="selected"' : ''?>>None</option>
298 298
           </select>
299 299
           covers per page
300 300
         </td>
@@ -318,9 +318,9 @@ echo $Val->GenerateJS('userform');
318 318
         <td class="label tooltip" title="Autocomplete will try to predict the word or phrase that you're typing. Selecting &quot;Everywhere&quot; will enable autocomplete on artist and tag fields across the site. Selecting &quot;Searches only&quot; will enable autocomplete in searches."><strong>Autocompletion</strong></td>
319 319
         <td>
320 320
           <select name="autocomplete">
321
-            <option value="0"<?=empty($SiteOptions['AutoComplete']) ? ' selected="selected"' : ''?>>Everywhere</option>
322
-            <option value="2"<?=$SiteOptions['AutoComplete'] === 2 ? ' selected="selected"' : ''?>>Searches only</option>
323
-            <option value="1"<?=$SiteOptions['AutoComplete'] === 1 ? ' selected="selected"' : ''?>>Disable</option>
321
+            <option value="0"<?=empty($SiteOptions ?? 'AutoComplete') ? ' selected="selected"' : ''?>>Everywhere</option>
322
+            <option value="2"<?=$SiteOptions ?? 'AutoComplete' === 2 ? ' selected="selected"' : ''?>>Searches only</option>
323
+            <option value="1"<?=$SiteOptions ?? 'AutoComplete' === 1 ? ' selected="selected"' : ''?>>Disable</option>
324 324
           </select>
325 325
         </td>
326 326
       </tr>
@@ -329,15 +329,15 @@ echo $Val->GenerateJS('userform');
329 329
         <td>
330 330
           <ul class="nobullet">
331 331
             <li>
332
-              <input type="checkbox" name="hide_lolicon" id="hide_lolicon"<?=($SiteOptions['HideLolicon']) ? ' checked="checked"' : ''?> />
332
+              <input type="checkbox" name="hide_lolicon" id="hide_lolicon"<?=($SiteOptions ?? 'HideLolicon') ? ' checked="checked"' : ''?> />
333 333
               <label for="hide_lolicon">Hide results with Lolicon, Shotacon, or Toddlercon</label>
334 334
             </li>
335 335
             <li>
336
-              <input type="checkbox" name="hide_scat" id="hide_scat"<?=($SiteOptions['HideScat']) ? ' checked="checked"' : ''?> />
336
+              <input type="checkbox" name="hide_scat" id="hide_scat"<?=($SiteOptions ?? 'HideScat') ? ' checked="checked"' : ''?> />
337 337
               <label for="hide_scat">Hide results with Scat</label>
338 338
             </li>
339 339
             <li>
340
-              <input type="checkbox" name="hide_snuff" id="hide_snuff"<?=($SiteOptions['HideSnuff']) ? ' checked="checked"' : ''?> />
340
+              <input type="checkbox" name="hide_snuff" id="hide_snuff"<?=($SiteOptions ?? 'HideSnuff') ? ' checked="checked"' : ''?> />
341 341
               <label for="hide_snuff">Hide results with Snuff</label>
342 342
             </li>
343 343
           </ul>
@@ -354,9 +354,9 @@ echo $Val->GenerateJS('userform');
354 354
         <td class="label tooltip" title="This option allows you to set the desired number of displayed posts per page within forum threads."><strong>Posts per page (forums)</strong></td>
355 355
         <td>
356 356
           <select name="postsperpage" id="postsperpage">
357
-            <option value="25"<?=$SiteOptions['PostsPerPage'] == 25 ? ' selected="selected"' : ''?>>25 (default)</option>
358
-            <option value="50"<?=$SiteOptions['PostsPerPage'] == 50 ? ' selected="selected"' : ''?>>50</option>
359
-            <option value="100"<?=$SiteOptions['PostsPerPage'] == 100 ? ' selected="selected"' : ''?>>100</option>
357
+            <option value="25"<?=$SiteOptions ?? 'PostsPerPage' == 25 ? ' selected="selected"' : ''?>>25 (default)</option>
358
+            <option value="50"<?=$SiteOptions ?? 'PostsPerPage' == 50 ? ' selected="selected"' : ''?>>50</option>
359
+            <option value="100"<?=$SiteOptions ?? 'PostsPerPage' == 100 ? ' selected="selected"' : ''?>>100</option>
360 360
           </select>
361 361
           posts per page
362 362
         </td>
@@ -371,7 +371,7 @@ echo $Val->GenerateJS('userform');
371 371
       <tr id="comm_emot_tr">
372 372
         <td class="label tooltip" title="Emoticons are small images which replace traditional text-based &quot;smileys&quot; like :) or :("><strong>Emoticons</strong></td>
373 373
         <td>
374
-          <input type="checkbox" name="disablesmileys" id="disablesmileys"<?=!empty($SiteOptions['DisableSmileys']) ? ' checked="checked"' : ''?> />
374
+          <input type="checkbox" name="disablesmileys" id="disablesmileys"<?=!empty($SiteOptions ?? 'DisableSmileys') ? ' checked="checked"' : ''?> />
375 375
           <label for="disablesmileys">Disable emoticons</label>
376 376
         </td>
377 377
       </tr>
@@ -379,8 +379,8 @@ echo $Val->GenerateJS('userform');
379 379
         <td class="label tooltip" title="This option allows you to disable all avatars or show all avatars with a placeholder for users without avatars." data-title-plain="This option allows you to disable all avatars or show all avatars with a placeholder for users without avatars."><strong>Avatar display (posts)</strong></td>
380 380
         <td>
381 381
           <select name="disableavatars" id="disableavatars">
382
-            <option value="1"<?=$SiteOptions['DisableAvatars'] == 1 ? ' selected="selected"' : ''?>>Disable avatars</option>
383
-            <option value="0"<?=$SiteOptions['DisableAvatars'] == 0 ? ' selected="selected"' : ''?>>Show avatars</option>
382
+            <option value="1"<?=$SiteOptions ?? 'DisableAvatars' == 1 ? ' selected="selected"' : ''?>>Disable avatars</option>
383
+            <option value="0"<?=$SiteOptions ?? 'DisableAvatars' == 0 ? ' selected="selected"' : ''?>>Show avatars</option>
384 384
           </select>
385 385
         </td>
386 386
       </tr>

Loading…
Cancel
Save