07-04-2009, 06:00 PM
|
#6 (permalink)
|
|
The Wanderer
Join Date: Jul 2009
Posts: 10
Thanks: 1
|
my read file:
PHP Code:
#!/usr/bin/php
<?php
/*
// Include phpbb's config for db info
//include("config.php");
echo 'Working...' . '</br>';
/*
roster_gen class posted by D1g1talS0ul on elitistjerks.com
*/
class roster_gen {
const BROWSER="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20070319 Firefox/2.0.0.3";
public $query;
public $server;
public $guild;
public $guildie;
public $page;
public function __construct ( $query, $server, $guild, $guildie, $page ) {
$this->query = $query;
$this->server = $server;
$this->guild = $guild;
$this->guildie = $guildie;
$this->page = $page;
} // end of __construct()
public function pull_xml() {
if( $this->query === 'roster' ) {
$url = 'http://eu.wowarmory.com/guild-info.xml?r=' . $this->server . '&n=' . $this->guild. '&p=' . $this->page;
} elseif( $this->query === 'character' ) {
$url = 'http://eu.wowarmory.com/character-sheet.xml?r=' . $this->server . '&n=' . $this->guildie;
} elseif( $this->query === 'achievements' ) {
$url = 'http://eu.wowarmory.com/character-achievements.xml?r=' . $this->server . '&cn=' . $this->guildie . '&gn=' .
$this->guild . '&c=168';
}
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt ($ch, CURLOPT_USERAGENT, roster_gen::BROWSER);
$url_string = curl_exec($ch);
return simplexml_load_string($url_string);
curl_close($ch);
} // end of pull_xml()
} // end class
$roster = new roster_gen ('roster', 'stormrage', 'heroes+of+warcraft', NULL, 1);
$xml_roster = $roster->pull_xml();
// Change to querying achievements
$roster->query='achievements';
// Set up the member array
$member_data = array();
$id = 0;
foreach ($xml_roster->guildInfo->guild->members->character as $char)
{
if ($char['level'] == 80 && $char['rank'] <= '3' ) {
$roster->guildie = $char['name'];
$xml_char = $roster->pull_xml();
$ach = find_category($xml_char->category);
$a = array();
$a[0] = check_achievement($ach, 0);
$a[1] = check_achievement($ach, 1);
$a[2] = check_achievement($ach, 2);
$a[3] = check_achievement($ach, 3);
$a[4] = check_achievement($ach, 4);
$a[5] = check_achievement($ach, 5);
$member_data[$id] = array(
'name' => $char['name'],
'0' => $a[0],
'1' => $a[1],
'2' => $a[2],
'3' => $a[3],
'4' => $a[4],
'5' => $a[5]
);
// Provide some output that it's doing stuff
echo 'Updated: <b>' . $char['name'] . '</b> ' . $a[0] . '-' . $a[1] . '-' . $a[2] . '-' . $a[3] . '-' . $a[4] . '-' . $a[5] . '</br>';
$id++;
}
}
/*
echo '</br>Inserting values into DB...</br>';
// Connect to the DB
$db = mysql_connect($dbhost, $dbuser, $dbpasswd);
$db_selected = mysql_select_db($dbname, $db);
foreach ($member_data as $member)
{
$name = $member['name'];
$sql = "insert into ach_data(name, a0, a1, a2, a3, a4, a5)
VALUES ('$name', '$member[0]', '$member[1]', '$member[2]', '$member[3]', '$member[4]', '$member[5]')";
$result = mysql_query($sql);
if(!$result);
echo mysql_error() . "\n";
}
echo 'Database update completed.';
*/
function find_category($xml)
{
foreach($xml->achievement as $ach) {
if($ach['id'] == 576)
return $ach;
}
}
function check_achievement($achievement, $num) {
if($achievement ['dateCompleted'] != NULL)
return 1;
else
if($achievement->criteria[$num]['date'] != NULL)
return 1;
else
return 0;
}
?>
source XML file is
http://eu.wowarmory.com/character-ac...warcraft&c=168
to find the area i might be having problems in the xml file just search for and look between the
Code:
[acheivement][/achievment]
tags, my read file is the ONLY code i use except a few settings in a config which are for mysql only anyways
Code:
function check_achievement($achievement, $num) {
if($achievement ['dateCompleted'] != NULL)
return 1;
else
if($achievement->criteria[$num]['date'] != NULL)
return 1;
else
return 0;
seems to be the area where the problem is and the error its kicking out is
Code:
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Notice: Trying to get property of non-object in C:\wamp\www\ulduar.php on line 163
Updated: Rabbitpt 0-0-0-0-0-0
|
|
|
|