Rift Shard Status Block
Mod Version: 1.01, by Jedric
vB Version: 4.x.x |
Rating: (1 vote - 5.00 average) |
Installs: 8 |
Released: 27 Feb 2011 |
Last Update: Never |
Downloads: 0 |
Not Supported
Re-usable Code
|
Want to add a shard status block for Rift to your forums or CMS?
- Go to Forums & Moderators, Forum Blocks Manager. Click "Add Block".
- For the title, name it something like "______ Shard Status".
- Cache Time = 1
- Active = Yes
- Content Type = PHP
- Content:
PHP Code:
// The URL of the official shard status feed
define ('URL', 'http://www.riftgame.com/en/status/na-status.xml');
// Change this to the name of your shard
define ('SHARD', 'Deepstrike');
if(($fp = fopen(URL, 'r'))) {
$respMsg = '';
while(!feof($fp)) {
$buffer .= fgets($fp, 128);
}
fclose($fp);
$output = '';
$doc = DOMDocument::loadXML($buffer);
if ($doc) {
$domXPath = new DOMXPath($doc);
$filtered = $domXPath->query('/status/shard[@name="' . SHARD . '"]');
if ($filtered->length == 1) {
$shardStatus = $filtered->item(0);
$shardIsUp = (strcasecmp($shardStatus->getAttribute('online'), 'True') == 0);
$shardPopulation = $shardStatus->getAttribute('population');
if (strcasecmp($shardPopulation, 'high') == 0) {
$shardPopulation = '<span style="color: red;">High</span>';
} else if (strcasecmp($shardPopulation, 'medium') == 0) {
$shardPopulation = '<span style="color: orange;">Medium</span>';
} else if (strcasecmp($shardPopulation, 'low') == 0) {
$shardPopulation = '<span style="color: green;">Low</span>';
}
$shardIsLocked = (strcasecmp($shardStatus->getAttribute('locked'), 'True') == 0);
$shardQueue = $shardStatus->getAttribute('queued');
$output .= '<center><p><b>Status:</b><br>';
if ($shardIsLocked) {
$output .= '<span style="color: red;">Locked</span>';
} else if ($shardIsUp) {
$shardIsUp ? $output .= '<span style="color: green;">Online</span>' : $output .= '<span style="color: red;">Offline</span>';
$output .= '</p><p><b>Population:</b><br>';
$output .= $shardPopulation . '<br></p><p><b>Queue:</b><br>' . $shardQueue . '</p>';
}
$output .= '<br />Code by <a href="http://nervehq.com" target="_blank">Nerve</a>.';
$output .= '</center>';
return $output;
}
}
} else {
return '';
}
- Change define ('SHARD', 'Deepstrike'); to define ('SHARD', 'YourShardName');
- Click "Save".
- You are done.
Example:
http://nervehq.com/forums/
Download
No files for download.
|