Jump to content

ShoutCast Info


RaythMistwalker

Recommended Posts

<? 
require("../config.php");
ini_set('display_errors', 'on');
error_reporting(E_ALL);

    $link = mysql_connect(DB_HOST, SAM_DB_USER, SAM_PASSWORD);
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }
    
    //Select database
    $db = mysql_select_db(SAM_DB_USER);
    if(!$db) {
        die("Unable to select database");
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.::RadioLightning::. Home</title>
<link href="red.css" rel="stylesheet" type="text/css" />
</head>
<body text="#0000ff" link="#00a5e9" vlink="#00a5e9" alink="#00a5e9" leftmargin="2" topmargin="2" marginwidth="2" marginheight="0">

<center><h1>RadioLightning</h1></center>
<table width=100% class='tableborder'><tr><td valign=top width=27%><div class='titlemedium'>Links</div><br>
<a href='index.php'>Home</a><br>
<a href='playlist.php'>AutoDJ Playlist</a><br>
<a href='request.php'>Request a Song</a><br> 
<a href='chat.php'>Chat Client</a><br>
</td><td width=73%>
<div class='maintitle'><center>Welcome</center></div><br>
Welcome to RadioLightning.
<br><br><div class='maintitle'><center>Live Info</center></div><br>
<?php
$ip = "stream.radiolightning.co.cc";
$port = "9258";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) 
    { 
    $title = "Connection timed out or the server is offline  ";
    } 
    else
    { 
    fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
    while (!feof($fp)) 
        {
        $info = fgets($fp);
        }
    $info = str_replace('</body></html>', "", $info);
    $split = explode(',', $info);
    if (empty($split[6]) )
        {
        $title = "The current song is not available  ";
        }
    else
        {
        $count = count($split);
        $i = "6";
        while($i<=$count)
            {
            if ($i > 6)
                {
                $title .= ", " . $split[$i];
                }
            else
                {
                $title .= $split[$i];
                }
            $i++;
            }
        }
    }
$title = substr($title, 0, -2);
echo "Current Song: ".$title;
if (!$fp) 
    { 
    $listeners = "0";
    } 
    else
    { 
    fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
    while (!feof($fp)) 
        {
        $info = fgets($fp);
        }
    $split = explode(',', $info);
    if ($split[1] == "0" )
        {
        $listeners = "0";
        }
    else
        {
        $listeners = $split[0];
        }
    }
echo "<br>Number of Listeners: ".$listeners;
?>
<?php
// Change these to your online/offline messages //
$online = "<img src='images/online.gif'>Online"; // Displays when stream is online
$offline = "<img src='images/offline.gif'>Offline"; // Displays when stream is offline
// don't edit below //
$ip = "stream.radiolightning.co.cc";
$port = "9258";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) 
    { 
    $status = $offline;
    } 
    else
    { 
    fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
    while (!feof($fp)) 
        {
        $info = fgets($fp);
        }
    $split = explode(',', $info);
    if ($split[1] == "0" )
        {
        $status = $offline;
        }
    else
        {
        $status = $online;
        }
    }
echo "<br>Status: ".$status;
?>
<td></tr></table>
<div class='copyright'>Copyright to RadioLightning.Co.Cc</div>
</body>
</html>

 

Ok this is the home page of my radio website and for some reason it isn't getting the stream song title or number of listeners. It seems the connection is timing out. Any help on this?

Link to comment
https://forums.phpfreaks.com/topic/197366-shoutcast-info/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.