|
Senior Member
|
05-09-2012
, 08:40
Re: Trash this one
|
#68
|
Quote:
Originally Posted by 8088
http://awesomatic.net/crap/status/styled.php
PHP Code:
<?php ini_set("display_errors", "2"); ERROR_REPORTING(E_ALL);
require_once('JG_Cache.php'); require_once('SourceQuery.class.php');
$servers = array( // add servers like this: //'server_01' => array ('name' => 'My shitty server', 'ip' => 'abc.example.com', 'port' => '27015'), 'server_02' => array('name' => 'My crap server', 'ip' => '8.6.2.43', 'port' => '27015'), 'server_03' => array('name' => 'My awesome server', 'ip' => '189.74.29.220', 'port' => '27015') );
$i = 0; $rows = array(); foreach ($servers as $server) {
$cache = new JG_Cache('/tmp'); $info = $cache->get($server['name'], 60); // second paramater = cache time in seconds
if ($info === false) { $query = new SourceQuery(); try { $query->Connect($server['ip'], $server['port']); $info = $query->GetInfo(); } catch (SourceQueryException $e) { $info = $e->getMessage(); } $cache->set($server['name'], $info); }
if ($i % 2 == 0) { $class = 'even'; } else { $class = 'odd'; }
if (is_array($info)) { $rows[$i]['class'] = $class; $rows[$i]['ip'] = $server['ip']; $rows[$i]['port'] = $server['port']; $rows[$i]['map'] = $info['Map']; $rows[$i]['players'] = $info['Players']; $rows[$i]['maxplayers'] = $info['MaxPlayers']; $rows[$i]['servername'] = $info['HostName']; $rows[$i]['a_class'] = 'online'; } else { $rows[$i]['class'] = $class; $rows[$i]['ip'] = $server['ip']; $rows[$i]['port'] = $server['port']; $rows[$i]['map'] = 'n/a'; $rows[$i]['players'] = 'n'; $rows[$i]['maxplayers'] = 'a'; $rows[$i]['servername'] = $server['name']; $rows[$i]['a_class'] = 'offline'; } $i++; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>hi</title> <style> html, body { font:10px Verdana; } table { background-color:#eeeded; } td, th { padding:5px; }
th { background-color:#212121; color:#fff; text-transform:capitalize; } .odd { background-color:#dcdcdc; }
a, a:visited { display:block; color:#fff; background-color:#51a619; padding:5px; border-radius: 5px; border:1px solid #357f07; text-decoration:none; } a.offline { background-color:#c51c00; border:1px solid #300700; } a:hover, a.offline:hover { color:#51a619; background-color:#fff; } tfoot td { text-align:right; } </style> </head> <body> <table> <thead> <tr> <th>server</th><th>players</th><th>map</th><th></th> </tr> </thead> <tbody> <?php foreach ($rows as $row): ?> <tr class="<?php echo $row['class']; ?>"> <td><?php echo htmlspecialchars($row['servername']); ?></td> <td><?php echo $row['players']; ?>/<?php echo $row['maxplayers']; ?></td> <td><?php echo htmlspecialchars($row['map']); ?></td> <td> <a class="<?php echo $row['a_class']; ?>" href="steam://connect/<?php echo $row['ip'] . ':' . $row['port']; ?>" title="connect">connect</a> </td> </tr> <?php endforeach; ?> </tbody> <tfoot> <tr> <td colspan="4"><?php echo count($rows) . ' items'; ?></td> </tr> </tfoot> </table> </body> </html>
@omer: you're a dick
|
Thanks 8088!!! very much just one thing and i'll leave you in peace lol.. would it be possible for this styled one to also list the player names on it? not a biggie but just wondering.
|
|
|
|