Old 10th April 2006, 06:39   #1
robindean
Member
 
Join Date: Apr 2006
Location: Chicago, IL
Posts: 56
Send a message via AIM to robindean
Broadcast Detection Script

I need a javascript or php script which will detect whether or not I'm broadcasting and redirect to a page based on the result.

Something like this ...

1) Visitor goes to my site
2) Index page has a javascript or php script
3) The script checks to see "is he broadcasting?"

4) if he is ... go to page yada
5) otherwise, go to page bada-bing

Currently, I've been using something called Lite.pm but it only works by asking for rtsp info.

I've had much difficulty making it work, so I'm hoping others have attempted what I'm after with more success.

P.s. Before you ask "but why would you want to?" ... please understand that such information doesn't matter in reference to the solution.
robindean is offline   Reply With Quote
Old 10th April 2006, 06:55   #2
Wavestreaming
Major Dude
 
Wavestreaming's Avatar
 
Join Date: Apr 2004
Location: United Kingdom
Posts: 1,563
Send a message via AIM to Wavestreaming Send a message via Yahoo to Wavestreaming
This is easily done with PHP. You may need to do a bit of modification to some existing script(s), however.

Check out www.hotscripts.com - search for Shoutcast under PHP.
Wavestreaming is offline   Reply With Quote
Old 10th April 2006, 07:15   #3
robindean
Member
 
Join Date: Apr 2006
Location: Chicago, IL
Posts: 56
Send a message via AIM to robindean
Here's the code I found which is "simple."

However, I can't even get this code to work as it is.

I've added the info for my server. Any suggestions to get the redirect?

the code ...

<?php

// Mysql staus image script by Anthony Parkes
// anthony@aj-services.com
// www.aj-services.com

$server = "robindean.no-ip.info"; // IP address to your shoutcast server.
$port = "8554"; // port of your shoutcast server
$online = "http://www.robindean.com/media_debut.jpg"; // Online Gif image
$offline = "http://www.robindean.com/media_shadows.jpg"; // offline gif image

// Start Data Collection

$fp = fsockopen("$server", $port, $errno, $errstr, 30);
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
while (!feof($fp))
{
$content .= fgets($fp,128);
}
fclose($fp);

// start data processing

$debut = strpos($content, '<body>') + strlen('<body>');
$fin = strpos($content, '</body>', $debut);
$string = substr($content, $debut, $fin - $debut);
$stats = explode(',', $string);

// Start Image generation
// Dedug Status echo "$stats[1]";

// offline

if ($stats[1] == "0")
{
header("Content-type: image/gif");
readfile('$offline');
}

//online

if ($stats[1] == "1")
{
header("Content-type: image/gif");
readfile('$online');
}

?>
robindean is offline   Reply With Quote
Old 8th June 2006, 17:23   #4
voice23
Junior Member
 
Join Date: Jun 2006
Posts: 18
What is a /7.html anyway. I have been getting a few of those.
voice23 is offline   Reply With Quote
Old 8th June 2006, 17:50   #5
dotme
Moderator
 
dotme's Avatar
 
Join Date: Feb 2005
Location: USA
Posts: 4,024
Go hit it on your dnas

http://yourip:yourport/7.html
dotme is offline   Reply With Quote
Old 8th June 2006, 18:06   #6
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
rob,

learn php heres how to use redirection. so you could add some lines in the existing code you have to change to a differnet page, rather than show the online/offline status

http://php.about.com/od/learnphp/ht/phpredirection.htm

This is not a shoutcast server problem, and if we teach you too much about web and scripting people tend to get uptight including myself

cheers

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 8th June 2006, 18:17   #7
voice23
Junior Member
 
Join Date: Jun 2006
Posts: 18
I don't want to learn PHP. I just want to know what it is and why someone would do it so it shows up in my shoutcast log.
voice23 is offline   Reply With Quote
Old 8th June 2006, 18:19   #8
voice23
Junior Member
 
Join Date: Jun 2006
Posts: 18
So it is someone determining wether I am broadcasting?
voice23 is offline   Reply With Quote
Old 8th June 2006, 18:36   #9
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
The script you had all ready will show if the station is online or not! If you want it to write to a log file you need to write that code or pary someone to do it.

There are more example of the radio station status scripts at http://www.streamsolutions.co.uk

Real simple to place into html/php files on your web server and it can show 'I AM ON THE AIR', 'I AM NOT ON THE AIR' or graphics like the one you posted here. If you wanted to redirect the entire site to another page, that can be done by changing the code around.

again its not shoutcast server problems, its web server setup. Ask around if someone will do it for free and white the stuff for your site.

heres a big question, do you have a web site on a host that supports php?? if you are a free account with yahoo, tripod, and others , they do NOT offer php.

Dissscusion closed??

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 8th June 2006, 20:24   #10
voice23
Junior Member
 
Join Date: Jun 2006
Posts: 18
I realized after the post that you had two conversations going on this thread. One was to Rob and one to me (Voice23). I apologize more my terse response.

I was just trying to determine what the /7.html was because I have never seen it before.

Now, if I can figure why I am not listed for weeks, and where Alvin and the Chipmunks on speed are coming from when you connect - I will have had my day completed.
voice23 is offline   Reply With Quote
Old 8th June 2006, 20:32   #11
dotme
Moderator
 
dotme's Avatar
 
Join Date: Feb 2005
Location: USA
Posts: 4,024
Ah - might be able to help there.

The chipmunks thing is often caused by an Intro or Backup file on a server that doesn't match frequency and bit rate of the stream. If you stream 64k, 44.1 kHz and you use backup files, make sure they are also encoded to those values.

You're not listed because the YP is selectively discarding servers. If you get the nak (100) error and on a server startup, you get the "added" message but no visit from the Directory Tester, you're not getting listed. I have found no pattern to this yet - except it's getting worse, and some servers get listed every time while others never get listed.
dotme is offline   Reply With Quote
Old 8th June 2006, 20:43   #12
voice23
Junior Member
 
Join Date: Jun 2006
Posts: 18
Ok, so it is an ongoing issue with the listing problem. I know I was listed a few weeks ago. So at least it is not me. I am glad that I do not depend on Shoutcast to market my stream. ( smile *)

As for the introfile. It is .../intro64.mp3. I am encoding a 64k 44.1hz stream in stereo. So I do not know what the deal is. I encoded the intro file to 64k 44.1hz.

I took it out and everything went back to normal. I understand what you are telling me, and I thought I had that covered. So once again I plead ignorance here.

Thanks for the response. You must be sitting at the computer. (Like Me). No life I guess.
voice23 is offline   Reply With Quote
Old 8th June 2006, 22:22   #13
hackerdork
Forum King
 
hackerdork's Avatar
 
Join Date: Feb 2006
Location: Earth Circa sometime.
Posts: 3,297
voice23 you need to start your own threads it gets too confusing. this thread started with dection scripts or html display of the station status

~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.
hackerdork is offline   Reply With Quote
Old 8th June 2006, 22:53   #14
voice23
Junior Member
 
Join Date: Jun 2006
Posts: 18
EXCUSE ME! I saw that it was dealing with the topic that I had a question. Excuse the distraction.
voice23 is offline   Reply With Quote
Old 14th June 2006, 18:56   #15
tarakonas
Junior Member
 
Join Date: Apr 2001
Location: Chicago, IL
Posts: 3
Send a message via Yahoo to tarakonas
Hi,

Here's the resolution I'm using. I was looking for similar script for myself. Here's what I did get:

PHP Code:
<?php $data=file_get_contents("http://url.to/script");
if ( 
$data !== false && strstr($data,'dj1') !== false ) { $img="http://url.to.images/dj1.jpg"; }
elseif ( 
$data !== false && strstr($data,'dj2') !== false ) { $img="http://url.to.images/dj2.jpg"; }
elseif ( 
$data !== false && strstr($data,'dj3') !== false ) { $img="http://url.to.images/dj3.jpg"; }
else { 
$img="http://url.to.images/default.jpg"; }
echo 
"<img src={$img} border=0>";
?>
Every dj is instructed to put their name into Genre field.
I have php/xml script, which gets info from stream server and displays Genre (which will be dj name or default server). If dj is on air, this code will replace default.jpg with dj1.jpg

You can edit this simple script to do redirection or whatever you like instead of displaying image.

Hope this helps.
Tom
tau.fm
tarakonas is offline   Reply With Quote
Old 14th June 2006, 19:04   #16
tarakonas
Junior Member
 
Join Date: Apr 2001
Location: Chicago, IL
Posts: 3
Send a message via Yahoo to tarakonas
If you wish to use redirection, you can replace path-to-images with path-to-html-files and replace
code:
echo "<img src={$img} border=0>";
line with
code:
header("Location: {$img}");
tarakonas is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

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