PDA

View Full Version : errors with radio stats



bunc.man
15-06-2008, 10:12 PM
hi im in need off some help, i have a radio_stats code php page when i have the details correct and pages linked correctly i get a

Warning: fsockopen() [function.fsockopen (http://www.habbomelody.com/function.fsockopen)]: unable to connect to 66.79.188.157:8220 in /home/habbomel/public_html/radio_stats.php on line 3
www.habbomelody.com (http://www.habbomelody.com)

below is my config code

<?php
$scdef = "www.habbomelody.com"; // Default station name to display when server or stream is down
$scip = ""; // ip or url of shoutcast server (DO NOT ADD HTTP:// )
$scport = ""; // port of shoutcast server
$scpass = ""; // password to shoutcast server
?>


obvious my details are in the part but im not going to say them on here.

and here is my radio_stats code

<?php
include('sn_config_radio.php'); //you may edit this path to fit your server environment otherwise leave it alone
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
if(!$scfp) {
$scsuccs=1;
echo''.$scdef.'1';
}
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);
}
################################################## ################################################## ##################
/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//define xml elements
$loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS");
$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);
// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
$y++;
}
//end intro xml elements
################################################## ################################################## ##################
################################################## ################################################## ##################
/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//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'
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel=stylesheet href="" type="text/css">
<title>'.$scdef.'</title>
</head>
<body text="#000000" bgcolor="#99CCFF">

<font face="Tahoma" size="1">
<b>&nbsp;Dj:</b>&nbsp;'.$servertitle.'</p>
<b>&nbsp;Listeners:</b>&nbsp;'.$currentlisteners.'</p>
<b>
Current Song:</b> '.$song[0].'
<br>
<br>
<b>Past Songs:</b>
<br>
<b>1.</b> '.$song[1].'<BR>
<b>2.</b> '.$song[2].'<BR>
<b>3.</b> '.$song[3].'<BR>
<b>4.</b> '.$song[4].'<BR>
</font>
</body>
</html>';
}
if($streamstatus == "0")
{
echo'
<html>
</body>
<head>
<title>Radio Server Is Offline</title>
</head>

</body>
</html>';
}
?>

with this code i keep getting the errors can anyone help me.

if it helps im using the php page on my main website host
if that is related to remote connections.

skateforlife
30-08-2008, 06:29 PM
have you tried using diff stats?

Anastasia
31-08-2008, 03:40 PM
Try using different stats as said above. Good Luck!

iUnknown
31-08-2008, 05:50 PM
I knew my tut would be useful, even on habboxforum. Read this thread, and tell your host about it too:

http://www.habboxforum.com/showthread.php?t=513298

Xtreamerthaneve
07-09-2008, 01:47 AM
Your host might not have that port open as well. Everytime I change radio servers, and have a different port, I have to get my host to open it.

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