TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

July 21, 2024, 09:17:14 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,333
  • Total Topics: 21,233
  • Online today: 103
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 64
  • Total: 64

Shoutcast Block

Started by ontap, September 03, 2005, 04:20:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ontap

heres the code to have a shoutcast block if anyones intrested...


// SHOUTcast Block For Tinyportal
// Thanks To Max For Code

// Edit The Next Two Lines With Your SHOUTCAST Server Information
$host = "yourdomain.net";
$port = "80000";

//  Station Name
$streamtitle = "My Cool Radio"; //Your Station Name

// Stream Url
$streamurl = "http://$host:$port/listen.pls";

// Connect To SHOUTcast Server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "<b>Cannot Connect To Shoutcast!</b>";
} else {

// Get Data From SHOUTcast Server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Exit If Connection Is Broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(100000);
}

// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);

// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);

if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE

echo "
<center>Playing On $streamtitle
<br>
<marquee>
<a href=\"$streamurl\">$song</a>
</marquee>
Birate @ $bit kbps <br> Listeners: $current / $max <br><center>
";
} else {
echo "
<b>$streamtitle Offline</b><br>Last Song Played Was:<br>
<marquee>$song</marquee>";
} }

bloc


mmeadwolfe

Nice little script there :D Is it possible to have the music play thoue?

timtimtim

Has anyone managed to get this to work? I've set up my settings correctly but have been unable to do get it to function.

ontap

#4
$host = "yourdomain.net"; (http://yourshoutcastsite.com)
$port = "80000"; (Shoutcast Port)

these must be changed for the php block to work,
have you a link i can check?

timtimtim

#5
Host: 87.81.202.19
Port: 8000

I seem to be able to listen to it fine.

// SHOUTcast Block For Tinyportal
// Thanks To Max For Code

// Edit The Next Two Lines With Your SHOUTCAST Server Information
$host = "87.81.202.19";
$port = "8000";

//  Station Name
$streamtitle = "HyperNexus Radio"; //Your Station Name

// Stream Url
$streamurl = "http://$host:$port/listen.pls";

// Connect To SHOUTcast Server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "<center><b>Cannot Connect To Shoutcast!</b><br />HyperNexus Radio is Offline</center>";
} else {

// Get Data From SHOUTcast Server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Exit If Connection Is Broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(100000);
}

// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);

// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);

if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE

echo "
<center>Playing On $streamtitle
<br>
<marquee>
<a href=\"$streamurl\">$song</a>
</marquee>
Birate @ $bit kbps <br> Listeners: $current / $max <br>
";
} else {
echo "
<b>$streamtitle Offline</b><br>Last Song Played Was:<br>
<marquee>$song</marquee>";
} }


www.hypernexusradio.co.uk Is the site of the radio, and
http://www.hypernexus.co.uk is my tinyportal address.

ontap


The code works fine when i make a new php block,  :-\
you could try another way using SSI...

Open SSI.php
Find ?>

Before Add
// Shoutcast Block
function ssi_shoutcast()
{
global $sourcedir;

include_once("Shoutcast.php");
}


Copy "Shoutcast.php" to your forums directory,
Create A New php block and insert "ssi_shoutcast();"

[attachment deleted by admin]

timtimtim

I'm afraid not - although it presents no parse errors, I still get the 'Cannot Connect To Shoutcast!' error in the block.

timtimtim

Anyone using a working version of this that they wouldn't mind linking to?

mmeadwolfe

I had a working example, but it was only for admins and i desided not to include it. Sorry. Thoue I just copyed the script exactly and changed the lines i was suposed to.

Quote from: ontap on September 03, 2005, 04:20:17 PM

$host = "yourdomain.net";
$port = "80000";
$streamtitle = "My Cool Radio"


Maby there are some settings on your server that are messed up, but don't take that as a fact, im just taking a random guess.

Try this:

Quote from: ontap on September 03, 2005, 04:20:17 PM

$host = "212.72.186.10";
$port = "8072";
$streamtitle = "1.FM"


Its a station i listen to often, and seems to work on my site.

Good Luck