Re: [TIP] Checking to see if an mp3 station is online
| From: | Todd Eddy | Date: | Tue, 26 Dec 2000 20:14:31 +0000 |
| Subject: | Re: [TIP] Checking to see if an mp3 station is online | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31873@lists.php.net to get a copy of this message | ||
Hi doug. The way it works now, you specify the address using the variable
$url which you can see in the example below. Now, you can also convert that
to a function, which you can call out amongst your script as needed, just
throw this into your include file or just at the top of the page where you
want to check the servers:
<?php
function checkMP3Svr ($url,$svr) {
if ($url) {
$fp = @fopen($url,"r");
if ($fp) { echo "<a
href=\"link/to/playlist-$svr.pls\">$url</a>"; }
else { echo "SERVER IS OFFLINE"; }
}
else {
echo "ERROR: No url was specified\n";
}
}
?>
Then call it out in the script as
<?php checkMP3Svr("http://192.168.1.100:8000/","lq");
?>
ok, edit where it says link/to/playlist-$svr.pls to where your .pls files are
located (there is a way to make them on the fly, but if you only have a few,
static addresses, its not really worth the extra processing time). The $svr
is the second option when you call out the function and its how you seperate
all the different playlists. just make sure the ip in playlist-lq matches the
ip that you use to call out the function. Also remeber the trailing / in the
address or php might freak out :) If you need a little more detail, don't
hesitate to ask.
Doug Stewart wrote:
> Hi, I'm pretty new to all this, but this is definitely a script that could
> be great to use for testing multiple servers ...could someone modify the
> code so that it lets you input (through the URL or through some sort of
> internal check) multiple sites / servers? I'm so clueless. :P
>
> Thanks in advance,
> Doug
>
> > If you run a couple MP3 servers, you might want to automatically let
> > people know what servers are online and offline. It's remarkably very
> > easy. I initally found this posted by jamie.watt@murchison.com.au on
> > the www.php.net/manual/function.fopen.php page and I thought I would
> > give try and see if it would work, and it does! You can see it at
> > http://www.vrillusions.com/test.php3?url=http://ip:port/
> > and the source
> > for it is below:
> >
> >
> > REMEBER TO REMOVE THE . IN FRONT OF THE HTML TAGS
> >
> > <.html><.body>
> > <?
> > if ($url) {
> > $fp = @fopen($url,"r");
> > if ($fp) { echo "$url is online"; }
> > else { echo "$url is offline"; }
> > }
> > else {
> > echo "Please enter a url, here's an example:<br><br>\n";
> > echo
> > "...$PHP_SELF?url=http://www.vrillusions.com/";
> > }
> > ?>
> >
> > <./body><./html>
> >
> > as you can see, its very easy to turn it into a function and run it for
> > several servers. Hope this helps anyone that's had that idea in their
> > heads.
--
Todd Eddy
vrillusions@mail.com
http://www.vrillusions.com/
I acceept PGP secured mail, You can get my public key at:
http://www.vrillusions.com/contact/