mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-12-14 07:59:46 +01:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7f241f8b8 | ||
|
|
5e67cf7450 | ||
|
|
2c050dae1b | ||
|
|
c2cdf5f3bf | ||
|
|
7fb0916f57 | ||
|
|
2e465075ae | ||
|
|
61d0bfcc8e | ||
|
|
fb6c391925 | ||
|
|
098d841533 | ||
|
|
0d15f5ddb9 | ||
|
|
0cf1f0fb46 | ||
|
|
c49842a8c7 | ||
|
|
9625654f96 | ||
|
|
5866ec4c71 |
229
Lua/TFS_10/revscriptsys/player_history.lua
Normal file
229
Lua/TFS_10/revscriptsys/player_history.lua
Normal 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()
|
||||
@@ -36,6 +36,11 @@ if ($view !== false){
|
||||
}
|
||||
|
||||
$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>
|
||||
<table class="znoteTable ThreadTable table table-striped">
|
||||
|
||||
@@ -83,6 +83,13 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
|
||||
<td>Position</td>
|
||||
<td><?php echo $position; ?></td>
|
||||
</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; ?>
|
||||
<!-- Player male / female -->
|
||||
<tr>
|
||||
|
||||
@@ -598,8 +598,8 @@
|
||||
'characterprofile' => true,
|
||||
'onlinelist' => true,
|
||||
// Image server may be unreliable and only for test,
|
||||
// host yourself: https://otland.net/threads/item-images-10-92.242492/
|
||||
'imageServer' => 'https://outfit-images.ots.me/animatedOutfits1099/animoutfit.php'
|
||||
// host yourself: https://otland.net/threads/item-images-12-80-for-website.279319/
|
||||
'imageServer' => 'https://outfit-images.ots.me/1285/animoutfit.php'
|
||||
);
|
||||
|
||||
// Show advanced inventory data in character profile
|
||||
@@ -657,6 +657,8 @@
|
||||
'port' => 7172,
|
||||
'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?
|
||||
$config['cache'] = array(
|
||||
|
||||
@@ -67,7 +67,7 @@ if (empty($_POST) === false) {
|
||||
}
|
||||
// Char count
|
||||
$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.';
|
||||
}
|
||||
if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -231,7 +231,7 @@ function validate_name($string) {
|
||||
// Checks if an IPv4(or localhost IPv6) address is valid
|
||||
function validate_ip($ip) {
|
||||
$ipL = safeIp2Long($ip);
|
||||
$ipR = long2ip($ipL);
|
||||
$ipR = long2ip((int)$ipL);
|
||||
|
||||
if ($ip === $ipR) {
|
||||
return true;
|
||||
|
||||
@@ -889,7 +889,7 @@ function user_account_add_premdays($accid, $days) {
|
||||
$days = (int)$days;
|
||||
mysql_update("
|
||||
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}';
|
||||
");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ if ($view !== false) {
|
||||
}
|
||||
$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!';
|
||||
include 'layout/overall/footer.php';
|
||||
die;
|
||||
|
||||
@@ -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"]): ?>
|
||||
|
||||
@@ -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>
|
||||
|
||||
63
layout/widgets/powergamers.php
Normal file
63
layout/widgets/powergamers.php
Normal 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>
|
||||
11
login.php
11
login.php
@@ -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 .= "\n".floor(time() / 30);
|
||||
|
||||
$freePremium = (isset($config['freePremium'])) ? $config['freePremium'] : true;
|
||||
$response = array(
|
||||
'session' => array(
|
||||
'fpstracking' => false,
|
||||
@@ -227,7 +228,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
|
||||
'emailcoderequest' => false,
|
||||
'sessionkey' => $sessionKey,
|
||||
'lastlogintime' => 0,
|
||||
'ispremium' => ($account['premium_ends_at'] > time()) ? true : false,
|
||||
'ispremium' => ($account['premium_ends_at'] > time() || $freePremium) ? true : false,
|
||||
'premiumuntil' => $account['premium_ends_at'],
|
||||
'status' => 'active'
|
||||
),
|
||||
@@ -240,7 +241,13 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
|
||||
'externalport' => $gameserver['port'],
|
||||
'previewstate' => 0,
|
||||
'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'],
|
||||
'externaladdressprotected' => $gameserver['ip'],
|
||||
'externalportunprotected' => $gameserver['port'],
|
||||
|
||||
@@ -60,7 +60,7 @@ if (isset($_GET['authenticate']) && $config['mailserver']['myaccount_verify_emai
|
||||
$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;");
|
||||
if ($user !== false) {
|
||||
$thisurl = config('site_url') . "myaccount.php";
|
||||
$thisurl = config('site_url') . "/myaccount.php";
|
||||
$thisurl .= "?authenticate&u=".$verify_account_id."&k=".$user['activekey'];
|
||||
|
||||
$mailer = new Mail($config['mailserver']);
|
||||
|
||||
242
powergamers.php
242
powergamers.php
@@ -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`,
|
||||
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 {
|
||||
$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'; ?>
|
||||
|
||||
45
register.php
45
register.php
@@ -36,7 +36,7 @@ if (empty($_POST) === false) {
|
||||
if ($isNoob) {
|
||||
$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) {
|
||||
$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) {
|
||||
$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).';
|
||||
}
|
||||
}
|
||||
if (strlen($_POST['flag']) < 1) {
|
||||
$errors[] = 'Please choose country.';
|
||||
}
|
||||
@@ -125,7 +127,6 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
|
||||
}
|
||||
|
||||
//Register
|
||||
if ($config['ServerEngine'] !== 'OTHIRE') {
|
||||
$register_data = array(
|
||||
'name' => $_POST['username'],
|
||||
'password' => $_POST['password'],
|
||||
@@ -134,16 +135,6 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
|
||||
'ip' => getIPLong(),
|
||||
'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']);
|
||||
if (!$config['mailserver']['debug']) header('Location: register.php?success');
|
||||
@@ -158,24 +149,23 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<ul>
|
||||
<li>
|
||||
Account Name:<br>
|
||||
<li>Account Name:<br>
|
||||
<input type="text" name="username">
|
||||
</li>
|
||||
<li>
|
||||
Password:<br>
|
||||
|
||||
<li>Password:<br>
|
||||
<input type="password" name="password">
|
||||
</li>
|
||||
<li>
|
||||
Password again:<br>
|
||||
|
||||
<li>Password again:<br>
|
||||
<input type="password" name="password_again">
|
||||
</li>
|
||||
<li>
|
||||
Email:<br>
|
||||
|
||||
<li>Email:<br>
|
||||
<input type="text" name="email">
|
||||
</li>
|
||||
<li>
|
||||
Country:<br>
|
||||
|
||||
<li>Country:<br>
|
||||
<select name="flag">
|
||||
<option value="">(Please choose)</option>
|
||||
<?php
|
||||
@@ -188,6 +178,7 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
|
||||
?>
|
||||
</select>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
if ($config['use_captcha']) {
|
||||
?>
|
||||
@@ -197,8 +188,8 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<li>
|
||||
<h2>Server Rules</h2>
|
||||
|
||||
<li><h2>Server Rules</h2>
|
||||
<p>The golden rule: Have fun.</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>
|
||||
@@ -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>
|
||||
submitted information. (Including exposing and logging your IP).</p>
|
||||
</li>
|
||||
<li>
|
||||
Do you agree to follow the server rules?<br>
|
||||
|
||||
<li>Do you agree to follow the server rules?<br>
|
||||
<select name="selected">
|
||||
<option value="0">Umh...</option>
|
||||
<option value="1">Yes.</option>
|
||||
|
||||
Reference in New Issue
Block a user