Determine If Website Is Up Using PHP

Phillip’s asking me to add features to Mud Songs Radio. I may have to ask Jim for some code so I don’t have to reinvent the wheel.

Today I made his ON THE AIR message dynamic, so he doesn’t have to edit that page everytime he goes on and off the air.

The function:

function DisplayOnAirStatus($on_air = 'ON AIR', $off_air = 'OFF AIR') {
$fp = fsockopen("mudsongs.hopto.org", 8000, $errno, $errstr, 15);
if ($fp) {
echo $on_air;
fclose($fp);
}
else
echo $off_air;
}

I’m working on getting ShoutCast data now, such as who’s listening, what songs have played, etc. Most of the code is done; I’m making it user-friendly.

Update: That’s done. What next, Phillip?

10 Replies to “Determine If Website Is Up Using PHP”

  1. Cool! Everyone who’s lurking, please forgive the following tech mumbo-jumbo…

    Just some notes and thoughts which, if you continue forward, you may find interesting (or not). If I’m not too lazy, I’ll provide links. Otherwise, my guess is a google will get you where you want to go. If not, email me.

    1) WAWI Winamp plugin. (WAWI=Winamp Web Interface Plugin) Let’s you query and control Winamp directly from a PHP program. I went through a lot of experimentation using different ways of letting the EJ PHP programs load, query, skip tracks in Winamp etc. and WAWI ended up being the most reliable and easiest way to do it. There are a ton of remote control plugins available. I found WAWI to be the best. It also has a very usable web-page interface that can be used to control Winamp remotely. I don’t use that page very often but instead programmed the EJs to programatically ‘read’ it and ‘hit buttons’ to control the player. The only thing I snarf off the Shoutcast public page is listeners … all song data (what’s playing, what’s coming up) comes from WAWI.

    2) Phillip commented about uneven audio levels. An obvious solution is a hardware compressor (which is probably the best solution). But you can also put a software Winamp plugin in Winamp’s output chain to get a little better control. I use a simple software compressor called “Compressor & Wider v1.1” to even levels out in Winamp. (I also use a hardware compressor but found the 2 in combination give best results for me.)

    3) Getting *really* esoteric, I also use “Resumer Plug-in v1.2” which saves the Winamp playlist to a file every X seconds (I believe I have it set to 2 seconds). It’s sort of a safeguard because once you start controlling Winamp programatically, it occasionally does weird stuff (freezes, loses its place in the playlist, stops updating ‘time left on song’, etc.) Having that playlist file allows you to restart and / or kick the player alive in most situations.

    4) If you decide to keep going and are willing to throw a bit of money into or request that listeners pay for the streaming cost (oh boy, just make SURE you want to keep going cuz once you start accepting donations, whether you like it or intend for it to or not, you will feel a sense of duty to keep the whole thing up and running and moving forward) I really suggest looking at bean-net.net … the monthly cost to run 10 relatively low-quality lines is very reasonable, you insure that your listeners have a good listening experience with a relatively uninterrupted stream, and you get rid of the headache and processing power required to keep your stream server running.

    I hope to tune in today, but I’m also trying to keep off the computer and away from audio media in order to give my head a chance to clear for a week or two. So, if I do tune in, it’ll likely be quietly … so I can truly sit back and listen rather than trying to simulcast MudSongs. :-)

  2. P.S. Oh, and it was just chance that I saw this entry. I’m weaning myself off of Bloglines and RSS readers but fell off the wagon this morning. So if you write something I need to reply to, just kick me via a quick email and I’ll come back.

  3. By the way, Jim, I’m responding to your last email, but writing my thesis at the same time, so I might not send it off until tonight or tomorrow.

    You still taking off for a week?

  4. Totally understand on the email. Respond if and when it feels good and feels right. I don’t know what’s going to happen for the week. I am definitely “taking it off” when it comes to feeling forced to do anything. But if I *want* to get on the mic, then I’ll do it. Esther and I just chatted on the mic like the old days, not trying to do a show, but just talking for about an hour. I don’t know if I’ll post it or not. Just doing that frigs with my head cuz it takes it right back into ‘performance’ mode. But at least it felt mostly good while it was happening although I felt bad for the listeners being force-subjected to it.

    Ugh…listening back, it sounds like the most conceited, self-serving load of horse crap I’ve ever heard. Pretty much like most of the ‘conversational’ podcasts I’ve heard. Yuck.

  5. Jim, I hear that. Jenny and I got behind the mix about 20mins ago after drinking too much wine, thinking we’d have some good stories to tell. Well… it was dumb, dumb, and dumb. (And now we feel stupid.)

    And so it goes…

    We’re gonna be behind the mix for next 30mins or so.

  6. What’s next?

    First off, the stats page, although very good so far, doesn’t show where the listeners are tuning in from. I’m looking for a quick-reference page I can go to that shows the general loccale of each listener, so I can say, “Hello to my listener in [blank’ and my listener in…” Right now I’m using this to find out where people are tuning in from — which works perfectly, except I have to copy and paste each new IP as it comes in. And although what you have set up so far is excellent, half the time when I click on the listener IP link, it doesn’t tell me anything, data unavailable or something.

    After that, a comment board or chat page would be nice, with the most recent comment on the top instead of the bottom on the page. (Being able to ban a person would be necessary, too, if somoene began posting inappropriate comments.)

    On WWR, when Jim has something special planned, he posts a notice for it at the top of the chat. Something like that would be good — especially now in the early stages when nothing is planned unless I have time for it. So I’m going to do something special, like plan an hour independent blues, whatever, I can post it at the top of the chat where it stays there until I change it.

    If the same announcement could appear on the main page, that’d be even better. That way, someone visiting could see what was immediately coming up.

    How’s that?

  7. Another idea: How about displaying the current song that’s playing on the webcast here on Steel White Table?

  8. Scratch that plan: SWT takes too long to load now, and retrieving the song info from mudsongs could delay the load of the page by seconds, which is a life time in the CPU world. Maybe when I get a new computer I’ll do it. I’ll look into the other stuff, though.

  9. > I’m looking for a quick-reference page I can go to that shows the general loccale of each listener

    I could do it with a LOT of work, but I don’t want to. I couldn’t find a free site to implement that functionality. Does Jim pay a site to use that feature?

    > a comment board or chat page would be nice

    I’ll think about it.

Leave a Reply

Your email address will not be published. Required fields are marked *

*