Hello, I'm more of a designer/Flash/CSS.. have been trying along with help threads here but just can't get it to work.
I'm trying to run the following as a PHP Direct Eval page, but getting syntax errors:
So I learned a bit about converting echo's, using outputs etc, but just can't manage.
Could anyone help getting this code into a working CMS page? It should display a nice table form, I'll be applying CSS and correct images to load in.
I'm trying to run the following as a PHP Direct Eval page, but getting syntax errors:
PHP Code:
<?php
//use cURL to get the data from TRION DO NOT EDIT THE LINES BELOW!!!
//IF YOU WANT TO EDIT TEXT JUMP TO LINE 28
function fetchXML($url)
{
$ch = curl_init();
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
define("USE_CURL", true);
$url = "http://www.riftgame.com/en/status/na-status.xml";
//get xml doc
$data = fetchXML($url);
//create a SimpleXML object to parse the xml
$status = new SimpleXmlElement($data);
//Display the Header for shard info table
echo "<h3>Current Shard Status:</h3>";
echo "<div style=\"width:600px; padding:3px; margin:3px;\">";
echo "<div style=\"width:125px; float:left; font-weight:bold;\">Shard Name:</div>";
echo "<div style=\"width:75px; float:left; font-weight:bold;\">Status:</div>";
echo "<div style=\"width:90px; float:left; font-weight:bold;\">Population:</div>";
echo "<div style=\"width:90px; float:left; font-weight:bold;\">Server Type:</div>";
echo "</div>";
//Print basic shard info then loop through it DO NOT EDIT!!!
foreach($status->shard as $result){
//Define Variables for Each Attribute DO NOT EDIT!!!
$shardname = $result->attributes()->name;
$status = $result->attributes()->online;
$population = $result->attributes()->population;
$pvp = $result->attributes()->pvp;
$rp = $result->attributes()->rp;
$locked = $result->attributes()->locked;
?>
<div style="width: 600px; padding: 3px; margin: 3px;">
<div style="width: 125px; float: left;"><?php echo $shardname;?></div>
<div style="width: 75px; float: left;">
<?php if($status == 'True'){?>
<img src="../online.png" width="25" height="25" alt="Shard is Currently Online" />
<?php }else{ ?>
<img src="../offline.png" width="25" height="25" alt="Shard is Currently Offline" />
<?php } ?>
</div>
<div style="width: 90px; float: left;">
<?php if($locked == 'true'){echo "<img src=\"../locked.png\" height=\"25\" width=\"25\" alt=\"The Shard is currently LOCKED\" />";}else{
if($population == 'low'){ echo "<img src=\"../low_pop.png\" width=\"25\" height=\"25\" alt=\"Population is currently LOW\" />"; }
elseif($population == 'medium'){ echo "<img src=\"../med_pop.png\" width=\"25\" height=\"25\" alt=\"Population is currently MEDIUM\" />"; }
elseif($population == 'high'){ echo "<img src=\"../high_pop.png\" width=\"25\" height=\"25\" alt=\"Population is currently HIGH\" />"; }
else{ echo "<img src=\"../full_pop.png\" width=\"25\" height=\"25\" alt=\"Population is currently FULL\" />"; }}?>
</div>
<div style="width: 90px; float: left;">
<?php if($pvp =='False' && $rp =='False'){echo "PVE";}
elseif($pvp =='True' && $rp =='False'){echo "PVP";}
elseif($pvp =='False' && $rp =='True'){echo "PVE-RP";}
else{echo "PVP-RP";}
?>
</div>
</div>
<? } ?>
Could anyone help getting this code into a working CMS page? It should display a nice table form, I'll be applying CSS and correct images to load in.
Comment