Old 5th March 2004, 18:24   #1
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
online status and what's playing with PHP

Hi,

I have allready a php script at my website and tell to visiters if we are online with music and allso what's playing at the moment, when I am not streaming (no source) then allso this script tell that the webradio is offline.
I have 2 servers.
When I am not playing music and allso the server is complete down (the server is down/kill server)something like http://81.68.224.65:8000 this script that not work good , because he can not connect to server.


Somebody know what i must change in this script when server is complete shutdown? I want of server is shutdown in my website get the message that the radio is offline.

here is the php script.

<?php
// This image you can call immediately from an html file in the image tag
// (i.e. <image src="black.php">) easy huh?

Header("Content-type: image/png");

// Fill in your own server information here:
$host = "81.171.103.188";
$port = "9440";
$listenlink = 'http://81.171.103.188:9440/listen.pls'; //make link to stream

$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
$success=2; //se-t if no connection
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //get 7.html
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$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

if($connected==1) //if DSP is connected
$wordconnected="yes"; //set variable
else //if no DSP connection
$wordconnected="no"; //set variable
$peaklisteners=$numbers[2]; //set variable
$maxlisteners=$numbers[3]; //set variable
$reportedlisteners=$numbers[4]; //set variable
$bit=$numbers[5];
}

// Image size can be changed here: (x, y)
$im = ImageCreate(200,60);

// Background color in R(ed)G(reen)B(lue) below
$background_color = ImageColorAllocate($im,0,0,0);

// text colors also in RGB
$text_color1 = ImageColorAllocate($im,0,204,255);
$text_color2 = ImageColorAllocate($im,0,204,51);

if($success!=2 && $connected==1){

// song information is splitted in artist - title:
// This requires consistent artist & title format (no ' - ' in title/artist)
// else you can use $numbers[6] as current song info below
$song=explode(" - ",$numbers[6]);

// strings can of course be replaced with your own bla
$string1= "Now playing on Liberty Radio";
$string2= $song[0];
$string3= $song[1];
$string4= "SERVER1: $bit kbps [$currentlisteners/$maxlisteners users]";
}
else {
$string1= "Liberty Radio is currently";
$string2= "OFFLINE.";
$string3= "Please return later.";
$string4= "SERVER1";
}

// positioning below
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString($im,1,$px,5,$string1,$text_color1);
// (image,font (from 1 to 5),starting x position, y position,line of text,color)
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString($im,1,$px,20,$string2,$text_color2);
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString($im,1,$px,30,$string3,$text_color2);
$px = (imagesx($im)-5*strlen($string4))/2;
ImageString($im,1,$px,45,$string4,$text_color1);
ImagePng($im);
// In response to KXRM's reaction:
// if you want to cache the picture, you should place this script in
// your internetpage, remove line 5 (Header-call)
// and use ImagePng($im, "filename.png");
// NB: filename.png must have the right permission settings
// (CHMOD 777 does it)
//
// Then you can place filename.png in the same html-file.
ImageDestroy($im);
?>


visit allso my website
http://www.ukraina.nl or
http://radio.ukraina.nl

Last edited by ukraina; 5th March 2004 at 19:18.
ukraina is offline   Reply With Quote
Old 6th March 2004, 04:05   #2
ruffdawg
Major Dude
 
ruffdawg's Avatar
 
Join Date: Feb 2003
Location: Mississauga, Ontario, Canada (Sauga Represent!)
Posts: 565
I believe what your taking about is when your server is down you want a "sever is down" message. A shoutcast page won't show up unless your DNAS is running. And if you are not playing music/broadcasting, but the sever is up, it will give you a server is down message. I hope this answers your question, it's just a little hard to understand.


Playin' the best classic rock trax
www.ruffdawgradio.com
ruffdawg is offline   Reply With Quote
Old 6th March 2004, 07:04   #3
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
Hello,


I have use to much words and then it is difficult to understand, but you understand what I mean.
Is it possible to change this php script that there is some message that the radio is offline when the server is totally off from the internet?(DNAS is off, kill server)

Server 2 you see the example , you see only red cross like he can to get the picture downloading.

Last edited by ukraina; 6th March 2004 at 07:46.
ukraina is offline   Reply With Quote
Old 6th March 2004, 07:18   #4
ruffdawg
Major Dude
 
ruffdawg's Avatar
 
Join Date: Feb 2003
Location: Mississauga, Ontario, Canada (Sauga Represent!)
Posts: 565
Well, with that script, if you do go offline, it already gives an offline message. And as for your second stream, you need a seperate script for each server/station you wish to show. Maybe getting a fresh version of that script and not fiddling with it so much might do the trick.


Playin' the best classic rock trax
www.ruffdawgradio.com
ruffdawg is offline   Reply With Quote
Old 6th March 2004, 07:52   #5
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
ok I understand but you have not some idea's ?
ukraina is offline   Reply With Quote
Old 6th March 2004, 07:57   #6
ruffdawg
Major Dude
 
ruffdawg's Avatar
 
Join Date: Feb 2003
Location: Mississauga, Ontario, Canada (Sauga Represent!)
Posts: 565
If what you are looking for is your status picture to show when your server is offline or you are not broadcasting, then you have already found it.


Playin' the best classic rock trax
www.ruffdawgradio.com
ruffdawg is offline   Reply With Quote
Old 6th March 2004, 08:11   #7
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
no I have not found the answer, the server was down and no source (music).

But you are use here the wrong link for listen with winamp.
Now you use http://rdr.zapto.org:8018/listen.pls,
you must change it in http://rdr.zapto.org:8000/listen.pls (wrong port numer)

You must change it in your signature
ukraina is offline   Reply With Quote
Old 6th March 2004, 08:13   #8
ruffdawg
Major Dude
 
ruffdawg's Avatar
 
Join Date: Feb 2003
Location: Mississauga, Ontario, Canada (Sauga Represent!)
Posts: 565
You can only get the server's down message, if the server isn't actually up and running. You must exit the DNAS, then take a look at the status picture.

I believe that what you are looking for is too complex. When you are not playing music, but the server is still up, try going here: http://your.servers.ip.address:yourport

(eg: http://25.0.6.24:2112)


Playin' the best classic rock trax
www.ruffdawgradio.com
ruffdawg is offline   Reply With Quote
Old 6th March 2004, 08:24   #9
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
I have allready a script what tell visitors at my website if server is up or down.

See here http://www.ukraina.nl/radio/php/servers/servers.php

Allso when I kill server because this server 2 (computer )is not 24 hours online in internet.
Now I have killed server 2 , then you can see what happens.
You see with this script he allways will show online or offline.
Here you can see the script for this.

<?php

// simple.php - shoutcast 7.html information display utility
// version 0.1.4a

// To use this script, save this page save simple.php then edit the information below as noted, uncomment what you need
// To imbed the information on your php site use the include function on the page you wish to display the information


// Edit the next two lines with your server information
$host = "81.68.224.65";
$port = "9000";

// Connect to server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo '<img src="red.gif" alt="server 2 is down " width="14" height="14" border="0">';
} else {

// Get data from server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// exit if connection broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
}

// 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 '<a href="http://81.68.224.65:9000" target="_blank"><img src="green.gif" alt="server 2 online" width="14" height="14" border="0"></a>
';

} else {
echo '<img src="red.gif" alt="server 2 offline" width="14" height="14" border="0">';
} }
?>
ukraina is offline   Reply With Quote
Old 6th March 2004, 08:33   #10
ruffdawg
Major Dude
 
ruffdawg's Avatar
 
Join Date: Feb 2003
Location: Mississauga, Ontario, Canada (Sauga Represent!)
Posts: 565
Here's something that Festerhead came up with:

PHP Code:
<?

$check1 
fsockopen("IP""portBase");

if (
$check1) {
  echo (
"<image border='0' src='images/thumbsup.gif' title='Stream is up!'>");
  
$close fclose($check1);
}
else
  echo (
"<image border='0' src='images/thumbsdown.gif' title='Stream is down!'>");

?>


Playin' the best classic rock trax
www.ruffdawgradio.com
ruffdawg is offline   Reply With Quote
Old 6th March 2004, 08:40   #11
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
thanks but it is not what I mean
ukraina is offline   Reply With Quote
Old 6th March 2004, 22:40   #12
jonnyg20032001
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 126
Send a message via AIM to jonnyg20032001
where do i put the script ?????
jonnyg20032001 is offline   Reply With Quote
Old 7th March 2004, 07:12   #13
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
ofcourse in your website and the webserver must have php otherwise this not working.
ukraina is offline   Reply With Quote
Old 7th March 2004, 07:31   #14
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
by the way the question was.
Is it possible to get a offline status in my website when the dnas server is kill, shutdown?
As long the shoutcast server is in the internet then you get a online or offline status depends if there is music source yes or no, so this works good.

Server 2 is now killed but show not offline status only a red cross that the image show. Who knows the answer?
I have allso trying something out :
Look here some example when server is killed It works half because there are a lot of errors after this red flashing offline pic.

Last edited by ukraina; 7th March 2004 at 08:11.
ukraina is offline   Reply With Quote
Old 7th March 2004, 12:30   #15
jonnyg20032001
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 126
Send a message via AIM to jonnyg20032001
where do i put it is it with the <head> <script> do i add stuff to it, and what and where ??? thanks jonny g
jonnyg20032001 is offline   Reply With Quote
Old 8th March 2004, 17:33   #16
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
you need first a php website where you can put this playlist.php script.

Then you can place this playlist.php somewhere (where you want) in your html site but between the body tags.
example

<html>
<head>
<title>title</title>
</head>
<body>
<img src="playlist.php" border="0">
</body>
</html>
More examples you can find in forum from other members
ukraina is offline   Reply With Quote
Old 9th March 2004, 14:48   #17
jonnyg20032001
Registered User
 
Join Date: Oct 2003
Location: England
Posts: 126
Send a message via AIM to jonnyg20032001
thanks :d
jonnyg20032001 is offline   Reply With Quote
Old 11th March 2004, 05:25   #18
ukraina
Junior Member
 
Join Date: Mar 2004
Location: Netherlands
Posts: 13
Send a message via ICQ to ukraina
I have found the answer for my question. Only put error_reporting(0); in begin of php script.then you allso not get red cross in site of no picture to show. just try it out.


<?php
error_reporting(0); // put this in script and then script show allso offline message when the shout DNAS is totally shut down, example when server is in your computer and you put computer off, still you can see offline message of server


Header("Content-type: image/png");

// Fill in your own server information here:
$host = "81.68.224.65";
$port = "9000";
$listenlink = 'http://81.68.224.65:9000/listen.pls'; //make link to stream

$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
$success=2; //se-t if no connection
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //get 7.html
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$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

if($connected==1) //if DSP is connected
$wordconnected="yes"; //set variable
else //if no DSP connection
$wordconnected="no"; //set variable
$peaklisteners=$numbers[2]; //set variable
$maxlisteners=$numbers[3]; //set variable
$reportedlisteners=$numbers[4]; //set variable
$bit=$numbers[5];
}

// Image size can be changed here: (x, y)
$im = ImageCreate(200,60);

// Background color in R(ed)G(reen)B(lue) below
$background_color = ImageColorAllocate($im,0,0,0);

// text colors also in RGB
$text_color1 = ImageColorAllocate($im,0,204,255);
$text_color2 = ImageColorAllocate($im,0,204,51);

if($success!=2 && $connected==1){

// song information is splitted in artist - title:
// This requires consistent artist & title format (no ' - ' in title/artist)
// else you can use $numbers[6] as current song info below
$song=explode(" - ",$numbers[6]);

// strings can of course be replaced with your own bla
$string1= "Now playing on Liberty Radio";
$string2= $song[0];
$string3= $song[1];
$string4= "SERVER2: $bit kbps [$currentlisteners/$maxlisteners users]";
}
else {
$string1= "Liberty Radio is currently";
$string2= "OFFLINE.";
$string3= "Please return later.";
$string4= "SERVER 2";
}

// positioning below
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString($im,1,$px,5,$string1,$text_color1);
// (image,font (from 1 to 5),starting x position, y position,line of text,color)
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString($im,1,$px,20,$string2,$text_color2);
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString($im,1,$px,30,$string3,$text_color2);
$px = (imagesx($im)-5*strlen($string4))/2;
ImageString($im,1,$px,45,$string4,$text_color1);
ImagePng($im);
// In response to KXRM's reaction:
// if you want to cache the picture, you should place this script in
// your internetpage, remove line 5 (Header-call)
// and use ImagePng($im, "filename.png");
// NB: filename.png must have the right permission settings
// (CHMOD 777 does it)
//
// Then you can place filename.png in the same html-file.
ImageDestroy($im);
?>
ukraina is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > SHOUTcast > SHOUTcast Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump