Player history and powergamers rewrite

This commit is contained in:
Znote 2021-12-20 10:36:11 +01:00
parent 098d841533
commit fb6c391925
5 changed files with 450 additions and 86 deletions

View File

@ -0,0 +1,229 @@
-- Auto install tables if we dont got them yet (first install)
db.query([[
CREATE TABLE IF NOT EXISTS `player_history_skill` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`player_id` int(11) NOT NULL,
`lastlogin` bigint(20) unsigned NOT NULL,
`lastlogout` bigint(20) unsigned NOT NULL,
`town_id` int(11) NOT NULL,
`lastip` int(10) unsigned NOT NULL,
`skull` tinyint(1) NOT NULL,
`blessings` tinyint(2) NOT NULL,
`onlinetime` int(11) NOT NULL,
`balance` bigint(20) unsigned NOT NULL,
`level` int(11) NOT NULL,
`experience` bigint(20) NOT NULL,
`maglevel` int(11) NOT NULL,
`skill_fist` int(10) unsigned NOT NULL,
`skill_club` int(10) unsigned NOT NULL,
`skill_sword` int(10) unsigned NOT NULL,
`skill_axe` int(10) unsigned NOT NULL,
`skill_dist` int(10) unsigned NOT NULL,
`skill_shielding` int(10) unsigned NOT NULL,
`skill_fishing` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
]])
-- Auto populate table if it is empty
local resultId = db.storeQuery("SELECT `id` FROM `player_history_skill` LIMIT 1;")
if resultId == false then
db.asyncQuery([[
INSERT INTO `player_history_skill` (
`player_id`,
`lastlogin`,
`lastlogout`,
`town_id`,
`lastip`,
`skull`,
`blessings`,
`onlinetime`,
`balance`,
`level`,
`experience`,
`maglevel`,
`skill_fist`,
`skill_club`,
`skill_sword`,
`skill_axe`,
`skill_dist`,
`skill_shielding`,
`skill_fishing`
)
SELECT
`p`.`id` AS `player_id`,
`zp`.`created` AS `lastlogin`,
CASE WHEN `p`.`lastlogout` > 0
THEN `p`.`lastlogout`
ELSE `zp`.`created`
END AS `lastlogout`,
`p`.`town_id`,
`p`.`lastip`,
`p`.`skull`,
`p`.`blessings`,
`p`.`onlinetime`,
`p`.`balance`,
`p`.`level`,
`p`.`experience`,
`p`.`maglevel`,
`p`.`skill_fist`,
`p`.`skill_club`,
`p`.`skill_sword`,
`p`.`skill_axe`,
`p`.`skill_dist`,
`p`.`skill_shielding`,
`p`.`skill_fishing`
FROM `players` AS `p`
INNER JOIN `znote_players` AS `zp`
ON `p`.`id` = `zp`.`player_id`
ORDER BY `zp`.`created`
]])
else
result.free(resultId)
end
-- Logout event, triggered by logout, and death
function historyLogoutEvent(player)
local blessdec = 0
local i = 0
while player:hasBlessing(i+1) do
blessdec = blessdec+2^i
i = i+1
end
local playerGuid = player:getGuid()
db.query([[
INSERT INTO `player_history_skill` (
`player_id`,
`lastlogin`,
`lastlogout`,
`town_id`,
`lastip`,
`skull`,
`blessings`,
`onlinetime`,
`balance`,
`level`,
`experience`,
`maglevel`,
`skill_fist`,
`skill_club`,
`skill_sword`,
`skill_axe`,
`skill_dist`,
`skill_shielding`,
`skill_fishing`
) VALUES (
]]..table.concat({
playerGuid,
player:getLastLoginSaved(),
os.time(),
player:getTown():getId(),
player:getIp(),
player:getSkull(),
blessdec,
"(SELECT `onlinetime` FROM `players` WHERE `id`='"..playerGuid.."') + ".. os.time() - player:getLastLoginSaved(),
player:getBankBalance(),
player:getLevel(),
player:getExperience(),
player:getMagicLevel(),
player:getSkillLevel(SKILL_FIST),
player:getSkillLevel(SKILL_CLUB),
player:getSkillLevel(SKILL_SWORD),
player:getSkillLevel(SKILL_AXE),
player:getSkillLevel(SKILL_DISTANCE),
player:getSkillLevel(SKILL_SHIELD),
player:getSkillLevel(SKILL_FISHING)
}, ",")..[[
);
]])
end
-- Log player state on logout
local player_history_skill = CreatureEvent("player_history_skill")
function player_history_skill.onLogout(player)
--print("2-logout["..player:getName().."]")
historyLogoutEvent(player)
return true
end
player_history_skill:register()
-- And on death
local player_history_skill_death = CreatureEvent("player_history_skill_death")
function player_history_skill_death.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
--print("3-death["..creature:getName().."]")
historyLogoutEvent(Player(creature))
end
player_history_skill_death:register()
-- If this is first login, insert current progress
local player_history_skill_login = CreatureEvent("player_history_skill_login")
function player_history_skill_login.onLogin(player)
--print("1-login["..player:getName().."]")
player:registerEvent("player_history_skill_death")
local playerGuid = player:getGuid()
local resultId = db.storeQuery("SELECT `id` FROM `player_history_skill` WHERE `player_id`="..playerGuid.." LIMIT 1;")
if resultId == false then
db.query([[
INSERT INTO `player_history_skill` (
`player_id`,
`lastlogin`,
`lastlogout`,
`town_id`,
`lastip`,
`skull`,
`blessings`,
`onlinetime`,
`balance`,
`level`,
`experience`,
`maglevel`,
`skill_fist`,
`skill_club`,
`skill_sword`,
`skill_axe`,
`skill_dist`,
`skill_shielding`,
`skill_fishing`
)
SELECT
`p`.`id` AS `player_id`,
`zp`.`created` AS `lastlogin`,
CASE WHEN `p`.`lastlogout` > 0
THEN `p`.`lastlogout`
ELSE `zp`.`created`
END AS `lastlogout`,
`p`.`town_id`,
`p`.`lastip`,
`p`.`skull`,
`p`.`blessings`,
`p`.`onlinetime`,
`p`.`balance`,
`p`.`level`,
`p`.`experience`,
`p`.`maglevel`,
`p`.`skill_fist`,
`p`.`skill_club`,
`p`.`skill_sword`,
`p`.`skill_axe`,
`p`.`skill_dist`,
`p`.`skill_shielding`,
`p`.`skill_fishing`
FROM `players` AS `p`
INNER JOIN `znote_players` AS `zp`
ON `p`.`id` = `zp`.`player_id`
WHERE `p`.`id` = ]]..playerGuid..[[
]])
else
result.free(resultId)
end
return true
end
player_history_skill_login:register()

View File

@ -11,6 +11,7 @@
include 'layout/widgets/charactersearch.php';
include 'layout/widgets/topplayers.php';
include 'layout/widgets/highscore.php';
if ($config['powergamers']['enabled']) include 'layout/widgets/powergamers.php';
include 'layout/widgets/serverinfo.php';
if ($config['ServerEngine'] !== 'TFS_02') include 'layout/widgets/houses.php';
if ($follow["enabled"]): ?>

View File

@ -22,6 +22,7 @@
<li><a href="forum.php">Forum</a> </li>
<li><a href="guilds.php">Guilds</a> </li>
<li><a href="highscores.php">Highscores</a> </li>
<?php if ($config['powergamers']['enabled']): ?><li><a href="powergamers.php">Powergamers</a> </li><?php endif; ?>
<li><a href="houses.php">Houses</a> </li>
<li><a href="killers.php">Killstatistics</a> </li>
<li><a href="deaths.php">Latest deaths</a> </li>

View File

@ -0,0 +1,63 @@
<div class="well widget">
<div class="header">
Top 5 Powergamers
</div>
<div class="body">
<table>
<?php
$cache = new Cache('engine/cache/widget_powergamers');
if ($cache->hasExpired()) {
$players = mysql_select_multi("
SELECT
`h`.`player_id`,
`p`.`name`,
`p`.`level`,
CAST(`p`.`experience` as signed) - CAST(`f`.`experience` as signed) AS `diff_experience`
FROM (
SELECT
`i`.`player_id`,
IFNULL(`o`.`id`, `i`.`id`) AS `from_id`
FROM `player_history_skill` AS `i`
LEFT JOIN (
SELECT
`x`.`player_id`,
MAX(`x`.`id`) AS `id`
FROM `player_history_skill` AS `x`
WHERE
`x`.`lastlogout` < UNIX_TIMESTAMP() - 7 * 24 * 60 * 60
GROUP BY
`x`.`player_id`
) AS `o`
ON `i`.`player_id` = `o`.`player_id`
WHERE
`i`.`lastlogout` >= UNIX_TIMESTAMP() - 7 * 24 * 60 * 60
GROUP BY
`i`.`player_id`
) AS `h`
INNER JOIN `player_history_skill` AS `f`
ON `h`.`from_id` = `f`.`id`
INNER JOIN `players` AS `p`
ON `h`.`player_id` = `p`.`id`
WHERE CAST(`p`.`experience` as signed) - CAST(`f`.`experience` as signed) > 0
ORDER BY CAST(`p`.`experience` as signed) - CAST(`f`.`experience` as signed) DESC
LIMIT 5
");
$cache->setContent($players);
$cache->save();
} else {
$players = $cache->load();
}
if ($players) {
foreach($players as $count => $player) {
$nr = $count+1;
$kexp = $player['diff_experience'] / 1000;
$kexp = number_format($kexp, 0, '', ' ');
echo "<tr><td>{$nr}</td><td><a href='characterprofile.php?name={$player['name']}'>{$player['name']}</a> ({$player['level']}) <span style='float: right;font-size:14px;'>{$kexp} K exp</span></td></tr>";
}
}
?>
</table>
</div>
</div>

View File

@ -1,92 +1,162 @@
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if (!$config['powergamers']['enabled']) {
echo 'This page has been disabled at config.php.';
include 'layout/overall/footer.php';
echo 'This page has been disabled at config.php.';
include 'layout/overall/footer.php';
exit();
}
$query_CTE = "
WITH CTE_history AS (
SELECT
`id`,
`player_id`,
CAST(DATE_FORMAT(FROM_UNIXTIME(`lastlogin`), '%y%m%d') as int) AS `login_int`,
CAST(DATE_FORMAT(FROM_UNIXTIME(`lastlogout`), '%y%m%d') as int) AS `logout_int`,
`experience`
FROM `player_history_skill`
), CTE_time AS (
SELECT
1 AS `link`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 7 * 24 * 60 * 60), '%y%m%d') as int) AS `d7ago`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 6 * 24 * 60 * 60), '%y%m%d') as int) AS `d6ago`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 5 * 24 * 60 * 60), '%y%m%d') as int) AS `d5ago`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 4 * 24 * 60 * 60), '%y%m%d') as int) AS `d4ago`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 3 * 24 * 60 * 60), '%y%m%d') as int) AS `d3ago`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 2 * 24 * 60 * 60), '%y%m%d') as int) AS `d2ago`,
CAST(DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP() - 1 * 24 * 60 * 60), '%y%m%d') as int) AS `d1ago`
), CTE_first AS (
SELECT `player_id`, MIN(`id`) AS `id`
FROM CTE_history
GROUP BY `player_id`
), CTE_7b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d7ago`
GROUP BY `player_id`
), CTE_6b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d6ago`
GROUP BY `player_id`
), CTE_5b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d5ago`
GROUP BY `player_id`
), CTE_4b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d4ago`
GROUP BY `player_id`
), CTE_3b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d3ago`
GROUP BY `player_id`
), CTE_2b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d2ago`
GROUP BY `player_id`
), CTE_1b AS (
SELECT `player_id`, MAX(`id`) AS `id`
FROM CTE_history INNER JOIN CTE_time AS `t` ON `t`.`link` = 1
WHERE `logout_int` <= `t`.`d1ago`
GROUP BY `player_id`
)
";
$cache = new Cache('engine/cache/page_powergamers');
if ($cache->hasExpired()) {
$players = mysql_select_multi($query_CTE."
SELECT
`p`.`name`,
IFNULL(`p`.`experience`, 0) - CASE WHEN `h7b`.`experience` IS NULL
THEN `hfb`.`experience`
ELSE `h7b`.`experience`
END AS `diff_exp`,
`p`.`experience` - IFNULL(`h1b`.`experience`, 0) AS `diff_0`,
IFNULL(`h1b`.`experience`, 0) - IFNULL(`h2b`.`experience`, 0) AS `diff_1`,
IFNULL(`h2b`.`experience`, 0) - IFNULL(`h3b`.`experience`, 0) AS `diff_2`,
IFNULL(`h3b`.`experience`, 0) - IFNULL(`h4b`.`experience`, 0) AS `diff_3`,
IFNULL(`h4b`.`experience`, 0) - IFNULL(`h5b`.`experience`, 0) AS `diff_4`,
IFNULL(`h5b`.`experience`, 0) - IFNULL(`h6b`.`experience`, 0) AS `diff_5`,
IFNULL(`h6b`.`experience`, 0) - IFNULL(`h7b`.`experience`, 0) AS `diff_6`
FROM `players` AS `p`
LEFT JOIN CTE_first AS `first` ON `p`.`id` = `first`.`player_id`
LEFT JOIN CTE_1b AS `d1b` ON `p`.`id` = `d1b`.`player_id`
LEFT JOIN CTE_2b AS `d2b` ON `p`.`id` = `d2b`.`player_id`
LEFT JOIN CTE_3b AS `d3b` ON `p`.`id` = `d3b`.`player_id`
LEFT JOIN CTE_4b AS `d4b` ON `p`.`id` = `d4b`.`player_id`
LEFT JOIN CTE_5b AS `d5b` ON `p`.`id` = `d5b`.`player_id`
LEFT JOIN CTE_6b AS `d6b` ON `p`.`id` = `d6b`.`player_id`
LEFT JOIN CTE_7b AS `d7b` ON `p`.`id` = `d7b`.`player_id`
LEFT JOIN CTE_history AS `hfb` ON `first`.`id` = `hfb`.`id`
LEFT JOIN CTE_history AS `h1b` ON `d1b`.`id` = `h1b`.`id`
LEFT JOIN CTE_history AS `h2b` ON `d2b`.`id` = `h2b`.`id`
LEFT JOIN CTE_history AS `h3b` ON `d3b`.`id` = `h3b`.`id`
LEFT JOIN CTE_history AS `h4b` ON `d4b`.`id` = `h4b`.`id`
LEFT JOIN CTE_history AS `h5b` ON `d5b`.`id` = `h5b`.`id`
LEFT JOIN CTE_history AS `h6b` ON `d6b`.`id` = `h6b`.`id`
LEFT JOIN CTE_history AS `h7b` ON `d7b`.`id` = `h7b`.`id`
WHERE IFNULL(`p`.`experience`, 0) - CASE WHEN `h7b`.`experience` IS NULL THEN `hfb`.`experience` ELSE `h7b`.`experience` END != 0
ORDER BY IFNULL(`p`.`experience`, 0) - CASE WHEN `h7b`.`experience` IS NULL THEN `hfb`.`experience` ELSE `h7b`.`experience` END DESC
");
$cache->setContent($players);
$cache->save();
} else {
$players = $cache->load();
}
$dates = mysql_select_single("
SELECT
FROM_UNIXTIME(UNIX_TIMESTAMP() - 7 * 24 * 60 * 60, '%d %b') AS `d7ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 6 * 24 * 60 * 60, '%d %b') AS `d6ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 5 * 24 * 60 * 60, '%d %b') AS `d5ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 4 * 24 * 60 * 60, '%d %b') AS `d4ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 3 * 24 * 60 * 60, '%d %b') AS `d3ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 2 * 24 * 60 * 60, '%d %b') AS `d2ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 1 * 24 * 60 * 60, '%d %b') AS `d1ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP(), '%d %b') AS `d0ago`
");
?>
<div class="panel">
<div class="page-header"><h3>Powergamers</h3></div>
<?php
$limit = $config['powergamers']['limit'];
$days = isset($_POST['days']);
$today = true;
if ($days) {
$selected = ($_POST['days']);
$days = (int) $selected[1];
$vocation = (int) $selected[0];
if ($days > 0)
$today = false;
} else {
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 ORDER BY `expdiff` DESC LIMIT '.$limit);
<table id="tbl_powergamers">
<thead>
<tr>
<th colspan="9"><h1>Powergamers</h1></th>
</tr>
<tr>
<th>Name</th>
<th>k Diff</th>
<th><?php echo $dates['d0ago']; ?></th>
<th><?php echo $dates['d1ago']; ?></th>
<th><?php echo $dates['d2ago']; ?></th>
<th><?php echo $dates['d3ago']; ?></th>
<th><?php echo $dates['d4ago']; ?></th>
<th><?php echo $dates['d5ago']; ?></th>
<th><?php echo $dates['d6ago']; ?></th>
</tr>
</thead>
<tbody>
<?php foreach($players AS $i => $player): ?>
<tr>
<td><?php echo $i+1 .". "; ?><a href="/characterprofile.php?name=<?php echo $player['name']; ?>"><?php echo $player['name']; ?></a></td>
<td><?php echo number_format($player['diff_exp'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_0'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_1'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_2'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_3'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_4'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_5'] / 1000,0,'',' '); ?></td>
<td><?php echo number_format($player['diff_6'] / 1000,0,'',' '); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<style type="text/css">
#tbl_powergamers {
padding: 0;
}
$limit = $config['powergamers']['limit'];
if(!empty($days) && !empty($vocation))
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 AND `a`.`vocation`='. (int)$vocation .' OR `a`.`vocation`='. ((int)$vocation +4) .' ORDER BY `exphist' . (int)$days . '` DESC LIMIT '.$limit);
elseif(empty($days) && !empty($vocation)) {
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 AND `a`.`vocation`='. (int)$vocation .' OR `a`.`vocation`='. ((int)$vocation +4) .' ORDER BY `expdiff` DESC LIMIT '.$limit);
}elseif(!empty($days) && empty($vocation))
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 ORDER BY `exphist' . (int)$days . '` DESC LIMIT '.$limit);
else
$znotePlayers = mysql_select_multi('SELECT `a`.`id`, `b`.`player_id`, `a`.`name`, `a`.`vocation`, `a`.`level`, `a`.`group_id`, `a`.`experience`, `b`.`exphist_lastexp`, `b`.`exphist1`, `b`.`exphist2`, `b`.`exphist3`, `b`.`exphist4`, `b`.`exphist5`, `b`.`exphist6`, `b`.`exphist7`, (`a`.`experience` - `b`.`exphist_lastexp`) AS `expdiff` FROM `players` `a` JOIN `znote_players` `b` ON `a`.`id` = `b`.`player_id` WHERE `a`.`group_id` < 2 ORDER BY `expdiff` DESC LIMIT '.$limit);
$showVoc = (!empty($vocation)) ? $vocation : 0;
?>
<form class="form form-inline" action="" method="post">
<div class="col sm-4">
<center>
<select class="form-control" name="days[]">
<option value="" selected="all">All</option>
<option value="1">Sorcerers</option>
<option value="2">Druids</option>
<option value="3">Paladins</option>
<option value="4">Knights</option>
<option value="none">No vocation</option>
</select>
<select class="form-control" name="days[]">
<option value="" selected="Today">Today</option>
<option value="1">Yesterday</option>
<option value="2">2 days ago</option>
<option value="3">3 days ago</option>
</select>
<input type="submit" class="btn btn-primary"><br>
<?php echo ($showVoc > 0) ? 'Showing only <b>'. strtolower(vocation_id_to_name($vocation)).'s</b> and' : 'Showing <b>all</b> vocations and'; ?>
<?php echo ($days > 0) ? 'sorted by <b>'. $days .'</b> days': 'sorted by <b>today</b>'; ?>.
</center>
</div>
</form>
<table class="table table-striped">
<td width="5%"><center>#</center></td>
<td>Name</td>
<?php
for($i = 3; $i >= 2; $i--)
echo ($days == $i) ? '<td class="pull-right" width="70%"><b>'.$i.' Days Ago</b></td>' : '';
echo ($days == 1) ? '<td class="pull-right" width="70%"><b>Yesterday</b></td>' : '';
echo ($today) ? '<td class="pull-right" width="70%"><b>Today</b></td>' : '';
echo ($days == 4) ? '<td class="pull-right" width="70%"><b>Total</b></td>' : '';
echo '</tr>';
$number_of_rows = 0;
if($znotePlayers) {
foreach($znotePlayers as $player)
{
$number_of_rows++;
echo '<td><center>'. $number_of_rows . '.</center></td>';
echo '<td><a href="characterprofile.php?name=' .$player['name']. '">' .$player['name']. '</a>';
echo '<br> '. ($player['level']. ' '.htmlspecialchars(vocation_id_to_name($player['vocation'])) ).' ';
echo ($days == 3) ? '<td><center>'. number_format($player['exphist3']) .'</center></td>' : '';
echo ($days == 2) ? '<td><center>'. $player['exphist2'] .'</center></td>' : '';
echo ($days == 1) ? '<td><center>'. $player['exphist1'] .'</center></td>' : '';
echo ($today == true) ? '<td><center>'. ($player['experience']-$player['exphist_lastexp']) .'</center></td>' : '';
echo '</tr>';
}
}
?>
</table>
<br>
</div>
</style>
<?php
include 'layout/overall/footer.php';
include 'layout/overall/footer.php'; ?>