Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // setup options can be set here
- $region ="us"; // region code
- $realm = "Greymane"; // realm name
- $guild = "Azeroths%Brotherhood"; // multiple worded guildnames must have %20 between the words to make script works
- $ranks = array('GM', 'Assistant GM', 'Officer', 'Veteran', 'Badass', 'Badass 2', 'Member', 'Initiate');
- // options end
- @$json = file_get_contents("http://us.battle.net/api/wow/guild/greymane/Azeroths%20Brotherhood?fields=members,achievements");
- if($json == false)
- {
- throw new Exception("Failed To load infomation. Silly goose. Are your configs right?");
- }
- $stormDecode = json_decode($json, true);
- //$rows = $stormDecode['members'];
- $rows=array();
- foreach ($stormDecode['members'] as $i => $e)
- {
- $rows[$i]['rank'] = $e['rank'];
- $rows[$i]['name'] = $e['character']['name'];
- $rows[$i]['class'] = $e['character']['class'];
- $rows[$i]['race'] = $e['character']['race'];
- $rows[$i]['level'] = $e['character']['level'];
- $rows[$i]['gender'] = $e['character']['gender'];
- }
- $s = (isset($_GET['s']) ? $_GET['s'] : '');
- $u = (isset($_GET['u']) ? $_GET['u'] : '0');
- if ($s != '')
- {
- sksort($rows,$s,$u);
- }
- else
- {
- sksort($rows,'rank',true);
- }
- //Guild Roster Table Headers
- echo " <div width='600px' align#'center'>";
- echo '
- <div align="center" id="roster" class="roster" style="float: none;">
- <table class="warcraft sortable" border="3" cellspacing="0" cellpadding="0" align="center">
- <tr>
- <!--<th width="80px" align="center" valign="top" ><strong><font color=red>Race</font></strong></a></th>-->
- <th width="140px" align="center" valign="top"><strong><font color=red>Name</font></strong></a></th>
- <th width="80px" align="center" valign="top"><strong><font color=red>Level</font></strong></a></th>
- <th width="140px" align="center" valign="top"><font color=red><strong>Rank</font></strong></a></th>
- </tr>';
- //Characters
- foreach($rows as $p) {
- $mRank = $p['rank'];
- $mName = $p['name'];
- $mClass = $p['class'];
- $mRace = $p['race'];
- $mLevel = $p['level'];
- $mGender = $p['gender'];
- //Table of GMember
- echo "
- <tr>
- <!--<td align='center'><strong><img style=\"padding-left: 5px;\" src=\"race/$mrace-$mgender.gif\"></img><img style=\"padding-left: 5px;\" src=\"class/$mclass.gif\"></img></strong></td>-->
- <td class='class_$mclass' width=\"140px\" align=\"center\" valign=\"top\" ><strong>$mname</strong></td>
- <td width=\"80px\" align=\"center\" valign=\"top\" ><strong>$mlevel</strong></td>
- <td sorttable_customkey='$mrank' width=\"140px\" align=\"center\" valign=\"top\" ><strong>$ranks[$mrank]</strong></td>
- </tr>
- ";
- }
- echo " </table></div>";
- function sksort(&$array, $subkey="id", $sort_ascending=false)
- {
- if (count($array))
- $temp_array[key($array)] = array_shift($array);
- foreach($array as $key => $val){
- $offset = 0;
- $found = false;
- foreach($temp_array as $tmp_key => $tmp_val)
- {
- if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey]))
- {
- $temp_array = array_merge( (array)array_slice($temp_array,0,$offset),
- array($key => $val),
- array_slice($temp_array,$offset)
- );
- $found = true;
- }
- $offset++;
- }
- if(!$found) $temp_array = array_merge($temp_array, array($key => $val));
- }
- if ($sort_ascending) $array = array_reverse($temp_array);
- else $array = $temp_array;
- }
- echo " </table></div>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement