Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.71 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']) : 10;
  9. if ($type > 9) $type = 10;
  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.         10 => "Reborns",
  49.     );
  50.     return $types[(int)$type];
  51. }
  52.  
  53. function pageCheck($index, $page, $rowPerPage) {
  54.     return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
  55. }
  56.  
  57. $cache = new Cache('engine/cache/highscores');
  58. if ($cache->hasExpired()) {
  59.     $vocGroups = fetchAllScores($rows, $config['ServerEngine'], $highscore['ignoreGroupId'], $configVocations, $vocation, $loadFlags, $loadOutfits);
  60.     $cache->setContent($vocGroups);
  61.     $cache->save();
  62. } else {
  63.     $vocGroups = $cache->load();
  64. }
  65.  
  66. if ($vocGroups) {
  67.     $vocGroup = (is_array($vocGroups[$vocation])) ? $vocGroups[$vocation] : $vocGroups[$vocGroups[$vocation]];
  68.     ?>
  69. <div id="news" class="Box">
  70.                                     <div class="Corner-tl" style="background-image:url(layout/images/global/content/corner-tl.gif);"></div>
  71.                                     <div class="Corner-tr" style="background-image:url(layout/images/global/content/corner-tr.gif);"></div>
  72.                                     <div class="Border_1" style="background-image:url(layout/images/global/content/border-1.gif);"></div>
  73.                                     <div class="BorderTitleText" style="background-image:url(layout/images/global/content/title-background-green.gif);"></div>
  74.                                     <img id="ContentBoxHeadline" class="Title" src="layout/images/global/images/highscores.png" alt="Contentbox headline" />
  75.                                     <div class="Border_2">
  76.                                         <div class="Border_3">
  77.                                             <div class="BoxContent" style="background-image:url(layout/images/global/content/scroll.gif);">
  78.     <h1>Ranking for <?php echo skillName($type) .", ". (($vocation === 'all') ? 'any vocation' : vocation_id_to_name($vocation)) ?>.</h1>
  79.  
  80.     <form action="" method="GET">
  81.  
  82.         <select name="type">
  83.             <option value="10" <?php if ($type == 10) echo "selected"; ?>>Reborns</option>
  84.         </select>
  85.  
  86.         <select name="vocation">
  87.             <option value="all" <?php if (!is_int($vocation)) echo "selected"; ?>>Any vocation</option>
  88.             <?php
  89.             foreach ($configVocations as $v_id => $v_data) {
  90.                 if ($v_data['fromVoc'] === false) {
  91.                     $selected = (is_int($vocation) && $vocation == $v_id) ? " selected $vocation = $v_id" : "";
  92.                     echo '<option value="'. $v_id .'"'. $selected .'>'. $v_data['name'] .'</option>';
  93.                 }
  94.             }
  95.             ?>
  96.         </select>
  97.  
  98.         <select name="page">
  99.             <?php
  100.             $pages = ($vocGroup[$type] !== false) ? ceil(min(($highscore['rows'] / $highscore['rowsPerPage']), (count($vocGroup[$type]) / $highscore['rowsPerPage']))) : 1;
  101.             for ($i = 0; $i < $pages; $i++) {
  102.                 $x = $i + 1;
  103.                 if ($x == $page) echo "<option value='".$x."' selected>Page: ".$x."</option>";
  104.                 else echo "<option value='".$x."'>Page: ".$x."</option>";
  105.             }
  106.             ?>
  107.         </select>
  108.  
  109.         <input type="submit" value=" View " class="btn btn-info">
  110.     </form>
  111.  
  112.     <table id="highscoresTable" class="table table-striped table-hover">
  113.  
  114.         <tr class="yellow">
  115.             <?php if ($loadOutfits) echo "<td>Outfit</td>"; ?>
  116.             <td>Rank</td>
  117.             <td>Name</td>
  118.             <td>Vocation</td>
  119.             <td>Reborns</td>
  120.             <?php if ($type === 7) echo "<td>Points</td>"; ?>
  121.         </tr>
  122.  
  123.         <?php
  124.         if ($vocGroup[$type] === false) {
  125.             ?>
  126.             <tr>
  127.                 <td colspan="5">Nothing to show here yet.</td>
  128.             </tr>
  129.             <?php
  130.         } else {
  131.             for ($i = 0; $i < count($vocGroup[$type]); $i++) {
  132.                 if (pageCheck($i, $page, $rowsPerPage)) {
  133.                     $flag = ($loadFlags === true && strlen($vocGroup[$type][$i]['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $vocGroup[$type][$i]['flag'] . '.png">  ' : '';
  134.                     ?>
  135.                     <tr>
  136.                         <?php if ($loadOutfits): ?>
  137.                             <td class="outfitColumn"><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $vocGroup[$type][$i]['type']; ?>&addons=<?php echo $vocGroup[$type][$i]['addons']; ?>&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>
  138.                         <?php endif; ?>
  139.                         <td><?php echo $i+1; ?></td>
  140.                         <td><?php echo $flag; ?><a href="characterprofile.php?name=<?php echo $vocGroup[$type][$i]['name']; ?>"><?php echo $vocGroup[$type][$i]['name']; ?></a></td>
  141.                         <td><?php echo vocation_id_to_name($vocGroup[$type][$i]['vocation']); ?></td>
  142.                         <td><?php echo $vocGroup[$type][$i]['value']; ?></td>
  143.                         <?php if ($type === 7) echo "<td>". $vocGroup[$type][$i]['experience'] ."</td>"; ?>
  144.                     </tr>
  145.                     <?php
  146.                 }
  147.             }
  148.         }
  149.         ?>
  150.     </table>
  151.     <?php
  152. }
  153. include 'layout/overall/footer.php'; ?>
  154.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement