14 Commits

Author SHA1 Message Date
Stefan A. Brannfjell
b7f241f8b8 Update cacert.pem
https://curl.se/docs/caextract.html
2024-02-25 21:11:52 +01:00
Luan Luciano
5e67cf7450 Fix error in helpdesk.php (#516)
Error: Warning: Trying to access array offset on value of type bool in C:....\helpdesk.php on line 34
If I put a non-existent ID in the URL, it throws the error.
2022-07-10 10:07:37 +02:00
Luan Luciano
2c050dae1b Fix error in email authentication link 2022-06-27 12:59:30 +02:00
Znote
c2cdf5f3bf More accurate premium duration calculation.
Dont skimp on the hours on the last day the premium expires.
2022-01-29 22:54:29 +01:00
Evil Puncker
7fb0916f57 updated image server with a more recent link/version 2022-01-23 12:28:24 +01:00
Znote
2e465075ae Bugfix: Powergamers: Support negative values in first day changes 2022-01-03 00:46:57 +01:00
Znote
61d0bfcc8e loginWebService correct pvptypes 2021-12-23 09:21:06 +01:00
Znote
fb6c391925 Player history and powergamers rewrite 2021-12-20 10:36:11 +01:00
Znote
098d841533 Let admins bypass character list count restriction 2021-12-16 23:18:56 +01:00
Znote
0d15f5ddb9 Fix #478 characterprofile message for pending deletions 2021-12-16 23:17:43 +01:00
Znote
0cf1f0fb46 Fix #497 Protocol 12 freePremium
having an account as free, make lots of weirds widgets to appear in game and even some client features unavailable.
This unlocks protocol 12 client features for servers who use freePremium in config.lua
2021-12-16 19:50:47 +01:00
Znote
c49842a8c7 register.php cleanup 2021-12-15 23:28:10 +01:00
Znote
9625654f96 Dont invoke IP validation if its disabled in config.php 2021-12-15 23:23:24 +01:00
Znote
5866ec4c71 validate_ip bugfix 2021-12-15 23:18:50 +01:00
16 changed files with 1260 additions and 582 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

@@ -36,6 +36,11 @@ if ($view !== false){
} }
$ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;"); $ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;");
if(!$ticketData) {
echo 'You can not view this ticket!';
include 'layout/overall/footer.php';
die;
}
?> ?>
<h1>View Ticket #<?php echo $ticketData['id']; ?></h1> <h1>View Ticket #<?php echo $ticketData['id']; ?></h1>
<table class="znoteTable ThreadTable table table-striped"> <table class="znoteTable ThreadTable table table-striped">

View File

@@ -83,6 +83,13 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
<td>Position</td> <td>Position</td>
<td><?php echo $position; ?></td> <td><?php echo $position; ?></td>
</tr> </tr>
<?php endif;
// pending deletion?
$deletion_time = mysql_select_single("SELECT `time` FROM `znote_deleted_characters` WHERE `character_name`='{$name}' AND `done` = '0' LIMIT 1;");
if ($deletion_time !== false): ?>
<tr>
<td colspan="2" style="color: red;">Flagged for deletion by owner after <?php echo $deletion_time['time']; ?>.</td>
</tr>
<?php endif; ?> <?php endif; ?>
<!-- Player male / female --> <!-- Player male / female -->
<tr> <tr>

View File

@@ -598,8 +598,8 @@
'characterprofile' => true, 'characterprofile' => true,
'onlinelist' => true, 'onlinelist' => true,
// Image server may be unreliable and only for test, // Image server may be unreliable and only for test,
// host yourself: https://otland.net/threads/item-images-10-92.242492/ // host yourself: https://otland.net/threads/item-images-12-80-for-website.279319/
'imageServer' => 'https://outfit-images.ots.me/animatedOutfits1099/animoutfit.php' 'imageServer' => 'https://outfit-images.ots.me/1285/animoutfit.php'
); );
// Show advanced inventory data in character profile // Show advanced inventory data in character profile
@@ -657,6 +657,8 @@
'port' => 7172, 'port' => 7172,
'name' => 'Forgotten' // Must be identical to config.lua (OT config file) server name. 'name' => 'Forgotten' // Must be identical to config.lua (OT config file) server name.
); );
// Unlock all protocol 12 client features? Free premium in config.lua? Then set this to true.
$config['freePremium'] = true;
// How often do you want highscores (cache) to update? // How often do you want highscores (cache) to update?
$config['cache'] = array( $config['cache'] = array(

View File

@@ -67,7 +67,7 @@ if (empty($_POST) === false) {
} }
// Char count // Char count
$char_count = user_character_list_count($session_user_id); $char_count = user_character_list_count($session_user_id);
if ($char_count >= $config['max_characters']) { if ($char_count >= $config['max_characters'] && !is_admin($user_data)) {
$errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.'; $errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.';
} }
if (validate_ip(getIP()) === false && $config['validate_IP'] === true) { if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {

File diff suppressed because it is too large Load Diff

View File

@@ -231,7 +231,7 @@ function validate_name($string) {
// Checks if an IPv4(or localhost IPv6) address is valid // Checks if an IPv4(or localhost IPv6) address is valid
function validate_ip($ip) { function validate_ip($ip) {
$ipL = safeIp2Long($ip); $ipL = safeIp2Long($ip);
$ipR = long2ip($ipL); $ipR = long2ip((int)$ipL);
if ($ip === $ipR) { if ($ip === $ipR) {
return true; return true;

View File

@@ -889,7 +889,7 @@ function user_account_add_premdays($accid, $days) {
$days = (int)$days; $days = (int)$days;
mysql_update(" mysql_update("
UPDATE `accounts` UPDATE `accounts`
SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400) SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP()) + ({$days} * 86400)
WHERE `id`='{$accid}'; WHERE `id`='{$accid}';
"); ");
} }

View File

@@ -21,7 +21,7 @@ if ($view !== false) {
} }
$ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;"); $ticketData = mysql_select_single("SELECT * FROM znote_tickets WHERE id='$view' LIMIT 1;");
if($ticketData['owner'] != $session_user_id) { if(!$ticketData || $ticketData['owner'] != $session_user_id) {
echo 'You can not view this ticket!'; echo 'You can not view this ticket!';
include 'layout/overall/footer.php'; include 'layout/overall/footer.php';
die; die;

View File

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

View File

@@ -22,6 +22,7 @@
<li><a href="forum.php">Forum</a> </li> <li><a href="forum.php">Forum</a> </li>
<li><a href="guilds.php">Guilds</a> </li> <li><a href="guilds.php">Guilds</a> </li>
<li><a href="highscores.php">Highscores</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="houses.php">Houses</a> </li>
<li><a href="killers.php">Killstatistics</a> </li> <li><a href="killers.php">Killstatistics</a> </li>
<li><a href="deaths.php">Latest deaths</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

@@ -216,6 +216,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
$sessionKey .= (isset($account['secret']) && strlen($account['secret']) > 5) ? "\n".$token : "\n"; $sessionKey .= (isset($account['secret']) && strlen($account['secret']) > 5) ? "\n".$token : "\n";
$sessionKey .= "\n".floor(time() / 30); $sessionKey .= "\n".floor(time() / 30);
$freePremium = (isset($config['freePremium'])) ? $config['freePremium'] : true;
$response = array( $response = array(
'session' => array( 'session' => array(
'fpstracking' => false, 'fpstracking' => false,
@@ -227,7 +228,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
'emailcoderequest' => false, 'emailcoderequest' => false,
'sessionkey' => $sessionKey, 'sessionkey' => $sessionKey,
'lastlogintime' => 0, 'lastlogintime' => 0,
'ispremium' => ($account['premium_ends_at'] > time()) ? true : false, 'ispremium' => ($account['premium_ends_at'] > time() || $freePremium) ? true : false,
'premiumuntil' => $account['premium_ends_at'], 'premiumuntil' => $account['premium_ends_at'],
'status' => 'active' 'status' => 'active'
), ),
@@ -240,7 +241,13 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
'externalport' => $gameserver['port'], 'externalport' => $gameserver['port'],
'previewstate' => 0, 'previewstate' => 0,
'location' => 'ALL', 'location' => 'ALL',
'pvptype' => 'pvp', // 0 - open pvp
// 1 - optional
// 2 - hardcore
// 3 - retro open pvp
// 4 - retro hardcore pvp
// 5 and higher - (unknown)
'pvptype' => 0,
'externaladdressunprotected' => $gameserver['ip'], 'externaladdressunprotected' => $gameserver['ip'],
'externaladdressprotected' => $gameserver['ip'], 'externaladdressprotected' => $gameserver['ip'],
'externalportunprotected' => $gameserver['port'], 'externalportunprotected' => $gameserver['port'],

View File

@@ -60,7 +60,7 @@ if (isset($_GET['authenticate']) && $config['mailserver']['myaccount_verify_emai
$verify_account_id = (int)$session_user_id; $verify_account_id = (int)$session_user_id;
$user = mysql_select_single("SELECT `id`, `activekey`, `active_email` FROM `znote_accounts` WHERE `account_id`='{$verify_account_id}' LIMIT 1;"); $user = mysql_select_single("SELECT `id`, `activekey`, `active_email` FROM `znote_accounts` WHERE `account_id`='{$verify_account_id}' LIMIT 1;");
if ($user !== false) { if ($user !== false) {
$thisurl = config('site_url') . "myaccount.php"; $thisurl = config('site_url') . "/myaccount.php";
$thisurl .= "?authenticate&u=".$verify_account_id."&k=".$user['activekey']; $thisurl .= "?authenticate&u=".$verify_account_id."&k=".$user['activekey'];
$mailer = new Mail($config['mailserver']); $mailer = new Mail($config['mailserver']);

View File

@@ -1,92 +1,162 @@
<?php <?php require_once 'engine/init.php'; include 'layout/overall/header.php';
require_once 'engine/init.php';
include 'layout/overall/header.php';
if (!$config['powergamers']['enabled']) { if (!$config['powergamers']['enabled']) {
echo 'This page has been disabled at config.php.'; echo 'This page has been disabled at config.php.';
include 'layout/overall/footer.php'; include 'layout/overall/footer.php';
exit(); exit();
} }
?>
<div class="panel"> $query_CTE = "
<div class="page-header"><h3>Powergamers</h3></div> WITH CTE_history AS (
<?php SELECT
$limit = $config['powergamers']['limit']; `id`,
$days = isset($_POST['days']); `player_id`,
$today = true; CAST(DATE_FORMAT(FROM_UNIXTIME(`lastlogin`), '%y%m%d') as int) AS `login_int`,
if ($days) { CAST(DATE_FORMAT(FROM_UNIXTIME(`lastlogout`), '%y%m%d') as int) AS `logout_int`,
$selected = ($_POST['days']); `experience`
$days = (int) $selected[1]; FROM `player_history_skill`
$vocation = (int) $selected[0]; ), CTE_time AS (
if ($days > 0) SELECT
$today = false; 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`,
CAST(`p`.`experience` as SIGNED) - 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 { } 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); $players = $cache->load();
} }
$limit = $config['powergamers']['limit'];
if(!empty($days) && !empty($vocation)) $dates = mysql_select_single("
$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); SELECT
elseif(empty($days) && !empty($vocation)) { FROM_UNIXTIME(UNIX_TIMESTAMP() - 7 * 24 * 60 * 60, '%d %b') AS `d7ago`,
$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); FROM_UNIXTIME(UNIX_TIMESTAMP() - 6 * 24 * 60 * 60, '%d %b') AS `d6ago`,
}elseif(!empty($days) && empty($vocation)) FROM_UNIXTIME(UNIX_TIMESTAMP() - 5 * 24 * 60 * 60, '%d %b') AS `d5ago`,
$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); FROM_UNIXTIME(UNIX_TIMESTAMP() - 4 * 24 * 60 * 60, '%d %b') AS `d4ago`,
else FROM_UNIXTIME(UNIX_TIMESTAMP() - 3 * 24 * 60 * 60, '%d %b') AS `d3ago`,
$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); FROM_UNIXTIME(UNIX_TIMESTAMP() - 2 * 24 * 60 * 60, '%d %b') AS `d2ago`,
FROM_UNIXTIME(UNIX_TIMESTAMP() - 1 * 24 * 60 * 60, '%d %b') AS `d1ago`,
$showVoc = (!empty($vocation)) ? $vocation : 0; FROM_UNIXTIME(UNIX_TIMESTAMP(), '%d %b') AS `d0ago`
?> ");
<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 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> </table>
<br> <style type="text/css">
</div> #tbl_powergamers {
padding: 0;
}
</style>
<?php <?php
include 'layout/overall/footer.php'; include 'layout/overall/footer.php'; ?>

View File

@@ -36,7 +36,7 @@ if (empty($_POST) === false) {
if ($isNoob) { if ($isNoob) {
$errors[] = 'This account name is blocked for registration.'; $errors[] = 'This account name is blocked for registration.';
} }
if ($config['ServerEngine'] !== 'OTHIRE' && $config['client'] >= 830) { if ($config['client'] >= 830) {
if (preg_match("/^[a-zA-Z0-9]+$/", $_POST['username']) == false) { if (preg_match("/^[a-zA-Z0-9]+$/", $_POST['username']) == false) {
$errors[] = 'Your account name can only contain characters a-z, A-Z and 0-9.'; $errors[] = 'Your account name can only contain characters a-z, A-Z and 0-9.';
} }
@@ -80,9 +80,11 @@ if (empty($_POST) === false) {
if ($_POST['selected'] != 1) { if ($_POST['selected'] != 1) {
$errors[] = 'You are only allowed to have an account if you accept the rules.'; $errors[] = 'You are only allowed to have an account if you accept the rules.';
} }
if (validate_ip(getIP()) === false && $config['validate_IP'] === true) { if ($config['validate_IP'] === true) {
if (validate_ip(getIP()) === false) {
$errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).'; $errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).';
} }
}
if (strlen($_POST['flag']) < 1) { if (strlen($_POST['flag']) < 1) {
$errors[] = 'Please choose country.'; $errors[] = 'Please choose country.';
} }
@@ -125,7 +127,6 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
} }
//Register //Register
if ($config['ServerEngine'] !== 'OTHIRE') {
$register_data = array( $register_data = array(
'name' => $_POST['username'], 'name' => $_POST['username'],
'password' => $_POST['password'], 'password' => $_POST['password'],
@@ -134,16 +135,6 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
'ip' => getIPLong(), 'ip' => getIPLong(),
'flag' => $_POST['flag'] 'flag' => $_POST['flag']
); );
} else {
$register_data = array(
'id' => $_POST['username'],
'password' => $_POST['password'],
'email' => $_POST['email'],
'created' => time(),
'ip' => getIPLong(),
'flag' => $_POST['flag']
);
}
user_create_account($register_data, $config['mailserver']); user_create_account($register_data, $config['mailserver']);
if (!$config['mailserver']['debug']) header('Location: register.php?success'); if (!$config['mailserver']['debug']) header('Location: register.php?success');
@@ -158,24 +149,23 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
?> ?>
<form action="" method="post"> <form action="" method="post">
<ul> <ul>
<li> <li>Account Name:<br>
Account Name:<br>
<input type="text" name="username"> <input type="text" name="username">
</li> </li>
<li>
Password:<br> <li>Password:<br>
<input type="password" name="password"> <input type="password" name="password">
</li> </li>
<li>
Password again:<br> <li>Password again:<br>
<input type="password" name="password_again"> <input type="password" name="password_again">
</li> </li>
<li>
Email:<br> <li>Email:<br>
<input type="text" name="email"> <input type="text" name="email">
</li> </li>
<li>
Country:<br> <li>Country:<br>
<select name="flag"> <select name="flag">
<option value="">(Please choose)</option> <option value="">(Please choose)</option>
<?php <?php
@@ -188,6 +178,7 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
?> ?>
</select> </select>
</li> </li>
<?php <?php
if ($config['use_captcha']) { if ($config['use_captcha']) {
?> ?>
@@ -197,8 +188,8 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
<?php <?php
} }
?> ?>
<li>
<h2>Server Rules</h2> <li><h2>Server Rules</h2>
<p>The golden rule: Have fun.</p> <p>The golden rule: Have fun.</p>
<p>If you get pwn3d, don't hate the game.</p> <p>If you get pwn3d, don't hate the game.</p>
<p>No <a href='https://en.wikipedia.org/wiki/Cheating_in_video_games' target="_blank">cheating</a> allowed.</p> <p>No <a href='https://en.wikipedia.org/wiki/Cheating_in_video_games' target="_blank">cheating</a> allowed.</p>
@@ -206,8 +197,8 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
<p>The staff can delete, ban, do whatever they want with your account and your <br> <p>The staff can delete, ban, do whatever they want with your account and your <br>
submitted information. (Including exposing and logging your IP).</p> submitted information. (Including exposing and logging your IP).</p>
</li> </li>
<li>
Do you agree to follow the server rules?<br> <li>Do you agree to follow the server rules?<br>
<select name="selected"> <select name="selected">
<option value="0">Umh...</option> <option value="0">Umh...</option>
<option value="1">Yes.</option> <option value="1">Yes.</option>