Log in

View Full Version : An error already! Hehe



Jackboy
10-04-2008, 06:12 PM
As expected, i don't do php for a few months, come back and DUH! Lol

I just bought a shoutcast server and im having trouble with the stats :P

It says theres an error connecting to the ip. I don't know if this is because the host hasn't allowed access adn i need to contact them? Any help will be +Repped


<?
// ** CONFIGURATION ** - Please enter details within the speech marks
//Radio IP
$scip = "78.129.167.15";
//Radio port
$scport = "8262";
//Radio password
$scpass = "MYPASSWORD :)";
//If offline, say:
$offlinemsg = "Sorry! The radio is currently offline!";
// ** END CONFIGURATION **
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo $offlinemsg;
}
if($scsuccs!=1){
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
while(!feof($scfp)) {
$page .= fgets($scfp, 1000);
}
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
$y++;
}
//end intro xml elements
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
//end song info
fclose($scfp);
}
//display stats
if($streamstatus == "1"){
//you may edit the html below, make sure to keep variable intact
echo "
<p align=center><center>
<b>DJ:</b> $servertitle<br>
<b>Listeners:</b> $currentlisteners / $maxlisteners<br>
<b>Current Song:</b> $song[0]</p>
<p><b>Song History</b></p>
<p><b>1.</b> $song[1]<br>
<b>2.</b> $song[2]<br>
<b>3.</b> $song[3]<br>
<b>4.</b> $song[4]<br></p>
";
}
//If radio is offline.
if($streamstatus == "0")
{
echo "<p>$offlinemsg</p>";
}
?>

Jackboy
13-04-2008, 01:19 PM
Well thanks for all your help lmao. :P

But i got it sorted, was my hosts firewall.

Want to hide these adverts? Register an account for free!