1<?php require_once 'engine/init.php'; theme_open();
2
3if ($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'] ?? null) : 7;
9if ($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';
18if (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'] ?? null);
27if (!$page || $page == 0) $page = 1;
28else $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
37function 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
52function pageCheck($index, $page, $rowPerPage) {
53 return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
54}
55
56$cache = new Cache('engine/cache/highscores');
57if ($cache->hasExpired()) {
58 $vocGroups = fetchAllScores($rows, znote_server_adapter()->normalizedEngine(), $highscore['ignoreGroupId'], $configVocations, $vocation, $loadFlags, $loadOutfits);
59 $cache->setContent($vocGroups);
60 $cache->save();
61} else {
62 $vocGroups = $cache->load();
63}
64
65view('highscores');
66
67theme_close();
68