1
unsinner
shoutcast
  • 2009/3/22 18:17

  • unsinner

  • Just popping in

  • Posts: 87

  • Since: 2006/3/15


This is for all you coding experts every time I try to use a script to retrieve stats from my shoutcast server it won’t work I have tried to use deferent php scripts I have even tried the modules for XOOPS like radio and such all I get is a blank screen

2
unsinner
Re: shoutcast
  • 2009/3/22 18:20

  • unsinner

  • Just popping in

  • Posts: 87

  • Since: 2006/3/15


this is the last one i tryed to use


/*--------------------------------------------------

DACstreamstats: retriever.php
Written by Hercules Avello

--------------------------------------------------*/




// ----------------------- Config ----------------------
// Fill in this information with your own


$title = "Psychohazard"; // Ex: Psychohazard
$url = "**.34.***.25"; // Ex: **.34.***.25
$port = "8***"; // Ex: 8***

// -----------------------------------------------------

if ($open = @fsockopen($url,$port)) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,1000);
$row = explode("content-type:text/html",$read);
$row = explode(",",$row [1]);
}

// create doctype
$dom = new DOMDocument("1.0");
$row[6] = substr($row[6], 0, -14);

// display document in browser as plain text
header("Content-Type: text/xml");

// root
$root = $dom->createElement("shoutcast");
$dom->appendChild($root);

// title
$item = $dom->createElement("title");
$root->appendChild($item);
$text = $dom->createTextNode($title);
$item->appendChild($text);

// url - http://ipaddress:port/;stream.nsv
$item = $dom->createElement("url");
$root->appendChild($item);
$text = $dom->createTextNode('http://'.$url.':'.$port);
$item->appendChild($text);

// currentListeners
$item = $dom->createElement("currentListeners");
$root->appendChild($item);
$text = $dom->createTextNode($row[4]);
$item->appendChild($text);

// maxListeners
$item = $dom->createElement("maxListeners");
$root->appendChild($item);
$text = $dom->createTextNode($row[3]);
$item->appendChild($text);

// bitrate
$item = $dom->createElement("bitrate");
$root->appendChild($item);
$text = $dom->createTextNode($row[5]);
$item->appendChild($text);

// currentSong
$item = $dom->createElement("currentSong");
$root->appendChild($item);
$text = $dom->createTextNode($row[6]);
$item->appendChild($text);

// status online/offilne
$item = $dom->createElement("status");
$root->appendChild($item);
$status = 'Offline';
if($row[1] == 1)
$status = 'Online';
$text = $dom->createTextNode($status);
$item->appendChild($text);

// If the song tags are formatted correctly,
// also show an "artist" and "title"
if(substr_count($row[6], ' - '))
{
$info = explode(' - ', $row[6]);
$song = $info[1];
$artist = $info[0];

$item = $dom->createElement("artist");
$root->appendChild($item);
$text = $dom->createTextNode($artist);
$item->appendChild($text);

$item = $dom->createElement("songTitle");
$root->appendChild($item);
$text = $dom->createTextNode($song);
$item->appendChild($text);
}

// display
echo $dom->saveXML();

?>

3
dbman
Re: shoutcast
  • 2009/3/23 1:13

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


If you are using as a custom php block the php open/close tags are not needed.

4
unsinner
Re: shoutcast
  • 2009/3/23 1:15

  • unsinner

  • Just popping in

  • Posts: 87

  • Since: 2006/3/15


no i dont think my server supports fsockopen

5
dbman
Re: shoutcast
  • 2009/3/23 1:27

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


Try this is a custom php block to test:
if(!function_exists("fsockopen")) { echo "Function Exists"; } else { echo"Function unavailable"; }


edit: reverse the echos:
if(!function_exists("fsockopen")) { echo "Function unavailable"; } else { echo "Function Exists"; }


6
unsinner
Re: shoutcast
  • 2009/3/23 3:39

  • unsinner

  • Just popping in

  • Posts: 87

  • Since: 2006/3/15


Function unavailable

7
dbman
Re: shoutcast
  • 2009/3/23 4:58

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


This is not a recommended setting but you can turn this on if you have control over your php.ini
allow_url_fopen On



8
unsinner
Re: shoutcast
  • 2009/3/23 5:27

  • unsinner

  • Just popping in

  • Posts: 87

  • Since: 2006/3/15


allow forpen is on but when i try to run the php file it times out cant connect to server

Login

Who's Online

372 user(s) are online (297 user(s) are browsing Support Forums)


Members: 0


Guests: 372


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits