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-08-2009, 12:36 AM   #1 (permalink)
The Visitor
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Dark Severance is on a distinguished road
Default xml Grabber w/ cURL w/ sortableTable?

Using code from this post:
World of Warcraft Armory xml Grabber with cURL

I started working with the from the Armory using what was there, combining that with a Sortable Table script so that the roster can be easily organized, filtered depending on what you are looking for.

Here is example of it working fine. Everything works great:
http://wow.guildregister.com/sortableTable/roster2.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PoD - Roster Test</title>

<link rel="stylesheet" href="../_common/css/main.css" type="text/css" media="all">

<link href="sortableTable.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="../_common/js/mootools.js"></script>
<script type="text/javascript" src="sortableTable.js"></script>

</head>
<body>
<script type="text/javascript" src="wz_tooltip.js"></script>

<?php

class armory {

 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() {

    // change the first part of the $url to the armory link that you need
    if( $this->query === 'roster' ){
        $url = 'http://www.wowarmory.com/guild-info.xml?r=' . urlencode($this->server) . '&n=' . urlencode($this->guild) . '&p=' . $this->page;
        
      }elseif( $this->query === 'character' ){
        $url = 'http://www.wowarmory.com/character-sheet.xml?r=' . urlencode($this->server) . '&n=' . $this->guildie;
        
        }  

    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 15);
    curl_setopt ($ch, CURLOPT_USERAGENT,  self::BROWSER);
    
    $url_string = curl_exec($ch);
    curl_close($ch);
    return simplexml_load_string($url_string);
    
   
 } // end of pull_xml()

} // end class  

$armory = new armory('roster', 'Drenden', 'Priests of Discord', NULL, NULL);
$xml = $armory->pull_xml(); 
			
?>

	<div id="container">
	
		<div id="PoD"><img src="http://wow.guildregister.com/mkportal/templates/wow/images/logo.jpg"></div>
		<br />
		<div class="nav"><a href="../">home</a></div>
		<p class="desc">Description information can go here .. .. ...</p>
		<h3 class="Guild">Guild Roster Test</h3>
		<div id="example">
			<div class="tableFilter">
		  		<form id="tableFilter" onsubmit="myTable.filter(this.id); return false;">Filter: 
					<select id="column">
		  				<option value="0">Level</option>
		  				<option value="1">Name</option>
						<option value="2">Class</option>
						<option value="3">Race</option>
						<option value="4">Achievement Points</option>

					</select>
					<input type="text" id="keyword" />
					<input type="submit" value="Submit" />
					<input type="reset" value="Clear" />
				</form>
		  </div>
		  <table id="myTable" cellpadding="0" cellpadding="0">
		  	<thead>
				<th axis="number">Level</th>
				<th axis="string">Name</th>
				<th axis="string">Class</th>
				<th axis="string">Race</th>
				<th axis="number">Achievement Points</th>
			</thead>
			<tbody>

<?
foreach ($xml->guildInfo->guild->members->character as $char) {
  echo "<tr id=\"".$char['name']."\">";
  echo "<td>".$char['level']."</td>";
  echo "<td>".$char['name']."</td>";
  echo "<td>".$char['class']."</td>";
  echo "<td>".$char['race']."</td>";
  echo "<td>".$char['achPoints']."</td>";
  echo "</tr>";

			}
?>
				
			</tbody>
			<tfoot>
				<tr>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</tfoot>
		  </table>

		<script type="text/javascript">
			var myTable = {};
			window.addEvent('domready', function(){
				myTable = new sortableTable('myTable', {overCls: 'over', onClick: function(){alert()}});
			});
		</script>
		</div>
		
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3333085-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
I wanted to add more to it by making the name linkable to the armory profile and also using icon graphic to represent class, race similar to the armory itself. The good news is I have it working. The bad news is that breaks the filter function, I can't seem to be able search by anything except level.

Here is it with the URL links and graphics working, however if you notice the filters aren't working anymore:
http://wow.guildregister.com/sortableTable/roster.php

The only code that I changed out was the echo for the "foreach" part adding in url and image links based on the variables.
Code:
<?
foreach ($xml->guildInfo->guild->members->character as $char) {
  echo "<tr id=\"".$char['name']."\">";
  echo "<td>".$char['level']."</td>";
  echo "<td>".$char['name']."<a href=\"http://www.wowarmory.com/character-sheet.xml?".$char['url']."\" onclick=\"window.open(this.href); return false\" \">".$char['name']."</a</td>";
  echo "<td><img src=\"images/icons/".$char['classId'].".gif\" onmouseover=\"Tip('".$char['class']."')\" onmouseout=\"UnTip()\"></td>";
  echo "<td><img src=\"images/icons/".$char['raceId']."-".$char['genderId'].".gif\" onmouseover=\"Tip('".$char['race']." ".$char['gender']."')\" onmouseout=\"UnTip()\"></td>";
  echo "<td>".$char['achPoints']."</td>";
  echo "</tr>";

			}
?>
Any idea on why the search function wouldn't work anymore?
Dark Severance 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
World of Warcraft Armory xml Grabber with cURL mortisimus Show Off 144 06-25-2012 12:34 PM
Yahoo! Grabber xenon Advanced PHP Programming 3 10-04-2008 01:03 PM
yet another curl question.... Jenski General 8 07-01-2008 10:36 AM
Saving ALL the cookie data using cURL Wildhoney Advanced PHP Programming 1 06-12-2008 07:07 PM
A serious curl checkbox problem bedri Advanced PHP Programming 1 05-22-2008 04:25 PM


All times are GMT. The time now is 02:36 AM.

 
     

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