Browse Source

Additional fixes for NULL related fields.

ngxez 8 years ago
parent
commit
410c84fa7f

+ 1
- 1
classes/script_start.php View File

@@ -158,7 +158,7 @@ if (isset($_COOKIE['session']) && isset($_COOKIE['userid'])) {
158 158
 
159 159
   // $LoggedUser['RatioWatch'] as a bool to disable things for users on Ratio Watch
160 160
   $LoggedUser['RatioWatch'] = (
161
-    $LoggedUser['RatioWatchEnds'] != NULL
161
+    !is_null($LoggedUser['RatioWatchEnds'])
162 162
     && time() < strtotime($LoggedUser['RatioWatchEnds'])
163 163
     && ($LoggedUser['BytesDownloaded'] * $LoggedUser['RequiredRatio']) > $LoggedUser['BytesUploaded']
164 164
   );

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

@@ -5,7 +5,7 @@ if (!extension_loaded('date')) {
5 5
 
6 6
 function time_ago($TimeStamp) {
7 7
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
8
-    if ($TimeStamp == NULL) {
8
+    if (is_null($TimeStamp)) {
9 9
       return false;
10 10
     }
11 11
     $TimeStamp = strtotime($TimeStamp);
@@ -22,7 +22,7 @@ function time_ago($TimeStamp) {
22 22
  */
23 23
 function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
24 24
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
25
-    if ($TimeStamp == NULL) {
25
+    if (is_null($TimeStamp)) {
26 26
       return 'Never';
27 27
     }
28 28
     $TimeStamp = strtotime($TimeStamp);

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

@@ -235,7 +235,7 @@ class Tools {
235 235
       SELECT Warned
236 236
       FROM users_info
237 237
       WHERE UserID = $UserID
238
-        AND Warned != NULL");
238
+        AND Warned IS NOT NULL");
239 239
     if (G::$DB->has_results()) {
240 240
       //User was already warned, appending new warning to old.
241 241
       list($OldDate) = G::$DB->next_record();

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

@@ -419,7 +419,7 @@ class Users {
419 419
       $Str .= Badges::display_badges(Badges::get_displayed_badges($UserID), true);
420 420
     }
421 421
 
422
-    $Str .= ($IsWarned && $UserInfo['Warned'] != NULL) ? '<a href="wiki.php?action=article&amp;id=218"'
422
+    $Str .= ($IsWarned && !is_null($UserInfo['Warned'])) ? '<a href="wiki.php?action=article&amp;id=218"'
423 423
           . '><img src="'.STATIC_SERVER.'common/symbols/warned.png" alt="Warned" title="Warned'
424 424
           . (G::$LoggedUser['ID'] === $UserID ? ' - Expires ' . date('Y-m-d H:i', strtotime($UserInfo['Warned'])) : '')
425 425
           . '" class="tooltip" /></a>' : '';

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

@@ -80,7 +80,7 @@ if (!extension_loaded('zlib')) {
80 80
 //Handles timestamps
81 81
 function dostime($TimeStamp = 0) {
82 82
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
83
-    if ($TimeStamp == NULL) {
83
+    if (is_null($TimeStamp)) {
84 84
       return 'Never';
85 85
     }
86 86
     $TimeStamp = strtotime($TimeStamp);

+ 1
- 1
sections/ajax/forum/forum.php View File

@@ -140,7 +140,7 @@ if (count($Forum) === 0) {
140 140
     $UserInfo = Users::user_info($LastAuthorID);
141 141
     $LastAuthorName = $UserInfo['Username'];
142 142
     // Bug fix for no last time available
143
-    if ($LastTime == NULL) {
143
+    if (is_null($LastTime)) {
144 144
       $LastTime = '';
145 145
     }
146 146
 

+ 1
- 1
sections/ajax/forum/thread.php View File

@@ -261,7 +261,7 @@ foreach ($Thread as $Key => $Post) {
261 261
       'paranoia' => $Paranoia,
262 262
       'artist' => $Artist === '1',
263 263
       'donor' => $Donor === '1',
264
-      'warned' => $Warned !== NULL,
264
+      'warned' => !is_null($Warned),
265 265
       'avatar' => $Avatar,
266 266
       'enabled' => $Enabled === '2' ? false : true,
267 267
       'userTitle' => $UserTitle

+ 1
- 1
sections/ajax/request.php View File

@@ -67,7 +67,7 @@ foreach ($Thread as $Key => $Post) {
67 67
     'authorId'        => (int)$AuthorID,
68 68
     'name'            => $Username,
69 69
     'donor'           => ($Donor == 1),
70
-    'warned'          => ($Warned != NULL),
70
+    'warned'          => !is_null($Warned),
71 71
     'enabled'         => ($Enabled == 2 ? false : true),
72 72
     'class'           => Users::make_class_string($PermissionID),
73 73
     'addedTime'       => $AddedTime,

+ 1
- 1
sections/ajax/tcomments.php View File

@@ -23,7 +23,7 @@ foreach ($Thread as $Key => $Post) {
23 23
       'authorName' => $Username,
24 24
       'artist' => $Artist == 1,
25 25
       'donor' => $Donor == 1,
26
-      'warned' => ($Warned != NULL),
26
+      'warned' => !is_null($Warned),
27 27
       'avatar' => $Avatar,
28 28
       'enabled' => ($Enabled == 2 ? false : true),
29 29
       'userTitle' => $UserTitle

+ 2
- 2
sections/ajax/user.php View File

@@ -308,7 +308,7 @@ if ($ParanoiaLevel == 0) {
308 308
 }
309 309
 
310 310
 //Bugfix for no access time available
311
-if ($LastAccess == NULL) {
311
+if (is_null($LastAccess)) {
312 312
   $LastAccess = '';
313 313
 }
314 314
 
@@ -342,7 +342,7 @@ json_print("success", array(
342 342
     'paranoia'      => (int)$ParanoiaLevel,
343 343
     'paranoiaText'  => $ParanoiaLevelText,
344 344
     'donor'         => ($Donor == 1),
345
-    'warned'        => ($Warned != NULL),
345
+    'warned'        => !is_null($Warned),
346 346
     'enabled'       => ($Enabled == '1' || $Enabled == '0' || !$Enabled),
347 347
     'passkey'       => $torrent_pass
348 348
   ),

+ 1
- 1
sections/ajax/usersearch.php View File

@@ -44,7 +44,7 @@ foreach ($Results as $Result) {
44 44
     'userId' => (int)$UserID,
45 45
     'username' => $Username,
46 46
     'donor' => $Donor == 1,
47
-    'warned' => ($Warned != NULL),
47
+    'warned' => !is_null($Warned),
48 48
     'enabled' => ($Enabled == 2 ? false : true),
49 49
     'class' => Users::make_class_string($PermissionID),
50 50
     'avatar' => $Avatar

+ 1
- 1
sections/forums/poll_mod.php View File

@@ -39,7 +39,7 @@ if (!list($Question,$Answers,$Votes,$Featured,$Closed) = $Cache->get_value('poll
39 39
 }
40 40
 
41 41
 if (isset($_POST['feature'])) {
42
-  if (!$Featured || $Featured == NULL) {
42
+  if (!$Featured || is_null($Featured)) {
43 43
     $Featured = sqltime();
44 44
     $Cache->cache_value('polls_featured',$TopicID,0);
45 45
     $DB->query('

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

@@ -260,7 +260,7 @@ if ($ThreadInfo['NoPoll'] == 0) {
260 260
 
261 261
 ?>
262 262
   <div class="box thin clear">
263
-    <div class="head colhead_dark"><strong>Poll<? if ($Closed) { echo ' [Closed]'; } ?><? if ($Featured && $Featured !== NULL) { echo ' [Featured]'; } ?></strong> <a href="#" onclick="$('#threadpoll').gtoggle(); log_hit(); return false;" class="brackets">View</a></div>
263
+    <div class="head colhead_dark"><strong>Poll<? if ($Closed) { echo ' [Closed]'; } ?><? if ($Featured && !is_null($Featured)) { echo ' [Featured]'; } ?></strong> <a href="#" onclick="$('#threadpoll').gtoggle(); log_hit(); return false;" class="brackets">View</a></div>
264 264
     <div class="pad<? if (/*$LastRead !== null || */$ThreadInfo['IsLocked']) { echo ' hidden'; } ?>" id="threadpoll">
265 265
       <p><strong><?=display_str($Question)?></strong></p>
266 266
 <?  if ($UserResponse !== null || $Closed || $ThreadInfo['IsLocked'] || !Forums::check_forumperm($ForumID)) { ?>
@@ -383,7 +383,7 @@ if ($ThreadInfo['NoPoll'] == 0) {
383 383
       </div>
384 384
 <?  }
385 385
   if (check_perms('forums_polls_moderate') && !$RevealVoters) {
386
-    if (!$Featured || $Featured == NULL) {
386
+    if (!$Featured || is_null($Featured)) {
387 387
 ?>
388 388
       <form class="manage_form" name="poll" action="forums.php" method="post">
389 389
         <input type="hidden" name="action" value="poll_mod" />

+ 2
- 2
sections/login/index.php View File

@@ -68,7 +68,7 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') {
68 68
               m.PassHash = '".db_string(Users::make_sec_hash($_REQUEST['password']))."',
69 69
               i.ResetKey = '',
70 70
               m.LastLogin = NOW(),
71
-              i.ResetExpires IS NULL
71
+              i.ResetExpires = NULL
72 72
             WHERE m.ID = '$UserID'
73 73
               AND i.UserID = m.ID");
74 74
           $DB->query("
@@ -94,7 +94,7 @@ if (isset($_REQUEST['act']) && $_REQUEST['act'] == 'recover') {
94 94
         $DB->query("
95 95
           UPDATE users_info
96 96
           SET ResetKey = '',
97
-            ResetExpires IS NULL
97
+            ResetExpires = NULL
98 98
           WHERE UserID = '$UserID'");
99 99
         $_SESSION['reseterr'] = 'The link you were given has expired.'; // Error message to display on form
100 100
       }

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

@@ -39,7 +39,7 @@ $DB->query("
39 39
   UPDATE requests
40 40
   SET TorrentID = 0,
41 41
     FillerID = 0,
42
-    TimeFilled IS NULL,
42
+    TimeFilled = NULL,
43 43
     Visible = 1
44 44
   WHERE ID = $RequestID");
45 45
 

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

@@ -20,7 +20,7 @@ if (count($OffRatioWatch) > 0) {
20 20
   $DB->query("
21 21
     UPDATE users_info AS ui
22 22
       JOIN users_main AS um ON um.ID = ui.UserID
23
-    SET ui.RatioWatchEnds IS NULL,
23
+    SET ui.RatioWatchEnds = NULL,
24 24
       ui.RatioWatchDownload = '0',
25 25
       um.can_leech = '1',
26 26
       ui.AdminComment = CONCAT('$sqltime - Leeching re-enabled by adequate ratio.\n\n', ui.AdminComment)
@@ -53,7 +53,7 @@ if (count($OffRatioWatch) > 0) {
53 53
   $DB->query("
54 54
     UPDATE users_info AS ui
55 55
       JOIN users_main AS um ON um.ID = ui.UserID
56
-    SET ui.RatioWatchEnds IS NULL,
56
+    SET ui.RatioWatchEnds = NULL,
57 57
       ui.RatioWatchDownload = '0',
58 58
       um.can_leech = '1'
59 59
     WHERE ui.UserID IN(".implode(',', $OffRatioWatch).')');

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

@@ -13,6 +13,6 @@ while (list($UserID) = $DB->next_record()) {
13 13
 
14 14
 $DB->query("
15 15
   UPDATE users_info
16
-  SET Warned IS NULL
16
+  SET Warned = NULL
17 17
   WHERE Warned < '$sqltime'");
18 18
 ?>

+ 1
- 1
sections/store/promotion.php View File

@@ -115,7 +115,7 @@ if ($DB->has_results()) {
115 115
 
116 116
     }
117 117
 
118
-    if ($Warned != NULL) {
118
+    if (!is_null($Warned)) {
119 119
       $Err[] = "You cannot be promoted while warned";
120 120
     }
121 121
 

+ 2
- 2
sections/torrents/details.php View File

@@ -571,14 +571,14 @@ foreach ($TorrentList as $Torrent) {
571 571
             <blockquote>
572 572
               Uploaded by <?=Users::format_username($UserID, false, false, false)?> <?=time_diff($TorrentTime);?>
573 573
 <?  if ($Seeders == 0) {
574
-    if ($LastActive != NULL && time() - strtotime($LastActive) >= 1209600) { ?>
574
+    if (!is_null($LastActive) && time() - strtotime($LastActive) >= 1209600) { ?>
575 575
             <br /><strong>Last active: <?=time_diff($LastActive); ?></strong>
576 576
 <?    } else { ?>
577 577
             <br />Last active: <?=time_diff($LastActive); ?>
578 578
 <?    }
579 579
   }
580 580
 
581
-  if (($Seeders == 0 && $LastActive != NULL && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
581
+  if (($Seeders == 0 && !is_null($LastActive) && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
582 582
             <br /><a href="torrents.php?action=reseed&amp;torrentid=<?=$TorrentID?>&amp;groupid=<?=$GroupID?>" class="brackets">Request re-seed</a>
583 583
 <?  }
584 584
 

+ 2
- 2
sections/torrents/functions.php View File

@@ -416,12 +416,12 @@ function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $G
416 416
             <blockquote>
417 417
               Uploaded by <?=(Users::format_username($UserID, false, false, false))?> <?=time_diff($TorrentTime);?>
418 418
 <?  if ($Seeders == 0) {
419
-    if ($LastActive != NULL && time() - strtotime($LastActive) >= 1209600) { ?>
419
+    if (!is_null($LastActive) && time() - strtotime($LastActive) >= 1209600) { ?>
420 420
                 <br /><strong>Last active: <?=time_diff($LastActive);?></strong>
421 421
 <?    } else { ?>
422 422
                 <br />Last active: <?=time_diff($LastActive);?>
423 423
 <?    }
424
-    if ($LastActive != NULL && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) { ?>
424
+    if (!is_null($LastActive) && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) { ?>
425 425
                 <br /><a href="torrents.php?action=reseed&amp;torrentid=<?=($TorrentID)?>&amp;groupid=<?=($GroupID)?>" class="brackets">Request re-seed</a>
426 426
 <?    }
427 427
   } ?>

+ 1
- 1
sections/torrents/reseed.php View File

@@ -16,7 +16,7 @@ if (!check_perms('users_mod')) {
16 16
   if (time() - strtotime($LastReseedRequest) < 864000) {
17 17
     error('There was already a re-seed request for this torrent within the past 10 days.');
18 18
   }
19
-  if ($LastActive == NULL || time() - strtotime($LastActive) < 345678) {
19
+  if (is_null($LastActive) || time() - strtotime($LastActive) < 345678) {
20 20
     error(403);
21 21
   }
22 22
 }

+ 6
- 6
sections/user/takemoderate.php View File

@@ -226,7 +226,7 @@ $DB->set_query_id($QueryID);
226 226
 if ($_POST['ResetRatioWatch'] && check_perms('users_edit_reset_keys')) {
227 227
   $DB->query("
228 228
     UPDATE users_info
229
-    SET RatioWatchEnds IS NULL, RatioWatchDownload = '0', RatioWatchTimes = '0'
229
+    SET RatioWatchEnds = NULL, RatioWatchDownload = '0', RatioWatchTimes = '0'
230 230
     WHERE UserID = '$UserID'");
231 231
   $EditSummary[] = 'RatioWatch history reset';
232 232
 }
@@ -486,7 +486,7 @@ if (check_perms('users_edit_badges')) {
486 486
   $Cache->delete_value("user_badges_".$UserID);
487 487
 }
488 488
 
489
-if ($Warned == 1 && $Cur['Warned'] == NULL && check_perms('users_warn')) {
489
+if ($Warned == 1 && is_null($Cur['Warned']) && check_perms('users_warn')) {
490 490
   $Weeks = 'week' . ($WarnLength === 1 ? '' : 's');
491 491
   Misc::send_pm($UserID, 0, 'You have received a warning', "You have been [url=".site_url()."wiki.php?action=article&amp;id=218]warned for $WarnLength {$Weeks}[/url] by [user]".$LoggedUser['Username']."[/user]. The reason given was:
492 492
 [quote]{$WarnReason}[/quote]");
@@ -498,8 +498,8 @@ if ($Warned == 1 && $Cur['Warned'] == NULL && check_perms('users_warn')) {
498 498
   $EditSummary[] = db_string($Msg);
499 499
   $LightUpdates['Warned'] = time_plus(3600 * 24 * 7 * $WarnLength);
500 500
 
501
-} elseif ($Warned == 0 && $Cur['Warned'] != NULL && check_perms('users_warn')) {
502
-  $UpdateSet[] = "Warned IS NULL";
501
+} elseif ($Warned == 0 && !is_null($Cur['Warned']) && check_perms('users_warn')) {
502
+  $UpdateSet[] = "Warned = NULL";
503 503
   $EditSummary[] = 'warning removed';
504 504
   $LightUpdates['Warned'] = NULL;
505 505
 
@@ -700,13 +700,13 @@ if ($EnableUser != $Cur['Enabled'] && check_perms('users_disable_users')) {
700 700
     Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'], 'visible' => $VisibleTrIP));
701 701
 
702 702
     if (($Cur['Downloaded'] == 0) || ($Cur['Uploaded'] / $Cur['Downloaded'] >= $Cur['RequiredRatio'])) {
703
-      $UpdateSet[] = "i.RatioWatchEnds IS NULL";
703
+      $UpdateSet[] = "i.RatioWatchEnds = NULL";
704 704
       $CanLeech = 1;
705 705
       $UpdateSet[] = "m.can_leech = '1'";
706 706
       $UpdateSet[] = "i.RatioWatchDownload = '0'";
707 707
     } else {
708 708
       $EnableStr .= ' (Ratio: '.Format::get_ratio_html($Cur['Uploaded'], $Cur['Downloaded'], false).', RR: '.number_format($Cur['RequiredRatio'],2).')';
709
-      if ($Cur['RatioWatchEnds'] != NULL) {
709
+      if (!is_null($Cur['RatioWatchEnds'])) {
710 710
         $UpdateSet[] = "i.RatioWatchEnds = NOW()";
711 711
         $UpdateSet[] = "i.RatioWatchDownload = m.Downloaded";
712 712
         $CanLeech = 0;

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

@@ -375,7 +375,7 @@ if ($LoggedUser['Class'] >= 200 || $DB->has_results()) { ?>
375 375
         <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>><a href="userhistory.php?action=token_history&amp;userid=<?=$UserID?>">Tokens</a>: <?=number_format($FLTokens)?></li>
376 376
 <?
377 377
   }
378
-  if (($OwnProfile || check_perms('users_mod')) && $Warned != NULL) {
378
+  if (($OwnProfile || check_perms('users_mod')) && !is_null($Warned)) {
379 379
 ?>
380 380
         <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Warning expires in: <?=time_diff((date('Y-m-d H:i', strtotime($Warned))))?></li>
381 381
 <?  } ?>
@@ -654,7 +654,7 @@ DonationsView::render_donor_stats($UserID);
654 654
   </div>
655 655
   <div class="main_column">
656 656
 <?
657
-if ($RatioWatchEnds != NULL
657
+if (!is_null($RatioWatchEnds)
658 658
     && (time() < strtotime($RatioWatchEnds))
659 659
     && ($Downloaded * $RequiredRatio) > $Uploaded
660 660
     ) {
@@ -1324,10 +1324,10 @@ if (!$DisablePoints) {
1324 1324
       <tr>
1325 1325
         <td class="label">Warned:</td>
1326 1326
         <td>
1327
-          <input type="checkbox" name="Warned"<? if ($Warned != NULL) { ?> checked="checked"<? } ?> />
1327
+          <input type="checkbox" name="Warned"<? if (!is_null($Warned)) { ?> checked="checked"<? } ?> />
1328 1328
         </td>
1329 1329
       </tr>
1330
-<?    if ($Warned == NULL) { // user is not warned ?>
1330
+<?    if (is_null($Warned)) { // user is not warned ?>
1331 1331
       <tr>
1332 1332
         <td class="label">Expiration:</td>
1333 1333
         <td>

+ 4
- 4
sections/userhistory/email_history2.php View File

@@ -114,25 +114,25 @@ if (count($History) === 1) {
114 114
   $Invite['EndTime'] = $Joined;
115 115
   $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
116 116
   $Invite['IP'] = $History[0]['IP'];
117
-  if ($Current['StartTime'] == NULL) {
117
+  if (is_null($Current['StartTime'])) {
118 118
     $Current['StartTime'] = $Joined;
119 119
   }
120 120
 } else {
121 121
   foreach ($History as $Key => $Val) {
122
-    if (isset($History[$Key + 1]) && $History[$Key + 1]['Time'] == NULL && $Val['Time'] != NULL) {
122
+    if (isset($History[$Key + 1]) && is_null($History[$Key + 1]['Time']) && is_null($Val['Time'])) {
123 123
       // Invited email
124 124
       $Invite['Email'] = $Val['Email'];
125 125
       $Invite['EndTime'] = $Joined;
126 126
       $Invite['AccountAge'] = date(time() + time() - strtotime($Joined)); // Same as EndTime but without ' ago'
127 127
       $Invite['IP'] = $Val['IP'];
128 128
 
129
-    } elseif (isset($History[$Key - 1]) && $History[$Key - 1]['Email'] != $Val['Email'] && $Val['Time'] != NULL) {
129
+    } elseif (isset($History[$Key - 1]) && $History[$Key - 1]['Email'] != $Val['Email'] && !is_null($Val['Time'])) {
130 130
       // Old email
131 131
       $i = 1;
132 132
       while ($Val['Email'] == $History[$Key + $i]['Email']) {
133 133
         $i++;
134 134
       }
135
-      $Old[$Key]['StartTime'] = (isset($History[$Key + $i]) && $History[$Key + $i]['Time'] != NULL) ? $History[$Key + $i]['Time'] : $Joined;
135
+      $Old[$Key]['StartTime'] = (isset($History[$Key + $i]) && !is_null($History[$Key + $i]['Time'])) ? $History[$Key + $i]['Time'] : $Joined;
136 136
       $Old[$Key]['EndTime'] = $Val['Time'];
137 137
       $Old[$Key]['IP'] = $Val['IP'];
138 138
       $Old[$Key]['ElapsedTime'] = date(time() + strtotime($Old[$Key]['EndTime']) - strtotime($Old[$Key]['StartTime']));

Loading…
Cancel
Save