PHP Help
PHP Help
I don't want a handout, but if someone could point me in the right direction, that'd be appreciated.
On a page like this:
http://ladder.guildwars.com/ladder.dll?name=war+machine
I want to parse out Rank, Rating, Wins and Loses.
I'm guessing this is fairly simple. Just a funciton name or two would be helpful. I'm looking through the function list and see many different options, but nothing is poping out to me as an obvious solution.
On a page like this:
http://ladder.guildwars.com/ladder.dll?name=war+machine
I want to parse out Rank, Rating, Wins and Loses.
I'm guessing this is fairly simple. Just a funciton name or two would be helpful. I'm looking through the function list and see many different options, but nothing is poping out to me as an obvious solution.
-
^misantropia^
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
here's code that seems to work:
lad.txt is just the html of the ladder page you linked to.
Code: Select all
<?php
$fp = fopen ("lad.txt", "r");
$contents = fread ($fp, filesize("lad.txt"));
$pattern = "/<TR CLASS=\"ladderRankB\"><TD ALIGN=\"center\" CLASS=\"ladderRankData\">(.*)<\/TD><TD ALIGN=\"center\">(.*)<\/TD><TD ALIGN=\"center\">(.*)<\/TD><TD ALIGN=\"center\">(.*)<\/TD><TD ALIGN=\"center\">(.*)<\/TD><TD ALIGN=\"center\">(.*)<\/TD><TD ALIGN=\"center\">(.*)<\/TD><\/TR>/i";
$count = preg_match($pattern, $contents, $match);
if ($count > 0)
{
$data['Rank'] = $match[1];
$data['Guild Name'] = $match[2];
$data['Tag'] = $match[3];
$data['Territory'] = $match[4];
$data['Rating'] = $match[5];
$data['Wins'] = $match[6];
$data['Losses'] = $match[7];
var_dump($data);
}
else
{
echo "Could not Extract Contents";
}
?>
-
Underpants?
- Posts: 4755
- Joined: Mon Oct 22, 2001 7:00 am
why not use a db to store passwords then?
[i]And shepherds we shall be, for thee my Lord for thee, Power hath descended forth from thy hand, that our feet may swiftly carry out thy command, we shall flow a river forth to thee, and teeming with souls shall it ever be. In nomine patris, et fili, et spiritus sancti.[/i]
Thanks mjrpes. :icon14:
Not finished yet, but here's the result

Now I need to cron the page fetch every hour or so and update a local file. That and figure out how to change the font.
edit: wtf why won't that image display??? It works if you just use the URL, but not w/ the img tags. Works on other boards, just not here.
Not finished yet, but here's the result
Now I need to cron the page fetch every hour or so and update a local file. That and figure out how to change the font.
edit: wtf why won't that image display??? It works if you just use the URL, but not w/ the img tags. Works on other boards, just not here.
Last edited by Fender on Sun Feb 19, 2006 1:58 pm, edited 4 times in total.
-
Underpants?
- Posts: 4755
- Joined: Mon Oct 22, 2001 7:00 am
No, SSL forms a link from the web server to the browsing client. It secures the data flow during requests from the client. PHP executes all the background tasks needed to generate the page and then sends normal HTML to the browser.Underpants? wrote:in, say, mysql password management I've always been curious to know whether the password exchange is encrypted? Would a ssl cert exchange break anything in the php/database login? I'm a little slow in this dept. srykthnxalotbrorlydmmh wrote:why not use a db to store passwords then?
-
^misantropia^
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
The password is encrypted by the client, i.e. libmysqlclient, using a one-way hash (actually a challenge-response type of authentication, IIRC). As of MySQL 4.1, the protocol has been modified a bit to make it more resistant against packet sniffing or man-in-the-middle attacks.Underpants? wrote:in, say, mysql password management I've always been curious to know whether the password exchange is encrypted? Would a ssl cert exchange break anything in the php/database login? I'm a little slow in this dept. srykthnxalotbrorly
-
Underpants?
- Posts: 4755
- Joined: Mon Oct 22, 2001 7:00 am
q3w bb won't display images that don't end with valid extension, jpg gif png, etc. If you want to go for perfection, you can have apache treat png files as php. Create an .htaccess file in the directory you're using and put this line in it:Fender wrote: edit: wtf why won't that image display??? It works if you just use the URL, but not w/ the img tags. Works on other boards, just not here.
Code: Select all
AddType application/x-httpd-php .png
Thanks.

Still not finished, however.
Edit: moved it to its own directory and added the .htaccess file there so it doesn't mess up png files in other directories
edit2: Also playing around w/ image creation
Create your own gradients with a URL like this

http://www.fender.net/sig/gradient.png? ... est%20test
lr = left gradient red value 0 - 255
lg = left gradient green
lb = left gradient blue
rr = right gradient red
rg = right gradient green
rb = right gradient blue
w = width
h = height
fr= font red
fg = font green
fb = font blue
t = text

Still not finished, however.
Edit: moved it to its own directory and added the .htaccess file there so it doesn't mess up png files in other directories
edit2: Also playing around w/ image creation
Create your own gradients with a URL like this

http://www.fender.net/sig/gradient.png? ... est%20test
lr = left gradient red value 0 - 255
lg = left gradient green
lb = left gradient blue
rr = right gradient red
rg = right gradient green
rb = right gradient blue
w = width
h = height
fr= font red
fg = font green
fb = font blue
t = text