Browse Source

Apparently NULL from the database becomes an empty string in PHP, not null

spaghetti 8 years ago
parent
commit
2e7d189568

+ 1
- 1
classes/script_start.php View File

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

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

4
 }
4
 }
5
 
5
 
6
 function time_ago($TimeStamp) {
6
 function time_ago($TimeStamp) {
7
+  if (!$TimeStamp) { return false; }
7
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
8
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
8
-    if (is_null($TimeStamp)) {
9
-      return false;
10
-    }
11
     $TimeStamp = strtotime($TimeStamp);
9
     $TimeStamp = strtotime($TimeStamp);
12
   }
10
   }
13
-  if ($TimeStamp == 0) {
14
-    return false;
15
-  }
16
   return time() - $TimeStamp;
11
   return time() - $TimeStamp;
17
 }
12
 }
18
 
13
 
21
  * difference in text (e.g. "16 hours and 28 minutes", "1 day, 18 hours").
16
  * difference in text (e.g. "16 hours and 28 minutes", "1 day, 18 hours").
22
  */
17
  */
23
 function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
18
 function time_diff($TimeStamp, $Levels = 2, $Span = true, $Lowercase = false) {
19
+  if (!$TimeStamp) { return 'Never'; }
24
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
20
   if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
25
-    if (is_null($TimeStamp)) {
26
-      return 'Never';
27
-    }
28
     $TimeStamp = strtotime($TimeStamp);
21
     $TimeStamp = strtotime($TimeStamp);
29
   }
22
   }
30
-  if ($TimeStamp == 0) {
31
-    return 'Never';
32
-  }
33
   $Time = time() - $TimeStamp;
23
   $Time = time() - $TimeStamp;
34
 
24
 
35
   // If the time is negative, then it expires in the future.
25
   // If the time is negative, then it expires in the future.

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

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

+ 0
- 16
classes/zip.class.php View File

76
 if (!extension_loaded('zlib')) {
76
 if (!extension_loaded('zlib')) {
77
   error('Zlib Extension not loaded.');
77
   error('Zlib Extension not loaded.');
78
 }
78
 }
79
-/*
80
-//Handles timestamps
81
-function dostime($TimeStamp = 0) {
82
-  if (!is_number($TimeStamp)) { // Assume that $TimeStamp is SQL timestamp
83
-    if (is_null($TimeStamp)) {
84
-      return 'Never';
85
-    }
86
-    $TimeStamp = strtotime($TimeStamp);
87
-  }
88
-  $Date = (($TimeStamp == 0) ? getdate() : getdate($TimeStamp));
89
-  $Hex = dechex((($Date['year'] - 1980) << 25) | ($Date['mon'] << 21) | ($Date['mday'] << 16) | ($Date['hours'] << 11) | ($Date['minutes'] << 5) | ($Date['seconds'] >> 1));
90
-  eval("\$Return = \"\x$Hex[6]$Hex[7]\x$Hex[4]$Hex[5]\x$Hex[2]$Hex[3]\x$Hex[0]$Hex[1]\";");
91
-  return $Return;
92
-}
93
-*/
94
 
79
 
95
 class Zip {
80
 class Zip {
96
   public $ArchiveSize = 0; // Total size
81
   public $ArchiveSize = 0; // Total size
116
     $this->Data .= "\x14\x00"; // Version requirements
101
     $this->Data .= "\x14\x00"; // Version requirements
117
     $this->Data .= "\x00\x08"; // Bit flag - 0x8 = UTF-8 file names
102
     $this->Data .= "\x00\x08"; // Bit flag - 0x8 = UTF-8 file names
118
     $this->Data .= "\x08\x00"; // Compression
103
     $this->Data .= "\x08\x00"; // Compression
119
-    //$this->Data .= dostime($TimeStamp); // Last modified
120
     $this->Data .= "\x00\x00\x00\x00";
104
     $this->Data .= "\x00\x00\x00\x00";
121
     $DataLength = strlen($FileData); // Saved as variable to avoid wasting CPU calculating it multiple times.
105
     $DataLength = strlen($FileData); // Saved as variable to avoid wasting CPU calculating it multiple times.
122
     $CRC32 = crc32($FileData); // Ditto.
106
     $CRC32 = crc32($FileData); // Ditto.

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

140
     $UserInfo = Users::user_info($LastAuthorID);
140
     $UserInfo = Users::user_info($LastAuthorID);
141
     $LastAuthorName = $UserInfo['Username'];
141
     $LastAuthorName = $UserInfo['Username'];
142
     // Bug fix for no last time available
142
     // Bug fix for no last time available
143
-    if (is_null($LastTime)) {
144
-      $LastTime = '';
145
-    }
143
+    if (!$LastTime) { $LastTime = ''; }
146
 
144
 
147
     $JsonTopics[] = array(
145
     $JsonTopics[] = array(
148
       'topicId' => (int)$TopicID,
146
       'topicId' => (int)$TopicID,

+ 21
- 25
sections/ajax/forum/thread.php View File

247
 
247
 
248
 
248
 
249
   $UserInfo = Users::user_info($EditedUserID);
249
   $UserInfo = Users::user_info($EditedUserID);
250
-  $JsonPosts[] = array(
250
+  $JsonPosts[] = [
251
     'postId' => (int)$PostID,
251
     'postId' => (int)$PostID,
252
     'addedTime' => $AddedTime,
252
     'addedTime' => $AddedTime,
253
     'bbBody' => $Body,
253
     'bbBody' => $Body,
255
     'editedUserId' => (int)$EditedUserID,
255
     'editedUserId' => (int)$EditedUserID,
256
     'editedTime' => $EditedTime,
256
     'editedTime' => $EditedTime,
257
     'editedUsername' => $UserInfo['Username'],
257
     'editedUsername' => $UserInfo['Username'],
258
-    'author' => array(
258
+    'author' => [
259
       'authorId' => (int)$AuthorID,
259
       'authorId' => (int)$AuthorID,
260
       'authorName' => $Username,
260
       'authorName' => $Username,
261
       'paranoia' => $Paranoia,
261
       'paranoia' => $Paranoia,
262
       'artist' => $Artist === '1',
262
       'artist' => $Artist === '1',
263
       'donor' => $Donor === '1',
263
       'donor' => $Donor === '1',
264
-      'warned' => !is_null($Warned),
264
+      'warned' => (bool)$Warned,
265
       'avatar' => $Avatar,
265
       'avatar' => $Avatar,
266
       'enabled' => $Enabled === '2' ? false : true,
266
       'enabled' => $Enabled === '2' ? false : true,
267
       'userTitle' => $UserTitle
267
       'userTitle' => $UserTitle
268
-    ),
269
-
270
-  );
268
+    ]
269
+  ];
271
 }
270
 }
272
 
271
 
273
-print
274
-  json_encode(
275
-    array(
276
-      'status' => 'success',
277
-      'response' => array(
278
-        'forumId' => (int)$ForumID,
279
-        'forumName' => $Forums[$ForumID]['Name'],
280
-        'threadId' => (int)$ThreadID,
281
-        'threadTitle' => display_str($ThreadInfo['Title']),
282
-        'subscribed' => in_array($ThreadID, $UserSubscriptions),
283
-        'locked' => $ThreadInfo['IsLocked'] == 1,
284
-        'sticky' => $ThreadInfo['IsSticky'] == 1,
285
-        'currentPage' => (int)$Page,
286
-        'pages' => ceil($ThreadInfo['Posts'] / $PerPage),
287
-        'poll' => empty($JsonPoll) ? null : $JsonPoll,
288
-        'posts' => $JsonPosts
289
-      )
290
-    )
291
-  );
272
+print json_encode([
273
+  'status' => 'success',
274
+  'response' => [
275
+    'forumId' => (int)$ForumID,
276
+    'forumName' => $Forums[$ForumID]['Name'],
277
+    'threadId' => (int)$ThreadID,
278
+    'threadTitle' => display_str($ThreadInfo['Title']),
279
+    'subscribed' => in_array($ThreadID, $UserSubscriptions),
280
+    'locked' => $ThreadInfo['IsLocked'] == 1,
281
+    'sticky' => $ThreadInfo['IsSticky'] == 1,
282
+    'currentPage' => (int)$Page,
283
+    'pages' => ceil($ThreadInfo['Posts'] / $PerPage),
284
+    'poll' => empty($JsonPoll) ? null : $JsonPoll,
285
+    'posts' => $JsonPosts
286
+  ]
287
+]);

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

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

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

10
 foreach ($Thread as $Key => $Post) {
10
 foreach ($Thread as $Key => $Post) {
11
   list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
11
   list($PostID, $AuthorID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername) = array_values($Post);
12
   list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
12
   list($AuthorID, $Username, $PermissionID, $Paranoia, $Artist, $Donor, $Warned, $Avatar, $Enabled, $UserTitle) = array_values(Users::user_info($AuthorID));
13
-  $JsonComments[] = array(
13
+  $JsonComments[] = [
14
     'postId' => (int)$PostID,
14
     'postId' => (int)$PostID,
15
     'addedTime' => $AddedTime,
15
     'addedTime' => $AddedTime,
16
     'bbBody' => $Body,
16
     'bbBody' => $Body,
18
     'editedUserId' => (int)$EditedUserID,
18
     'editedUserId' => (int)$EditedUserID,
19
     'editedTime' => $EditedTime,
19
     'editedTime' => $EditedTime,
20
     'editedUsername' => $EditedUsername,
20
     'editedUsername' => $EditedUsername,
21
-    'userinfo' => array(
21
+    'userinfo' => [
22
       'authorId' => (int)$AuthorID,
22
       'authorId' => (int)$AuthorID,
23
       'authorName' => $Username,
23
       'authorName' => $Username,
24
       'artist' => $Artist == 1,
24
       'artist' => $Artist == 1,
25
       'donor' => $Donor == 1,
25
       'donor' => $Donor == 1,
26
-      'warned' => !is_null($Warned),
26
+      'warned' => (bool)$Warned,
27
       'avatar' => $Avatar,
27
       'avatar' => $Avatar,
28
       'enabled' => ($Enabled == 2 ? false : true),
28
       'enabled' => ($Enabled == 2 ? false : true),
29
       'userTitle' => $UserTitle
29
       'userTitle' => $UserTitle
30
-    )
31
-  );
30
+    ]
31
+  ];
32
 }
32
 }
33
 
33
 
34
-json_die("success", array(
34
+json_die("success", [
35
   'page' => (int)$Page,
35
   'page' => (int)$Page,
36
   'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
36
   'pages' => ceil($NumComments / TORRENT_COMMENTS_PER_PAGE),
37
   'comments' => $JsonComments
37
   'comments' => $JsonComments
38
-));
38
+]);

+ 12
- 14
sections/ajax/user.php View File

308
 }
308
 }
309
 
309
 
310
 //Bugfix for no access time available
310
 //Bugfix for no access time available
311
-if (is_null($LastAccess)) {
312
-  $LastAccess = '';
313
-}
311
+if (!$LastAccess) { $LastAccess = ''; }
314
 
312
 
315
 header('Content-Type: text/plain; charset=utf-8');
313
 header('Content-Type: text/plain; charset=utf-8');
316
 
314
 
317
-json_print("success", array(
315
+json_print("success", [
318
   'username'    => $Username,
316
   'username'    => $Username,
319
   'avatar'      => $Avatar,
317
   'avatar'      => $Avatar,
320
   'isFriend'    => (bool)$Friend,
318
   'isFriend'    => (bool)$Friend,
321
   'profileText' => Text::full_format($Info),
319
   'profileText' => Text::full_format($Info),
322
-  'stats'       => array(
320
+  'stats'       => [
323
     'joinedDate'    => $JoinDate,
321
     'joinedDate'    => $JoinDate,
324
     'lastAccess'    => $LastAccess,
322
     'lastAccess'    => $LastAccess,
325
     'uploaded'      => (int)$Uploaded,
323
     'uploaded'      => (int)$Uploaded,
326
     'downloaded'    => (int)$Downloaded,
324
     'downloaded'    => (int)$Downloaded,
327
     'ratio'         => (float)$Ratio,
325
     'ratio'         => (float)$Ratio,
328
     'requiredRatio' => (float)$RequiredRatio
326
     'requiredRatio' => (float)$RequiredRatio
329
-  ),
330
-  'ranks' => array(
327
+  ],
328
+  'ranks' => [
331
     'uploaded'    => (int)$UploadedRank,
329
     'uploaded'    => (int)$UploadedRank,
332
     'downloaded'  => (int)$DownloadedRank,
330
     'downloaded'  => (int)$DownloadedRank,
333
     'uploads'     => (int)$UploadsRank,
331
     'uploads'     => (int)$UploadsRank,
336
     'posts'       => (int)$PostRank,
334
     'posts'       => (int)$PostRank,
337
     'artists'     => (int)$ArtistsRank,
335
     'artists'     => (int)$ArtistsRank,
338
     'overall'     => (int)$OverallRank
336
     'overall'     => (int)$OverallRank
339
-  ),
340
-  'personal' => array(
337
+  ],
338
+  'personal' => [
341
     'class'         => $ClassLevels[$Class]['Name'],
339
     'class'         => $ClassLevels[$Class]['Name'],
342
     'paranoia'      => (int)$ParanoiaLevel,
340
     'paranoia'      => (int)$ParanoiaLevel,
343
     'paranoiaText'  => $ParanoiaLevelText,
341
     'paranoiaText'  => $ParanoiaLevelText,
344
     'donor'         => ($Donor == 1),
342
     'donor'         => ($Donor == 1),
345
-    'warned'        => !is_null($Warned),
343
+    'warned'        => (bool)$Warned,
346
     'enabled'       => ($Enabled == '1' || $Enabled == '0' || !$Enabled),
344
     'enabled'       => ($Enabled == '1' || $Enabled == '0' || !$Enabled),
347
     'passkey'       => $torrent_pass
345
     'passkey'       => $torrent_pass
348
-  ),
349
-  'community' => array(
346
+  ],
347
+  'community' => [
350
     'posts'           => (int)$ForumPosts,
348
     'posts'           => (int)$ForumPosts,
351
     'torrentComments' => (int)$NumComments,
349
     'torrentComments' => (int)$NumComments,
352
     'artistComments'  => (int)$NumArtistComments,
350
     'artistComments'  => (int)$NumArtistComments,
365
     'snatched'        => (int)$Snatched,
363
     'snatched'        => (int)$Snatched,
366
     'invited'         => (int)$Invited,
364
     'invited'         => (int)$Invited,
367
     'artistsAdded'    => (int)$ArtistsAdded
365
     'artistsAdded'    => (int)$ArtistsAdded
368
-  )
369
-));
366
+  ]
367
+]);
370
 ?>
368
 ?>

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

36
 
36
 
37
 }
37
 }
38
 
38
 
39
-$JsonUsers = array();
39
+$JsonUsers = [];
40
 foreach ($Results as $Result) {
40
 foreach ($Results as $Result) {
41
   list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned, $Avatar) = $Result;
41
   list($UserID, $Username, $Enabled, $PermissionID, $Donor, $Warned, $Avatar) = $Result;
42
 
42
 
43
-  $JsonUsers[] = array(
43
+  $JsonUsers[] = [
44
     'userId' => (int)$UserID,
44
     'userId' => (int)$UserID,
45
     'username' => $Username,
45
     'username' => $Username,
46
     'donor' => $Donor == 1,
46
     'donor' => $Donor == 1,
47
-    'warned' => !is_null($Warned),
47
+    'warned' => (bool)$Warned,
48
     'enabled' => ($Enabled == 2 ? false : true),
48
     'enabled' => ($Enabled == 2 ? false : true),
49
     'class' => Users::make_class_string($PermissionID),
49
     'class' => Users::make_class_string($PermissionID),
50
     'avatar' => $Avatar
50
     'avatar' => $Avatar
51
-  );
51
+  ];
52
 }
52
 }
53
 
53
 
54
-json_die("success", array(
54
+json_die("success", [
55
   'currentPage' => (int)$Page,
55
   'currentPage' => (int)$Page,
56
   'pages' => ceil($NumResults / USERS_PER_PAGE),
56
   'pages' => ceil($NumResults / USERS_PER_PAGE),
57
   'results' => $JsonUsers
57
   'results' => $JsonUsers
58
-));
58
+]);

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

39
 }
39
 }
40
 
40
 
41
 if (isset($_POST['feature'])) {
41
 if (isset($_POST['feature'])) {
42
-  if (!$Featured || is_null($Featured)) {
42
+  if (!$Featured) {
43
     $Featured = sqltime();
43
     $Featured = sqltime();
44
     $Cache->cache_value('polls_featured',$TopicID,0);
44
     $Cache->cache_value('polls_featured',$TopicID,0);
45
     $DB->query('
45
     $DB->query('

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

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

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

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

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

571
             <blockquote>
571
             <blockquote>
572
               Uploaded by <?=Users::format_username($UserID, false, false, false)?> <?=time_diff($TorrentTime);?>
572
               Uploaded by <?=Users::format_username($UserID, false, false, false)?> <?=time_diff($TorrentTime);?>
573
 <?  if ($Seeders == 0) {
573
 <?  if ($Seeders == 0) {
574
-    if (!is_null($LastActive) && time() - strtotime($LastActive) >= 1209600) { ?>
574
+    if ($LastActive && time() - strtotime($LastActive) >= 1209600) { ?>
575
             <br /><strong>Last active: <?=time_diff($LastActive); ?></strong>
575
             <br /><strong>Last active: <?=time_diff($LastActive); ?></strong>
576
 <?    } else { ?>
576
 <?    } else { ?>
577
             <br />Last active: <?=time_diff($LastActive); ?>
577
             <br />Last active: <?=time_diff($LastActive); ?>
578
 <?    }
578
 <?    }
579
   }
579
   }
580
 
580
 
581
-  if (($Seeders == 0 && !is_null($LastActive) && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
581
+  if (($Seeders == 0 && $LastActive && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
582
             <br /><a href="torrents.php?action=reseed&amp;torrentid=<?=$TorrentID?>&amp;groupid=<?=$GroupID?>" class="brackets">Request re-seed</a>
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
             <blockquote>
416
             <blockquote>
417
               Uploaded by <?=(Users::format_username($UserID, false, false, false))?> <?=time_diff($TorrentTime);?>
417
               Uploaded by <?=(Users::format_username($UserID, false, false, false))?> <?=time_diff($TorrentTime);?>
418
 <?  if ($Seeders == 0) {
418
 <?  if ($Seeders == 0) {
419
-    if (!is_null($LastActive) && time() - strtotime($LastActive) >= 1209600) { ?>
419
+    if ($LastActive && time() - strtotime($LastActive) >= 1209600) { ?>
420
                 <br /><strong>Last active: <?=time_diff($LastActive);?></strong>
420
                 <br /><strong>Last active: <?=time_diff($LastActive);?></strong>
421
 <?    } else { ?>
421
 <?    } else { ?>
422
                 <br />Last active: <?=time_diff($LastActive);?>
422
                 <br />Last active: <?=time_diff($LastActive);?>
423
 <?    }
423
 <?    }
424
-    if (!is_null($LastActive) && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) { ?>
424
+    if ($LastActive && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) { ?>
425
                 <br /><a href="torrents.php?action=reseed&amp;torrentid=<?=($TorrentID)?>&amp;groupid=<?=($GroupID)?>" class="brackets">Request re-seed</a>
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
   if (time() - strtotime($LastReseedRequest) < 864000) {
16
   if (time() - strtotime($LastReseedRequest) < 864000) {
17
     error('There was already a re-seed request for this torrent within the past 10 days.');
17
     error('There was already a re-seed request for this torrent within the past 10 days.');
18
   }
18
   }
19
-  if (is_null($LastActive) || time() - strtotime($LastActive) < 345678) {
19
+  if ($LastActive || time() - strtotime($LastActive) < 345678) {
20
     error(403);
20
     error(403);
21
   }
21
   }
22
 }
22
 }

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

486
   $Cache->delete_value("user_badges_".$UserID);
486
   $Cache->delete_value("user_badges_".$UserID);
487
 }
487
 }
488
 
488
 
489
-if ($Warned == 1 && is_null($Cur['Warned']) && check_perms('users_warn')) {
489
+if ($Warned == 1 && !$Cur['Warned'] && check_perms('users_warn')) {
490
   $Weeks = 'week' . ($WarnLength === 1 ? '' : 's');
490
   $Weeks = 'week' . ($WarnLength === 1 ? '' : 's');
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:
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
 [quote]{$WarnReason}[/quote]");
492
 [quote]{$WarnReason}[/quote]");
498
   $EditSummary[] = db_string($Msg);
498
   $EditSummary[] = db_string($Msg);
499
   $LightUpdates['Warned'] = time_plus(3600 * 24 * 7 * $WarnLength);
499
   $LightUpdates['Warned'] = time_plus(3600 * 24 * 7 * $WarnLength);
500
 
500
 
501
-} elseif ($Warned == 0 && !is_null($Cur['Warned']) && check_perms('users_warn')) {
501
+} elseif ($Warned == 0 && $Cur['Warned'] && check_perms('users_warn')) {
502
   $UpdateSet[] = "Warned = NULL";
502
   $UpdateSet[] = "Warned = NULL";
503
   $EditSummary[] = 'warning removed';
503
   $EditSummary[] = 'warning removed';
504
   $LightUpdates['Warned'] = NULL;
504
   $LightUpdates['Warned'] = NULL;
706
       $UpdateSet[] = "i.RatioWatchDownload = '0'";
706
       $UpdateSet[] = "i.RatioWatchDownload = '0'";
707
     } else {
707
     } else {
708
       $EnableStr .= ' (Ratio: '.Format::get_ratio_html($Cur['Uploaded'], $Cur['Downloaded'], false).', RR: '.number_format($Cur['RequiredRatio'],2).')';
708
       $EnableStr .= ' (Ratio: '.Format::get_ratio_html($Cur['Uploaded'], $Cur['Downloaded'], false).', RR: '.number_format($Cur['RequiredRatio'],2).')';
709
-      if (!is_null($Cur['RatioWatchEnds'])) {
709
+      if ($Cur['RatioWatchEnds']) {
710
         $UpdateSet[] = "i.RatioWatchEnds = NOW()";
710
         $UpdateSet[] = "i.RatioWatchEnds = NOW()";
711
         $UpdateSet[] = "i.RatioWatchDownload = m.Downloaded";
711
         $UpdateSet[] = "i.RatioWatchDownload = m.Downloaded";
712
         $CanLeech = 0;
712
         $CanLeech = 0;

+ 5
- 8
sections/user/user.php View File

375
         <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>><a href="userhistory.php?action=token_history&amp;userid=<?=$UserID?>">Tokens</a>: <?=number_format($FLTokens)?></li>
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')) && !is_null($Warned)) {
378
+  if (($OwnProfile || check_perms('users_mod')) && $Warned) {
379
 ?>
379
 ?>
380
         <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Warning expires in: <?=time_diff((date('Y-m-d H:i', strtotime($Warned))))?></li>
380
         <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Warning expires in: <?=time_diff((date('Y-m-d H:i', strtotime($Warned))))?></li>
381
 <?  } ?>
381
 <?  } ?>
654
   </div>
654
   </div>
655
   <div class="main_column">
655
   <div class="main_column">
656
 <?
656
 <?
657
-if (!is_null($RatioWatchEnds)
658
-    && (time() < strtotime($RatioWatchEnds))
659
-    && ($Downloaded * $RequiredRatio) > $Uploaded
660
-    ) {
657
+if ($RatioWatchEnds && (time() < strtotime($RatioWatchEnds)) && ($Downloaded * $RequiredRatio) > $Uploaded) {
661
 ?>
658
 ?>
662
     <div class="box">
659
     <div class="box">
663
       <div class="head">Ratio watch</div>
660
       <div class="head">Ratio watch</div>
1324
       <tr>
1321
       <tr>
1325
         <td class="label">Warned:</td>
1322
         <td class="label">Warned:</td>
1326
         <td>
1323
         <td>
1327
-          <input type="checkbox" name="Warned"<? if (!is_null($Warned)) { ?> checked="checked"<? } ?> />
1324
+          <input type="checkbox" name="Warned"<? if ($Warned) { ?> checked="checked"<? } ?> />
1328
         </td>
1325
         </td>
1329
       </tr>
1326
       </tr>
1330
-<?    if (is_null($Warned)) { // user is not warned ?>
1327
+<?    if (!$Warned) { ?>
1331
       <tr>
1328
       <tr>
1332
         <td class="label">Expiration:</td>
1329
         <td class="label">Expiration:</td>
1333
         <td>
1330
         <td>
1340
           </select>
1337
           </select>
1341
         </td>
1338
         </td>
1342
       </tr>
1339
       </tr>
1343
-<?    } else { // user is warned ?>
1340
+<?    } else { ?>
1344
       <tr>
1341
       <tr>
1345
         <td class="label">Extension:</td>
1342
         <td class="label">Extension:</td>
1346
         <td>
1343
         <td>

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

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

Loading…
Cancel
Save