473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem with some code..

have this code and I'm trying to get it to work. It mostly works, but
$serverpop does not seem to work. What it looks to me like this code
does is scan http://www.worldofwarcraft.com*/serverstatus/ for
keywords
and grab the information about the server that you're looking for. Can
anyone help me try and get the $serverpop part to work?
Thanks in advance,
Craft
______________________________*__________
$server = "Bonechewer";
$up = 'Up';
$down = 'Down';
$hig = 'High';
$med = 'Medium';
$low = 'Low';
// PHP Magic Below, Don't Edit
$html =
file_get_contents('http://www.worldofwarcraft.com*/serverstatus/');
$server = str_replace("'", "'", $server);
$length = strlen($server);
$pos = strpos($html, $server);
$serverstatus = stristr(substr(substr($html, -(strlen($html) - $pos +
154)), 0 ,4), "up");
if ($serverstatus == false) {$serverstatus = "down"; $length = $length
+ 2;}
$servertype = substr(substr($html, -(strlen($html) - ($pos + $length +
117))), 0, 3);
if ($serverstatus == "up") $fontcolor=("00FF00");
if ($serverstatus == "down") $fontcolor=("FF0000");
if ($servertype == "(RP") {$length = $length + 1; $servertype =
"Roleplay";}
else if ($servertype == "Nor") {$length = $length + 3; $servertype =
"Normal";}
else {$length = $length + 2; $servertype= "PVP";}
$serverpop = strtolower(substr(substr($html*, -(strlen($html) - ($pos
+
$length + 256))), 0, 3));
if ($serverpop == "hig") $fontcolr=("FF0000");
if ($serverpop == "med") $fontcolr=("FFFFFF");
if ($serverpop == "low") $fontcolr=("FFFF00");
$serverstatus = $$serverstatus; $serverpop = $$serverpop;
//////////////////////////////*//////////// Output, Edit at your own
risk:
echo "<body bgcolor=black>";
echo "<font color=white><b>Server Name: </b></font>";
echo "<font color=4444FF><b>$server</b></font><br>";
echo "<font color=white><b>Server Type: </font>";
echo "<font color =\"$fontcolor\">";
echo "$servertype</font><br>";
echo "<font color=white><b>Server Status: </font>";
echo "<font color =\"$fontcolor\">";
echo "$serverstatus</font><br>";
echo "<font color=white>Server Load: </font>";
echo "<font color =\"$fontcolr\"> ";
echo "$serverpop </font></b> <br><br><br><br>";
echo "</body>";

Jul 17 '05 #1
3 1355
Craft (cr*****@gmail.com) decided we needed to hear...
have this code and I'm trying to get it to work. It mostly works, but
$serverpop does not seem to work. What it looks to me like this code
does is scan http://www.worldofwarcraft.com*/serverstatus/ for
keywords
and grab the information about the server that you're looking for. Can
anyone help me try and get the $serverpop part to work?
<snip code>
$serverpop = strtolower(substr(substr($html*, -(strlen($html) - ($pos
+
$length + 256))), 0, 3));

<snip>

It all seems like a pretty slack way of parsing HTML to me, and not
very robust if the HTML changes - its crying out for a rewrite ;)

Your problem with serverpop is probably to do with the number 256
above... seems like thats meant to step past all of those blanks
in the HTML to actually get to the <TD> that contains the value
required. You could try doing some manual char counting in the HTML
file and in/de-creasing the 256 as appropriate - or by trial and
error, which ever suits you.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #2
how would i count my friend help me code this but his pc just crashed
so he hasnt been online.. like iuno wtf

$serverpop = strtolower(substr(substr($html**, -(strlen($html) -
($pos + $length + 256))), 0, 3));

is.. so uh can u help?

Jul 17 '05 #3
Craft (cr*****@gmail.com) decided we needed to hear...
how would i count my friend help me code this but his pc just crashed
so he hasnt been online.. like iuno wtf

$serverpop = strtolower(substr(substr($html**, -(strlen($html) -
($pos + $length + 256))), 0, 3));

is.. so uh can u help?


Well, if you still really want to do it the way you're doing it in the
script, the following *might* work (but untested)...
1) Grab the HTML file yourself (view in a browser, do a view source,
then copy/paste into an editor).
2) Count the number of chars from the end of the server name to the
start of the server pop (including newlines)
3) Replace the 256 with the value you got in 2.

If you're serious about making the script work, regardless of changes
to the HTML, you'd be better off investigating HTML parsing routines,
can't think of any off-hand but someone else might give you some
pointers.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
6
by: Páll Ólafsson | last post by:
Hi I have a problem with the Microsoft.ApplicationBlocks.ExceptionManagement? I can't get it to work in RELEASE mode? If I run the project in debug mode the block works fine but when I run the...
2
by: Netanel | last post by:
Hi, I have a site that I developed in ASP / VBScript. Some of the visitors are complaining that they can't get in into the system (using the login form of-course). My login form includes...
5
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
87
by: pereges | last post by:
I have a C program which I created on Windows machine. I have compiled and executed the program on windows machine and it gives me the consistent output every time i run it. for eg. input a = 2,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.