TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-30-2009, 09:53 PM   #21 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Looks good mate :)

dont forget the quotes on the string arguments:
PHP Code:
$armory = new armory(character$realmnameNULL$charnameNULL); 
//should be
$armory = new armory('character'$realmnameNULL$charnameNULL); 
It works eitherway but the latter doesnt throw a PHP warning about an undefined constant.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 01-30-2009, 10:15 PM   #22 (permalink)
The Contributor
 
SaintIsaiah's Avatar
 
Join Date: Jan 2009
Posts: 48
Thanks: 5
SaintIsaiah is on a distinguished road
Default

Good point. Took care of that. Here's a skinned version where it's part of the site. Just need to do some layout work and it should be good to go.

http://hellfireclub.org/character.php?name=Haiasi
SaintIsaiah is offline  
Reply With Quote
Old 02-02-2009, 06:22 AM   #23 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Well this looks to be the best place to get an answer to a question that has been plaguing me.

While I did find some interesting stuff prior to this most of it is fairly basic and straight forward and what I am looking to do is take it one step further.

The question is how to get at the bank logs?

Obviously this requires logging in. I have tried using CURLOPT_POSTFIELDS, CURLOPT_HTTPAUTH, CURLOPT_COOKIEJAR, CURLOPT_COOKIEFILE and then submitting the data. As well I have tried submitting data straight to the log in page to see if it would let me in and no luck there either. Of course I was forced to get an authenticator so that may be complicating it.

I am hoping a few of you have played around with it more and have a trick up your sleeves.
Krik is offline  
Reply With Quote
Old 02-02-2009, 12:05 PM   #24 (permalink)
The Contributor
 
SaintIsaiah's Avatar
 
Join Date: Jan 2009
Posts: 48
Thanks: 5
SaintIsaiah is on a distinguished road
Default

It is highly possible to get the guild bank logs as that is something I've wanted for myself. However, unless you're logged into the armory and your account has a character in the guild, you cant see it. You could hypothetically embed your username and password in the script to do this, but that will create a security issue for yourself. Unless you make your own form to curl the guild bank requiring a login each time, you're kind of SOL.
SaintIsaiah is offline  
Reply With Quote
Old 02-02-2009, 06:54 PM   #25 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Yes the idea is to make it so an administrator logs in to the guild web site. Then goes to bank log update page and enters the WoW login info and, bang, it grabs the bank logs automatically and stores them on the data base.

I have used cURL for ton of featured on the site. And I can go and manually download a copy of the XML from the bank log and parse it into the data base. Just cannot get the login to work so it can be automated for the less computer literate administrators.

I used cURL to view the non-XML source for their login page so as to see their forms as well have used the XML data they generate as the page source to find out what all the form fields are that need to be submitted. And every thing I have so far tried to submit is not allowing the login.

I am hoping some one has done this and can share their tricks with us.
Krik is offline  
Reply With Quote
Old 02-03-2009, 01:50 AM   #26 (permalink)
The Contributor
 
SaintIsaiah's Avatar
 
Join Date: Jan 2009
Posts: 48
Thanks: 5
SaintIsaiah is on a distinguished road
Default

Unfortunately, this goes a bit passed my current knowledge of PHP. But I will try to work with some functions and post a solution here if I can find one.
SaintIsaiah is offline  
Reply With Quote
Old 02-04-2009, 11:31 PM   #27 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

EDIT
Posted a few hours too early.

PHP Code:
<html>
<body>
<?php
if (isset($_POST['submit'])) {

$username $_POST['username'];
$password $_POST['password'];
$authenticate $_POST['authenticate'];

$postvars "accountName=" $username "&password=" $password;

define(US_LOGIN_URL'https://www.blizzard.com/login/login.xml?referer=http%3A%2F%2Fwww.wowarmory.com%2Fvault%2Fguild-bank-log.xml%3Fr%3DMy%2BRealm%26n%3DMy%2BGuild&loginType=com');


    
$ch curl_init(US_LOGIN_URL);
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_POSTFIELDS$postvars);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt ($chCURLOPT_COOKIEJAR'cookie.txt');
    
$returnedPage curl_exec($ch);
    
curl_close($ch);


    if (
strstr($returnedPage"Invalid account name or password")) {
        echo 
"FAIL: Invalid account name or password<br>";
    }
    elseif (
strstr($returnedPage"Account name required")) {
        echo 
"FAIL: Invalid account name or password<br>";
    }
    elseif (
strstr($returnedPage"Password required")) {
        echo 
"FAIL: Invalid account name or password<br>";
    }
    elseif (
strstr($returnedPage"Authenticator code required")) {
        echo 
"FAIL: Invalid Authenticator code<br>";
    }
    elseif (
strstr($returnedPage"Login failed")) {
        echo 
"FAIL: Invalid account name or password<br>";
    }
    elseif (
strstr($returnedPage"Authenticator Code")) {
        
$postauth "authValue=" $authenticate;
        
        
$ch curl_init(US_LOGIN_URL);
        
curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$postauth);
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_HEADER0);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt ($chCURLOPT_COOKIEJAR'cookie.txt');
        
$returnedPage curl_exec($ch);
        
curl_close($ch);
    
        echo 
$returnedPage;
    }
    else {
        echo 
$returnedPage;
    }
}
else {
?>
<form action="banklog.php" id="loginForm" method="post">

Account Name<input id="username" name="username" type="text" /><br>

Password<input id="password" name="password" type="password" /><br>

Authenticator<input id="authenticate" name="authenticate" type="text" /><br>

<input type="submit" name="submit" value="Submit">

</form>
<?php
}
?>
</body>
</html>
It's a bit sloppy but it works to get the bank logs open, I will clean it up more later. But I am not having any luck getting the XML out of it. I have parsed XML off other WoW pages but I can't off this I keep getting HTML and javascript. Any thoughts here.

Last edited by Krik : 02-05-2009 at 04:07 AM.
Krik is offline  
Reply With Quote
Old 02-05-2009, 07:51 AM   #28 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

Well it seems I keep progressing on this.

PHP Code:
<?php
if (isset($_POST['submit'])) {

$username $_POST['username'];
$password $_POST['password'];
$authenticate $_POST['authenticate'];

$loginvars "accountName=" $username "&password=" $password;

define(WOW_LOGIN_URL'https://www.blizzard.com/login/login.xml?referer=http%3A%2F%2Fwww.wowarmory.com%2Fvault%2Fguild-bank-log.xml%3Fr%3DMy%2BRealm%26n%3DMy%2BGuild&loginType=com');

    
$ch curl_init(WOW_LOGIN_URL);
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_POSTFIELDS$loginvars);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_COOKIEJAR'../hidden/cookie.txt');
    
$results curl_exec($ch);
    
curl_close($ch);


    if (
strstr($results"Invalid account name or password")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Account name required")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Password required")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Authenticator code required")) {
        echo 
"Invalid Authenticator code<br>";
    }
    elseif (
strstr($results"Login failed")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Authenticator Code")) {
        
$loginauth "authValue=" $authenticate;
        
        
$ch curl_init(WOW_LOGIN_URL);
        
curl_setopt($chCURLOPT_COOKIEFILE'../hidden/cookie.txt');
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$loginauth);
        
curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_HEADER0);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_COOKIEJAR'../hidden/cookie.txt');
        
$results curl_exec($ch);
        
curl_close($ch);
    
        echo 
$results;
    }
    else {
        echo 
$results;
    }
}
else {
?>
<html>
<body>
<form action="banklog.php" id="loginForm" method="post">

Account Name<input id="username"name="username" type="text" /><br>

Password<input id="password" name="password" type="password" /><br>

Authenticator<input id="authenticate" name="authenticate" type="text" /><br>

<input type="submit" name="submit" value="Submit">

</form>
</body>
</html>
<?php
}
?>
My earlier mistake was in forgetting the CURLOPT_USERAGENT.

Now I am on the other side of this I can get it to work with my authenticator but I don't think it will work for those that don't have one as the CURLOPT_USERAGENT is not set in the first curl options. When I put it in there it I can't login with my authenticator.
Krik is offline  
Reply With Quote
Old 02-06-2009, 11:59 PM   #29 (permalink)
The Wanderer
 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Yinx is on a distinguished road
Default

Anybody familiar with caching?
Wondering how to cache the displayed data for when the armory is offline as a example.

And to speed up the process of showing, like after it has reached a certain time it shows the cached information.
Yinx is offline  
Reply With Quote
Old 02-07-2009, 07:00 AM   #30 (permalink)
The Contributor
 
Join Date: Feb 2009
Posts: 65
Thanks: 0
Krik is on a distinguished road
Default

You parse the XML and store it in a database. Right now I have the last 5 months of my guilds bank logs stored in a database and the page for viewing them has many of the features of the armory with a few other options for sorting and displaying it added.

Actually the above scripts main purpose will be to allow administrators to log in and update the stored data as often as needed without needing know anything more than their WoW loging info.

On a side note if your just looking to have your browser hold the data you can set up you browser to store websites for use offline. Of course if the armory is just slow to get that data you will need to disconnect your PC from your ISP for it to work.
Krik is offline  
Reply With Quote
Old 02-08-2009, 09:12 PM   #31 (permalink)
The Visitor
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
xtsu is on a distinguished road
Default

This was just what I was looking for! However I do have a question or two. I was wondering how I can parse the achievement pages? I need to grab the Cooking, First Aid and Fishing level of my members and yet I can't seem to get it to work by back engineering the scripts on here.

This is what I have tried to do so far.

First I created a new condition in the function pull_xml If you insert the c=132 into the URL it will take you to that characters info page outlining certain achievements.

Code:
elseif( $this->query === 'skills' ){
        $url = 'http://www.wowarmory.com/character-statistics.xml?c=132&' . urlencode($this->server) . '&n=' . $this->guildie;
        
        }
After that I tried creating the call to that function:

Code:
$armory = new armory('skills', 'steamwheedle cartel', 'fallen legacy', 'xtsu', NULL);
$xml = $armory->pull_xml();

foreach($xml->category as $catg)
{
    $catg = reset($catg);
    echo $catg['name'],'<br />';
}
The above was to see if I could pull and list the different categories but no luck. I am not too sure what to try next and am seeking advice. Like I said I would like to be able to pull the numbers off this page.

Here is a hard link to the XML page that blizzard puts out and that would need to be parsed.

http://www.wowarmory.com/character-s...+Cartel&n=Xtsu
xtsu is offline  
Reply With Quote
Old 02-10-2009, 01:50 AM   #32 (permalink)
The Visitor
 
Join Date: Feb 2009
Posts: 4
Thanks: 0
xtsu is on a distinguished road
Default

PHP Code:
        $armory = new armory('roster''steamwheedle cartel''fallen legacy'NULLNULL);
        
$xml $armory->pull_xml();  

foreach (
$xml->guildInfo->guild->members->character as $char) {
    echo 
$char['name'] . "<br>";

The returns this error now:


Warning: Invalid argument supplied for foreach() in .../fallenlegacy/test3.php on line 96

so I thought it might be the cURL stuff soo I tried the other way and in addition to the above warning I also got this:

Warning: file_get_contents(http://www.wowarmory.com/guild-info....llen+legacy&p=) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in .../fallenlegacy/test3.php on line 81

Does that mean my webserver has a temp ban on it? Or where my webserver is located can't get to the armory?
xtsu is offline  
Reply With Quote
Old 02-11-2009, 02:09 PM   #33 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by Krik View Post
Well it seems I keep progressing on this.

PHP Code:
<?php
if (isset($_POST['submit'])) {

$username $_POST['username'];
$password $_POST['password'];
$authenticate $_POST['authenticate'];

$loginvars "accountName=" $username "&password=" $password;

define(WOW_LOGIN_URL'https://www.blizzard.com/login/login.xml?referer=http%3A%2F%2Fwww.wowarmory.com%2Fvault%2Fguild-bank-log.xml%3Fr%3DMy%2BRealm%26n%3DMy%2BGuild&loginType=com');

    
$ch curl_init(WOW_LOGIN_URL);
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_POSTFIELDS$loginvars);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
    
curl_setopt($chCURLOPT_COOKIEJAR'../hidden/cookie.txt');
    
$results curl_exec($ch);
    
curl_close($ch);


    if (
strstr($results"Invalid account name or password")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Account name required")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Password required")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Authenticator code required")) {
        echo 
"Invalid Authenticator code<br>";
    }
    elseif (
strstr($results"Login failed")) {
        echo 
"Invalid account name or password<br>";
    }
    elseif (
strstr($results"Authenticator Code")) {
        
$loginauth "authValue=" $authenticate;
        
        
$ch curl_init(WOW_LOGIN_URL);
        
curl_setopt($chCURLOPT_COOKIEFILE'../hidden/cookie.txt');
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_POSTFIELDS$loginauth);
        
curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
        
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
curl_setopt($chCURLOPT_HEADER0);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_COOKIEJAR'../hidden/cookie.txt');
        
$results curl_exec($ch);
        
curl_close($ch);
    
        echo 
$results;
    }
    else {
        echo 
$results;
    }
}
else {
?>
<html>
<body>
<form action="banklog.php" id="loginForm" method="post">

Account Name<input id="username"name="username" type="text" /><br>

Password<input id="password" name="password" type="password" /><br>

Authenticator<input id="authenticate" name="authenticate" type="text" /><br>

<input type="submit" name="submit" value="Submit">

</form>
</body>
</html>
<?php
}
?>
My earlier mistake was in forgetting the CURLOPT_USERAGENT.

Now I am on the other side of this I can get it to work with my authenticator but I don't think it will work for those that don't have one as the CURLOPT_USERAGENT is not set in the first curl options. When I put it in there it I can't login with my authenticator.
Keep working on it! I'm sure you will solve it
And when it's working, we can add it to the class
PHP Code:
$guildLog $armory->pull_guildLog($username$password$authenticate); 
Auth would ofcourse be optional, since not everyone has it.
__________________
Tanax is offline  
Reply With Quote
Old 02-12-2009, 02:58 PM   #34 (permalink)
The Wanderer
 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Yinx is on a distinguished road
Default

Cheers for the OP and everyone's else contribution.

Got my roster working and caching, http://resistance.pewpew.nl/members.php
Yinx is offline  
Reply With Quote
Old 02-12-2009, 03:14 PM   #35 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

How did you solve the caching?

Looks good!
__________________
Tanax is offline  
Reply With Quote
Old 02-12-2009, 03:25 PM   #36 (permalink)
The Wanderer
 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Yinx is on a distinguished road
Default

Instead of using some database, which sounded so complicated and making more connections etc.
I went for a file based caching with the use of ob_start() and ob_end_flush().

PHP Code:
<?php
if ($_GET['name']) {
    
$cachefile 'cache/'.$_GET['name'].'.cache'// different cache file for each member profile
} else {
    
$cachefile 'cache/roster.cache'// main members page cache file.
}
$cachetime 24 60 60// hold the cache for 1 day before re-fetching data from armory.
if (file_exists($cachefile) && (time() - $cachetime filemtime($cachefile))) {
    include(
$cachefile); // if cache is not older than 1 day include the cache file.
    
echo "<!-- Cached ".date('jS F Y H:i'filemtime($cachefile))." -->\n";
    exit; 
// stop continuing the script if cache file is included.
}
ob_start(); // start buffering/caching up.
require_once("header.php");
?>
Your usual HTML and or PHP code here, in other words your dynamic content such as this armory member stuff.
<?php
require_once("footer.php");

$cachefp fopen($cachefile'w');
fwrite($cachefpob_get_contents()); //write the buffered/cached data to the cache file.
fclose($cachefp);
ob_end_flush();
?>
Simple but seems to be working :)
Yinx is offline  
Reply With Quote
Old 02-12-2009, 04:09 PM   #37 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Great!

Just a question though. Say the armory goes offline, then this will still work because it's cached for the next 24 hours, great! What if the armory is offline when it's supposed to recache? Then it will cache everything with nothing.. and it won't update it until 24 hours later o.O

Armory won't be offline for 24 hours hopefully, but still, it could be an issue. Any idea? Perhaps try sockets and see if armory is online? Or something..
__________________
Tanax is offline  
Reply With Quote
Old 02-12-2009, 07:23 PM   #38 (permalink)
The Wanderer
 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Yinx is on a distinguished road
Default

Won't be a issue.
Else for a quick fix, just add some extra copy backup old cache and do a filesize check etc :D
Yinx is offline  
Reply With Quote
Old 02-12-2009, 08:18 PM   #39 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

How come that won't be an issue?
Yea, but that is spacerequiring, wouldn't it be better to run a check if the armory is online?
__________________
Tanax is offline  
Reply With Quote
Old 02-12-2009, 09:29 PM   #40 (permalink)
The Wanderer
 
Join Date: Feb 2009
Posts: 11
Thanks: 2
Yinx is on a distinguished road
Default

Don't know how limited you are or how heavy your site is.
For me it is like 10-13KB per cache file.
Yinx is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:53 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design