Advertisement
HalestormXV

Roster

Oct 18th, 2013
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.23 KB | None | 0 0
  1. <?php
  2. // setup options can be set here
  3. $region ="us"; // region code
  4. $realm = "Greymane"; // realm name
  5. $guild = "Azeroths%Brotherhood"; // multiple worded guildnames must have %20 between the words to make script works
  6. $ranks = array('GM', 'Assistant GM', 'Officer', 'Veteran', 'Badass', 'Badass 2', 'Member', 'Initiate');
  7.  
  8. // options end
  9.  
  10. @$json = file_get_contents("http://us.battle.net/api/wow/guild/greymane/Azeroths%20Brotherhood?fields=members,achievements");
  11. if($json == false)
  12. {
  13. throw new Exception("Failed To load infomation. Silly goose. Are your configs right?");
  14. }
  15. $stormDecode = json_decode($json, true);
  16. //$rows = $stormDecode['members'];
  17. $rows=array();
  18. foreach ($stormDecode['members'] as $i => $e)
  19. {
  20. $rows[$i]['rank'] = $e['rank'];
  21. $rows[$i]['name'] = $e['character']['name'];
  22. $rows[$i]['class'] = $e['character']['class'];
  23. $rows[$i]['race'] = $e['character']['race'];
  24. $rows[$i]['level'] = $e['character']['level'];
  25. $rows[$i]['gender'] = $e['character']['gender'];
  26. }
  27.  
  28. $s = (isset($_GET['s']) ? $_GET['s'] : '');
  29. $u = (isset($_GET['u']) ? $_GET['u'] : '0');
  30.  
  31. if ($s != '')
  32. {
  33. sksort($rows,$s,$u);
  34. }
  35. else
  36. {
  37. sksort($rows,'rank',true);
  38. }
  39. //Guild Roster Table Headers
  40. echo " <div width='600px' align#'center'>";
  41. echo '
  42. <div align="center" id="roster" class="roster" style="float: none;">
  43. <table class="warcraft sortable" border="3" cellspacing="0" cellpadding="0" align="center">
  44. <tr>
  45. <!--<th width="80px" align="center" valign="top" ><strong><font color=red>Race</font></strong></a></th>-->
  46. <th width="140px" align="center" valign="top"><strong><font color=red>Name</font></strong></a></th>
  47. <th width="80px" align="center" valign="top"><strong><font color=red>Level</font></strong></a></th>
  48. <th width="140px" align="center" valign="top"><font color=red><strong>Rank</font></strong></a></th>
  49. </tr>';
  50.  
  51. //Characters
  52. foreach($rows as $p) {
  53. $mRank = $p['rank'];
  54. $mName = $p['name'];
  55. $mClass = $p['class'];
  56. $mRace = $p['race'];
  57. $mLevel = $p['level'];
  58. $mGender = $p['gender'];
  59. //Table of GMember
  60. echo "
  61. <tr>
  62. <!--<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>-->
  63. <td class='class_$mclass' width=\"140px\" align=\"center\" valign=\"top\" ><strong>$mname</strong></td>
  64. <td width=\"80px\" align=\"center\" valign=\"top\" ><strong>$mlevel</strong></td>
  65. <td sorttable_customkey='$mrank' width=\"140px\" align=\"center\" valign=\"top\" ><strong>$ranks[$mrank]</strong></td>
  66. </tr>
  67. ";
  68. }
  69. echo " </table></div>";
  70.  
  71. function sksort(&$array, $subkey="id", $sort_ascending=false)
  72. {
  73.  
  74. if (count($array))
  75. $temp_array[key($array)] = array_shift($array);
  76.  
  77. foreach($array as $key => $val){
  78. $offset = 0;
  79. $found = false;
  80. foreach($temp_array as $tmp_key => $tmp_val)
  81. {
  82. if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey]))
  83. {
  84. $temp_array = array_merge( (array)array_slice($temp_array,0,$offset),
  85. array($key => $val),
  86. array_slice($temp_array,$offset)
  87. );
  88. $found = true;
  89. }
  90. $offset++;
  91. }
  92. if(!$found) $temp_array = array_merge($temp_array, array($key => $val));
  93. }
  94.  
  95. if ($sort_ascending) $array = array_reverse($temp_array);
  96.  
  97. else $array = $temp_array;
  98. }
  99. echo " </table></div>";
  100. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement