PDA

View Full Version : anything rong with this code



Jamie.
25-08-2006, 01:10 PM
Hey im still having radio stats trouble, i trying the techtuts 1 just to build on it but i keep getting this error:


Warning: fsockopen() [function.fsockopen]: unable to connect to 193.192.248.244:1903 (Connection refused) in /home/habtune/public_html/Radio statistics/Test.php on line 11

Heres the code:

<?php
//To Install - Copy This Code With The Following Information Into Any .php File
//Login Information
$radiohost='IP HERE';
$radioport='PORT HERE';
$radioofflinemsg='Sorry, No dj is currently on air. The dj may be switching with the next dj, please check the timetable.';
$radiopassword='PASS HERE';
//Do Not Edit Below Here
$timeout='6';
$listenlink='http://'.$radiohost.':'.$radioport.'/listen.pls';
$radio=fsockopen("$radiohost", $radioport, &$errno, &$errstr, $timeout);
if(!$radio){
$success='2';
echo $radioofflinemsg;
die();
}
//Connection
if($success!='2'){ //If Connection
fputs($radio,"Get /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //Get 7.HTML
while(!feof($radio)){
$page.=fgets($radio, 1000);
}
//Data
$page=ereg_replace(".*<body>", "", $page); //Extract Data
$page=ereg_replace("</body>.*", ",", $page); //Extract Data
$numbers=explode(",",$page); //Extract Data
$currentlisteners=$numbers[0]; //Set Variable
$connected=$numbers[1]; //Set Variable
//Open Connection
$fp=fsockopen("$radiohost", $radioport, &$errno, &$errstr, 3);
if(!$fp){ //If Connection
$success2='2';
echo "The Radio Server Is Currently Offline";
}
if($success2!='2'){ //If Connected
fputs($fp,"Get /admin.cgi?pass=$radiopassword&mode=viewxml HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //Get XML Page
while(!feof($fp)){
$page.= fgets($fp, 1000);
}
$security=explode(",",$page);
$security=explode("401",$security[7]);
$u='0';
while($security[$u]!=""){
if($security[1]!='')
{
die("Incorrect Server Password");
}
$u++;
}
//Array
$loop=array("AVERAGETIME", "SERVERGENRE", "SERVERURL", "SERVERTITLE", "SONGTITLE", "SONGURL", "IRC", "ICQ", "AIM", "WEBHITS", "STREAMHITS", "INDEX", "LISTEN", "PALM7",
"LOGIN", "LOGINFAIL", "PLAYED", "COOKIE", "ADMIN", "UPDINFO", "KICKSRC", "KICKDST", "UNBANDST", "BANDST", "VIEWBAN", "UNRIPDST", "VIEWRIP", "VIEWXML",
"VIEWLOG", "INVALID"); //Define All The Variables To Get (Delete Any Ones You Don't Want)
$y='0';
while($loop[$y]!=''){ //While There Are Things In The Loop
$pageed=ereg_replace(".*<$loop[$y]>", "", $page); //Extract Data
$phpname=strtolower($loop[$y]);
$$phpname=ereg_replace("</$loop[$y]>.*", "", $pageed); //Finish Extracting Data
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE)
$$phpname=urldecode($$phpname);
$phpname = $phpname;
$y++;
}
}
if($connected=='1')
$wordconnected="yes";
else
$wordconnected="no";
$peaklisteners=$numbers[2];
$maxlisteners=$numbers[3];
$reportedlisteners=$numbers[4];
$song=$numbers[6];
$bitrate=$numbers[5];
$site=explode(" ", $servertitle);
$title=explode("DJ",$servertitle);
if($wordconnected=="no" && $connected=="0")
{
echo $radioofflinemsg;
}else{
echo"<div align=\"center\">
<table align=\"center\">
<tr>
<td align=\"center\">
<a href=\"http://$serverurl\">$servertitle</a>
</td>
</tr>
<tr>
<td align=\"center\">
<center>$reportedlisteners/$maxlisteners Listeners<br />Bitrate: ".$bitrate."Kbps<p>
Current Song: <br />$numbers[6]</p>
</td>
</tr>
<tr>
<td align=\"center\">
<a href=$listenlink></a>
</td>
</tr>
<tr>
<td align=\"center\"><br />

</td></tr>
</table>
</div>
";
//Close Connection
fclose($radio);
}
}
?>



Line 11:

$radio=fsockopen("$radiohost", $radioport, &$errno, &$errstr, $timeout);


so if u can help ;)

ClubTime
25-08-2006, 01:12 PM
$radiohost='IP HERE';
$radioport='PORT HERE';
$radioofflinemsg='Sorry, No dj is currently on air. The dj may be switching with the next dj, please check the timetable.';
$radiopassword='PASS HERE';
//Do Not Edit Below Here


put your radio info in where it says

Jamie.
25-08-2006, 01:15 PM
i have, just removed so ppl wont hack :)

JoeComins
25-08-2006, 01:33 PM
So youve removed that line?

If you do, then you wont be able to use it. You need that info in.

the wombats
25-08-2006, 01:34 PM
So youve removed that line?

If you do, then you wont be able to use it. You need that info in.

He means he removed the info so he could post it here.

ClubTime
25-08-2006, 01:39 PM
Ask for help on techtuts if your making it from there

Mentor
25-08-2006, 01:45 PM
the errors pretty obvious if you read it. "unable to connect to 193.192.248.244:1903"

Aka that host is refuseing your connection meaning ether some of the details or wrong or its not working correctly

Jamie.
25-08-2006, 03:55 PM
hmm proberly host as you say, as they gone mental last few days.

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