TinyPortal

Development => Block Codes => Topic started by: dark4sorrow on April 02, 2008, 05:35:17 PM

Title: WoW Launcher Alert Status
Post by: dark4sorrow on April 02, 2008, 05:35:17 PM
==============================================
This is the latest phpblock code in this thread: Updated 04.08.08
==============================================

$thelink = "<a href=\"http://launcher.worldofwarcraft.com/alert\">[*Link]</a>";
$fp = fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = fread($fp, 128);
fclose($fp);

if (strlen($data)<=1) {
echo "* There are no alerts at this time.".$thelink;
} else {
echo $data."...".$thelink;
}



==========
Original Post:
==========


I want to preface this by saying that I've never coded in PHP before, so what you see here is the most basic piece of code that I could put together, but it does seem to work thus far. :)

What it does is take the following URL and either prints out what is listed there or if nothing is found says that there is no alert available.

http://launcher.worldofwarcraft.com/alert

The text in the above location is what you see on the left hand side of your login screen in your WoW client.

As an example, one of yesterday's messages was:

"SERVERALERT: April 1, 2008, 3:14PM PDT We have identified the issues that were affecting the realms and all realms should be playable by approximately 4:30PM PDT. Thank you, Blizzard Entertainment."

I wanted to be able to see what that alert message was on my guild website while I was offline (at work, etc..). 

So, I created a PHP Block with the following code in it:


$fp = fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = fread($fp, 128);
fclose($fp);

if (strlen($data)==1) {
echo "No alerts available at this time.";
} else {
echo $data;
}


If anyone notices anything incorrect, easier ways of doing things, fixes, modifications, etc... Please feel free to reply here so that I can modify my own code on my site. :)

thanks,
-sorrow
Title: Re: WoW Launcher Alert Status
Post by: JPDeni on April 02, 2008, 06:29:12 PM
The proof of the program is whether it works or not and this one does, so it's great. :) Congratulations!! :up:
Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 02, 2008, 07:21:15 PM
Well, all of my testing this morning was giving me a strlen($data) of 1.  So, this code was working fine all morning then suddenly it wasn't.  Checking on the strlen($data) now, it seems to be 0.  So, I am not sure what Blizzard did (removed a space?). 

But, anyway, here is some modified code that checks to see if strlen($data) is either 0 or 1.  Hopefully anything other than that will be an actual alert. :)


$fp = fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = fread($fp, 128);
fclose($fp);

if (strlen($data)==1 || strlen($data)==0) {
echo "No alerts available at this time.";
} else {
echo $data;
}


If there is an easier or better way to check on that, I'd be willing to listen. :)

-sorrow
Title: Re: WoW Launcher Alert Status
Post by: JPDeni on April 02, 2008, 07:52:15 PM
You could use

if (strlen($data)<=1) {
Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 02, 2008, 08:24:48 PM
Quote from: JPDeni on April 02, 2008, 07:52:15 PM
You could use

if (strlen($data)<=1) {


Oh yeah.  That's what was on my mind, but for some reason I did an || instead.
Thanks. :)
Title: Re: WoW Launcher Alert Status
Post by: JPDeni on April 02, 2008, 08:39:53 PM
No problem. I don't know that it really makes any difference. I just like to use as few characters as possible.

You've done a really good job. php programming is like potato chips, though. You can't do just one!! ;)
Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 02, 2008, 11:06:02 PM
Quote from: JPDeni on April 02, 2008, 08:39:53 PM
You've done a really good job. php programming is like potato chips, though. You can't do just one!! ;)

Thanks, tho' I can't take all of the credit.  I copied code from wherever I could find it. :)

Oh, also, I thought I would add in my site in case anyone wanted to take a quick look at it working.  It's in the top-right (and yes, the site is still under construction).  :uglystupid2:

http://pinion-guild.com

Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 04, 2008, 09:41:28 AM
So, this seems to be working fine right now, but if the alert is pretty long you will only see part of it (I'm guessing 128 chars total at this point).

What I would like to do is have the alert displayed and then at the end of it add in something like:

<a href="http://launcher.worldofwarcraft.com/alert">[*Link]</a>

but, all of my attempts of adding that to the php block keep giving me errors, so obviously (as I stated previously), I don't know PHP very well (at all). :) 

Example:  Now, I am seeing:

"SERVERALERT: April 3, 2008, 10:50PM PDT We will be performing rolling restarts at 5:00 AM PDT, April 4, for all realms. These r"

I would like to see:

"SERVERALERT: April 3, 2008, 10:50PM PDT We will be performing rolling restarts at 5:00 AM PDT, April 4, for all realms. These r...<a href="http://launcher.worldofwarcraft.com/alert">[*Link]</a>"


So that someone can click on the [*Link] and it would open up the URL with the full display, which right now looks like this:

"SERVERALERT:
April 3, 2008, 10:50PM PDT

We will be performing rolling restarts at 5:00 AM PDT, April 4, for all realms. These restarts are expected to affect each realm for no more than 15 minutes. We apologize for any interruption this may cause in your normally scheduled play."


So, does anyone mind throwing that (probably) simple code out to finish this up?


$fp = fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = fread($fp, 128);
fclose($fp);

if (strlen($data)==1 || strlen($data)==0) {
echo "* There are no alerts at this time.";
} else {
echo $data;
echo  "...";
// <-- This is where I would like to add in the URL + Link
}


Thanks for any help.

p.s. I hope my 1:40am rambling made sense.... and, if not, please let me know.
:o

-sorrow

Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 04, 2008, 06:31:50 PM
Well, I think I figured out my own question this morning.  It's nice to have some friends at work who know PHP a bit. :)

Silly escape character thingies!

So, here is what I have come up with, although I haven't been able to test it 100% since there is no alert going on right now, but it does work on the no alert part, so it should work when there is an alert as well.   When there is a new alert, I will test it and modify this code if it seems troublesome.


$thelink = "<a href=\"http://launcher.worldofwarcraft.com/alert\">[*Link]</a>";
$fp = fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = fread($fp, 128);
fclose($fp);

if (strlen($data)<=1) {
echo "* There are no alerts at this time.".$thelink;
} else {
echo $data."...".$thelink;
}


Obviously, if there are no alerts you wouldn't need to link to it, so you can just take off the .$thelink variable out of the first echo, like so:


if (strlen($data)<=1) {
echo "* There are no alerts at this time.";
} else {
echo $data."...".$thelink;
}


-sorrow
Title: Re: WoW Launcher Alert Status
Post by: DarkRedMage on April 08, 2008, 05:28:34 AM
I'm trying to get this block code to work on my own guild's site:

http://www.soulsocietyguild.org

And I cannot get anything other than the "There are no alerts at this time" as a return on the code. I haven't changed anything and I can visit the launcher.worldofwarcraft.com/alert url and get a legitimate return. I'm wondering if there is something wrong with either the code, or possibly my site/host.
Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 08, 2008, 04:45:26 PM
Quote from: DarkRedMage on April 08, 2008, 05:28:34 AM
I'm trying to get this block code to work on my own guild's site:

http://www.soulsocietyguild.org

Did you use the latest code that is shown further down in the thread?  I know that when there was a legitimate alert (last night) that it worked perfectly on my site without any changes at all to the code.

I haven't noticed any errors at all on my site with it up to this point and every time I notice an alert when I logon to WoW I do check my site to make sure that the code is working correctly.

99% of the time you will see "There are no alerts at this time.." since the alerts are few and far between. 

Here is the latest code that I am using on my site right now:


$thelink = "<a href=\"http://launcher.worldofwarcraft.com/alert\">[*Link]</a>";
$fp = fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = fread($fp, 128);
fclose($fp);

if (strlen($data)<=1) {
echo "* There are no alerts at this time.".$thelink;
} else {
echo $data."...".$thelink;
}


If you can click on the link and it takes you directly to the alert status (whether there is one there or not), I wouldn't believe that there would actually be a problem with your site in accessing that page.

-sorrow
Title: Re: WoW Launcher Alert Status
Post by: DarkRedMage on April 08, 2008, 05:02:58 PM
Okay, I've updated the block code with what you posted as the latest code you're using. I know that right now there are no alerts, but if and when another alert comes up I will see if it actually pulls the info and shows it on my site.

Thanks.
Title: Re: WoW Launcher Alert Status
Post by: dark4sorrow on April 08, 2008, 06:00:39 PM
I updated the original post to show the latest code to be used.  Hopefully that will help if anyone has been having issues using the original code and didn't read on through the rest of the posts to see the fixes and the new code. ;)

-sorrow
Title: Re: WoW Launcher Alert Status
Post by: Will_Enigma on December 20, 2008, 02:47:34 PM
For those that found this and want to use it, I think it's a great little addition to a WoW site, my only problem is that I found that the alert page isn't always up, which wreaks havok in the error log if you have all the error reporting turned on. (Call me paranoid, but I like to know what's going on on my site.)  Now since this is a minor error, you may want to supress the 3-4 error messages that a 404 can generate, per page view, with this script.... here's the code...
$thelink = "<a href=\"http://launcher.worldofwarcraft.com/alert\">[*Link]</a>";
$fp = @fopen("http://launcher.worldofwarcraft.com/alert", "r");
$data = @fread($fp, 128);
@fclose($fp);
if (strlen($data)<=1) {
echo "* There are no alerts at this time.";
} else {
echo $data."...".$thelink;
}
Title: Re: WoW Launcher Alert Status
Post by: tragidy on February 08, 2009, 11:24:46 PM
I have tried to get this to work with the EU version of wow.

Is there a known alert url for the eu?

http://launcher.wow-europe.com/en/
Title: Re: WoW Launcher Alert Status
Post by: Will_Enigma on February 11, 2009, 12:32:43 AM
the url for the EU version of WoW is http://status.wow-europe.com/en/alert you can substitute the en in the link for the supported language of your choice for example http://status.wow-europe.com/fr/alert for French.  Enjoy  O0