Advertisement
Guest User

Untitled

a guest
Feb 6th, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.46 KB | None | 0 0
  1. <?php require_once 'engine/init.php'; include 'layout/overall/header.php';
  2.  
  3. if ($config['log_ip']) {
  4. znote_visitor_insert_detailed_data(3);
  5. }
  6.  
  7. // Fetch highscore type
  8. $type = (isset($_GET['type'])) ? (int)getValue($_GET['type']) : 7;
  9. if ($type > 9) $type = 7;
  10.  
  11. // Fetch highscore vocation
  12. $configVocations = $config['vocations'];
  13. //$debug['configVocations'] = $configVocations;
  14.  
  15. $vocationIds = array_keys($configVocations);
  16.  
  17. $vocation = 'all';
  18. if (isset($_GET['vocation']) && is_numeric($_GET['vocation'])) {
  19. $vocation = (int)$_GET['vocation'];
  20. if (!in_array($vocation, $vocationIds)) {
  21. $vocation = "all";
  22. }
  23. }
  24.  
  25. // Fetch highscore page
  26. $page = getValue(@$_GET['page']);
  27. if (!$page || $page == 0) $page = 1;
  28. else $page = (int)$page;
  29.  
  30. $highscore = $config['highscore'];
  31. $loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['highscores']) ? true : false;
  32. $loadOutfits = ($config['show_outfits']['highscores']) ? true : false;
  33.  
  34. $rows = $highscore['rows'];
  35. $rowsPerPage = $highscore['rowsPerPage'];
  36.  
  37. function skillName($type) {
  38. $types = array(
  39. 1 => "Club",
  40. 2 => "Sword",
  41. 3 => "Axe",
  42. 4 => "Distance",
  43. 5 => "Shield",
  44. 6 => "Fish",
  45. 7 => "Experience", // Hardcoded
  46. 8 => "Magic Level", // Hardcoded
  47. 9 => "Fist", // Since 0 returns false I will make 9 = 0. :)
  48. );
  49. return $types[(int)$type];
  50. }
  51.  
  52. function pageCheck($index, $page, $rowPerPage) {
  53. return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
  54. }
  55.  
  56. $cache = new Cache('engine/cache/highscores');
  57. if ($cache->hasExpired()) {
  58. $vocGroups = fetchAllScores($rows, $config['ServerEngine'], $highscore['ignoreGroupId'], $configVocations, $vocation, $loadFlags, $loadOutfits);
  59. $cache->setContent($vocGroups);
  60. $cache->save();
  61. } else {
  62. $vocGroups = $cache->load();
  63. }
  64.  
  65. if ($vocGroups) {
  66. $vocGroup = (is_array($vocGroups[$vocation])) ? $vocGroups[$vocation] : $vocGroups[$vocGroups[$vocation]];
  67. ?>
  68.  
  69. <h1>Ranking for <?php echo skillName($type) .", ". (($vocation === 'all') ? 'any vocation' : vocation_id_to_name($vocation)) ?>.</h1>
  70.  
  71. <form action="" method="GET">
  72.  
  73. <select name="type">
  74. <option value="7" <?php if ($type == 7) echo "selected"; ?>>Experience</option>
  75. <option value="8" <?php if ($type == 8) echo "selected"; ?>>Magic</option>
  76. <option value="5" <?php if ($type == 5) echo "selected"; ?>>Shield</option>
  77. <option value="2" <?php if ($type == 2) echo "selected"; ?>>Sword</option>
  78. <option value="1" <?php if ($type == 1) echo "selected"; ?>>Club</option>
  79. <option value="3" <?php if ($type == 3) echo "selected"; ?>>Axe</option>
  80. <option value="4" <?php if ($type == 4) echo "selected"; ?>>Distance</option>
  81. <option value="6" <?php if ($type == 6) echo "selected"; ?>>Fish</option>
  82. <option value="9" <?php if ($type == 9) echo "selected"; ?>>Fist</option>
  83. </select>
  84.  
  85. <select name="vocation">
  86. <option value="all" <?php if (!is_int($vocation)) echo "selected"; ?>>Any vocation</option>
  87. <?php
  88. foreach ($configVocations as $v_id => $v_data) {
  89. if ($v_data['fromVoc'] === false) {
  90. $selected = (is_int($vocation) && $vocation == $v_id) ? " selected $vocation = $v_id" : "";
  91. echo '<option value="'. $v_id .'"'. $selected .'>'. $v_data['name'] .'</option>';
  92. }
  93. }
  94. ?>
  95. </select>
  96.  
  97. <select name="page">
  98. <?php
  99. $pages = ($vocGroup[$type] !== false) ? ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($vocGroup[$type]) / $highscore['rowsPerPage']))) : 1;
  100. for ($i = 0; $i < $pages; $i++) {
  101. $x = $i + 1;
  102. if ($x == $page) echo "<option value='".$x."' selected>Page: ".$x."</option>";
  103. else echo "<option value='".$x."'>Page: ".$x."</option>";
  104. }
  105. ?>
  106. </select>
  107.  
  108. <input type="submit" value=" View " class="btn btn-info">
  109. </form>
  110.  
  111. <table id="highscoresTable" class="table table-striped table-hover">
  112.  
  113. <tr class="yellow">
  114. <?php if ($loadOutfits) echo "<td>Outfit</td>"; ?>
  115. <td>Rank</td>
  116. <td>Name</td>
  117. <td>Vocation</td>
  118. <td>Level</td>
  119. <?php if ($type === 7) echo "<td>Points</td>"; ?>
  120. </tr>
  121.  
  122. <?php
  123. if ($vocGroup[$type] === false) {
  124. ?>
  125. <tr>
  126. <td colspan="5">Nothing to show here yet.</td>
  127. </tr>
  128. <?php
  129. } else {
  130. for ($i = 0; $i < count($vocGroup[$type]); $i++) {
  131. if (pageCheck($i, $page, $rowsPerPage)) {
  132. $flag = ($loadFlags === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $vocGroup[$type][$i]['flag'] . '.png"> ' : '';
  133. ?>
  134. <tr>
  135. <?php if ($loadOutfits): ?>
  136. <td class="outfitColumn"><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $vocGroup[$type][$i]['type']; ?>&head=<?php echo $vocGroup[$type][$i]['head']; ?>&body=<?php echo $vocGroup[$type][$i]['body']; ?>&legs=<?php echo $vocGroup[$type][$i]['legs']; ?>&feet=<?php echo $vocGroup[$type][$i]['feet']; ?>" alt="img"></td>
  137. <?php endif; ?>
  138. <td><?php echo $i+1; ?></td>
  139. <td><?php echo $flag; ?><a href="characterprofile.php?name=<?php echo $vocGroup[$type][$i]['name']; ?>"><?php echo $vocGroup[$type][$i]['name']; ?></a></td>
  140. <td><?php echo vocation_id_to_name($vocGroup[$type][$i]['vocation']); ?></td>
  141. <td><?php echo $vocGroup[$type][$i]['value']; ?></td>
  142. <?php if ($type === 7) echo "<td>". $vocGroup[$type][$i]['experience'] ."</td>"; ?>
  143. </tr>
  144. <?php
  145. }
  146. }
  147. }
  148. ?>
  149. </table>
  150. <?php
  151. }
  152. include 'layout/overall/footer.php'; ?>
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement