Add null check for history lookups

This commit is contained in:
Ruan 2015-07-09 14:07:56 +02:00
parent 928594e9b9
commit 84341fcd6e
4 changed files with 24 additions and 20 deletions

View File

@ -13,22 +13,23 @@
global $table_bans, $conn, $show_inactive_bans; global $table_bans, $conn, $show_inactive_bans;
$result = run_query($table_bans); $result = run_query($table_bans);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$timeResult = millis_to_date($row['time']); $player_name = get_name($row['uuid']);
$expiresResult = millis_to_date($row['until']); if ($player_name === null) continue;
$until = millis_to_date($row['until']);
?> ?>
<tr> <tr>
<td><?php echo get_avatar(get_name($row['uuid'])); ?></td> <td><?php echo get_avatar($player_name); ?></td>
<td><?php echo get_avatar(get_banner_name($row)); ?></td> <td><?php echo get_avatar(get_banner_name($row)); ?></td>
<td style="width: 30%;"><?php echo clean($row['reason']); ?></td> <td style="width: 30%;"><?php echo clean($row['reason']); ?></td>
<td><?php echo $timeResult; ?></td> <td><?php echo millis_to_date($row['time']); ?></td>
<td> <td>
<?php if ($row['until'] <= 0) { <?php if ($row['until'] <= 0) {
$expiresResult = 'Permanent Ban'; $until = 'Permanent Ban';
} }
if ($show_inactive_bans && !$row['active']) { if ($show_inactive_bans && !$row['active']) {
$expiresResult .= ' (Unbanned)'; $until .= ' (Unbanned)';
} }
echo $expiresResult; echo $until;
?> ?>
</td> </td>
</tr> </tr>

View File

@ -101,7 +101,7 @@ function print_check_form($table) {
<form onsubmit="captureForm(event);" class="form-inline"><div class="form-group"><input type="text" class="form-control" id="user" placeholder="Player"></div><button type="submit" class="btn btn-default" style="margin-left: 5px;">Check</button></form> <form onsubmit="captureForm(event);" class="form-inline"><div class="form-group"><input type="text" class="form-control" id="user" placeholder="Player"></div><button type="submit" class="btn btn-default" style="margin-left: 5px;">Check</button></form>
</div> </div>
<script type="text/javascript">function captureForm(b){o=$("#output");o.removeClass("in");x=setTimeout(function(){o.html("<br>")}, 150);$.ajax({type:"POST",url:"check.php",data:{name:$("#user").val(),table:"' . $table . '"}}).done(function(c){clearTimeout(x);o.html(c);o.addClass("in")});b.preventDefault();return false};</script> <script type="text/javascript">function captureForm(b){o=$("#output");o.removeClass("in");x=setTimeout(function(){o.html("<br>")}, 150);$.ajax({type:"POST",url:"check.php",data:{name:$("#user").val(),table:"' . $table . '"}}).done(function(c){clearTimeout(x);o.html(c);o.addClass("in")});b.preventDefault();return false};</script>
<div id="output" class="success fade" data-alert="alert" style="margin-left: 15px;"></div> <div id="output" class="success fade" data-alert="alert" style="margin-left: 15px;"><br></div>
</div> </div>
'); ');
} }

View File

@ -12,22 +12,23 @@
global $table_mutes, $conn, $show_inactive_bans; global $table_mutes, $conn, $show_inactive_bans;
$result = run_query($table_mutes); $result = run_query($table_mutes);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$timeResult = millis_to_date($row['time']); $player_name = get_name($row['uuid']);
$expiresResult = millis_to_date($row['until']); if ($player_name === null) continue;
$until = millis_to_date($row['until']);
?> ?>
<tr> <tr>
<td><?php echo get_avatar(get_name($row['uuid'])); ?></td> <td><?php echo get_avatar($player_name); ?></td>
<td><?php echo get_avatar(get_banner_name($row)); ?></td> <td><?php echo get_avatar(get_banner_name($row)); ?></td>
<td style="width: 30%;"><?php echo clean($row['reason']); ?></td> <td style="width: 30%;"><?php echo clean($row['reason']); ?></td>
<td><?php echo $timeResult; ?></td> <td><?php echo millis_to_date($row['time']); ?></td>
<td> <td>
<?php if ($row['until'] <= 0) { <?php if ($row['until'] <= 0) {
$expiresResult = 'Permanent Mute'; $until = 'Permanent Mute';
} }
if ($show_inactive_bans && !$row['active']) { if ($show_inactive_bans && !$row['active']) {
$expiresResult .= ' (Unmuted)'; $until .= ' (Unmuted)';
} }
echo $expiresResult; echo $until;
?> ?>
</td> </td>
</tr> </tr>

View File

@ -12,20 +12,22 @@
global $table_warnings, $conn, $show_inactive_bans; global $table_warnings, $conn, $show_inactive_bans;
$result = run_query($table_warnings); $result = run_query($table_warnings);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$expiresResult = millis_to_date($row['until']); $player_name = get_name($row['uuid']);
if ($player_name === null) continue;
$until = millis_to_date($row['until']);
?> ?>
<tr> <tr>
<td><?php echo get_avatar(get_name($row['uuid'])); ?></td> <td><?php echo get_avatar($player_name); ?></td>
<td><?php echo get_avatar(get_banner_name($row)); ?></td> <td><?php echo get_avatar(get_banner_name($row)); ?></td>
<td style="width: 30%;"><?php echo clean($row['reason']); ?></td> <td style="width: 30%;"><?php echo clean($row['reason']); ?></td>
<td> <td>
<?php if ($row['until'] <= 0) { <?php if ($row['until'] <= 0) {
$expiresResult = 'Permanent Warning'; $until = 'Permanent Warning';
} }
if ($show_inactive_bans && !$row['active']) { if ($show_inactive_bans && !$row['active']) {
$expiresResult .= ' (Expired)'; $until .= ' (Expired)';
} }
echo $expiresResult; echo $until;
?> ?>
</td> </td>
<td> <td>