Guest User

Untitled

a guest
Jun 18th, 2021
30
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php require_once 'engine/init.php';
  2.  
  3. if ($config['log_ip']) {
  4. znote_visitor_insert_detailed_data(3);
  5. }
  6.  
  7. function fetchAllScoresh($rows, $tfs, $g, $v = -1) {
  8. // Return scores ordered by type and vocation (if set)
  9. $data = array();
  10. if ($tfs == 'TFS_10') {
  11.  
  12. // Generate SQL WHERE-clause for vocation if $v is set
  13. $v = ($v > -1) ? 'AND `vocation` = '. intval($v) : NULL;
  14.  
  15. $data[1] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_club` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_club` DESC LIMIT 0, $rows;");
  16. $data[2] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_sword` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_sword` DESC LIMIT 0, $rows;");
  17. $data[3] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_axe` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_axe` DESC LIMIT 0, $rows;");
  18. $data[4] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_dist` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_dist` DESC LIMIT 0, $rows;");
  19. $data[5] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_shielding` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_shielding` DESC LIMIT 0, $rows;");
  20. $data[6] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_fishing` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fishing` DESC LIMIT 0, $rows;");
  21. $data[7] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `experience`, `level` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC LIMIT 0, $rows;");
  22. $data[8] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `maglevel` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC LIMIT 0, $rows;");
  23. $data[9] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_fist` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fist` DESC LIMIT 0, $rows;");
  24. } else {
  25.  
  26. // Generate SQL WHERE-clause for vocation if $v is set
  27. $v = ($v > -1) ? 'AND `vocation` = '. intval($v) : NULL;
  28.  
  29. $data[9] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 0 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  30. $data[1] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 1 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  31. $data[2] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 2 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  32. $data[3] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 3 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  33. $data[4] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 4 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  34. $data[5] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 5 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  35. $data[6] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` FROM `player_skills` AS `s` LEFT JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` WHERE `s`.`skillid` = 6 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
  36. $data[7] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `id`, `name`, `vocation`, `experience`, `level` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC limit 0, $rows;");
  37. $data[8] = mysql_select_multi("SELECT `looktype`, `lookhead`, `lookbody`, `looklegs`, `lookfeet`, `id`, `name`, `vocation`, `maglevel` AS `value` FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC limit 0, $rows;");
  38. }
  39. return $data;
  40. }
  41.  
  42. // Fetch highscore type
  43. $type = (isset($_GET['type'])) ? (int)getValue($_GET['type']) : 7;
  44. if ($type > 9) $type = 7;
  45.  
  46. // Fetch highscore vocation
  47. $vocation = (isset($_GET['vocation'])) ? (int)getValue($_GET['vocation']) : -1;
  48. if ($vocation > 8) $vocation = -1;
  49.  
  50. // Fetch highscore page
  51. $page = getValue(@$_GET['pag']);
  52. if (!$page || $page == 0) $page = 1;
  53. else $page = (int)$page;
  54.  
  55. $highscore = $config['highscore'];
  56.  
  57. $rows = $highscore['rows'];
  58. $rowsPerPage = $highscore['rowsPerPage'];
  59.  
  60. function skillName($type) {
  61. $types = array(
  62. 1 => "Club",
  63. 2 => "Sword",
  64. 3 => "Axe",
  65. 4 => "Distance",
  66. 5 => "Shield",
  67. 6 => "Fish",
  68. 7 => "Experience", // Hardcoded
  69. 8 => "Magic Level", // Hardcoded
  70. 9 => "Fist", // Since 0 returns false I will make 9 = 0. :)
  71. );
  72. return $types[(int)$type];
  73. }
  74.  
  75. function pageCheck($index, $page, $rowPerPage) {
  76. return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
  77. }
  78.  
  79. $cache = new Cache('engine/cache/highscores');
  80. if ($cache->hasExpired()) {
  81. $scores = fetchAllScoresh($rows, $config['TFSVersion'], $highscore['ignoreGroupId'], $vocation);
  82.  
  83. $cache->setContent($scores);
  84. $cache->save();
  85. } else {
  86. $scores = $cache->load();
  87. }
  88.  
  89. if ($scores) {
  90. ?>
  91. <style>
  92. .newstext img
  93. {
  94. max-width: 562px;
  95. height: auto;
  96. margin: 0 5px;
  97. }
  98. .pagination
  99. {
  100. text-align: center;
  101. margin: 10px 0;
  102. }
  103. .pagination a
  104. {
  105. display: inline-block;
  106. color: #52412f;
  107. font-size: 14px;
  108. line-height: 24px;
  109. height: 24px;
  110. width: 24px;
  111. font-weight: bold;
  112. text-align: center;
  113. border: 1px solid #886a4d;
  114. margin: 0 5px 0 0;
  115. border-radius: 24px;
  116. box-shadow: 0 2px 3px rgb(255, 214, 175) inset;
  117. background: #dcaf83;
  118. transition: opacity 0.1s linear;
  119. }
  120. .pagination a:hover
  121. {
  122. opacity: 0.7;
  123. }
  124. .pagination a.current
  125. {
  126. background: #ad1a1a;
  127. color: #fff;
  128. border: 1px solid #000000;
  129. box-shadow: 0 2px 3px rgb(255, 62, 62) inset;
  130. }
  131. </style>
  132.  
  133. <form type="submit" action="" method="GET">
  134. <br>
  135. <center>Skill: <input type="hidden" name="page" value="highscores"/>
  136. <select style="vertical-align:middle;" name="type">
  137. <option value="7" <?php if ($type == 7) echo "selected"; ?>>Experience</option>
  138. <option value="8" <?php if ($type == 8) echo "selected"; ?>>Magic</option>
  139. <option value="5" <?php if ($type == 5) echo "selected"; ?>>Shield</option>
  140. <option value="2" <?php if ($type == 2) echo "selected"; ?>>Sword</option>
  141. <option value="1" <?php if ($type == 1) echo "selected"; ?>>Club</option>
  142. <option value="3" <?php if ($type == 3) echo "selected"; ?>>Axe</option>
  143. <option value="4" <?php if ($type == 4) echo "selected"; ?>>Distance</option>
  144. <option value="6" <?php if ($type == 6) echo "selected"; ?>>Fish</option>
  145. <option value="9" <?php if ($type == 9) echo "selected"; ?>>Fist</option>
  146. </select>
  147. &nbsp;&nbsp;Vocation: <select style="vertical-align:middle;" name="vocation">
  148. <option value="-1" <?php if ($vocation < 0) echo "selected"; ?>>Any vocation</option>
  149.  
  150. <?php
  151. foreach (config('vocations') as $v_id => $v_name) {
  152. $selected = ($vocation == $v_id) ? " selected" : NULL;
  153.  
  154. echo '<option value="'. $v_id .'"'. $selected .'>'. $v_name .'</option>';
  155. }
  156. ?>
  157. </select>
  158.  
  159. <input type="submit" class="hover" value=""
  160. style="background-image: url(layout/tibia_img/sbutton_submit.gif); vertical-align:middle; border: solid 0px #000000; width: 120px; height: 18px;" />
  161. </center>
  162. </form>
  163.  
  164.  
  165. <br><center><span class="pagination">
  166. <?php
  167. $pages = ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($scores[$type]) / $highscore['rowsPerPage'])));
  168. for ($i = 0; $i < $pages; $i++) {
  169. $x = $i + 1;
  170. if ($x == $page) echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\" class=\"current\">".$x."</a>";
  171. else echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\">".$x."</a>";
  172. }
  173. ?>
  174. </span></center>
  175.  
  176.  
  177. <table id="highscoresTable" cellpadding="4" class="stripped">
  178. <tr>
  179. <th colspan="7">Ranking for <?php echo skillName($type) .", ". (($vocation < 0) ? 'any vocation' : vocation_id_to_name($vocation)) ?></th>
  180. </tr>
  181. <tr>
  182. <td width="8%"><center>#</center></td>
  183. <td width="8%"><center><strong>outfit</strong></center></td>
  184. <?php if ($config['country_flags'] === true) echo'<td width="5%"><center><strong>flag</strong></center></td>'; ?>
  185. <td><strong>Name</strong></td>
  186. <td><center><strong>Vocation</strong></center></td>
  187. <td width="15%"><center><strong>Level</strong></center></td>
  188. <?php if ($type === 7) echo "<td width=\"15%\"><center><strong>Points</strong></center></td>"; ?>
  189. </tr>
  190. <?php
  191. for ($i = 0; $i < count($scores[$type]); $i++) {
  192. if ($scores[$type] === false) {
  193. ?>
  194. <tr>
  195. <td colspan="7">Nothing to show here yet.</td>
  196. </tr>
  197. <?php
  198. } else {
  199. if (pageCheck($i, $page, $rowsPerPage)) {
  200. $profile_data = user_character_data($scores[$type][$i]['id'], 'account_id');
  201.  
  202. $account_data = user_znote_account_data($profile_data['account_id'], 'flag');
  203. if ($config['country_flags'] === true) $flag = '<td><center><img src="flags/' . $account_data['flag'] . '.png"></center></td>';
  204. else $flag = '';
  205. ?>
  206. <tr>
  207. <td><center><?php echo $i+1; ?>.</center></td>
  208. <td>
  209. <?php
  210. echo '<div style="position:relative; left:-32px; top:-32px;width: 32px;height:32px;">
  211. <div style="background-image: url(layout/outfitter/outfit.php?id='.$scores[$type][$i]['looktype'].'&head='.$scores[$type][$i]['lookhead'].'&body='.$scores[$type][$i]['lookbody'].'&legs='.$scores[$type][$i]['looklegs'].'&feet='.$scores[$type][$i]['lookfeet'].');
  212. width:64px;height:64px;position:absolute;background-repeat:no-repeat;background-position:right bottom;">
  213. </div>';
  214. ?>
  215.  
  216. </td>
  217. <?php echo $flag; ?>
  218. <td><strong><a href="characterprofile.php?name=<?php echo $scores[$type][$i]['name']; ?>"><?php echo $scores[$type][$i]['name']; ?></a></strong></td>
  219. <td><center><?php echo vocation_id_to_name($scores[$type][$i]['vocation']); ?></center></td>
  220. <td><center><?php echo $scores[$type][$i]['value']; ?></center></td>
  221. <?php if ($type === 7) echo "<td><center>". $scores[$type][$i]['experience'] ."</center></td>"; ?>
  222. </tr>
  223. <?php
  224. }
  225. }
  226. }
  227. ?>
  228. </table>
  229. <center><span class="pagination">
  230. <?php
  231. $pages = ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($scores[$type]) / $highscore['rowsPerPage'])));
  232. for ($i = 0; $i < $pages; $i++) {
  233. $x = $i + 1;
  234. if ($x == $page) echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\" class=\"current\">".$x."</a>";
  235. else echo "<a href=\"?".$_SERVER['QUERY_STRING']."&pag=".$x."\">".$x."</a>";
  236. }
  237. ?>
  238. </span></center>
  239. <?php
  240. }
  241. ?>
  242.  
RAW Paste Data