diff --git a/config.php b/config.php
index 8eedd7b..d33c9af 100644
--- a/config.php
+++ b/config.php
@@ -4,7 +4,7 @@
// TFS 0.3 = TFS_03 (If ur using 0.3.6, set $config['salt'] to false)!
// TFS 0.4 = TFS_03
// TFS 1.0 = TFS_10 (Under developement)
- $config['TFSVersion'] = 'TFS_10';
+ $config['TFSVersion'] = 'TFS_04';
$config['site_title'] = 'Znote AAC';
$config['site_title_context'] = 'Because open communities are good communities. :3';
@@ -14,13 +14,13 @@
// ------------------------ \\
// phpmyadmin username for OT server: (DONT USE "root" if ur hosting to public.).
- $config['sqlUser'] = 'dev';
+ $config['sqlUser'] = 'gremlee';
// phpmyadmin password for OT server:
- $config['sqlPassword'] = 'dev';
+ $config['sqlPassword'] = 'gremlee';
// The database name to connect to. (This is usually same as username).
- $config['sqlDatabase'] = 'dev';
+ $config['sqlDatabase'] = 'gremlee';
// Hostname is usually localhost or 127.0.0.1.
$config['sqlHost'] = 'localhost';
@@ -140,6 +140,13 @@
// WEBSITE STUFF \\
// -------------- \\
+ // Highscore configuration
+ $config['highscore'] = array(
+ 'rows' => 100,
+ 'rowsPerPage' => 20,
+ 'ignoreGroupId' => 2, // Ignore group id higher than this (staff)
+ );
+
// ONLY FOR TFS 0.2 (TFS 0.3/4 users don't need to care about this, as its fully loaded from db)
$config['house'] = array(
'house_file' => 'C:\test\Mystic Spirit_0.2.5\data\world\forgotten-house.xml',
diff --git a/engine/function/users.php b/engine/function/users.php
index 83284b2..ddef958 100644
--- a/engine/function/users.php
+++ b/engine/function/users.php
@@ -809,103 +809,35 @@ function user_character_list_count($account_id) {
// END MY ACCOUNT RELATED
-// HIGHSCORE FUNCTIONS \\(I think I will move this to an own file later)
-function highscore_getAll() {
- $result = array();
- for ($i = 0; $i <= 6; $i++) {
- $result[$i] = highscore_skills($i);
- }
- $result[7] = highscore_experience();
- $result[8] = highscore_maglevel();
-
- return $result;
-}
-
-// TFS 1.0 highscore
-function highscore_getAll_10($from = 0, $to = 30) {
- $result = array();
- for ($i = 0; $i <= 8; $i++) {
- $result[$i] = highscore_getSkill_10($i, $from, $to);
- }
- return $result;
-}
-function highscore_getSkill_10($id = 8, $from = 0, $to = 30) {
- $skills = array(
- 0 => 'skill_fist',
- 1 => 'skill_club',
- 2 => 'skill_sword',
- 3 => 'skill_axe',
- 4 => 'skill_dist',
- 5 => 'skill_shielding',
- 6 => 'skill_fishing',
- 8 => 'maglevel',
- 7 => 'level',
- );
-
- if ($id < 7 || $id > 7) $scores = mysql_select_multi("SELECT `". $skills[$id] ."` AS `value`, `name`, `vocation` FROM `players` WHERE `group_id`<'2' ORDER BY `". $skills[$id] ."` DESC LIMIT {$from}, {$to};");
- else $scores = mysql_select_multi("SELECT `". $skills[$id] ."` AS `level`, `experience` AS `value`, `name`, `vocation` FROM `players` WHERE `group_id`<'2' ORDER BY `experience` DESC LIMIT {$from}, {$to};");
- for ($i = 0; $i < count($scores); $i++) $scores[$i]['vocation'] = vocation_id_to_name($scores[$i]['vocation']);
- return $scores;
-}
-
-// Returns an array containing up to 30 best players in terms of (selected skillid). Returns player ID and skill value.
-function highscore_skills($skillid) {
- $skillid = (int)$skillid;
-
- $data = mysql_select_multi("SELECT `player_id`, `value` FROM `player_skills` WHERE `skillid`='$skillid' ORDER BY `value` DESC LIMIT 0, 30");
-
- if ($data !== false) {
- for ($i = 0; $i < count($data); $i++) {
- // Fetch extra data from SQL players table
- if ($skillid == 6 || $skillid == 5) $vd = mysql_select_single("SELECT `vocation`, `group_id`, `name` FROM `players` WHERE `id` = '". $data[$i]['player_id'] ."';");
- else $vd = mysql_select_single("SELECT `group_id`, `name` FROM `players` WHERE `id` = '". $data[$i]['player_id'] ."';");
-
- // If skillid is fish fighting, lets display vocation name instead of id.
- if ($skillid == 6 || $skillid == 5) {
-
- if ($vd !== false) $data[$i]['vocation'] = vocation_id_to_name($vd['vocation']);
- else $data[$i]['vocation'] = 'Unknown';
- }
-
- // Happen to every skill group
- $data[$i]['group_id'] = $vd['group_id'];
- $data[$i]['name'] = $vd['name'];
- unset($data[$i]['player_id']);
- }
- }
-
- return $data;
-}
-
-// Returns an array containing up to 30 best players in terms of experience. Returns name, experience, vocation and level.
-function highscore_experience() {
- $data = mysql_select_multi("SELECT `name`, `experience` as `value`, `vocation`, `level`, `group_id` FROM `players` WHERE `experience`>500 ORDER BY `experience` DESC LIMIT 0, 30");
- if ($data !== false) {
- for ($i = 0; $i < count($data); $i++) {
- $data[$i]['vocation'] = vocation_id_to_name($data[$i]['vocation']);
- }
+// HIGHSCORE FUNCTIONS \\
+function fetchAllScores($rows, $tfs, $g) {
+ // Return scores ordered by type
+ $data = array();
+ if ($tfs == 'TFS_10') {
+ $data[1] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_club` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_club` DESC LIMIT 0, $rows;");
+ $data[2] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_sword` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_sword` DESC LIMIT 0, $rows;");
+ $data[3] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_axe` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_axe` DESC LIMIT 0, $rows;");
+ $data[4] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_dist` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_dist` DESC LIMIT 0, $rows;");
+ $data[5] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_shielding` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_shielding` DESC LIMIT 0, $rows;");
+ $data[6] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_fishing` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_fishing` DESC LIMIT 0, $rows;");
+ $data[7] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `experience`, `level` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `experience` DESC LIMIT 0, $rows;");
+ $data[8] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `maglevel` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `maglevel` DESC LIMIT 0, $rows;");
+ $data[9] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `skill_fist` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `skill_fist` DESC LIMIT 0, $rows;");
+ } else {
+ $data[9] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[1] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[2] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[3] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[4] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[5] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[6] = mysql_select_multi("SELECT `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 ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
+ $data[7] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `experience`, `level` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `experience` DESC limit 0, $rows;");
+ $data[8] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `maglevel` AS `value` FROM `players` WHERE `group_id` < $g ORDER BY `maglevel` DESC limit 0, $rows;");
}
return $data;
}
-
-// Returns an array containing up to 30 best players with high magic level (returns their name and magic level)
-function highscore_maglevel() {
- return mysql_select_multi("SELECT `name`, `maglevel` as `value`, `group_id` FROM `players` WHERE `experience`>500 ORDER BY `maglevel` DESC LIMIT 0, 30");
-}
-
-// Count how many skill entries are in the db for a certain skillid (this can relate to how many players exist).
-function highscore_count($skillid) {
- $data = mysql_select_single("SELECT COUNT(`player_id`) AS `count` FROM `player_skills` WHERE `skillid`='$skillid' LIMIT 0, 30");
- return ($data !== false) ? $data['count'] : 0;
-}
-
-// Count how many players have higher exp than 500
-function highscore_experience_count() {
- $data = mysql_select_single("SELECT COUNT(`id`) AS `count` FROM `players` WHERE `experience`>'500' LIMIT 0, 30");
- return ($data !== false) ? $data['count'] : 0;
-}
-
// END HIGHSCORE FUNCTIONS
+
function user_recover($mode, $edom, $email, $character, $ip) {
/* -- Lost account function - user_recovery --
diff --git a/highscores.php b/highscores.php
index 6faea9c..2fc67aa 100644
--- a/highscores.php
+++ b/highscores.php
@@ -1,110 +1,105 @@
hasExpired()) {
- if ($config['TFSVersion'] != 'TFS_10') $tmp = highscore_getAll();
- else $tmp = highscore_getAll_10(0, 30);
+// Fetch highscore type
+$type = getValue($_GET['type']);
+if (!$type) $type = 7;
+else $type = (int)$type;
+if ($type > 9) $type = 7;
- $cache->setContent($tmp);
- $cache->save();
+// Fetch highscore page
+$page = getValue($_GET['page']);
+if (!$page || $page == 0) $page = 1;
+else $page = (int)$page;
- $array = isset($tmp[$skillid]) ? $tmp[$skillid] : $tmp[7];
- } else {
- $tmp = $cache->load();
- $array = $tmp[$skillid];
- }
-
- if ($skillid < 9) {
- // Design and present the list
- if ($array) {
- ?>
-
- scoreboard. Next update:
- remainingTime() > 0) {
- $hours = seconds_to_hours($cache->remainingTime());
- $minutes = ($hours - (int)$hours) * 60;
- $seconds = ($minutes - (int)$minutes) * 60;
- if ($hours >= 1) {
- echo (int)$hours .'h';
- }
- if ($minutes >= 1) {
- echo ' '. (int)$minutes .'m';
- }
- if ($seconds >= 1) {
- echo ' '. (int)$seconds .'s';
- }
- } else {
- echo '0s';
- }
-
- ?>. remainingTime());?>
-
-
-
- | Name: |
- Level:Experience: | ';
- else {
- ?>
- Value: |
- Vocation:';
- }
- ?>
-
- ';
- echo ''. $value['name'] .' | ';
- if ($skillid == 7) echo ''. $value['level'] .' | ';
- echo ''. $value['value'] .' | ';
- if ($skillid == 7 || $skillid == 6 || $skillid == 5) {
- echo ''. $value['vocation'] .' | ';
- }
- echo '';
- }
- // end foreach
- }
- ?>
-
-
';
- //Token::debug($_POST['token']);
- echo 'Please clear your web cache/cookies OR use another web browser
';
- }
+$highscore = $config['highscore'];
+
+$rows = $highscore['rows'];
+$rowsPerPage = $highscore['rowsPerPage'];
+
+function skillName($type) {
+ $types = array(
+ 1 => "Club",
+ 2 => "Sword",
+ 3 => "Axe",
+ 4 => "Distance",
+ 5 => "Shield",
+ 6 => "Fish",
+ 7 => "Experience", // Hardcoded
+ 8 => "Magic Level", // Hardcoded
+ 9 => "Fist", // Since 0 returns false I will make 9 = 0. :)
+ );
+ return $types[(int)$type];
}
-/*
-0 fist: SELECT (SELECT `name` from `players` WHERE `player_id`=`id`) AS `name`, `value` FROM `player_skills` WHERE `skillid`=0
-1 club:
-2 sword:
-3 axe:
-4 dist:
-5 Shield:
-6 Fish
-7 Hardcoded experience
-8 Hardcoded maglevel
-*/
+function pageCheck($index, $page, $rowPerPage) {
+ return ($index < ($page * $rowPerPage) && $index >= ($page * $rowPerPage) - $rowPerPage) ? true : false;
+}
+
+$cache = new Cache('engine/cache/highscores');
+if ($cache->hasExpired()) {
+ $scores = fetchAllScores($rows, $config['TFSVersion'], $highscore['ignoreGroupId']);
+
+ $cache->setContent($scores);
+ $cache->save();
+} else {
+ $scores = $cache->load();
+}
+
+if ($scores) {
+ ?>
+ Ranking for .
+
+
+
+ | Rank |
+ Name |
+ Vocation |
+ Level |
+ Points"; ?>
+
+
+
+ |
+ |
+ |
+ |
+ ". $scores[$type][$i]['experience'] .""; ?>
+
+
+
+
\ No newline at end of file
diff --git a/layout/widgets/highscore.php b/layout/widgets/highscore.php
index 7ca4aab..0ba644b 100644
--- a/layout/widgets/highscore.php
+++ b/layout/widgets/highscore.php
@@ -1,24 +1,20 @@