For some some reason i can't get this code to work on my site. It works fine on my other site and i checked and the widget is accepting PHP coding. Can anyone help me out? I person made this code for me a long time ago and though the years i modified it, its to view online and offline steams from twitch.tv
<?php
define("SHOW_OFFLINE_STREAMS", true);
$streams = array(
new streamer("Believe", "gm", "p", "iambelieve"),
new streamer("Legend", "gm", "t", "EliteLegend"),
new streamer("WinD", "gm", "z", "neomaestro"),
new streamer("dheinzen", "d", "z", "dheinzen13"),
new streamer("MyaurA", "d", "z", "myaurasc2"),
new streamer("PingPang", "d", "t", "stephen_c"),
);
class streamer
{
private $name;
private $league;
private $race;
private $streamID;
private $online;
public function __construct($nName, $nLeague, $nRace, $nStreamID) {
$this->name = $nName;
$this->league = strtolower($nLeague);
$this->race = strtolower($nRace);
$this->streamID = strtolower($nStreamID);
$this->online = false;
}
public function isOnline() {return $this->online;}
public function setOnline($bool) {$this->online = $bool;}
public function getStreamID() {return $this->streamID;}
private function onlineStatusImage() {
if($this->online) {
return "<img src='http://stratk.com/wp-content/uploads/2014/06/online.png'/>";
} else {
return "<img src='http://stratk.com/wp-content/uploads/2014/05/OfflineIcon1.png'/>";
}
}
private function streamLeagueImage() {
switch($this->league) {
case "gm":
return "<img src='http://stratk.com/wp-content/uploads/2014/06/grade1.png'/>";
case "m":
return "<img src='http://stratk.com/wp-content/uploads/2014/06/masterS.png'/>";
case "d":
return "<img src='http://stratk.com/wp-content/uploads/2014/06/diamondS.png'/>";
case "p":
return "<img src='http://stratk.com/wp-content/uploads/2014/06/diamondS.png'/>";
case "g":
return "<img src='http://stratk.com/wp-content/uploads/2014/05/Gold.png'/>";
case "s":
return "<img src='http://stratk.com/wp-content/uploads/2014/05/Silver.png'/>";
case "b":
return "<img src='http://stratk.com/wp-content/uploads/2014/05/Bronze.png'/>";
default:
return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/sRandomIcon.png'/>";
}
}
private function streamRaceImage() {
switch($this->race) {
case "t":
return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/Ticon_small.png'/>";
case "p":
return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/Picon_small.png'/>";
case "z":
return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/Zicon_small.png'/>";
case "r":
return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/sRandomIcon.png'/>";
default:
return "<img src='http://all-inspiration.com/wp-content/uploads/2013/06/sRandomIcon.png'/>";
}
}
private function streamLink() {
return "<a>streamID."'>".$this->name."</a>";
}
public function linkTextLine() {
return $this->onlineStatusImage().$this->streamLeagueImage().$this->streamRaceImage().$this->streamLink();
}
}
$nameArray = array();
foreach($streams as $stream) {$nameArray[] = $stream->getStreamID();}
$json_file = file_get_contents("http://api.justin.tv/api/stream/list.json?channel=".implode(',',$nameArray), 0, null, null);
$json_array = json_decode($json_file, true);
foreach($streams as $stream) {
foreach($json_array as $api) {
if ($api['name'] == "live_user_{$stream->getStreamID()}") {
$stream->setOnline(true);
}
}
}
echo "<ul style='list-style-type:none !important'>";
foreach($streams as $stream) {
if(SHOW_OFFLINE_STREAMS) {
echo "<li style='list-style:none !important;'>".$stream->linkTextLine()."\n";
} else {
if($stream->isOnline()) {
echo "<li style='list-style:none !important;'>".$stream->linkTextLine()."\n";
}
}
}
echo "";
?>
[Moderator Note: Please post code or markup between backticks or use the code button. Or better still - use a pastebin. Your posted code may now have been permanently damaged by the forum's parser.]