Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. <?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>
  2. <td width="95%"><img src="layout/images/line_body.gif" width="100%" height="7" border="0" hspace="0" vspace="0" align="left"></td>
  3. <img src="layout/images/titles/t_highscores.png"/>
  4. <td width="95%"><img src="layout/images/line_body.gif" width="100%" height="7" border="0" hspace="0" vspace="0" align="left"></td>
  5. <br><br><p>
  6. <?php
  7.  
  8. if ($config['log_ip']) {
  9. znote_visitor_insert_detailed_data(3);
  10. }
  11.  
  12. // Fetch highscore type
  13. $type = (isset($_GET['type'])) ? (int)getValue($_GET['type']) : 7;
  14. if ($type > 9) $type = 7;
  15.  
  16. // Fetch highscore page
  17. $page = getValue(@$_GET['page']);
  18. if (!$page || $page == 0) $page = 1;
  19. else $page = (int)$page;
  20.  
  21. $highscore = $config['highscore'];
  22.  
  23. $rows = $highscore['rows'];
  24. $rowsPerPage = $highscore['rowsPerPage'];
  25.  
  26. function skillName($type) {
  27. $types = array(
  28. 1 => "Club",
  29. 2 => "Sword",
  30. 3 => "Axe",
  31. 4 => "Distance",
  32. 5 => "Shielding",
  33. 6 => "Fishing",
  34. 7 => "Experience", // Hardcoded
  35. 8 => "Magic Level", // Hardcoded
  36. 9 => "Fist", // Since 0 returns false I will make 9 = 0. :)
  37. );
  38. return $types[(int)$type];
  39. }
  40.  
  41. function pageCheck($index, $page, $rowPerPage) {
  42. return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
  43. }
  44.  
  45. $cache = new Cache('engine/cache/highscores');
  46. if ($cache->hasExpired()) {
  47. $scores = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId']);
  48.  
  49. $cache->setContent($scores);
  50. $cache->save();
  51. } else {
  52. $scores = $cache->load();
  53. }
  54.  
  55. if ($scores) {
  56. ?>
  57. <form action="" method="GET">
  58. <select name="type">
  59. <option value="7" <?php if ($type == 7) echo "selected"; ?>>Experience</option>
  60. <option value="8" <?php if ($type == 8) echo "selected"; ?>>Magic</option>
  61. <option value="5" <?php if ($type == 5) echo "selected"; ?>>Shielding</option>
  62. <option value="2" <?php if ($type == 2) echo "selected"; ?>>Sword</option>
  63. <option value="1" <?php if ($type == 1) echo "selected"; ?>>Club</option>
  64. <option value="3" <?php if ($type == 3) echo "selected"; ?>>Axe</option>
  65. <option value="4" <?php if ($type == 4) echo "selected"; ?>>Distance</option>
  66. <option value="6" <?php if ($type == 6) echo "selected"; ?>>Fishing</option>
  67. <option value="9" <?php if ($type == 9) echo "selected"; ?>>Fist</option>
  68. </select>
  69. <select name="page">
  70. <?php
  71. $pages = (int)($highscore['rows'] / $highscore['rowsPerPage']);
  72. for ($i = 0; $i < $pages; $i++) {
  73. $x = $i + 1;
  74. if ($x == $page) echo "<option value='".$x."' selected>Page: ".$x."</option>";
  75. else echo "<option value='".$x."'>Page: ".$x."</option>";
  76. }
  77. ?>
  78. </select>
  79. <input type="submit" value=" View " class="btn btn-info">
  80. </form>
  81. <table id="highscoresTable" class="table table-striped table-hover">
  82. <tr class="yellow">
  83. <td>Rank</td>
  84. <td>Name</td>
  85. <td>Vocation</td>
  86. <td>Level</td>
  87. <?php if ($type === 7) echo "<td width='10%'>Experience</td>"; ?>
  88. </tr>
  89. <?php
  90. for ($i = 0; $i < count($scores[$type]); $i++) {
  91. if (pageCheck($i, $page, $rowsPerPage)) {
  92. ?>
  93. <tr>
  94. <td><?php echo $i+1; ?></td>
  95. <td><a href="characterprofile.php?name=<?php echo $scores[$type][$i]['name']; ?>"><?php echo $scores[$type][$i]['name']; ?></a></td>
  96. <?php $extra = isPromoted($scores[$type][$i]['id']) == 1 ? 4 : 0; ?>
  97. <td><?php echo vocation_id_to_name($scores[$type][$i]['vocation']+$extra); ?></td>
  98. <td><?php echo $scores[$type][$i]['value']; ?></td>
  99. <?php if ($type === 7) echo "<td>". $scores[$type][$i]['experience'] ."</td>"; ?>
  100. </tr>
  101. <?php
  102. }
  103. }
  104. ?>
  105. </table>
  106. <?php
  107. }
  108. include 'layout/overall/footer.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement