TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 531
  • Total: 531

WoW Launcher Alert Status

Started by dark4sorrow, April 02, 2008, 05:35:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dark4sorrow

==============================================
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

JPDeni

The proof of the program is whether it works or not and this one does, so it's great. :) Congratulations!! :up:

dark4sorrow

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

JPDeni

You could use

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

dark4sorrow

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. :)

JPDeni

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!! ;)

dark4sorrow

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


dark4sorrow

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


dark4sorrow

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

DarkRedMage

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.

This website is proudly hosted on Crocweb Cloud Website Hosting.