fsockopen errors - Shoutcast Now Playing script

NoelF1

New member
Hi techies,

I'm trying to use a "Shoutcast Now Playing" script

which can be found here:
Code:
http://radiosolution.info/clients/knowledgebase/36/Now-playing-script-for-Shoutcast.html
and an example:
Code:
http://www.radiosolution.info/tools/nowplaying.php


now I'm having a problem with the same script on my site
Code:
http://noelborg.com/testing/stats/radio_stats.php

Do you allow connections via "fsockopen" ? Can I use such script, please?
username: noelpro
 

Genesis

Administrator
Staff member
Depends on whether the connection is closed by default for security reasons. DJB or un4saken would be able to confirm whether it is closed.
 

NoelF1

New member
jaran said:
When I try to visit your site then the problem look appear like this.
Code:
Fatal error: Call-time pass-by-reference has been removed in /home/noelpro/public_html/testing/stats/radio_stats.php on line 16

It seem the problem is coming from line 16. I found other related article which is disscussing the problem like yours.

http://stackoverflow.com/questions/8971261/php-5-4-call-time-pass-by-reference-easy-fix-available.


I honestly have no idea what you're talking about. Didn't find that cose in the radio_stats,php.

This is the code I've got at present.

Code:
  <?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// ?2004-2005 Daniel Brown http://www.gmtt.co.uk
// Please refer to the readme file for use.


// Add-On MAXLISTNERS insead of the / 10 MAXLISTENERS which was set, and the BITRATE add-on.
// Online and Offline graphics, and add-on code.
// Better HTML Script.

// Do Not Try To Edit This Only Unless You Know What You're Doing!!!!!!!

include('config_radio.php');

$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
 if(!$scfp) {
  $scsuccs=1;
echo''.$scdef.' is Offline'; 
 }
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", "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);

// 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 http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel=stylesheet href="" type="text/css">
<title>'.$scdef.'</title>
</head>

<body text="" bgcolor="">


<p align="center"><center>
<img src="online.jpg"><br>
<b>Stream Title:</b> '.$servertitle.'<br>
<b>Listeners:</b> '.$currentlisteners.' / '.$maxlisteners.'<br>
<b>Bitrate:</b> '.$bitrate.'kbps<br>
<b>Current Song:</b> '.$song[0].'</p><b>
</p>
</body>

</html>';
}
if($streamstatus == "0")
{
//you may edit the html below, make sure to keep variable intact
echo'
<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel=stylesheet href="" type="text/css">
<title>Radio Server Is Offline</title>
</head>

<body text="" bgcolor="">
<center>
<img src="offline.jpg">
</body>

</html>';
}
?>
 

GigaGreg

Moderator
Staff member
You need to enable "fsockopen" in your php settings. I have website on gigarank that uses "fsockopen" and I have no problem with that, because it works perfect for me.
 

NoelF1

New member
igdesigner said:
You need to enable "fsockopen" in your php settings. I have website on gigarank that uses "fsockopen" and I have no problem with that, because it works perfect for me.

Where do I find php.ini, can't find it anywhere in my cPanel/FileManager.

thanks mate.
 

jaran

New member
As I said before at above you had the error because "&" variable at line 16
Your script,
PHP:
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
It should be,
PHP:
$scfp = fsockopen("$scip", $scport, $errno, $errstr, 30);
 

GigaGreg

Moderator
Staff member
NoelF1 said:
igdesigner said:
You need to enable "fsockopen" in your php settings. I have website on gigarank that uses "fsockopen" and I have no problem with that, because it works perfect for me.

Where do I find php.ini, can't find it anywhere in my cPanel/FileManager.

thanks mate.

In your php.ini file you need to write this:

PHP:
allow_url_fopen = On

Also make sure that it is working create .htaccess file and pase this:

PHP:
Options +FollowSymLinks
RewriteEngine On

Hope it helps.
 

NoelF1

New member
igdesigner said:
NoelF1 said:
igdesigner said:
You need to enable "fsockopen" in your php settings. I have website on gigarank that uses "fsockopen" and I have no problem with that, because it works perfect for me.

Where do I find php.ini, can't find it anywhere in my cPanel/FileManager.

thanks mate.

In your php.ini file you need to write this:

PHP:
allow_url_fopen = On

Also make sure that it is working create .htaccess file and pase this:

PHP:
Options +FollowSymLinks
RewriteEngine On

Hope it helps.

Thanks a lot mate, edited my .htaccess file. But I can't find my php.ini file anywhere. :undecided:
 

NoelF1

New member
jaran said:
As I said before at above you had the error because "&" variable at line 16
Your script,
PHP:
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
It should be,
PHP:
$scfp = fsockopen("$scip", $scport, $errno, $errstr, 30);

Thanks a lot Jaran, seems like half of the problem is solved.

but now I still got the fsockopen error. I still can't find my php.ini anywhere and don't know how I am going to enable the thing. :/
I've done a phpinfo page though.
Code:
http://noelborg.com/testing/phpinfo.php

Code:
Warning: fsockopen(): unable to connect to free-shoutcast.com:18536 (Connection timed out) in /home/noelpro/public_html/testing/stats/radio_stats.php on line 16
NoelBorg.com // Radio is Offline

Code:
http://noelborg.com/testing/stats/radio_stats.php


igdesigner said:
Ohh, just create one in your public_html :) using notepad ++ or similar program.

Just created one.

added the following code only;

Code:
allow_url_fopen = On

Still ain't working :(:sorry
 

jaran

New member
NoelF1 said:
jaran said:
As I said before at above you had the error because "&" variable at line 16
Your script,
PHP:
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
It should be,
PHP:
$scfp = fsockopen("$scip", $scport, $errno, $errstr, 30);

Thanks a lot Jaran, seems like half of the problem is solved.

but now I still got the fsockopen error. I still can't find my php.ini anywhere and don't know how I am going to enable the thing. :/
I've done a phpinfo page though.
Code:
http://noelborg.com/testing/phpinfo.php

Code:
Warning: fsockopen(): unable to connect to free-shoutcast.com:18536 (Connection timed out) in /home/noelpro/public_html/testing/stats/radio_stats.php on line 16
NoelBorg.com // Radio is Offline

Code:
http://noelborg.com/testing/stats/radio_stats.php


igdesigner said:
Ohh, just create one in your public_html :) using notepad ++ or similar program.

Just created one.

added the following code only;

Code:
allow_url_fopen = On

Still ain't working :(:sorry



Again, the problem is not coming from the hosting. To remove all error reporting, you can add this code at the top of line.
PHP:
ini_set('display_errors','OFF');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes

//YOUR SCRIPT.......
 

NoelF1

New member
jaran said:
NoelF1 said:
jaran said:
As I said before at above you had the error because "&" variable at line 16
Your script,
PHP:
$scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30);
It should be,
PHP:
$scfp = fsockopen("$scip", $scport, $errno, $errstr, 30);

Thanks a lot Jaran, seems like half of the problem is solved.

but now I still got the fsockopen error. I still can't find my php.ini anywhere and don't know how I am going to enable the thing. :/
I've done a phpinfo page though.
Code:
http://noelborg.com/testing/phpinfo.php

Code:
Warning: fsockopen(): unable to connect to free-shoutcast.com:18536 (Connection timed out) in /home/noelpro/public_html/testing/stats/radio_stats.php on line 16
NoelBorg.com // Radio is Offline

Code:
http://noelborg.com/testing/stats/radio_stats.php


igdesigner said:
Ohh, just create one in your public_html :) using notepad ++ or similar program.

Just created one.

added the following code only;

Code:
allow_url_fopen = On

Still ain't working :(:sorry



Again, the problem is not coming from the hosting. To remove all error reporting, you can add this code at the top of line.
PHP:
ini_set('display_errors','OFF');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes

//YOUR SCRIPT.......



Superb help Jaran ! Finally that line 16 error is gone !
But the script still ain't working... all I see is radio is offline... no image no nothing... even when the server is on :( ...this getting to be tedious to set up... :/
 

jaran

New member
@NoelF1

I think you should ask it with your radio station. Maybe your port is wrong or missing something configuration.
 

NoelF1

New member
jaran said:
@NoelF1

I think you should ask it with your radio station. Maybe your port is wrong or missing something configuration.

Well my script config file has the ip, port and password all good. So the config should be good.
I think it's something to do with the script. Although I've managed to get the script working before without all this mess.
 

jaran

New member
NoelF1 said:
jaran said:
@NoelF1

I think you should ask it with your radio station. Maybe your port is wrong or missing something configuration.

Well my script config file has the ip, port and password all good. So the config should be good.
I think it's something to do with the script. Although I've managed to get the script working before without all this mess.

I have no experienced with shoutcast configuration. But I have other link maybe you would test it for your project. Its using jquery for configuration.

https://github.com/Wavestreaming/jquery-shoutcast