$end = $start + $size; if (!empty($filter)) { $start = 0; $end = $total; } for ($i = $start; $i < $end; ++$i) { if (!isset($playerNames[$i])) { break; } $player = $found[$playerNames[$i]]; $expireTime = $player['expires'] + $mysqlSecs - $timeNow; if ($player['expires'] == 0) { $expires = '<span class="label label-danger">Permanent</span>'; } else { if (isset($expireTime) && $expireTime > 0) { $expires = '<span class="label label-warning">' . secs_to_hmini($expireTime) . '</span>'; } else { $expires = '<span class="label label-warning">Expired</span>'; } } if (!empty($filter)) { $skip = false; switch ($filterCol) { case 0: if (stripos($playerNames[$i], $filter) === false) { $skip = true; } break; case 1: if (stripos($player['type'], $filter) === false) { $skip = true;
function latestWarnings($server, $serverID) { global $settings; // Clear old latest warnings cache's clearCache($serverID . '/latestwarnings', 300); clearCache($serverID . '/mysqlTime', 300); $result = cache("SELECT HEX(player_id) AS player_id, p.name, a.name AS actor_name, reason, created, expires FROM " . $server['playerWarningsTable'] . " b JOIN " . $server['playersTable'] . " p ON b.player_id = p.id JOIN " . $server['playersTable'] . " a ON b.actor_id = a.id ORDER BY created DESC LIMIT " . $settings['widget_warnings_count'], $settings['cache_home'], $serverID . '/search', $server); if (isset($result[0]) && !is_array($result[0]) && !empty($result[0])) { $result = array($result); } $rows = count($result); if ($rows == 0) { echo '<li><span class="label label-info">No Records</span></li>'; } else { $timeDiff = cache('SELECT (' . time() . ' - UNIX_TIMESTAMP(now()))/3600 AS mysqlTime', 5, $serverID . '/mysqlTime', $server); // Cache it for a few seconds $mysqlTime = $timeDiff['mysqlTime']; $mysqlTime = $mysqlTime > 0 ? floor($mysqlTime) : ceil($mysqlTime); $mysqlSecs = $mysqlTime * 60 * 60; foreach ($result as $r) { $playername = $r['name']; $actorname = $r['actor_name']; echo '<li class="latestban"><a href="index.php?action=viewplayer&player=' . $playername . '&server=' . $serverID . '"><img src="' . str_replace(array('%name%', '%uuid%'), array($playername, $r['player_id']), $settings['skin']['helm']) . '" class="skin-helm" /> ' . $playername . '</a><button class="btn btn-info ban-info" rel="popover" data-html="true" data-content="' . str_replace('"', '"', $r['reason']) . '" data-original-title="' . $actorname; if ($r['expires'] == 0) { echo ' <span class=\'label label-danger\'>Never</span>'; } else { if ($expires > 0) { echo ' <span class=\'label label-warning\'>' . secs_to_hmini($expires) . '</span>'; } else { echo ' <span class=\'label label-success\'>Now</span>'; } } echo '"><span class="glyphicon glyphicon-info-sign"></span></button></li>'; } } }