2 Commits
v2 ... 1.6

Author SHA1 Message Date
Znote
26c486ef27 Tagging Znote AAC as version 1.6 2021-07-22 17:57:09 +02:00
Znote
ddd54a932e Better guild validations, Fix #457 2021-07-22 17:30:49 +02:00
41 changed files with 3372 additions and 3803 deletions

View File

@@ -25,23 +25,23 @@ end
-- SQL Query to execute: -- -- SQL Query to execute: --
--[[ --[[
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT NOT NULL DEFAULT '0', ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT NOT NULL DEFAULT '0', ADD `exphist1` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT NOT NULL DEFAULT '0', ADD `exphist2` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT NOT NULL DEFAULT '0', ADD `exphist3` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT NOT NULL DEFAULT '0', ADD `exphist4` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT NOT NULL DEFAULT '0', ADD `exphist5` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT NOT NULL DEFAULT '0', ADD `exphist6` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT NOT NULL DEFAULT '0', ADD `exphist7` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetimetoday` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetimetoday` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime1` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime1` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime2` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime2` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime3` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime3` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime4` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime4` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime5` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime5` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime6` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime6` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime7` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime7` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetimeall` INT UNSIGNED NOT NULL DEFAULT '0'; ADD `onlinetimeall` BIGINT NOT NULL DEFAULT '0';
]]-- ]]--
-- after that execute: -- -- after that execute: --

View File

@@ -1,229 +0,0 @@
-- 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

@@ -25,23 +25,23 @@ end
-- SQL Query to execute: -- -- SQL Query to execute: --
--[[ --[[
ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT NOT NULL DEFAULT '0', ALTER TABLE `znote_players` ADD `exphist_lastexp` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist1` BIGINT NOT NULL DEFAULT '0', ADD `exphist1` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist2` BIGINT NOT NULL DEFAULT '0', ADD `exphist2` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist3` BIGINT NOT NULL DEFAULT '0', ADD `exphist3` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist4` BIGINT NOT NULL DEFAULT '0', ADD `exphist4` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist5` BIGINT NOT NULL DEFAULT '0', ADD `exphist5` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist6` BIGINT NOT NULL DEFAULT '0', ADD `exphist6` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `exphist7` BIGINT NOT NULL DEFAULT '0', ADD `exphist7` BIGINT UNSIGNED NOT NULL DEFAULT '0',
ADD `onlinetimetoday` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetimetoday` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime1` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime1` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime2` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime2` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime3` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime3` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime4` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime4` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime5` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime5` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime6` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime6` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetime7` MEDIUMINT UNSIGNED NOT NULL DEFAULT '0', ADD `onlinetime7` BIGINT NOT NULL DEFAULT '0',
ADD `onlinetimeall` INT UNSIGNED NOT NULL DEFAULT '0'; ADD `onlinetimeall` BIGINT NOT NULL DEFAULT '0';
]]-- ]]--
-- after that execute: -- -- after that execute: --

View File

@@ -1,14 +1,6 @@
ZnoteAAC ZnoteAAC
======== ========
[![CodeFactor](https://www.codefactor.io/repository/github/znote/znoteaac/badge)](https://www.codefactor.io/repository/github/znote/znoteaac) [![CodeFactor](https://www.codefactor.io/repository/github/znote/znoteaac/badge)](https://www.codefactor.io/repository/github/znote/znoteaac)
### Branch: v2
The purpose of this branch is to server as code cleanup, and strip distro compatibility for anything below TFS 1.4.
I want to refactor some code, try to get Znote AAC a bit more lightweight. Remove single-use functions from globally included function files etc.
New features and bugfixes might arrive here first, and then backported to 1.5/6 (master branch).
---
### What is Znote AAC? ### What is Znote AAC?
Znote AAC is a full-fledged website used together with an Open Tibia(OT) server. Znote AAC is a full-fledged website used together with an Open Tibia(OT) server.
@@ -21,8 +13,6 @@ We use github to distribute our versions, stable are tagged as releases, while d
* [Stable](https://github.com/Znote/ZnoteAAC/releases) * [Stable](https://github.com/Znote/ZnoteAAC/releases)
* [Development](https://github.com/Znote/ZnoteAAC/archive/master.zip) * [Development](https://github.com/Znote/ZnoteAAC/archive/master.zip)
**NOTE:** Development version supports TFS 1.3, but you can expect bugs to occur.
### Compatible OT distributions ### Compatible OT distributions
Znote AAC primarily aims to be compatible with [Forgotten Server](https://github.com/otland/forgottenserver) Znote AAC primarily aims to be compatible with [Forgotten Server](https://github.com/otland/forgottenserver)
Forgotten Server is commonly known as TFS (The Forgotten Server) and Znote AAC supports these versions: Forgotten Server is commonly known as TFS (The Forgotten Server) and Znote AAC supports these versions:

View File

@@ -36,11 +36,6 @@ 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

@@ -1,14 +1,12 @@
<?php <?php
// Verify the PHP version, gives tutorial if fail. // Verify the PHP version, gives tutorial if fail.
if (version_compare(phpversion(), '7.2', '<')) die('PHP version 7.2 or higher is required.'); if (version_compare(phpversion(), '5.6', '<')) die('PHP version 5.6 or higher is required.');
if (!isset($filepath)) $filepath = '../'; if (!isset($filepath)) $filepath = '../';
$version = '2.0_DEV'; $version = '1.6';
session_start(); session_start();
ob_start(); ob_start();
require_once $filepath.'config.php'; require_once $filepath.'config.php';
$sessionPrefix = $config['session_prefix'];
require_once $filepath.'engine/database/connect.php'; require_once $filepath.'engine/database/connect.php';
require_once $filepath.'engine/function/general.php'; require_once $filepath.'engine/function/general.php';
require_once $filepath.'engine/function/cache.php'; require_once $filepath.'engine/function/cache.php';

View File

@@ -54,7 +54,6 @@ if (user_logged_in()) {
<h1>Changelog</h1> <h1>Changelog</h1>
<?php <?php
$cache = new Cache('engine/cache/changelog'); $cache = new Cache('engine/cache/changelog');
$cache->useMemory(false);
if ($updateCache === true) { if ($updateCache === true) {
$changelogs = mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;"); $changelogs = mysql_select_multi("SELECT `id`, `text`, `time`, `report_id`, `status` FROM `znote_changelog` ORDER BY `id` DESC;");

View File

@@ -11,20 +11,36 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
if ($user_id !== false) { if ($user_id !== false) {
$loadOutfits = $config['show_outfits']['characterprofile']; $loadOutfits = $config['show_outfits']['characterprofile'];
if (!$loadOutfits) { if ($config['ServerEngine'] == 'TFS_10') {
$profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin'); if (!$loadOutfits) {
} else { // Load outfits $profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin');
if ($config['client'] < 780) { } else { // Load outfits
$profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype'); if ($config['client'] < 780) {
} else { $profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype');
$profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype', 'lookaddons'); } else {
$profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype', 'lookaddons');
}
} }
} $profile_data['online'] = user_is_online_10($user_id);
$profile_data['online'] = user_is_online_10($user_id);
if ($config['Ach']) { if ($config['Ach']) {
$user_id = (int) $user_id; $user_id = (int) $user_id;
$achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`={$user_id} LIMIT 1"); $achievementPoints = mysql_select_single("SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`={$user_id} LIMIT 1");
}
} else { // TFS 0.2, 0.3
if (!$loadOutfits) {
$profile_data = user_character_data($user_id, 'name', 'account_id', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'lastlogin', 'online', 'sex');
} else { // Load outfits
if ($config['ServerEngine'] !== 'OTHIRE') {
if ($config['client'] < 780) {
$profile_data = user_character_data($user_id, 'name', 'account_id', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'lastlogin', 'online', 'sex', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype');
} else {
$profile_data = user_character_data($user_id, 'name', 'account_id', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'lastlogin', 'online', 'sex', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype', 'lookaddons');
}
} else {
$profile_data = user_character_data($user_id, 'name', 'account_id', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'lastlogin', 'online', 'sex', 'lookbody', 'lookfeet', 'lookhead', 'looklegs', 'looktype');
}
}
} }
$profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment'); $profile_znote_data = user_znote_character_data($user_id, 'created', 'hide_char', 'comment');
@@ -66,29 +82,10 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
</thead> </thead>
<tbody> <tbody>
<!-- Player Position --> <!-- Player Position -->
<?php if ($profile_data['group_id'] > 1): <?php if ($profile_data['group_id'] > 1): ?>
$position = mysql_select_single("
SELECT
`a`.`type`
FROM `players` AS `p`
INNER JOIN `accounts` AS `a`
ON `p`.`account_id` = `a`.`id`
WHERE
`a`.`type` > 1
AND `p`.`id` = '{$user_id}'
");
$position = (isset($config['ingame_positions'][$position['type']])) ? $config['ingame_positions'][$position['type']] : "Unknown";
?>
<tr> <tr>
<td>Position</td> <td>Position</td>
<td><?php echo $position; ?></td> <td><?php echo group_id_to_name($profile_data['group_id']); ?></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> </tr>
<?php endif; ?> <?php endif; ?>
<!-- Player male / female --> <!-- Player male / female -->
@@ -127,20 +124,31 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
<?php endif; ?> <?php endif; ?>
<!-- Display house start --> <!-- Display house start -->
<?php <?php
if ($config['ServerEngine'] !== 'TFS_02') {
// Compatibility fix
$column_town_id = array(
'OTHIRE' => 'townid',
'TFS_03' => 'town'
// Default: town_id
);
$column_town_id = (isset($column_town_id[$config['ServerEngine']]))
? $column_town_id[$config['ServerEngine']]
: 'town_id';
$houses = mysql_select_multi(" $houses = mysql_select_multi("
SELECT `id`, `owner`, `name`, `town_id` AS `town_id` SELECT `id`, `owner`, `name`, `{$column_town_id}` AS `town_id`
FROM `houses` FROM `houses`
WHERE `owner` = {$user_id}; WHERE `owner` = {$user_id};
"); ");
if ($houses !== false) { if ($houses !== false) {
foreach ($houses as $h): ?> foreach ($houses as $h): ?>
<tr> <tr>
<td>House</td> <td>House</td>
<td><?php echo $h['name'] . ', ' . $config['towns'][$h['town_id']]; ?></td> <td><?php echo $h['name'] . ', ' . $config['towns'][$h['town_id']]; ?></td>
</tr> </tr>
<?php endforeach; <?php endforeach;
}
} }
?> ?>
<!-- Display player status --> <!-- Display player status -->
@@ -172,30 +180,56 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
AND `pid`<'11' AND `pid`<'11'
"); ");
$soulStamina = " `soul`, `stamina`,"; $soulStamina = (in_array($config['ServerEngine'], ['TFS_10']))
? " `soul`, `stamina`,"
: " `p`.`soul`, `p`.`stamina`,";
if ($config['client'] < 780) { if ($config['client'] < 780) {
$soulStamina = " 0 AS `soul`, 0 AS `stamina`,"; $soulStamina = " 0 AS `soul`, 0 AS `stamina`,";
} }
$player_query = " $player_query = (in_array($config['ServerEngine'], ['TFS_10']))
SELECT ? /* true */ "SELECT
`health`, `healthmax`, `health`, `healthmax`,
`mana`, `manamax`, `mana`, `manamax`,
`cap`, `cap`,
`experience`, `level`, `experience`, `level`,
{$soulStamina} {$soulStamina}
`maglevel`, `maglevel`,
`skill_fist`, `skill_fist`,
`skill_club`, `skill_club`,
`skill_sword`, `skill_sword`,
`skill_axe`, `skill_axe`,
`skill_dist`, `skill_dist`,
`skill_shielding`, `skill_shielding`,
`skill_fishing` `skill_fishing`
FROM `players` FROM `players`
WHERE `id`={$user_id} WHERE `id`={$user_id}
LIMIT 1; LIMIT 1;"
"; : /* false */ "SELECT
`p`.`health`, `p`.`healthmax`,
`p`.`mana`, `p`.`manamax`,
`p`.`cap`,
`p`.`experience`, `p`.`level`,
{$soulStamina}
`p`.`maglevel`,
`fist`.`value` AS `skill_fist`,
`club`.`value` AS `skill_club`,
`sword`.`value` AS `skill_sword`,
`axe`.`value` AS `skill_axe`,
`dist`.`value` AS `skill_dist`,
`shield`.`value` AS `skill_shielding`,
`fish`.`value` AS `skill_fishing`
FROM `players` AS `p`
LEFT JOIN `player_skills` AS `fist` ON `p`.`id` = `fist`.`player_id` AND `fist`.`skillid` = 0
LEFT JOIN `player_skills` AS `club` ON `p`.`id` = `club`.`player_id` AND `club`.`skillid` = 1
LEFT JOIN `player_skills` AS `sword` ON `p`.`id` = `sword`.`player_id` AND `sword`.`skillid` = 2
LEFT JOIN `player_skills` AS `axe` ON `p`.`id` = `axe`.`player_id` AND `axe`.`skillid` = 3
LEFT JOIN `player_skills` AS `dist` ON `p`.`id` = `dist`.`player_id` AND `dist`.`skillid` = 4
LEFT JOIN `player_skills` AS `shield` ON `p`.`id` = `shield`.`player_id` AND `shield`.`skillid` = 5
LEFT JOIN `player_skills` AS `fish` ON `p`.`id` = `fish`.`player_id` AND `fish`.`skillid` = 6
WHERE `p`.`id`= {$user_id}
LIMIT 1;";
$playerstats = mysql_select_single($player_query); $playerstats = mysql_select_single($player_query);
$playerstats['experience'] = number_format($playerstats['experience'],0,'',','); $playerstats['experience'] = number_format($playerstats['experience'],0,'',',');
@@ -218,8 +252,9 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
[133,134,143,144,145], [133,134,143,144,145],
[146,151,152,153,154], [146,151,152,153,154],
[251,268,273,278,289], [251,268,273,278,289],
[325,328,335,367], [325,328,335,367,430],
//430,432,463,465,472,512,516,541,574,577,610,619,633,634,637,665,667,684,695,697,699,725,733,746,750,760,846,853,873,884,899 [432,463,465,472,512],
//516,541,574,577,610,619,633,634,637,665,667,684,695,697,699,725,733,746,750,760,846,853,873,884,899
); );
$female_outfits = array( $female_outfits = array(
@@ -227,8 +262,9 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
[141,142,147,148,149], [141,142,147,148,149],
[150,155,156,157,158], [150,155,156,157,158],
[252,269,270,279,288], [252,269,270,279,288],
[324,329,336,366], [324,329,336,366,431],
//431,433,464,466,471,513,514,542,575,578,618,620,632,635,636,664,666,683,694,696,698,724,732,745,749,759,845,852,874,885,900 [433,464,466,471,513],
//514,542,575,578,618,620,632,635,636,664,666,683,694,696,698,724,732,745,749,759,845,852,874,885,900
); );
$featured_outfits = ($profile_data['sex'] == 1) ? $male_outfits : $female_outfits; $featured_outfits = ($profile_data['sex'] == 1) ? $male_outfits : $female_outfits;
@@ -375,15 +411,11 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
} }
#piv_flex img { #piv_flex img {
position: absolute; position: absolute;
bottom: 0;
right: 0;
} }
#piv_i .inventory_outfit { #piv_i .inventory_outfit {
position: absolute; position: absolute;
top: 130px; top: 130px;
left: -24px; left: -24px;
width: 64px;
height: 64px;
} }
#piv_lifebar { #piv_lifebar {
position: absolute; position: absolute;
@@ -679,63 +711,121 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
</thead> </thead>
<tbody> <tbody>
<?php <?php
$deaths = mysql_select_multi(" if ($config['ServerEngine'] == 'TFS_10') {
SELECT $deaths = mysql_select_multi("
`player_id`, SELECT
`time`, `player_id`,
`level`, `time`,
`killed_by`, `level`,
`is_player`, `killed_by`,
`mostdamage_by`, `is_player`,
`mostdamage_is_player`, `mostdamage_by`,
`unjustified`, `mostdamage_is_player`,
`mostdamage_unjustified` `unjustified`,
FROM `player_deaths` `mostdamage_unjustified`
WHERE `player_id`=$user_id FROM `player_deaths`
ORDER BY `time` DESC WHERE `player_id`=$user_id
LIMIT 10; ORDER BY `time` DESC
"); LIMIT 10;
");
if ($deaths) { if ($deaths) {
foreach ($deaths as $d) { foreach ($deaths as $d) {
$lasthit = ($d['is_player']) $lasthit = ($d['is_player'])
? "<a href='characterprofile.php?name=".$d['killed_by']."'>".$d['killed_by']."</a>" ? "<a href='characterprofile.php?name=".$d['killed_by']."'>".$d['killed_by']."</a>"
: $d['killed_by']; : $d['killed_by'];
?> ?>
<tr> <tr>
<td><?php echo getClock($d['time'], true, true); ?></td> <td><?php echo getClock($d['time'], true, true); ?></td>
<td> <td>
<?php <?php
echo "Killed at level ".$d['level']." by {$lasthit}"; echo "Killed at level ".$d['level']." by {$lasthit}";
if ($d['unjustified']) { if ($d['unjustified']) {
echo " <font color='red' style='font-style: italic;'>(unjustified)</font>";
}
$mostdmg = ($d['mostdamage_by'] !== $d['killed_by']) ? true : false;
if ($mostdmg) {
$mostdmg = ($d['mostdamage_is_player'])
? "<a href='characterprofile.php?name=".$d['mostdamage_by']."'>".$d['mostdamage_by']."</a>"
: $d['mostdamage_by'];
echo "<br>and by $mostdmg.";
if ($d['mostdamage_unjustified']) {
echo " <font color='red' style='font-style: italic;'>(unjustified)</font>"; echo " <font color='red' style='font-style: italic;'>(unjustified)</font>";
} }
} else { $mostdmg = ($d['mostdamage_by'] !== $d['killed_by']) ? true : false;
echo " <b>(soloed)</b>"; if ($mostdmg) {
} $mostdmg = ($d['mostdamage_is_player'])
?> ? "<a href='characterprofile.php?name=".$d['mostdamage_by']."'>".$d['mostdamage_by']."</a>"
</td> : $d['mostdamage_by'];
echo "<br>and by $mostdmg.";
if ($d['mostdamage_unjustified']) {
echo " <font color='red' style='font-style: italic;'>(unjustified)</font>";
}
} else {
echo " <b>(soloed)</b>";
}
?>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="2">This player has never died.</td>
</tr>
<?php
}
} elseif ($config['ServerEngine'] == 'TFS_02') {
$array = user_fetch_deathlist($user_id);
if ($array) {
foreach ($array as $value):
if ($value['is_player'] == 1) {
$value['killed_by'] = 'player: <a href="characterprofile.php?name='. $value['killed_by'] .'">'. $value['killed_by'] .'</a>';
} else {
$value['killed_by'] = 'monster: '. $value['killed_by'] .'.';
}
?>
<tr>
<td><?php echo getClock($value['time'], true, true); ?></td>
<td><?php echo 'Killed at level '. $value['level'] .' by '. $value['killed_by']; ?></td>
</tr>
<?php endforeach;
} else {
?>
<tr>
<td colspan="2">This player has never died.</td>
</tr>
<?php
}
} elseif (in_array($config['ServerEngine'], array('TFS_03', 'OTHIRE'))) {
//mysql_select_single("SELECT * FROM players WHERE name='TEST DEBUG';");
$array = user_fetch_deathlist03($user_id);
if ($array) {
// Design and present the list
foreach ($array as $value):
$value[3] = user_get_killer_id(user_get_kid($value['id']));
if ($value[3] !== false && $value[3] >= 1) {
$namedata = user_character_data((int)$value[3], 'name');
if ($namedata !== false) {
$value[3] = $namedata['name'];
$value[3] = 'player: <a href="characterprofile.php?name='. $value[3] .'">'. $value[3] .'</a>';
} else {
$value[3] = 'deleted player.';
}
} else {
$value[3] = user_get_killer_m_name(user_get_kid($value['id']));
if ($value[3] === false) {
$value[3] = 'deleted player.';
}
}
?>
<tr>
<td><?php echo getClock($value['date'], true, true); ?></td>
<td><?php echo 'Killed at level '. $value['level'] .' by '. $value[3]; ?></td>
</tr>
<?php endforeach;
} else {
?>
<tr>
<td colspan="2">This player has never died.</td>
</tr> </tr>
<?php <?php
} }
} else {
?>
<tr>
<td colspan="2">This player has never died.</td>
</tr>
<?php
} }
?> ?>
</tbody> </tbody>
@@ -803,6 +893,14 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
<!-- CHARACTER LIST --> <!-- CHARACTER LIST -->
<?php <?php
// Backward compatibility
$select_online = "CASE WHEN `l`.`player_id` IS NULL THEN 0 else 1 END as `online`";
$join_online = "LEFT JOIN `players_online` as `l` ON `p`.`id` = `l`.`player_id`";
if ($config['ServerEngine'] != 'TFS_10') {
$select_online = "`p`.`online`";
$join_online = "";
}
// Load other visible characters // Load other visible characters
$otherChars = mysql_select_multi(" $otherChars = mysql_select_multi("
SELECT SELECT
@@ -811,7 +909,7 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
`p`.`level`, `p`.`level`,
`p`.`vocation`, `p`.`vocation`,
`p`.`lastlogin`, `p`.`lastlogin`,
CASE WHEN `l`.`player_id` IS NULL THEN 0 else 1 END as `online` {$select_online}
FROM `players` as `o` FROM `players` as `o`
JOIN `players` as `p` JOIN `players` as `p`
ON `o`.`account_id` = `p`.`account_id` ON `o`.`account_id` = `p`.`account_id`
@@ -819,7 +917,7 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
ON `p`.`id` = `z`.`player_id` ON `p`.`id` = `z`.`player_id`
LEFT JOIN `znote_players` as `z2` LEFT JOIN `znote_players` as `z2`
ON `o`.`id` = `z2`.`player_id` ON `o`.`id` = `z2`.`player_id`
LEFT JOIN `players_online` as `l` ON `p`.`id` = `l`.`player_id` {$join_online}
WHERE `o`.`id` = {$user_id} WHERE `o`.`id` = {$user_id}
AND `p`.`id` != `o`.`id` AND `p`.`id` != `o`.`id`
AND `z`.`hide_char` = 0 AND `z`.`hide_char` = 0

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-12-80-for-website.279319/ // host yourself: https://otland.net/threads/item-images-10-92.242492/
'imageServer' => 'https://outfit-images.ots.me/1285/animoutfit.php' 'imageServer' => 'https://outfit-images.ots.me/animatedOutfits1099/animoutfit.php'
); );
// Show advanced inventory data in character profile // Show advanced inventory data in character profile
@@ -657,27 +657,15 @@
'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 to update?
$config['cache'] = array( $config['cache_lifespan'] = 5; // 60 * 15; // 15 minutes.
// If you have two instances installed on same server, make each instance prefix unique
'prefix' => 'znote_',
// 60 * 15; // 15 minutes.
'lifespan' => 5,
// Store cache in memory/RAM? Requires PHP extension APCu
'memory' => true
);
// WARNING! Account names written here will have admin access to web page! // WARNING! Account names written here will have admin access to web page!
$config['page_admin_access'] = array( $config['page_admin_access'] = array(
'firstaccountName', 'firstaccountName',
'secondaccountName', 'secondaccountName',
); );
// Allow admins to see executed SQL queries overlay
// Useful for testing and optimizing query usage on website
$config['admin_show_queries'] = true;
// Built-in FORUM // Built-in FORUM
// Enable forum, enable guildboards, level to create threads/post in them // Enable forum, enable guildboards, level to create threads/post in them

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'] && !is_admin($user_data)) { if ($char_count >= $config['max_characters']) {
$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

@@ -1,6 +1,6 @@
<?php <?php
$time = time(); $time = time();
if (!isset($version)) $version = '2.0_DEV'; if (!isset($version)) $version = '1.6';
if (!function_exists("elapsedTime")) { if (!function_exists("elapsedTime")) {
function elapsedTime($l_start = false, $l_time = false) { function elapsedTime($l_start = false, $l_time = false) {

View File

@@ -1,6 +1,6 @@
-- Start of Znote AAC database schema -- Start of Znote AAC database schema
SET @znote_version = '2.0_DEV'; SET @znote_version = '1.6';
CREATE TABLE IF NOT EXISTS `znote` ( CREATE TABLE IF NOT EXISTS `znote` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,

View File

@@ -1,167 +1,122 @@
<?php <?php
class Cache class Cache
{ {
protected $_file = false; protected $_file = false;
protected $_lifespan = 0; protected $_lifespan = 0;
protected $_content; protected $_content;
protected $_memory = false;
protected $_canMemory = false;
const EXT = '.cache.php'; const EXT = '.cache.php';
/** /**
* @param string $file * @param string $file
* @access public * @access public
* @return void * @return void
**/ **/
public function __construct($file) { public function __construct($file) {
$cfg = config('cache'); $this->_file = $file . self::EXT;
$this->setExpiration(config('cache_lifespan'));
$this->setExpiration($cfg['lifespan']);
if (function_exists('apcu_fetch')) {
$this->_canMemory = true;
$this->_memory = $cfg['memory'];
} }
$this->_file = $file . self::EXT;
if (!$this->_memory && $cfg['memory']) die("
<p><strong>Configuration error!</strong>
<br>Cannot save cache to memory, but it is configured to do so.
<br>You need to enable PHP extension APCu to enable memory cache.
<br>Install it or set \$config['cache']['memory'] to false!
<br><strong>Ubuntu install:</strong> sudo apt install php-apcu</p>
");
}
/** /**
* Sets the cache expiration limit (IMPORTANT NOTE: seconds, NOT ms!). * Sets the cache expiration limit (IMPORTANT NOTE: seconds, NOT ms!).
* *
* @param integer $span * @param integer $span
* @access public * @access public
* @return void * @return void
**/ **/
public function setExpiration($span) { public function setExpiration($span) {
$this->_lifespan = $span; $this->_lifespan = $span;
} }
/** /**
* Enable or disable memory RAM storage. * Set the content you'd like to cache.
* *
* @param bool $bool * @param mixed $content
* @access public * @access public
* @return bool $status * @return void
**/ **/
public function useMemory($bool) { public function setContent($content) {
if ($bool and $this->_canMemory) { switch (strtolower(gettype($content))) {
$this->_memory = true; case 'array':
$this->_content = json_encode($content);
break;
default:
$this->_content = $content;
break;
}
}
/**
* Validates whether it is time to refresh the cache data or not.
*
* @access public
* @return boolean
**/
public function hasExpired() {
if (is_file($this->_file) && time() < filemtime($this->_file) + $this->_lifespan) {
return false;
}
return true; return true;
} }
$this->_memory = false;
return false;
}
/**
/** * Returns remaining time before scoreboard will update itself.
* Set the content you'd like to cache. *
* * @access public
* @param mixed $content * @return integer
* @access public **/
* @return void public function remainingTime() {
**/ $remaining = 0;
public function setContent($content) { if (!$this->hasExpired()) {
$this->_content = (!$this->_memory && strtolower(gettype($content)) == 'array') ? json_encode($content) : $content; $remaining = (filemtime($this->_file) + $this->_lifespan) - time();
}
/**
* Validates whether it is time to refresh the cache data or not.
*
* @access public
* @return boolean
**/
public function hasExpired() {
if ($this->_memory) {
return !apcu_exists($this->_file);
}
if (is_file($this->_file) && time() < filemtime($this->_file) + $this->_lifespan) {
return false;
}
return true;
}
/**
* Returns remaining time before scoreboard will update itself.
*
* @access public
* @return integer
**/
public function remainingTime() {
$remaining = 0;
if ($this->_memory) {
if (apcu_exists($this->_file)) {
$meta = apc_cache_info('user');
foreach ($meta['cache_list'] AS $item) {
if ($item['info'] == $this->_file) {
$remaining = ($item['creation_time'] + $item['ttl']) - time();
return ($remaining > 0) ? $remaining : 0;
}
}
} }
return $remaining; return $remaining;
} }
if (!$this->hasExpired()) {
$remaining = (filemtime($this->_file) + $this->_lifespan) - time();
}
return $remaining;
}
/** /**
* Saves the content into its appropriate cache file. * Saves the content into its appropriate cache file.
* *
* @access public * @access public
* @return void * @return void
**/ **/
public function save() { public function save() {
if ($this->_memory) { $handle = fopen($this->_file, 'w');
return apcu_store($this->_file, $this->_content, $this->_lifespan); fwrite($handle, $this->_content);
} fclose($handle);
$handle = fopen($this->_file, 'w');
fwrite($handle, $this->_content);
fclose($handle);
}
/**
* Loads the content from a specified cache file.
*
* @access public
* @return mixed
**/
public function load() {
if ($this->_memory) {
return apcu_fetch($this->_file);
}
if (!is_file($this->_file)) {
return false;
} }
ob_start();
include_once($this->_file);
$content = ob_get_clean();
if (!isset($content) && strlen($content) == 0) { /**
return false; * Loads the content from a specified cache file.
} *
* @access public
* @return mixed
**/
public function load() {
if (!is_file($this->_file)) {
return false;
}
if ($content = json_decode($content, true)) { ob_start();
return (array) $content; include_once($this->_file);
} else { $content = ob_get_clean();
return $content;
if (!isset($content) && strlen($content) == 0) {
return false;
}
if ($content = json_decode($content, true)) {
return (array) $content;
} else {
return $content;
}
} }
} }
}

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((int)$ipL); $ipR = long2ip($ipL);
if ($ip === $ipR) { if ($ip === $ipR) {
return true; return true;
@@ -422,8 +422,10 @@ function output_errors($errors) {
return '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>'; return '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>';
} }
// Resize images and create image // Resize images
function resize_imagex($file, $width, $height) { function resize_imagex($file, $width, $height) {
list($w, $h) = getimagesize($file['tmp']); list($w, $h) = getimagesize($file['tmp']);
$ratio = max($width/$w, $height/$h); $ratio = max($width/$w, $height/$h);
@@ -441,8 +443,7 @@ function resize_imagex($file, $width, $height) {
0, 0, 0, 0,
$x, 0, $x, 0,
$width, $height, $width, $height,
$w, $h $w, $h);
);
imagegif($tmp, $path); imagegif($tmp, $path);
imagedestroy($image); imagedestroy($image);
@@ -451,43 +452,71 @@ function resize_imagex($file, $width, $height) {
return true; return true;
} }
// Validate guild logo // Guild logo upload security
function check_image($image) { function check_image($image) {
$image_data = array(
'new_name' => $_GET['name'].'.gif',
'name' => $image['name'],
'tmp' => $image['tmp_name'],
'error' => $image['error'],
'size' => $image['size'],
'type' => $image['type']
);
if ($image_data['type'] !== 'image/gif') { $image_data = array('new_name' => $_GET['name'].'.gif', 'name' => $image['name'], 'tmp' => $image['tmp_name'], 'error' => $image['error'], 'size' => $image['size'], 'type' => $image['type']);
// First security check, quite useless but still do its job
if ($image_data['type'] === 'image/gif') {
// Second security check, lets go
$check = getimagesize($image_data['tmp']);
if ($check) {
// Third
if ($check['mime'] === 'image/gif') {
$path_info = pathinfo($image_data['name']);
// Last one
if ($path_info['extension'] === 'gif') {
// Resize image
$img = resize_imagex($image_data, 100, 100);
if ($img) {
header('Location: guilds.php?name='. $_GET['name']);
exit();
}
} else {
header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$path_info['extension'].'].&name='. $_GET['name']);
exit();
}
} else {
header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$check['mime'].'].&name='. $_GET['name']);
exit();
}
} else {
header('Location: guilds.php?error=Uploaded image is invalid.&name='. $_GET['name']);
exit();
}
} else {
header('Location: guilds.php?error=Only gif images are accepted, you uploaded:['.$image_data['type'].'].&name='. $_GET['name']); header('Location: guilds.php?error=Only gif images are accepted, you uploaded:['.$image_data['type'].'].&name='. $_GET['name']);
exit(); exit();
} }
}
$check = getimagesize($image_data['tmp']); // Check guild logo
if (!$check) { function logo_exists($guild) {
header('Location: guilds.php?error=Uploaded image is invalid.&name='. $_GET['name']); $guild = sanitize($guild);
exit(); if (file_exists('engine/guildimg/'.$guild.'.gif')) {
}
if ($check['mime'] !== 'image/gif') { echo'engine/guildimg/'.$guild.'.gif';
header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$check['mime'].'].&name='. $_GET['name']);
exit();
}
$path_info = pathinfo($image_data['name']); } else {
if ($path_info['extension'] !== 'gif') {
header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$path_info['extension'].'].&name='. $_GET['name']);
exit();
}
// Resize image echo'engine/guildimg/default@logo.gif';
if (resize_imagex($image_data, 100, 100)) {
header('Location: guilds.php?name='. $_GET['name']);
exit();
} }
} }

View File

@@ -143,18 +143,7 @@ function support_list03() {
// NEWS // NEWS
function fetchAllNews() { function fetchAllNews() {
return mysql_select_multi(" return mysql_select_multi("SELECT `n`.`id`, `n`.`title`, `n`.`text`, `n`.`date`, `p`.`name` FROM `znote_news` AS `n` INNER JOIN `players` AS `p` ON `n`.`pid` = `p`.`id` ORDER BY `n`.`id` DESC;");
SELECT
`n`.`id`,
`n`.`title`,
`n`.`text`,
`n`.`date`,
`p`.`name`
FROM `znote_news` AS `n`
INNER JOIN `players` AS `p`
ON `n`.`pid` = `p`.`id`
ORDER BY `n`.`id` DESC;
");
} }
// HOUSES // HOUSES
@@ -261,6 +250,62 @@ function guild_remove_member_10($cid) {
mysql_update("DELETE FROM `guild_membership` WHERE `player_id`='$cid' LIMIT 1;"); mysql_update("DELETE FROM `guild_membership` WHERE `player_id`='$cid' LIMIT 1;");
} }
// Change guild rank name.
function guild_change_rank($rid, $name) {
$rid = (int)$rid;
$name = sanitize($name);
mysql_update("UPDATE `guild_ranks` SET `name`='$name' WHERE `id`=$rid");
}
// Change guild leader (parameters: cid, new and old leader).
function guild_change_leader($nCid, $oCid) {
$nCid = (int)$nCid;
$oCid = (int)$oCid;
$gid = guild_leader_gid($oCid);
$ranks = get_guild_rank_data($gid);
$leader_rid = 0;
$vice_rid = 0;
// Get rank id for leader and vice leader.
foreach ($ranks as $rank) {
if ($rank['level'] == 3) $leader_rid = $rank['id'];
if ($rank['level'] == 2) $vice_rid = $rank['id'];
}
$status = false;
if ($leader_rid > 0 && $vice_rid > 0) $status = true;
// Verify that we found the rank ids for vice leader and leader.
if ($status) {
// Update players and set their new rank id
if (config('ServerEngine') !== 'TFS_10') {
mysql_update("UPDATE `players` SET `rank_id`='$leader_rid' WHERE `id`=$nCid LIMIT 1;");
mysql_update("UPDATE `players` SET `rank_id`='$vice_rid' WHERE `id`=$oCid LIMIT 1;");
} else {
mysql_update("UPDATE `guild_membership` SET `rank_id`='$leader_rid' WHERE `player_id`=$nCid LIMIT 1;");
mysql_update("UPDATE `guild_membership` SET `rank_id`='$vice_rid' WHERE `player_id`=$oCid LIMIT 1;");
}
// Update guilds set new ownerid
guild_new_leader($nCid, $gid);
}
return $status;
}
// Changes leadership of aguild to player_id
function guild_new_leader($new_leader, $gid) {
$new_leader = (int)$new_leader;
$gid = (int)$gid;
if (config('ServerEngine') !== 'OTHIRE')
mysql_update("UPDATE `guilds` SET `ownerid`='$new_leader' WHERE `id`=$gid");
else
mysql_update("UPDATE `guilds` SET `owner_id`='$new_leader' WHERE `id`=$gid");
}
// Returns $gid of a guild leader($cid). // Returns $gid of a guild leader($cid).
function guild_leader_gid($leader) { function guild_leader_gid($leader) {
$leader = (int)$leader; $leader = (int)$leader;
@@ -281,12 +326,158 @@ function guild_leader($gid) {
return ($data !== false) ? $data['ownerid'] : false; return ($data !== false) ? $data['ownerid'] : false;
} }
// Disband guild
function guild_remove_invites($gid) {
$gid = (int)$gid;
mysql_delete("DELETE FROM `guild_invites` WHERE `guild_id`='$gid';");
}
// Remove guild invites
function guild_delete($gid) {
$gid = (int)$gid;
mysql_delete("DELETE FROM `guilds` WHERE `id`='$gid';");
}
// Player leave guild
function guild_player_leave($cid) {
$cid = (int)$cid;
mysql_update("UPDATE `players` SET `rank_id`='0', `guildnick`= NULL WHERE `id`=$cid LIMIT 1;");
}
function guild_player_leave_10($cid) {
$cid = (int)$cid;
mysql_delete("DELETE FROM `guild_membership` WHERE `player_id`='$cid' LIMIT 1;");
}
// Player join guild
function guild_player_join($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
// Create a status we can return depending on results.
$status = false;
if (config('ServerEngine') !== 'TFS_10') {
// Get rank data
$ranks = get_guild_rank_data($gid);
// Locate rank id for regular member position in this guild
$rid = false;
foreach ($ranks as $rank) {
if ($rank['level'] == 1) $rid = $rank['id'];
}
// Add to guild if rank id was found:
if ($rid != false) {
// Remove the invite:
//guild_remove_invitation($cid, $gid);
guild_remove_all_invitations($cid);
// Add to guild:
mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`=$cid");
$status = true;
}
} else {
// Find rank id for regular member in this guild
$guildrank = mysql_select_single("SELECT `id` FROM `guild_ranks` WHERE `guild_id`='$gid' AND `level`='1' LIMIT 1;");
if ($guildrank !== false) {
$rid = $guildrank['id'];
// Remove invite
//guild_remove_invitation($cid, $gid);
guild_remove_all_invitations($cid);
// Add to guild
mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('$cid', '$gid', '$rid', '');");
// Return success
return true;
} return false;
}
return $status;
}
// Remove cid invitation from guild (gid)
function guild_remove_invitation($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid' AND `guild_id`='$gid';");
}
// Remove ALL invitations
function guild_remove_all_invitations($cid) {
$cid = (int)$cid;
mysql_delete("DELETE FROM `guild_invites` WHERE `player_id`='$cid';");
}
// Invite character to guild
function guild_invite_player($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
mysql_insert("INSERT INTO `guild_invites` (`player_id`, `guild_id`) VALUES ('$cid', '$gid')");
}
// Gets a list of invited players to a particular guild. // Gets a list of invited players to a particular guild.
function guild_invite_list($gid) { function guild_invite_list($gid) {
$gid = (int)$gid; $gid = (int)$gid;
return mysql_select_multi("SELECT `gi`.`player_id`, `gi`.`guild_id`, `p`.`name` FROM `guild_invites` AS `gi` INNER JOIN `players` AS `p` ON `gi`.`player_id`=`p`.`id` WHERE `gi`.`guild_id`='$gid';"); return mysql_select_multi("SELECT `gi`.`player_id`, `gi`.`guild_id`, `p`.`name` FROM `guild_invites` AS `gi` INNER JOIN `players` AS `p` ON `gi`.`player_id`=`p`.`id` WHERE `gi`.`guild_id`='$gid';");
} }
// Update player's guild position
function update_player_guild_position($cid, $rid) {
$cid = (int)$cid;
$rid = (int)$rid;
mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`=$cid");
}
function update_player_guild_position_10($cid, $rid) {
$cid = (int)$cid;
$rid = (int)$rid;
mysql_update("UPDATE `guild_membership` SET `rank_id`='$rid' WHERE `player_id`=$cid");
}
// Update player's guild nick
function update_player_guildnick($cid, $nick) {
$cid = (int)$cid;
$nick = sanitize($nick);
if (!empty($nick)) {
mysql_update("UPDATE `players` SET `guildnick`='$nick' WHERE `id`=$cid");
} else {
mysql_update("UPDATE `players` SET `guildnick`='' WHERE `id`=$cid");
}
}
function update_player_guildnick_10($cid, $nick) {
$cid = (int)$cid;
$nick = sanitize($nick);
if (!empty($nick)) {
mysql_update("UPDATE `guild_membership` SET `nick`='$nick' WHERE `player_id`=$cid");
} else {
mysql_update("UPDATE `guild_membership` SET `nick`='' WHERE `player_id`=$cid");
}
}
// Get guild data, using guild id.
function get_guild_rank_data($gid) {
$gid = (int)$gid;
return mysql_select_multi("SELECT `id`, `guild_id`, `name`, `level` FROM `guild_ranks` WHERE `guild_id`='$gid' ORDER BY `id` DESC LIMIT 0, 30");
}
// Creates a guild, where cid is the owner of the guild, and name is the name of guild.
function create_guild($cid, $name) {
$cid = (int)$cid;
$name = trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", sanitize($name))));
$time = time();
// Create the guild
if (config('ServerEngine') !== 'OTHIRE')
mysql_insert("INSERT INTO `guilds` (`name`, `ownerid`, `creationdata`, `motd`) VALUES ('$name', '$cid', '$time', '');");
else
mysql_insert("INSERT INTO `guilds` (`name`, `owner_id`, `creationdate`) VALUES ('$name', '$cid', '$time');");
// Get guild id
$gid = get_guild_id($name);
// Get rank id for guild leader
$data = mysql_select_single("SELECT `id` FROM `guild_ranks` WHERE `guild_id`='$gid' AND `level`='3' LIMIT 1;");
$rid = ($data !== false) ? $data['id'] : false;
// Give player rank id for leader of his guild
if (config('ServerEngine') !== 'TFS_10') mysql_update("UPDATE `players` SET `rank_id`='$rid' WHERE `id`='$cid' LIMIT 1;");
else mysql_insert("INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES ('$cid', '$gid', '$rid', '');");
}
// Search player table on cid for his rank_id, returns rank_id // Search player table on cid for his rank_id, returns rank_id
function get_character_guild_rank($cid) { function get_character_guild_rank($cid) {
$cid = (int)$cid; $cid = (int)$cid;
@@ -306,6 +497,13 @@ function get_player_guild_rank($rank_id) {
return ($data !== false) ? $data['name'] : false; return ($data !== false) ? $data['name'] : false;
} }
// Get a player guild position ID, using his rank_id
function get_guild_position($rid) {
$rid = (int)$rid;
$data = mysql_select_single("SELECT `level` FROM `guild_ranks` WHERE `id`=$rid;");
return ($data !== false) ? $data['level'] : false;
}
// Get a players rank_id, guild_id, rank_level(ID), rank_name(string), using cid(player id) // Get a players rank_id, guild_id, rank_level(ID), rank_name(string), using cid(player id)
function get_player_guild_data($cid) { function get_player_guild_data($cid) {
$cid = (int)$cid; $cid = (int)$cid;
@@ -324,7 +522,7 @@ function get_player_guild_data($cid) {
// Returns guild name of guild id // Returns guild name of guild id
function get_guild_name($gid) { function get_guild_name($gid) {
$gid = (int)$gid; $gid = (int)$gid;
$guild = mysql_select_single("SELECT `name` FROM `guilds` WHERE `id`={$gid} LIMIT 1;"); $guild = mysql_select_single("SELECT `name` FROM `guilds` WHERE `id`=$gid LIMIT 1;");
if ($guild !== false) return $guild['name']; if ($guild !== false) return $guild['name'];
else return false; else return false;
} }
@@ -332,7 +530,7 @@ function get_guild_name($gid) {
// Returns guild id from name // Returns guild id from name
function get_guild_id($name) { function get_guild_id($name) {
$name = sanitize($name); $name = sanitize($name);
$data = mysql_select_single("SELECT `id` FROM `guilds` WHERE `name`='{$name}';"); $data = mysql_select_single("SELECT `id` FROM `guilds` WHERE `name`='$name';");
return ($data !== false) ? $data['id'] : false; return ($data !== false) ? $data['id'] : false;
} }
@@ -375,6 +573,18 @@ function get_guild_level_data($gid) {
} else return false; } else return false;
} }
// Returns total members in a guild (integer)
function count_guild_members($gid) {
$gid = (int)$gid;
if (config('ServerEngine') !== 'TFS_10') {
$data = mysql_select_single("SELECT COUNT(p.id) AS total FROM players AS p LEFT JOIN guild_ranks AS gr ON gr.id = p.rank_id WHERE gr.guild_id =$gid");
return ($data !== false) ? $data['total'] : false;
} else {
$data = mysql_select_single("SELECT COUNT('guild_id') AS `total` FROM `guild_membership` WHERE `guild_id`='$gid';");
return ($data !== false) ? $data['total'] : false;
}
}
// //
// GUILD WAR // GUILD WAR
// //
@@ -651,30 +861,16 @@ function user_character_list($account_id) {
//$count = user_character_list_count($account_id); //$count = user_character_list_count($account_id);
$account_id = (int)$account_id; $account_id = (int)$account_id;
$characters = mysql_select_multi(" if (config('ServerEngine') == 'TFS_10') {
SELECT $characters = mysql_select_multi("SELECT `p`.`id`, `p`.`name`, `p`.`level`, `p`.`vocation`, `p`.`town_id`, `p`.`lastlogin`, `gm`.`rank_id`, `po`.`player_id` AS `online` FROM `players` AS `p` LEFT JOIN `guild_membership` AS `gm` ON `p`.`id`=`gm`.`player_id` LEFT JOIN `players_online` AS `po` ON `p`.`id`=`po`.`player_id` WHERE `p`.`account_id`='$account_id' ORDER BY `p`.`level` DESC");
`p`.`id`, if ($characters !== false) {
`p`.`name`, for ($i = 0; $i < count($characters); $i++) {
`p`.`level`, $characters[$i]['online'] = ($characters[$i]['online'] > 0) ? 1 : 0;
`p`.`vocation`, //unset($characters[$i]['id']);
`p`.`town_id`, }
`p`.`lastlogin`, }
`gm`.`rank_id`,
`zp`.`hide_char`, } else $characters = mysql_select_multi("SELECT `id`, `name`, `level`, `vocation`, `town_id`, `lastlogin`, `online`, `rank_id` FROM `players` WHERE `account_id`='$account_id' ORDER BY `level` DESC");
CASE WHEN `po`.`player_id` IS NULL
THEN 0
ELSE 1
END AS `online`
FROM `players` AS `p`
LEFT JOIN `guild_membership` AS `gm`
ON `p`.`id`=`gm`.`player_id`
LEFT JOIN `players_online` AS `po`
ON `p`.`id`=`po`.`player_id`
LEFT JOIN `znote_players` AS `zp`
ON `p`.`id`=`zp`.`player_id`
WHERE `p`.`account_id`='{$account_id}'
ORDER BY `p`.`level` DESC
");
if ($characters !== false) { if ($characters !== false) {
$count = count($characters); $count = count($characters);
@@ -714,10 +910,14 @@ function user_character_list_count($account_id) {
// HIGHSCORE FUNCTIONS \\ // HIGHSCORE FUNCTIONS \\
function fetchAllScores($rows, $tfs, $g, $vlist, $v = -1, $flags = false, $outfits = false) { function fetchAllScores($rows, $tfs, $g, $vlist, $v = -1, $flags = false, $outfits = false) {
if (config('client') < 780) { if (config('ServerEngine') !== 'OTHIRE') {
$outfits = ($outfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : ""; if (config('client') < 780) {
$outfits = ($outfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
} else {
$outfits = ($outfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons`" : "";
}
} else { } else {
$outfits = ($outfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons`" : ""; $outfits = ($outfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
} }
// Return scores ordered by type and vocation (if set) // Return scores ordered by type and vocation (if set)
$data = array(); $data = array();
@@ -756,30 +956,59 @@ function fetchAllScores($rows, $tfs, $g, $vlist, $v = -1, $flags = false, $outfi
if ($vGrp !== 'all') if ($vGrp !== 'all')
$v = (strpos($vGrp, ',') !== false) ? 'AND `p`.`vocation` IN ('. $vGrp . ')' : 'AND `p`.`vocation` = \''.intval($vGrp).'\''; $v = (strpos($vGrp, ',') !== false) ? 'AND `p`.`vocation` IN ('. $vGrp . ')' : 'AND `p`.`vocation` = \''.intval($vGrp).'\'';
if ($flags === false) { // In this case we only need to query players table if ($tfs == 'TFS_10') {
$v = str_replace('`p`.', '', $v);
$outfits = str_replace('`p`.', '', $outfits);
$vocGroups[$vGrp][1] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_club` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_club` DESC LIMIT 0, $rows;"); if ($flags === false) { // In this case we only need to query players table
$vocGroups[$vGrp][2] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_sword` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_sword` DESC LIMIT 0, $rows;"); $v = str_replace('`p`.', '', $v);
$vocGroups[$vGrp][3] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_axe` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_axe` DESC LIMIT 0, $rows;"); $outfits = str_replace('`p`.', '', $outfits);
$vocGroups[$vGrp][4] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_dist` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_dist` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][5] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_shielding` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_shielding` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][6] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_fishing` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fishing` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][7] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `experience`, `level` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][8] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `maglevel` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][9] = mysql_select_multi("SELECT `name`, `vocation`, `lastlogout`, `skill_fist` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fist` DESC LIMIT 0, $rows;");
} else { // Inner join znote_accounts table to retrieve the flag $vocGroups[$vGrp][1] = mysql_select_multi("SELECT `name`, `vocation`, `skill_club` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_club` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][1] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_club` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_club` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][2] = mysql_select_multi("SELECT `name`, `vocation`, `skill_sword` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_sword` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][2] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_sword` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_sword` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][3] = mysql_select_multi("SELECT `name`, `vocation`, `skill_axe` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_axe` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][3] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_axe` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_axe` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][4] = mysql_select_multi("SELECT `name`, `vocation`, `skill_dist` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_dist` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][4] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_dist` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_dist` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][5] = mysql_select_multi("SELECT `name`, `vocation`, `skill_shielding` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_shielding` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][5] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_shielding` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_shielding` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][6] = mysql_select_multi("SELECT `name`, `vocation`, `skill_fishing` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fishing` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][6] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_fishing` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_fishing` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][7] = mysql_select_multi("SELECT `name`, `vocation`, `experience`, `level` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][7] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`experience`, `level` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`experience` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][8] = mysql_select_multi("SELECT `name`, `vocation`, `maglevel` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][8] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`maglevel` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`maglevel` DESC LIMIT 0, $rows;"); $vocGroups[$vGrp][9] = mysql_select_multi("SELECT `name`, `vocation`, `skill_fist` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `skill_fist` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][9] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`lastlogout`, `p`.`skill_fist` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_fist` DESC LIMIT 0, $rows;");
} else { // Inner join znote_accounts table to retrieve the flag
$vocGroups[$vGrp][1] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_club` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_club` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][2] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_sword` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_sword` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][3] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_axe` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_axe` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][4] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_dist` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_dist` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][5] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_shielding` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_shielding` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][6] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_fishing` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_fishing` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][7] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`experience`, `level` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`experience` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][8] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`maglevel` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`maglevel` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][9] = mysql_select_multi("SELECT `p`.`name`, `p`.`vocation`, `p`.`skill_fist` AS `value`, `za`.`flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`skill_fist` DESC LIMIT 0, $rows;");
}
} else { // TFS 0.2, 0.3, 0.4
if ($flags === false) {
$vocGroups[$vGrp][9] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][1] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][2] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][3] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][4] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][5] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][6] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation` $outfits 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 $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$v = str_replace('`p`.', '', $v);
$outfits = str_replace('`p`.', '', $outfits);
$vocGroups[$vGrp][7] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `experience`, `level` AS `value` $outfits $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `experience` DESC limit 0, $rows;");
$vocGroups[$vGrp][8] = mysql_select_multi("SELECT `id`, `name`, `vocation`, `maglevel` AS `value` $outfits $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `maglevel` DESC limit 0, $rows;");
} else { // Inner join znote_accounts table to retrieve the flag
$vocGroups[$vGrp][9] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 0 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][1] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 1 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][2] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 2 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][3] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 3 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][4] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 4 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][5] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 5 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][6] = mysql_select_multi("SELECT `s`.`player_id` AS `id`, `s`.`value` AS `value`, `p`.`name` AS `name`, `p`.`vocation` AS `vocation`, `za`.`flag` AS `flag` $outfits FROM `player_skills` AS `s` INNER JOIN `players` AS `p` ON `s`.`player_id`=`p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `s`.`skillid` = 6 AND `p`.`group_id` < $g $v ORDER BY `s`.`value` DESC LIMIT 0, $rows;");
$vocGroups[$vGrp][7] = mysql_select_multi("SELECT `p`.`id`, `p`.`name`, `p`.`vocation`, `p`.`experience`, `p`.`level` AS `value`, `za`.`flag` AS `flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`experience` DESC limit 0, $rows;");
$vocGroups[$vGrp][8] = mysql_select_multi("SELECT `p`.`id`, `p`.`name`, `p`.`vocation`, `p`.`maglevel` AS `value`, `za`.`flag` AS `flag` $outfits FROM `players` AS `p` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id`=`za`.`account_id` WHERE `p`.`group_id` < $g $v ORDER BY `p`.`maglevel` DESC limit 0, $rows;");
}
} }
} }
} }
@@ -885,13 +1114,36 @@ function user_account_id_from_name($id) {
// Add additional premium days to account id // Add additional premium days to account id
function user_account_add_premdays($accid, $days) { function user_account_add_premdays($accid, $days) {
global $tfs_10_hasPremDays; // Initialized in engine/init.php
$accid = (int)$accid; $accid = (int)$accid;
$days = (int)$days; $days = (int)$days;
mysql_update("
UPDATE `accounts` if (config('ServerEngine') !== 'OTHIRE') {
SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP()) + ({$days} * 86400) if ($tfs_10_hasPremDays) {
WHERE `id`='{$accid}'; if (mysql_select_single("SHOW COLUMNS from `accounts` WHERE `Field` = 'lastday'") === false) {
"); mysql_update("UPDATE `accounts` SET `premdays` = `premdays`+{$days} WHERE `id`='{$accid}'");
} else {
mysql_update(" UPDATE `accounts`
SET `premdays` = `premdays`+{$days}
,`lastday` = GREATEST(`lastday`,UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
WHERE `id`='{$accid}'
");
}
} else {
mysql_update(" UPDATE `accounts`
SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP(CURDATE())) + ({$days} * 86400)
WHERE `id`='{$accid}';
");
}
} else {
$data = mysql_select_single("SELECT `premend` FROM `accounts` WHERE `id`='$accid';");
$tmp = $data['premend'];
if($tmp == 0)
$tmp = time() + ($days * 24 * 60 * 60);
else
$tmp = $tmp + ($days * 24 * 60 * 60);
mysql_update("UPDATE `accounts` SET `premend`='$tmp' WHERE `id`='$accid'");
}
} }
// Name = char name. Changes from male to female & vice versa. // Name = char name. Changes from male to female & vice versa.
@@ -1195,8 +1447,19 @@ function user_create_character($character_data) {
// Returns counted value of all players online // Returns counted value of all players online
function user_count_online() { function user_count_online() {
$online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;"); if (config('ServerEngine') == 'TFS_10') {
return ($online !== false) ? $online['value'] : 0; $online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
return ($online !== false) ? $online['value'] : 0;
} else {
$data = mysql_select_single("SELECT COUNT(`id`) AS `count` from `players` WHERE `online` = 1;");
return ($data !== false) ? $data['count'] : 0;
}
}
// Returns counted value of all accounts.
function user_count_accounts() {
$result = mysql_select_single("SELECT COUNT(`id`) AS `id` from `accounts`;");
return ($result !== false) ? $result['id'] : 0;
} }
/* user_character_data (fetches whatever data you want from players table)! /* user_character_data (fetches whatever data you want from players table)!
@@ -1473,4 +1736,33 @@ function user_logged_in() {
return (getSession('user_id') !== false) ? true : false; return (getSession('user_id') !== false) ? true : false;
} }
function guild_war_invitation($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
$gname = get_guild_name($cid);
$ename = get_guild_name($gid);
$time = time();
mysql_insert("INSERT INTO `guild_wars` (`guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended`) VALUES ('$cid', '$gid', '$gname', '$ename', '0', '$time', '0');");
}
function accept_war_invitation($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
mysql_update("UPDATE `guild_wars` SET `status` = 1 WHERE `guild1` = '$cid' AND `guild2` = '$gid' AND `status` = 0;");
}
function reject_war_invitation($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
$time = time();
mysql_update("UPDATE `guild_wars` SET `status` = 2, `ended` = '$time' WHERE `guild1` = '$cid' AND `guild2` = '$gid';");
}
function cancel_war_invitation($cid, $gid) {
$cid = (int)$cid;
$gid = (int)$gid;
$time = time();
mysql_update("UPDATE `guild_wars` SET `status` = 3, `ended` = '$time' WHERE `guild2` = '$cid' AND `guild1` = '$gid';");
}
?> ?>

View File

@@ -1,4 +1,4 @@
<?php if (version_compare(phpversion(), '7.2', '<')) die('PHP version 7.2 or higher is required.'); <?php if (version_compare(phpversion(), '5.6', '<')) die('PHP version 5.6 or higher is required.');
$l_time = microtime(); $l_time = microtime();
$l_time = explode(' ', $l_time); $l_time = explode(' ', $l_time);
@@ -15,7 +15,7 @@ function elapsedTime($l_start = false, $l_time = false) {
} }
$time = time(); $time = time();
$version = '2.0_DEV'; $version = '1.6';
$aacQueries = 0; $aacQueries = 0;
$accQueriesData = array(); $accQueriesData = array();
@@ -50,10 +50,25 @@ if (isset($_SESSION['token'])) {
} }
Token::generate(); Token::generate();
$tfs_10_hasPremDays = true; // https://github.com/otland/forgottenserver/pull/2813
if (user_logged_in() === true) { if (user_logged_in() === true) {
$session_user_id = (int)getSession('user_id'); $session_user_id = getSession('user_id');
$user_data = user_data($session_user_id, 'id', 'name', 'password', 'email', 'premium_ends_at'); if ($config['ServerEngine'] !== 'OTHIRE') {
$user_data['premdays'] = ($user_data['premium_ends_at'] - time() > 0) ? floor(($user_data['premium_ends_at'] - time()) / 86400) : 0; if ($config['ServerEngine'] == 'TFS_10') {
$hasPremDays = mysql_select_single("SHOW COLUMNS from `accounts` WHERE `Field` = 'premdays'");
if ($hasPremDays === false) {
$tfs_10_hasPremDays = false;
$user_data = user_data($session_user_id, 'id', 'name', 'password', 'email', 'premium_ends_at');
$user_data['premdays'] = ($user_data['premium_ends_at'] - time() > 0) ? floor(($user_data['premium_ends_at'] - time()) / 86400) : 0;
} else {
$user_data = user_data($session_user_id, 'id', 'name', 'password', 'email', 'premdays');
}
} else {
$user_data = user_data($session_user_id, 'id', 'name', 'password', 'email', 'premdays');
}
} else
$user_data = user_data($session_user_id, 'id', 'password', 'email', 'premend');
$user_znote_data = user_znote_account_data($session_user_id, 'ip', 'created', 'points', 'cooldown', 'flag' ,'active_email'); $user_znote_data = user_znote_account_data($session_user_id, 'ip', 'created', 'points', 'cooldown', 'flag' ,'active_email');
} }
$errors = array(); $errors = array();

1728
guilds.php

File diff suppressed because it is too large Load Diff

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 || $ticketData['owner'] != $session_user_id) { if($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;

130
house.php
View File

@@ -4,22 +4,12 @@ if ($config['log_ip']) {
} }
$house = (isset($_GET['id']) && (int)$_GET['id'] > 0) ? (int)$_GET['id'] : false; $house = (isset($_GET['id']) && (int)$_GET['id'] > 0) ? (int)$_GET['id'] : false;
$house_SQL = "";
if ($house !== false) { if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
$house_SQL = " $house_SQL = "SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='$house';";
SELECT
`h`.`id`, `h`.`owner`, `h`.`paid`, `h`.`name`, `h`.`rent`, `h`.`town_id`,
`h`.`size`, `h`.`beds`, `h`.`bid`, `h`.`bid_end`, `h`.`last_bid`, `h`.`highest_bidder`,
`p`.`name` AS `ownername`
FROM `houses` AS `h`
LEFT JOIN `players` AS `p`
ON `h`.`owner` > 0
AND `p`.`id` = `h`.`owner`
WHERE `h`.`id`='{$house}';
";
$house = mysql_select_single($house_SQL); $house = mysql_select_single($house_SQL);
$minbid = $config['houseConfig']['minimumBidSQM'] * $house['size']; $minbid = $config['houseConfig']['minimumBidSQM'] * $house['size'];
if ($house['owner'] == 0) unset($house['ownername']); if ($house['owner'] > 0) $house['ownername'] = user_name($house['owner']);
if ($config['houseConfig']['shopPoints']['enabled']) { if ($config['houseConfig']['shopPoints']['enabled']) {
$house['points'] = $house['size']; $house['points'] = $house['size'];
@@ -38,36 +28,19 @@ if ($house !== false) {
if ($bid_amount && $bid_char) { if ($bid_amount && $bid_char) {
$bid_char = (int)$bid_char; $bid_char = (int)$bid_char;
$bid_amount = (int)$bid_amount; $bid_amount = (int)$bid_amount;
$player = mysql_select_single("SELECT `id`, `account_id`, `name`, `level`, `balance` FROM `players` WHERE `id`='$bid_char' LIMIT 1;");
$player = mysql_select_single("
SELECT `id`, `account_id`, `name`, `level`, `balance`
FROM `players`
WHERE `id`='$bid_char' LIMIT 1;
");
if (user_logged_in() === true && $player['account_id'] == $session_user_id) { if (user_logged_in() === true && $player['account_id'] == $session_user_id) {
// Does player have or need premium? // Does player have or need premium?
$premstatus = ($config['houseConfig']['requirePremium'] && $user_data['premdays'] == 0) ? false : true; $premstatus = ($config['houseConfig']['requirePremium'] && $user_data['premdays'] == 0) ? false : true;
if ($premstatus) { if ($premstatus) {
// Can player have or bid on more houses? // Can player have or bid on more houses?
$pHouseCount = mysql_select_single(" $pHouseCount = mysql_select_single("SELECT COUNT('id') AS `value` FROM `houses` WHERE ((`highest_bidder`='$bid_char' AND `owner`='$bid_char') OR (`highest_bidder`='$bid_char') OR (`owner`='$bid_char')) AND `id`!='".$house['id']."' LIMIT 1;");
SELECT COUNT('id') AS `value`
FROM `houses`
WHERE (
(`highest_bidder`='{$bid_char}' AND `owner`='{$bid_char}')
OR (`highest_bidder`='{$bid_char}')
OR (`owner`='{$bid_char}')
)
AND `id`!='{$house['id']}' LIMIT 1;
");
if ($pHouseCount['value'] < $config['houseConfig']['housesPerPlayer']) { if ($pHouseCount['value'] < $config['houseConfig']['housesPerPlayer']) {
// Is character level high enough? // Is character level high enough?
if ($player['level'] >= $config['houseConfig']['levelToBuyHouse']) { if ($player['level'] >= $config['houseConfig']['levelToBuyHouse']) {
// Can player afford this bid? // Can player afford this bid?
if ($player['balance'] > $bid_amount) { if ($player['balance'] > $bid_amount) {
// Is bid higher than previous bid? // Is bid higher than previous bid?
if ($bid_amount > $house['bid']) { if ($bid_amount > $house['bid']) {
// Is bid higher than lowest bid? // Is bid higher than lowest bid?
@@ -82,51 +55,17 @@ if ($house !== false) {
// Has bid already started? // Has bid already started?
if ($house['bid_end'] > 0) { if ($house['bid_end'] > 0) {
if ($house['bid_end'] > time()) { if ($house['bid_end'] > time()) {
mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
mysql_update(" $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
UPDATE `houses`
SET
`highest_bidder`='{$player['id']}',
`bid`='{$bid_amount}',
`last_bid`='{$lastbid}'
WHERE `id`='{$house['id']}' LIMIT 1;
");
$house = mysql_select_single("
SELECT
`id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`,
`beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder`
FROM `houses`
WHERE `id`='{$house['id']}';
");
} }
} else { } else {
$lastbid = $minbid + 1; $lastbid = $minbid + 1;
$bidend = time() + $config['houseConfig']['auctionPeriod']; $bidend = time() + $config['houseConfig']['auctionPeriod'];
mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid', `bid_end`='$bidend' WHERE `id`='". $house['id'] ."' LIMIT 1;");
mysql_update(" $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
UPDATE `houses`
SET
`highest_bidder`='{$player['id']}',
`bid`='{$bid_amount}',
`last_bid`='{$lastbid}',
`bid_end`='{$bidend}'
WHERE `id`='{$house['id']}' LIMIT 1;
");
$house = mysql_select_single("
SELECT
`id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`,
`beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder`
FROM `houses`
WHERE `id`='{$house['id']}';
");
} }
echo "<b><font color='green'>You have the highest bid on this house!</font></b>"; echo "<b><font color='green'>You have the highest bid on this house!</font></b>";
} else echo "<b><font color='red'>You need to place a bid that is higher or equal to {$minbid}gp.</font></b>"; } else echo "<b><font color='red'>You need to place a bid that is higher or equal to {$minbid}gp.</font></b>";
} else { } else {
// Check if current bid is higher than last_bid // Check if current bid is higher than last_bid
if ($bid_amount > $house['last_bid']) { if ($bid_amount > $house['last_bid']) {
@@ -134,21 +73,8 @@ if ($house !== false) {
// being forced to pay his full previous bid. // being forced to pay his full previous bid.
if ($house['highest_bidder'] != $player['id']) { if ($house['highest_bidder'] != $player['id']) {
$lastbid = $bid_amount + 1; $lastbid = $bid_amount + 1;
mysql_update("UPDATE `houses` SET `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
mysql_update(" $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
UPDATE `houses`
SET `last_bid`='$lastbid'
WHERE `id`='{$house['id']}' LIMIT 1;
");
$house = mysql_select_single("
SELECT
`id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`,
`beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder`
FROM `houses`
WHERE `id`='{$house['id']}';
");
echo "<b><font color='orange'>Unfortunately your bid was not higher than previous bidder.</font></b>"; echo "<b><font color='orange'>Unfortunately your bid was not higher than previous bidder.</font></b>";
} else { } else {
echo "<b><font color='orange'>You already have a higher pledge on this house.</font></b>"; echo "<b><font color='orange'>You already have a higher pledge on this house.</font></b>";
@@ -177,22 +103,8 @@ if ($house !== false) {
if ($account_points >= $house['points']) { if ($account_points >= $house['points']) {
$bid_char = (int)$bid_char; $bid_char = (int)$bid_char;
$player = mysql_select_single(" $player = mysql_select_single("SELECT `id`, `account_id`, `name`, `level` FROM `players` WHERE `id`='$bid_char' LIMIT 1;");
SELECT `id`, `account_id`, `name`, `level` $pHouseCount = mysql_select_single("SELECT COUNT('id') AS `value` FROM `houses` WHERE ((`highest_bidder`='$bid_char' AND `owner`='$bid_char') OR (`highest_bidder`='$bid_char') OR (`owner`='$bid_char')) AND `id`!='".$house['id']."' LIMIT 1;");
FROM `players`
WHERE `id`='$bid_char' LIMIT 1;
");
$pHouseCount = mysql_select_single("
SELECT COUNT('id') AS `value`
FROM `houses`
WHERE (
(`highest_bidder`='$bid_char' AND `owner`='$bid_char')
OR (`highest_bidder`='$bid_char')
OR (`owner`='$bid_char')
)
AND `id`!='{$house['id']}' LIMIT 1;
");
if (user_logged_in() === true if (user_logged_in() === true
&& $player['account_id'] == $session_user_id && $player['account_id'] == $session_user_id
@@ -265,12 +177,12 @@ if ($house !== false) {
<li><b>Town</b>: <li><b>Town</b>:
<?php <?php
$town_name = &$config['towns'][$house['town_id']]; $town_name = &$config['towns'][$house['town_id']];
echo "<a href='houses.php?id={$house['town_id']}'>". ($town_name ? $town_name : 'Specify town id ' . $house['town_id'] . ' name in config.php first.') ."</a>"; echo "<a href='houses.php?id=". $house['town_id'] ."'>". ($town_name ? $town_name : 'Specify town id ' . $house['town_id'] . ' name in config.php first.') ."</a>";
?></li> ?></li>
<li><b>Size</b>: <?php echo $house['size']; ?></li> <li><b>Size</b>: <?php echo $house['size']; ?></li>
<li><b>Beds</b>: <?php echo $house['beds']; ?></li> <li><b>Beds</b>: <?php echo $house['beds']; ?></li>
<li><b>Owner</b>: <?php <li><b>Owner</b>: <?php
if ($house['owner'] > 0) echo "<a href='characterprofile.php?name={$house['ownername']}' target='_BLANK'>{$house['ownername']}</a>"; if ($house['owner'] > 0) echo "<a href='characterprofile.php?name=". $house['ownername'] ."' target='_BLANK'>". $house['ownername'] ."</a>";
else echo "Available for auction."; else echo "Available for auction.";
?></li> ?></li>
<li><b>Rent</b>: <?php echo $house['rent']; ?></li> <li><b>Rent</b>: <?php echo $house['rent']; ?></li>
@@ -286,17 +198,17 @@ if ($house !== false) {
<?php <?php
if ($house['highest_bidder'] == 0) echo "<b>This house don't have any bidders yet.</b>"; if ($house['highest_bidder'] == 0) echo "<b>This house don't have any bidders yet.</b>";
else { else {
$bidder = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='{$house['highest_bidder']}' LIMIT 1;"); $bidder = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='". $house['highest_bidder'] ."' LIMIT 1;");
echo "<b>This house have bidders! If you want this house, now is your chance!</b>"; echo "<b>This house have bidders! If you want this house, now is your chance!</b>";
echo "<br><b>Active bid:</b> {$house['last_bid']}gp"; echo "<br><b>Active bid:</b> ". $house['last_bid'] ."gp";
echo "<br><b>Active bid by:</b> <a href='characterprofile.php?name={$bidder['name']}' target='_BLANK'>{$bidder['name']}</a>"; echo "<br><b>Active bid by:</b> <a href='characterprofile.php?name=". $bidder['name'] ."' target='_BLANK'>". $bidder['name'] ."</a>";
echo "<br><b>Bid will end on:</b> ". getClock($house['bid_end'], true); echo "<br><b>Bid will end on:</b> ". getClock($house['bid_end'], true);
} }
if ($house['bid_end'] == 0 || $house['bid_end'] > time()) { if ($house['bid_end'] == 0 || $house['bid_end'] > time()) {
if (user_logged_in()) { if (user_logged_in()) {
// Your characters, indexed by char_id // Your characters, indexed by char_id
$yourChars = mysql_select_multi("SELECT `id`, `name`, `balance` FROM `players` WHERE `account_id`='{$user_data['id']}';"); $yourChars = mysql_select_multi("SELECT `id`, `name`, `balance` FROM `players` WHERE `account_id`='". $user_data['id'] ."';");
if ($yourChars !== false) { if ($yourChars !== false) {
$charData = array(); $charData = array();
foreach ($yourChars as $char) { foreach ($yourChars as $char) {
@@ -307,7 +219,7 @@ if ($house !== false) {
<select name="char"> <select name="char">
<?php <?php
foreach ($charData as $id => $char) { foreach ($charData as $id => $char) {
echo "<option value='$id'>{$char['name']} [{$char['balance']}]</option>"; echo "<option value='$id'>". $char['name'] ." [". $char['balance'] ."]</option>";
} }
?> ?>
</select> </select>

View File

@@ -5,150 +5,317 @@ include 'layout/overall/header.php';
if ($config['log_ip']) if ($config['log_ip'])
znote_visitor_insert_detailed_data(3); znote_visitor_insert_detailed_data(3);
// Fetch values if (empty($_POST) === false && $config['ServerEngine'] === 'TFS_03') {
$querystring_id = &$_GET['id'];
$townid = ($querystring_id) ? (int)$_GET['id'] : $config['houseConfig']['HouseListDefaultTown'];
$towns = $config['towns'];
$order = &$_GET['order']; /* Token used for cross site scripting security */
$type = &$_GET['type']; if (isset($_POST['token']) && Token::isValid($_POST['token'])) {
// Create Search house box $townid = (int)$_POST['selected'];
?> $cache = new Cache('engine/cache/houses');
<form action="" method="get" class="houselist"> $array = array();
<table> if ($cache->hasExpired()) {
<tr> $tmp = fetchAllHouses_03();
<td>Town</td> $cache->setContent($tmp);
<td>Order</td> $cache->save();
<td>Sort</td>
</tr>
<tr>
<td>
<select name="id">
<?php
foreach ($towns as $id => $name)
echo '<option value="'. $id .'"' . ($townid != $id ?: ' selected') . '>'. $name .'</option>';
?>
</select>
</td>
<td>
<select name="order">
<?php
$order_allowed = array('id', 'name', 'size', 'beds', 'rent', 'owner');
foreach($order_allowed as $o)
echo '<option value="' . $o . '"' . ($o != $order ?: ' selected') . '>' . ucfirst($o) . '</option>';
?>
</select>
</td>
<td>
<select name="type">
<?php
$type_allowed = array('desc', 'asc');
foreach($type_allowed as $t)
echo '<option value="' . $t . '"' . ($t != $type ?: ' selected') . '>' . ($t == 'desc' ? 'Descending' : 'Ascending') .'</option>';
?>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<input type="submit" value="Fetch houses"/>
</td>
</tr>
</table>
</form>
<?php
if(!in_array($order, $order_allowed))
$order = 'id';
if(!in_array($type, $type_allowed)) foreach ($tmp as $t) {
$type = 'desc'; if ($t['town'] == $townid) $array[] = $t;
}
// Create or fetch data from cache $array = isset($array) ? $array : false;
$cache = new Cache('engine/cache/houses/houses-' . $order . '-' . $type); } else {
$houses = array(); $tmp = $cache->load();
foreach ($tmp as $t) {
if ($cache->hasExpired()) { if ($t['town'] == $townid) $array[] = $t;
}
$houses = mysql_select_multi(" $array = isset($array) ? $array : false;
SELECT
`id`, `owner`, `paid`, `warnings`, `name`, `rent`, `town_id`,
`size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder`
FROM `houses`
ORDER BY {$order} {$type};
");
if ($houses !== false) {
// Fetch player names
$playerlist = array();
foreach ($houses as $h)
if ($h['owner'] > 0)
$playerlist[] = $h['owner'];
if (!empty($playerlist)) {
$ids = join(',', $playerlist);
$tmpPlayers = mysql_select_multi("SELECT `id`, `name` FROM players WHERE `id` IN ($ids);");
// Sort $tmpPlayers by player id
$tmpById = array();
foreach ($tmpPlayers as $p)
$tmpById[$p['id']] = $p['name'];
for ($i = 0; $i < count($houses); $i++)
if ($houses[$i]['owner'] > 0)
$houses[$i]['ownername'] = $tmpById[$houses[$i]['owner']];
} }
$cache->setContent($houses); // Design and present the list
$cache->save(); if ($array) {
} $guild_support = (isset($array[0]['guild'])) ? true : false;
} else ?>
$houses = $cache->load(); <h2>
<?php echo ucfirst(town_id_to_name($townid)); ?> house list.
</h2>
<div class="well widget">
<div class="header">
Town list / houses
</div>
<div class="body">
<form action="houses.php" method="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "post"; else echo "get" ;?>">
<select name="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "selected"; else echo "id" ;?>">
<?php
foreach ($config['towns'] as $id => $name)
echo '<option value="'. $id .'">'. $name .'</option>';
?>
</select>
<?php Token::create(); ?>
<input type="submit" value="Fetch houses">
</form>
</div>
</div>
<table id="housesTable" class="table table-striped">
<tr class="yellow">
<th>Name:</th>
<th>Size:</th>
<th>Doors:</th>
<th>Beds:</th>
<th>Price:</th>
<th>Owner:</th>
if ($houses !== false || !empty($houses)) { </tr>
// Intialize stuff
//data_dump($houses, false, "House data");
?>
<table id="housetable">
<tr class="yellow">
<th>Name</th>
<th>Size</th>
<th>Beds</th>
<th>Rent</th>
<th>Owner</th>
<th>Town</th>
</tr>
<?php
foreach ($houses as $house) {
if ($house['town_id'] == $townid) {
?>
<tr>
<td><?php echo "<a href='house.php?id=". $house['id'] ."'>". $house['name'] ."</a>"; ?></td>
<td><?php echo $house['size']; ?></td>
<td><?php echo $house['beds']; ?></td>
<td><?php echo $house['rent']; ?></td>
<?php <?php
// Status: foreach ($array as $value) {
if ($house['owner'] != 0) echo '<tr>';
echo "<td><a href='characterprofile.php?name=". $house['ownername'] ."' target='_BLANK'>". $house['ownername'] ."</a></td>"; echo "<td>". $value['name'] ."</td>";
else echo "<td>". $value['size'] ."</td>";
echo ($house['highest_bidder'] == 0 ? '<td>None</td>' : '<td><b>Selling</b></td>'); echo "<td>". $value['doors'] ."</td>";
echo "<td>". $value['beds'] ."</td>";
echo "<td>". $value['price'] ."</td>";
if ($value['owner'] == 0)
echo "<td>None</td>";
else {
if ($guild_support && $value['guild'] == 1) {
$guild_name = get_guild_name($value['owner']);
echo '<td><a href="guilds.php?name='. $guild_name .'">'. $guild_name .'</a></td>';
} else {
$data = user_character_data($value['owner'], 'name');
echo '<td><a href="characterprofile.php?name='. $data['name'] .'">'. $data['name'] .'</a></td>';
}
}
echo '</tr>';
}
?> ?>
<td><?php </table>
$town_name = &$towns[$house['town_id']]; <?php
echo ($town_name ? $town_name : 'Specify town id ' . $house['town_id'] . ' name in config.php first.'); } else {
?></td> echo 'Empty list, it appears no houses are listed in this town.';
}
//Done.
} else {
echo 'Token appears to be incorrect.<br><br>';
//Token::debug($_POST['token']);
echo 'Please clear your web cache/cookies <b>OR</b> use another web browser<br>';
}
} else {
if (empty($_POST) === true && $config['ServerEngine'] === 'TFS_03') {
?>
<div class="well widget">
<div class="header">
Town list / houses
</div>
<div class="body">
<form action="houses.php" method="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "post"; else echo "get" ;?>">
<select name="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "selected"; else echo "id" ;?>">
<?php
foreach ($config['towns'] as $id => $name)
echo '<option value="'. $id .'">'. $name .'</option>';
?>
</select>
<?php Token::create(); ?>
<input type="submit" value="Fetch houses">
</form>
</div>
</div>
<?php
} else if ($config['ServerEngine'] === 'TFS_02' || $config['ServerEngine'] == 'OTHIRE') {
$house = $config['house'];
if (!is_file($house['house_file'])) {
echo("<h3>House file not found</h3><p>FAILED TO LOCATE/READ FILE AT:<br><font color='red'>". $house['house_file'] ."</font><br><br>LINUX users: Make sure www-data have read access to file.<br>WINDOWS users: Learn to write correct file path.</p>");
exit();
}
// Load and cache SQL house data:
$cache = new Cache('engine/cache/houses/sqldata');
if ($cache->hasExpired()) {
$house_query = mysql_select_multi('SELECT `players`.`name`, `houses`.`id` FROM `players`, `houses` WHERE `houses`.`owner` = `players`.`id`;');
$cache->setContent($house_query);
$cache->save();
} else
$house_query = $cache->load();
$sqmPrice = $house['price_sqm'];
$house_load = simplexml_load_file($house['house_file']);
if ($house_query !== false && $house_load !== false) {
?>
<h2>House list</h2>
<table>
<tr class="yellow">
<td><b>House</b></td>
<td><b>Location</b></td>
<td><b>Owner</b></td>
<td><b>Size</b></td>
<td><b>Rent</b></td>
</tr>
<?php
//execute code.
foreach($house_query as $row)
$house_info[(int)$row['id']] = '<a href="characterprofile.php?name='. $row['name'] .'">'. $row['name'] .'</a>';
foreach ($house_load as $house_fetch){
$house_price = (int)$house_fetch['size'] * $sqmPrice;
?>
<tr>
<td><?php echo htmlspecialchars($house_fetch['name']); ?></td>
<td>
<?php
if (isset($config['towns'][(int)$house_fetch['townid']])) echo htmlspecialchars($config['towns'][(int)$house_fetch['townid']]);
else echo '(Missing town)';
?>
</td>
<td>
<?php
if (isset($house_info[(int)$house_fetch['houseid']])) echo $house_info[(int)$house_fetch['houseid']];
else echo 'None [Available]';
?>
</td>
<td><?php echo $house_fetch['size']; ?></td>
<td><?php echo $house_price; ?></td>
</tr>
<?php
}
?>
</table>
<?php
} else echo '<p><font color="red">Something is wrong with the cache.</font></p>';
} else if ($config['ServerEngine'] === 'TFS_10') {
// Fetch values
$querystring_id = &$_GET['id'];
$townid = ($querystring_id) ? (int)$_GET['id'] : $config['houseConfig']['HouseListDefaultTown'];
$towns = $config['towns'];
$order = &$_GET['order'];
$type = &$_GET['type'];
// Create Search house box
?>
<form action="" method="get" class="houselist">
<table>
<tr>
<td>Town</td>
<td>Order</td>
<td>Sort</td>
</tr>
<tr>
<td>
<select name="id">
<?php
foreach ($towns as $id => $name)
echo '<option value="'. $id .'"' . ($townid != $id ?: ' selected') . '>'. $name .'</option>';
?>
</select>
</td>
<td>
<select name="order">
<?php
$order_allowed = array('id', 'name', 'size', 'beds', 'rent', 'owner');
foreach($order_allowed as $o)
echo '<option value="' . $o . '"' . ($o != $order ?: ' selected') . '>' . ucfirst($o) . '</option>';
?>
</select>
</td>
<td>
<select name="type">
<?php
$type_allowed = array('desc', 'asc');
foreach($type_allowed as $t)
echo '<option value="' . $t . '"' . ($t != $type ?: ' selected') . '>' . ($t == 'desc' ? 'Descending' : 'Ascending') .'</option>';
?>
</select>
</td>
</tr>
<tr>
<td colspan="3">
<input type="submit" value="Fetch houses"/>
</td>
</tr>
</table>
</form>
<?php
if(!in_array($order, $order_allowed))
$order = 'id';
if(!in_array($type, $type_allowed))
$type = 'desc';
// Create or fetch data from cache
$cache = new Cache('engine/cache/houses/houses-' . $order . '-' . $type);
$houses = array();
if ($cache->hasExpired()) {
$houses = mysql_select_multi("SELECT `id`, `owner`, `paid`, `warnings`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` ORDER BY {$order} {$type};");
if ($houses !== false) {
// Fetch player names
$playerlist = array();
foreach ($houses as $h)
if ($h['owner'] > 0)
$playerlist[] = $h['owner'];
if (!empty($playerlist)) {
$ids = join(',', $playerlist);
$tmpPlayers = mysql_select_multi("SELECT `id`, `name` FROM players WHERE `id` IN ($ids);");
// Sort $tmpPlayers by player id
$tmpById = array();
foreach ($tmpPlayers as $p)
$tmpById[$p['id']] = $p['name'];
for ($i = 0; $i < count($houses); $i++)
if ($houses[$i]['owner'] > 0)
$houses[$i]['ownername'] = $tmpById[$houses[$i]['owner']];
}
$cache->setContent($houses);
$cache->save();
}
} else
$houses = $cache->load();
if ($houses !== false || !empty($houses)) {
// Intialize stuff
//data_dump($houses, false, "House data");
?>
<table id="housetable">
<tr class="yellow">
<th>Name</th>
<th>Size</th>
<th>Beds</th>
<th>Rent</th>
<th>Owner</th>
<th>Town</th>
</tr> </tr>
<?php <?php
} foreach ($houses as $house) {
} if ($house['town_id'] == $townid) {
?> ?>
</table> <tr>
<td><?php echo "<a href='house.php?id=". $house['id'] ."'>". $house['name'] ."</a>"; ?></td>
<td><?php echo $house['size']; ?></td>
<td><?php echo $house['beds']; ?></td>
<td><?php echo $house['rent']; ?></td>
<?php
// Status:
if ($house['owner'] != 0)
echo "<td><a href='characterprofile.php?name=". $house['ownername'] ."' target='_BLANK'>". $house['ownername'] ."</a></td>";
else
echo ($house['highest_bidder'] == 0 ? '<td>None</td>' : '<td><b>Selling</b></td>');
?>
<td><?php
$town_name = &$towns[$house['town_id']];
echo ($town_name ? $town_name : 'Specify town id ' . $house['town_id'] . ' name in config.php first.');
?></td>
</tr>
<?php
}
}
?>
</table>
<?php <?php
} else { } else
echo "<h1>Failed to fetch data from sql->houses table.</h1><p>Is the table empty?</p>"; echo "<h1>Failed to fetch data from sql->houses table.</h1><p>Is the table empty?</p>";
} // End TFS 1.0 logic
} }
include 'layout/overall/footer.php'; ?> include 'layout/overall/footer.php'; ?>

View File

@@ -15,7 +15,6 @@ require_once 'engine/init.php'; include 'layout/overall/header.php';
// Changelog ticker // // Changelog ticker //
// Load from cache // Load from cache
$changelogCache = new Cache('engine/cache/changelog'); $changelogCache = new Cache('engine/cache/changelog');
$changelogCache->useMemory(false);
$changelogs = $changelogCache->load(); $changelogs = $changelogCache->load();
if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) { if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {

View File

@@ -11,7 +11,6 @@
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

@@ -229,9 +229,6 @@ table, .header, .well, .smedia a {
} }
/* Znote AAC */ /* Znote AAC */
.leftPane img {
max-width: 100%;
}
/* adding button style to select */ /* adding button style to select */
select { select {
background: rgb(15,17,20); background: rgb(15,17,20);

View File

@@ -22,7 +22,6 @@
<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

@@ -14,57 +14,10 @@
<!-- <!--
Designed By <a href="https://otland.net/members/snavy.155163/" target="_blank">Snavy</a> Designed By <a href="https://otland.net/members/snavy.155163/" target="_blank">Snavy</a>
--> -->
</footer> </footer>
</div><!-- Main container END --> </div><!-- Main container END -->
<?php
// If you are logged in as an admin, display SQL queries admin overlay
if ($config['admin_show_queries'] && user_logged_in() && is_admin($user_data)): ?>
<div id="admin-queries">
<label for="admin-toggle">Admin: Toggle Queries</label>
<input id="admin-toggle" name="admin-toggle" type="checkbox">
<div id="admin-show-queries">
<?php data_dump($accQueriesData, false, "Logged in as Admin: Showing executed SQL queries:"); ?>
</div>
</div>
<style type="text/css">
#admin-queries {
position: fixed;
top: 0;
left: 0;
z-index: 9999;
background-color: rgb(30,33,40);
opacity: 0.94;
max-width: 95%;
max-height: 950px;
border: 1px solid #d1a233;
overflow: overlay;
}
#admin-queries pre {
margin: 0;
padding-right: 10px;
padding-bottom: 25px;
}
#admin-queries label {
user-select: none;
display: inline-block;
padding: 5px;
color: #b39062;
}
#admin-queries label:hover {
color: #e79424;
text-decoration: underline;
}
#admin-queries input,
#admin-queries #admin-show-queries,
#admin-queries br:last-of-type {
display: none;
}
#admin-queries input:checked + #admin-show-queries {
display: block;
}
</style>
<?php endif; ?>
</body> </body>
</html> </html>
<!-- <!--

View File

@@ -4,7 +4,6 @@ if ($config['UseChangelogTicker']) {
// Changelog ticker // // Changelog ticker //
// Load from cache // Load from cache
$changelogCache = new Cache('engine/cache/changelog'); $changelogCache = new Cache('engine/cache/changelog');
$changelogCache->useMemory(false);
$changelogs = $changelogCache->load(); $changelogs = $changelogCache->load();
if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) { if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {

View File

@@ -30,31 +30,24 @@
</li> </li>
<?php <?php
$new = 0; $new = 0;
$cache = new Cache('engine/cache/asideFeedbackCount'); $cat = 4; //Category ID for feedback section
if ($cache->hasExpired()) { $threads = mysql_select_multi("SELECT `id`, `player_id` FROM `znote_forum_threads` WHERE `forum_id`='$cat' AND `closed`='0';");
$cat = 4; //Category ID for feedback section if ($threads !== false) {
$threads = mysql_select_multi("SELECT `id`, `player_id` FROM `znote_forum_threads` WHERE `forum_id`='$cat' AND `closed`='0';"); $staffs = mysql_select_multi("SELECT `id` FROM `players` WHERE `group_id` > '1';");
if ($threads !== false) {
$staffs = mysql_select_multi("SELECT `id` FROM `players` WHERE `group_id` > '1';");
foreach($threads as $thread) { foreach($threads as $thread) {
$response = false; $response = false;
$posts = mysql_select_multi("SELECT `id`, `player_id` FROM `znote_forum_posts` WHERE `thread_id`='". $thread['id'] ."';"); $posts = mysql_select_multi("SELECT `id`, `player_id` FROM `znote_forum_posts` WHERE `thread_id`='". $thread['id'] ."';");
if ($posts !== false) { if ($posts !== false) {
foreach($posts as $post) { foreach($posts as $post) {
foreach ($staffs as $staff) { foreach ($staffs as $staff) {
if ($post['player_id'] == $staff['id']) $response = true; if ($post['player_id'] == $staff['id']) $response = true;
}
} }
} }
if (!$response) $new++;
} }
if (!$response) $new++;
} }
$cache->setContent($new);
$cache->save();
} else {
$new = $cache->load();
} }
?> ?>
<li> <li>

View File

@@ -29,7 +29,7 @@
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">
window.searchNames = <?php echo json_encode($names); ?>; window.searchNames = <?php echo json_encode($names)?>;
$(function() { $(function() {
if (window.searchNames.length > 0) { if (window.searchNames.length > 0) {
$('#src_name').keyup(function(e) { $('#src_name').keyup(function(e) {

View File

@@ -3,13 +3,17 @@
Town list / houses Town list / houses
</div> </div>
<div class="body"> <div class="body">
<form action="houses.php" method="get"> <form action="houses.php" method="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "post"; else echo "get" ;?>">
<select name="id"> <select name="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "selected"; else echo "id" ;?>">
<?php <?php
foreach ($config['towns'] as $id => $name) foreach ($config['towns'] as $id => $name)
echo '<option value="'. $id .'">'. $name .'</option>'; echo '<option value="'. $id .'">'. $name .'</option>';
?> ?>
</select> </select>
<?php
/* Form file */
if ($config['ServerEngine'] !== 'TFS_10') Token::create();
?>
<input type="submit" value="Fetch houses"> <input type="submit" value="Fetch houses">
</form> </form>
</div> </div>

View File

@@ -1,6 +1,6 @@
<div class="well myaccount_widget widget" id="loginContainer"> <div class="well myaccount_widget widget" id="loginContainer">
<div class="header"> <div class="header">
Welcome, <?php echo $user_data['name']; ?>. Welcome, <?php if ($config['ServerEngine'] !== 'OTHIRE') echo $user_data['name']; else echo $user_data['id'];?>.
</div> </div>
<div class="body"> <div class="body">
<ul class="linkbuttons"> <ul class="linkbuttons">

View File

@@ -1,63 +0,0 @@
<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,27 +1,34 @@
<?php
$cache = new Cache('engine/cache/asideServerInfo');
if ($cache->hasExpired()) {
$asideServerInfo = mysql_select_single("
SELECT
(SELECT COUNT(`id`) FROM `accounts`) as `accounts`,
(SELECT COUNT(`id`) FROM `players`) as `players`,
(SELECT COUNT(`player_id`) FROM `players_online`) as `online`
");
$cache->setContent($asideServerInfo);
$cache->save();
} else {
$asideServerInfo = $cache->load();
}
?>
<div class="well widget"> <div class="well widget">
<div class="header"> <div class="header">
Server Information Server Information
</div> </div>
<div class="body"> <div class="body">
<ul> <ul>
<li><a href="onlinelist.php">Players online: <?php echo $asideServerInfo['online']; ?></a></li> <?php
<li>Registered accounts: <?php echo $asideServerInfo['accounts'];?></li> $status = true;
<li>Registered players: <?php echo $asideServerInfo['players'];?></li> if ($config['status']['status_check']) {
@$sock = fsockopen ($config['status']['status_ip'], $config['status']['status_port'], $errno, $errstr, 1);
if(!$sock) {
echo "<span style='color:red;font-weight:bold;'><center>Server Offline!</center></span><br/>";
$status = false;
}
else {
$info = chr(6).chr(0).chr(255).chr(255).'info';
fwrite($sock, $info);
$data='';
while (!feof($sock))$data .= fgets($sock, 1024);
fclose($sock);
echo "<span style='color:green;font-weight:bold;'><center>Server Online!</center></span><br />";
}
}
if ($status) {
?>
<li><a href="onlinelist.php">Players online:
<?php echo user_count_online(); ?></a></li>
<?php
}
?>
<li>Registered accounts: <?php echo user_count_accounts();?></li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@@ -7,11 +7,7 @@
<?php <?php
$cache = new Cache('engine/cache/topPlayer'); $cache = new Cache('engine/cache/topPlayer');
if ($cache->hasExpired()) { if ($cache->hasExpired()) {
$players = mysql_select_multi(" $players = mysql_select_multi('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscore']['ignoreGroupId'] . ' ORDER BY `level` DESC, `experience` DESC LIMIT 5;');
SELECT `name`, `level`, `experience`
FROM `players` WHERE `group_id` < {$config['highscore']['ignoreGroupId']}
ORDER BY `level` DESC, `experience` DESC LIMIT 5;
");
$cache->setContent($players); $cache->setContent($players);
$cache->save(); $cache->save();

View File

@@ -154,7 +154,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
$password = SHA1($client->password); $password = SHA1($client->password);
$token = (isset($client->token)) ? sanitize($client->token) : false; $token = (isset($client->token)) ? sanitize($client->token) : false;
$fields = '`id`, `premium_ends_at`'; $fields = '`id`, `premdays`';
if ($config['twoFactorAuthenticator']) $fields .= ', `secret`'; if ($config['twoFactorAuthenticator']) $fields .= ', `secret`';
$account = false; $account = false;
@@ -213,10 +213,8 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
} }
$sessionKey = ($email !== false) ? $email."\n".$client->password : $username."\n".$client->password; $sessionKey = ($email !== false) ? $email."\n".$client->password : $username."\n".$client->password;
$sessionKey .= (isset($account['secret']) && strlen($account['secret']) > 5) ? "\n".$token : "\n"; if (isset($account['secret']) && strlen($account['secret']) > 5) $sessionKey .= "\n".$token."\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,
@@ -228,8 +226,8 @@ 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() || $freePremium) ? true : false, 'ispremium' => ($account['premdays'] > 0) ? true : false,
'premiumuntil' => $account['premium_ends_at'], 'premiumuntil' => time() + ($account['premdays'] * 86400),
'status' => 'active' 'status' => 'active'
), ),
'playdata' => array( 'playdata' => array(
@@ -241,13 +239,7 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
'externalport' => $gameserver['port'], 'externalport' => $gameserver['port'],
'previewstate' => 0, 'previewstate' => 0,
'location' => 'ALL', 'location' => 'ALL',
// 0 - open pvp 'pvptype' => '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

@@ -5,15 +5,7 @@ include 'layout/overall/header.php';
$undelete_id = @$_GET['cancel_delete_id']; $undelete_id = @$_GET['cancel_delete_id'];
if($undelete_id) { if($undelete_id) {
$undelete_id = (int)$undelete_id; $undelete_id = (int)$undelete_id;
$undelete_q1 = mysql_select_single(" $undelete_q1 = mysql_select_single('SELECT `character_name` FROM `znote_deleted_characters` WHERE `done` = 0 AND `id` = ' . $undelete_id . ' AND `original_account_id` = ' . $session_user_id . ' AND NOW() < `time`');
SELECT
`character_name`
FROM `znote_deleted_characters`
WHERE `done` = 0
AND `id` = {$undelete_id}
AND `original_account_id` = {$session_user_id}
AND NOW() < `time`
");
if($undelete_q1) { if($undelete_q1) {
mysql_delete('DELETE FROM `znote_deleted_characters` WHERE `id` = ' . $undelete_id); mysql_delete('DELETE FROM `znote_deleted_characters` WHERE `id` = ' . $undelete_id);
echo 'Pending delete of ' . $undelete_q1['character_name'] . ' has been successfully canceled.<br/>'; echo 'Pending delete of ' . $undelete_q1['character_name'] . ' has been successfully canceled.<br/>';
@@ -60,7 +52,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']);
@@ -101,7 +93,7 @@ if (!empty($_POST['selected_character'])) {
switch($action) { switch($action) {
// Change character comment PAGE2 (Success). // Change character comment PAGE2 (Success).
case 'update_comment': case 'update_comment':
if ((int)user_character_account_id($char_name) === $session_user_id) { if (user_character_account_id($char_name) === $session_user_id) {
user_update_comment(user_character_id($char_name), getValue($_POST['comment'])); user_update_comment(user_character_id($char_name), getValue($_POST['comment']));
echo 'Successfully updated comment.'; echo 'Successfully updated comment.';
} }
@@ -111,7 +103,7 @@ if (!empty($_POST['selected_character'])) {
// Hide character // Hide character
case 'toggle_hide': case 'toggle_hide':
$hide = (user_character_hide($char_name) == 1 ? 0 : 1); $hide = (user_character_hide($char_name) == 1 ? 0 : 1);
if ((int)user_character_account_id($char_name) === $session_user_id) { if (user_character_account_id($char_name) === $session_user_id) {
user_character_set_hide(user_character_id($char_name), $hide); user_character_set_hide(user_character_id($char_name), $hide);
} }
break; break;
@@ -119,13 +111,21 @@ if (!empty($_POST['selected_character'])) {
// DELETE character // DELETE character
case 'delete_character': case 'delete_character':
if ((int)user_character_account_id($char_name) === $session_user_id) { if (user_character_account_id($char_name) === $session_user_id) {
$charid = user_character_id($char_name); $charid = user_character_id($char_name);
if ($charid !== false) { if ($charid !== false) {
if (!user_is_online_10($charid)) { if ($config['ServerEngine'] === 'TFS_10') {
if (guild_leader_gid($charid) === false) user_delete_character_soft($charid); if (!user_is_online_10($charid)) {
else echo 'Character is leader of a guild, you must disband the guild or change leadership before deleting character.'; if (guild_leader_gid($charid) === false) user_delete_character_soft($charid);
} else echo 'Character must be offline first.'; else echo 'Character is leader of a guild, you must disband the guild or change leadership before deleting character.';
} else echo 'Character must be offline first.';
} else {
$chr_data = user_character_data($charid, 'online');
if ($chr_data['online'] != 1) {
if (guild_leader_gid($charid) === false) user_delete_character_soft($charid);
else echo 'Character is leader of a guild, you must disband the guild or change leadership before deleting character.';
} else echo 'Character must be offline first.';
}
} }
} }
break; break;
@@ -137,8 +137,10 @@ if (!empty($_POST['selected_character'])) {
$newname = isset($_POST['newName']) ? getValue($_POST['newName']) : ''; $newname = isset($_POST['newName']) ? getValue($_POST['newName']) : '';
$player = false; $player = false;
$player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'"); if ($config['ServerEngine'] === 'TFS_10') {
$player['online'] = (user_is_online_10($player['id'])) ? 1 : 0; $player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'");
$player['online'] = (user_is_online_10($player['id'])) ? 1 : 0;
} else $player = mysql_select_single("SELECT `id`, `account_id`, `online` FROM `players` WHERE `name` = '$oldname'");
// Check if user is online // Check if user is online
if ($player['online'] == 1) { if ($player['online'] == 1) {
@@ -202,11 +204,13 @@ if (!empty($_POST['selected_character'])) {
// Change character sex // Change character sex
case 'change_gender': case 'change_gender':
if ((int)user_character_account_id($char_name) === $session_user_id) { if (user_character_account_id($char_name) === $session_user_id) {
$char_id = (int)user_character_id($char_name); $char_id = (int)user_character_id($char_name);
$account_id = user_character_account_id($char_name); $account_id = user_character_account_id($char_name);
$chr_data['online'] = user_is_online_10($char_id) ? 1 : 0; if ($config['ServerEngine'] == 'TFS_10') {
$chr_data['online'] = user_is_online_10($char_id) ? 1 : 0;
} else $chr_data = user_character_data($char_id, 'online');
if ($chr_data['online'] != 1) { if ($chr_data['online'] != 1) {
// Verify that we are not messing around with data // Verify that we are not messing around with data
if ($account_id != $user_data['id']) die("wtf? Something went wrong, try relogging."); if ($account_id != $user_data['id']) die("wtf? Something went wrong, try relogging.");
@@ -250,7 +254,7 @@ if (!empty($_POST['selected_character'])) {
// Change character comment PAGE1: // Change character comment PAGE1:
case 'change_comment': case 'change_comment':
$render_page = false; // Regular "myaccount" page should not render $render_page = false; // Regular "myaccount" page should not render
if ((int)user_character_account_id($char_name) === $session_user_id) { if (user_character_account_id($char_name) === $session_user_id) {
$comment_data = user_znote_character_data(user_character_id($char_name), 'comment'); $comment_data = user_znote_character_data(user_character_id($char_name), 'comment');
?> ?>
<!-- Changing comment MARKUP --> <!-- Changing comment MARKUP -->
@@ -299,12 +303,21 @@ if ($render_page) {
?> ?>
<div id="myaccount"> <div id="myaccount">
<h1>My account</h1> <h1>My account</h1>
<p>Welcome to your account page, <?php echo $user_data['name']; ?><br> <p>Welcome to your account page, <?php if ($config['ServerEngine'] !== 'OTHIRE') echo $user_data['name']; else echo $user_data['id']; ?><br>
<?php <?php if ($config['ServerEngine'] !== 'OTHIRE') {
// Todo: If premdays is less than 2, inform how many hours are left. if ($user_data['premdays'] != 0) {
if ($user_data['premdays'] != 0) echo "You have {$user_data['premdays']} remaining premium account days."; echo 'You have ' .$user_data['premdays']. ' remaining premium account days.';
else echo 'You are free account.'; } else {
echo 'You are free account.';
}
} else {
if ($user_data['premend'] != 0) {
echo 'Your premium account will last till ';
echo date("d/m/Y", $user_data['premend']);
} else {
echo 'You do not have premium account days.';
}
}
if ($config['mailserver']['myaccount_verify_email']): if ($config['mailserver']['myaccount_verify_email']):
?><br>Email: <?php echo $user_data['email']; ?><br>Email: <?php echo $user_data['email'];
if ($user_znote_data['active_email'] == 1) { if ($user_znote_data['active_email'] == 1) {
@@ -315,7 +328,7 @@ if ($render_page) {
endif; ?> endif; ?>
</p> </p>
<?php <?php
if ($config['twoFactorAuthenticator']) { if ($config['ServerEngine'] === 'TFS_10' && $config['twoFactorAuthenticator']) {
$query = mysql_select_single("SELECT `secret` FROM `accounts` WHERE `id`='".(int)$session_user_id."' LIMIT 1;"); $query = mysql_select_single("SELECT `secret` FROM `accounts` WHERE `id`='".(int)$session_user_id."' LIMIT 1;");
$status = ($query['secret'] === NULL) ? false : true; $status = ($query['secret'] === NULL) ? false : true;
?><p>Account security with Two-factor Authentication: <a href="twofa.php"><?php echo ($status) ? 'Enabled' : 'Disabled'; ?></a></p><?php ?><p>Account security with Two-factor Authentication: <a href="twofa.php"><?php echo ($status) ? 'Enabled' : 'Disabled'; ?></a></p><?php
@@ -330,28 +343,18 @@ if ($render_page) {
?> ?>
<table id="myaccountTable" class="table table-striped table-hover"> <table id="myaccountTable" class="table table-striped table-hover">
<tr class="yellow"> <tr class="yellow">
<th>NAME</th> <th>NAME</th><th>LEVEL</th><th>VOCATION</th><th>TOWN</th><th>LAST LOGIN</th><th>STATUS</th><th>HIDE</th>
<th>LEVEL</th>
<th>VOCATION</th>
<th>TOWN</th>
<th>LAST LOGIN</th>
<th>STATUS</th>
<th>HIDE</th>
</tr> </tr>
<?php <?php
foreach ($char_array as $value): ?> $characters = array();
<tr> foreach ($char_array as $value) {
<td><a href="characterprofile.php?name=<?php echo $value['name']; ?>"><?php echo $value['name']; ?></a></td> // characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online
<td><?php echo $value['level']; ?></td> echo '<tr>';
<td><?php echo $value['vocation']; ?></td> echo '<td><a href="characterprofile.php?name='. $value['name'] .'">'. $value['name'] .'</a></td><td>'. $value['level'] .'</td><td>'. $value['vocation'] .'</td><td>'. $value['town_id'] .'</td><td>'. $value['lastlogin'] .'</td><td>'. $value['online'] .'</td><td>'. hide_char_to_name(user_character_hide($value['name'])) .'</td>';
<td><?php echo $value['town_id']; ?></td> echo '</tr>';
<td><?php echo $value['lastlogin']; ?></td> $characters[] = $value['name'];
<td><?php echo $value['online']; ?></td> }
<td><?php echo hide_char_to_name($value['hide_char']); ?></td> ?>
</tr>
<?php
endforeach;
?>
</table> </table>
<!-- FORMS TO EDIT CHARACTER--> <!-- FORMS TO EDIT CHARACTER-->
<form action="" method="post"> <form action="" method="post">
@@ -359,9 +362,15 @@ if ($render_page) {
<tr> <tr>
<td> <td>
<select id="selected_character" name="selected_character" class="form-control"> <select id="selected_character" name="selected_character" class="form-control">
<?php foreach ($char_array as $character): ?> <?php
<option value="<?php echo $character['name']; ?>"><?php echo $character['name']; ?></option> for ($i = 0; $i < $char_count; $i++) {
<?php endforeach; ?> if (user_character_hide($characters[$i]) == 1) {
echo '<option value="'. $characters[$i] . '">'. $characters[$i] .'</option>';
} else {
echo '<option value="'. $characters[$i] . '">'. $characters[$i] .'</option>';
}
}
?>
</select> </select>
</td> </td>
<td> <td>
@@ -386,7 +395,7 @@ if ($render_page) {
</form> </form>
<?php <?php
} else { } else {
echo "You don't have any characters. Why don't you <a href='createcharacter.php'>create one</a>?"; echo 'You don\'t have any characters. Why don\'t you <a href="createcharacter.php">create one</a>?';
} }
?> ?>
</div> </div>

View File

@@ -1,19 +1,20 @@
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; <?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>
$history = array( <h1>Who is online?</h1>
"enabled" => true, <?php
"days" => 14,
"cache" => 300
);
// Returns a list of players online // Returns a list of players online
$array = false; $array = false;
$loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['onlinelist']) ? true : false; $loadFlags = ($config['country_flags']['enabled'] && $config['country_flags']['onlinelist']) ? true : false;
$loadOutfits = ($config['show_outfits']['onlinelist']) ? true : false; $loadOutfits = ($config['show_outfits']['onlinelist']) ? true : false;
if ($config['client'] < 780) { if ($config['ServerEngine'] != 'OTHIRE') {
$outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : ""; if ($config['client'] < 780) {
$outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
} else {
$outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons`" : "";
}
} else { } else {
$outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`, `p`.`lookaddons` AS `addons`" : ""; $outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
} }
// Small 30 seconds players_online cache. // Small 30 seconds players_online cache.
@@ -21,7 +22,11 @@ $cache = new Cache('engine/cache/onlinelist');
$cache->setExpiration(30); $cache->setExpiration(30);
if ($cache->hasExpired()) { if ($cache->hasExpired()) {
// Load online list data from SQL // Load online list data from SQL
$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname`, `za`.`flag` AS `flag` $outfitQuery FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id` = `za`.`account_id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;") : mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname` $outfitQuery FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;"); if ($config['ServerEngine'] == 'TFS_10') {
$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname`, `za`.`flag` AS `flag` $outfitQuery FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` INNER JOIN `znote_accounts` AS `za` ON `p`.`account_id` = `za`.`account_id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;") : mysql_select_multi("SELECT `p`.`name` AS `name`, `p`.`level` AS `level`, `p`.`vocation` AS `vocation`, `g`.`name` AS `gname` $outfitQuery FROM `players_online` AS `o` INNER JOIN `players` AS `p` ON `o`.`player_id` = `p`.`id` LEFT JOIN `guild_membership` AS `gm` ON `o`.`player_id` = `gm`.`player_id` LEFT JOIN `guilds` AS `g` ON `gm`.`guild_id` = `g`.`id`;");
} else {
$array = ($loadFlags === true) ? mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname`, `za`.`flag` as `flag` $outfitQuery FROM `players` as `p` INNER JOIN `znote_accounts` as `za` ON `za`.`account_id` = `p`.`account_id` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;") : mysql_select_multi("SELECT `p`.`name` as `name`, `p`.`level` as `level`, `p`.`vocation` as `vocation`, `g`.`name` as `gname` $outfitQuery FROM `players` as `p` LEFT JOIN `guild_ranks` as `gr` ON `gr`.`id` = `p`.`rank_id` LEFT JOIN `guilds` as `g` ON `gr`.`guild_id` = `g`.`id` WHERE `p`.`online` = '1' ORDER BY `p`.`name` DESC;");
}
// End loading data from SQL // End loading data from SQL
$cache->setContent($array); $cache->setContent($array);
$cache->save(); $cache->save();
@@ -30,63 +35,9 @@ if ($cache->hasExpired()) {
} }
// End cache // End cache
// 5 minute logout history cache if (!empty($array) && $array !== false) {
if ($history["enabled"]) { ?>
$time = time();
$cache = new Cache('engine/cache/onlinelist_rec');
$cache->setExpiration($history['cache']);
if ($cache->hasExpired()) {
// Load online list data from SQL
$recents = ($loadFlags === true) ? mysql_select_multi("
SELECT
`p`.`name` AS `name`,
`p`.`level` AS `level`,
`p`.`vocation` AS `vocation`,
`p`.`lastlogout`,
`g`.`name` AS `gname`,
`za`.`flag` AS `flag`
$outfitQuery
FROM `players` AS `p`
INNER JOIN `znote_accounts` AS `za`
ON `p`.`account_id` = `za`.`account_id`
LEFT JOIN `guild_membership` AS `gm`
ON `p`.`id` = `gm`.`player_id`
LEFT JOIN `guilds` AS `g`
ON `gm`.`guild_id` = `g`.`id`
WHERE `p`.`lastlogout` >= $time - ({$history['days']} * 24 * 60 * 60)
ORDER BY `p`.`lastlogout` DESC;
") : mysql_select_multi("
SELECT
`p`.`name` AS `name`,
`p`.`level` AS `level`,
`p`.`vocation` AS `vocation`,
`p`.`lastlogout`,
`g`.`name` AS `gname`
$outfitQuery
FROM `players` AS `p`
LEFT JOIN `guild_membership` AS `gm`
ON `p`.`id` = `gm`.`player_id`
LEFT JOIN `guilds` AS `g`
ON `gm`.`guild_id` = `g`.`id`
WHERE `p`.`lastlogout` >= $time - ({$history['days']} * 24 * 60 * 60)
ORDER BY `p`.`lastlogout` DESC;
");
// End loading data from SQL
$cache->setContent($recents);
$cache->save();
} else {
$recents = $cache->load();
}
}
// End cache
?>
<h1>Who is online?</h1>
<?php
// Players currently logged in
if (!empty($array) && $array !== false): ?>
<h2>Currently online:</h2>
<table id="onlinelistTable" class="table table-striped table-hover"> <table id="onlinelistTable" class="table table-striped table-hover">
<tr class="yellow"> <tr class="yellow">
<?php if ($loadOutfits) echo "<th>Outfit</th>"; ?> <?php if ($loadOutfits) echo "<th>Outfit</th>"; ?>
@@ -96,12 +47,12 @@ if (!empty($array) && $array !== false): ?>
<th>Vocation:</th> <th>Vocation:</th>
</tr> </tr>
<?php <?php
foreach ($array as $value): foreach ($array as $value) {
$url = url("characterprofile.php?name=". $value['name']); $url = url("characterprofile.php?name=". $value['name']);
$flag = ($loadFlags === true && strlen($value['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $value['flag'] . '.png"> ' : ''; $flag = ($loadFlags === true && strlen($value['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $value['flag'] . '.png"> ' : '';
$guildname = (!empty($value['gname'])) ? '<a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a>' : ''; $guildname = (!empty($value['gname'])) ? '<a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a>' : '';
?> ?>
<tr class="special"> <tr class="special" onclick="javascript:window.location.href='<?php echo $url; ?>'">
<?php if ($loadOutfits): ?> <?php if ($loadOutfits): ?>
<td class="outfitColumn"><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $value['type']; ?>&addons=<?php echo $value['addons']; ?>&head=<?php echo $value['head']; ?>&body=<?php echo $value['body']; ?>&legs=<?php echo $value['legs']; ?>&feet=<?php echo $value['feet']; ?>" alt="img"></td> <td class="outfitColumn"><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $value['type']; ?>&addons=<?php echo $value['addons']; ?>&head=<?php echo $value['head']; ?>&body=<?php echo $value['body']; ?>&legs=<?php echo $value['legs']; ?>&feet=<?php echo $value['feet']; ?>" alt="img"></td>
<?php endif; ?> <?php endif; ?>
@@ -111,53 +62,13 @@ if (!empty($array) && $array !== false): ?>
<td><?php echo vocation_id_to_name($value['vocation']); ?></td> <td><?php echo vocation_id_to_name($value['vocation']); ?></td>
</tr> </tr>
<?php <?php
endforeach; ?> }
</table>
<?php
else:
?>
<p>Nobody is online.</p>
<?php
endif;
// Players online logout history
if ($history["enabled"]) {
$time = time();
if (!empty($recents) && $recents !== false): ?>
<h2>Online past <?php echo $history['days']; ?> days:</h2>
<table id="recentlistTable" class="table table-striped table-hover">
<tr class="yellow">
<?php if ($loadOutfits) echo "<th>Outfit</th>"; ?>
<th>Name:</th>
<th>Guild:</th>
<th>Level:</th>
<th>Logout [days] - date</th>
</tr>
<?php
foreach ($recents as $value):
$days = floor(($time - $value['lastlogout']) / 86400);
$url = url("characterprofile.php?name=". $value['name']);
$flag = ($loadFlags === true && strlen($value['flag']) > 1) ? '<img src="' . $config['country_flags']['server'] . '/' . $value['flag'] . '.png"> ' : '';
$guildname = (!empty($value['gname'])) ? '<a href="guilds.php?name='. $value['gname'] .'">'. $value['gname'] .'</a>' : '';
?>
<tr class="special">
<?php if ($loadOutfits): ?>
<td class="outfitColumn"><img src="<?php echo $config['show_outfits']['imageServer']; ?>?id=<?php echo $value['type']; ?>&addons=<?php echo $value['addons']; ?>&head=<?php echo $value['head']; ?>&body=<?php echo $value['body']; ?>&legs=<?php echo $value['legs']; ?>&feet=<?php echo $value['feet']; ?>" alt="img"></td>
<?php endif; ?>
<td><?php echo $flag; ?><a href="characterprofile.php?name=<?php echo $value['name']; ?>"><?php echo $value['name']; ?></a></td>
<td><?php echo $guildname; ?></td>
<td><?php echo $value['level']; ?></td>
<td><?php echo "{$days}D: " . getClock($value['lastlogout'], true); ?></td>
</tr>
<?php
endforeach; ?>
</table>
<?php
else:
?> ?>
<p>Nobody has logged in past <?php echo $history['days']; ?> days.</p> </table>
<?php
endif;
}
include 'layout/overall/footer.php'; ?> <?php
} else {
echo 'Nobody is online.';
}
?>
<?php include 'layout/overall/footer.php'; ?>

View File

@@ -1,162 +1,92 @@
<?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']) { 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();
} }
$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`
");
?> ?>
<table id="tbl_powergamers"> <div class="panel">
<thead> <div class="page-header"><h3>Powergamers</h3></div>
<tr> <?php
<th colspan="9"><h1>Powergamers</h1></th> $limit = $config['powergamers']['limit'];
</tr> $days = isset($_POST['days']);
<tr> $today = true;
<th>Name</th> if ($days) {
<th>k Diff</th> $selected = ($_POST['days']);
<th><?php echo $dates['d0ago']; ?></th> $days = (int) $selected[1];
<th><?php echo $dates['d1ago']; ?></th> $vocation = (int) $selected[0];
<th><?php echo $dates['d2ago']; ?></th> if ($days > 0)
<th><?php echo $dates['d3ago']; ?></th> $today = false;
<th><?php echo $dates['d4ago']; ?></th> } else {
<th><?php echo $dates['d5ago']; ?></th> $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);
<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;
} }
</style> $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>
<?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['client'] >= 830) { if ($config['ServerEngine'] !== 'OTHIRE' && $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,14 +80,12 @@ 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 ($config['validate_IP'] === true) { if (validate_ip(getIP()) === false && $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) {
$errors[] = 'Please choose country.';
} }
if (strlen($_POST['flag']) < 1) {
$errors[] = 'Please choose country.';
}
} }
} }
@@ -127,14 +125,25 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
} }
//Register //Register
$register_data = array( if ($config['ServerEngine'] !== 'OTHIRE') {
'name' => $_POST['username'], $register_data = array(
'password' => $_POST['password'], 'name' => $_POST['username'],
'email' => $_POST['email'], 'password' => $_POST['password'],
'created' => time(), 'email' => $_POST['email'],
'ip' => getIPLong(), 'created' => time(),
'flag' => $_POST['flag'] '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']); 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');
@@ -149,23 +158,24 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
?> ?>
<form action="" method="post"> <form action="" method="post">
<ul> <ul>
<li>Account Name:<br> <li>
Account Name:<br>
<input type="text" name="username"> <input type="text" name="username">
</li> </li>
<li>
<li>Password:<br> Password:<br>
<input type="password" name="password"> <input type="password" name="password">
</li> </li>
<li>
<li>Password again:<br> Password again:<br>
<input type="password" name="password_again"> <input type="password" name="password_again">
</li> </li>
<li>
<li>Email:<br> Email:<br>
<input type="text" name="email"> <input type="text" name="email">
</li> </li>
<li>
<li>Country:<br> Country:<br>
<select name="flag"> <select name="flag">
<option value="">(Please choose)</option> <option value="">(Please choose)</option>
<?php <?php
@@ -178,7 +188,6 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
?> ?>
</select> </select>
</li> </li>
<?php <?php
if ($config['use_captcha']) { if ($config['use_captcha']) {
?> ?>
@@ -188,8 +197,8 @@ if (isset($_GET['success']) && empty($_GET['success'])) {
<?php <?php
} }
?> ?>
<li>
<li><h2>Server Rules</h2> <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>
@@ -197,8 +206,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>
<li>Do you agree to follow the server rules?<br> 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>

View File

@@ -27,7 +27,6 @@ function toYesNo($bool) {
} }
// Loading stage list // Loading stage list
$cache = new Cache('engine/cache/stages'); $cache = new Cache('engine/cache/stages');
$cache->useMemory(false);
if (user_logged_in() && is_admin($user_data)) { if (user_logged_in() && is_admin($user_data)) {
if (isset($_GET['loadStages'])) { if (isset($_GET['loadStages'])) {
echo "<p><strong>Logged in as admin, loading engine/XML/stages.xml file and updating cache.</strong></p>"; echo "<p><strong>Logged in as admin, loading engine/XML/stages.xml file and updating cache.</strong></p>";
@@ -36,18 +35,34 @@ if (user_logged_in() && is_admin($user_data)) {
if ($stagesXML !== false) { if ($stagesXML !== false) {
$stagesData = array(); $stagesData = array();
// Load config (stages enabled or disabled) // Load config (stages enabled or disabled)
foreach ($stagesXML->config->attributes() as $name => $value) if ($config['ServerEngine'] == 'TFS_10')
$stagesData["$name"] = "$value"; foreach ($stagesXML->config->attributes() as $name => $value)
$stagesData["$name"] = "$value";
// Load stage levels // Load stage levels
// Each stage XML object // Each stage XML object
foreach ($stagesXML->stage as $stage) { if ($config['ServerEngine'] == 'TFS_10') {
$rowData = array(); foreach ($stagesXML->stage as $stage) {
// Each attribute name and values on current stage object $rowData = array();
foreach ($stage->attributes() as $name => $value) { // Each attribute name and values on current stage object
$rowData["$name"] = "$value"; foreach ($stage->attributes() as $name => $value) {
$rowData["$name"] = "$value";
}
// Populate XML assoc array
$stagesData['stages'][] = $rowData;
}
} else {
// TFS 0.3/4
foreach ($stagesXML->world as $world) {
foreach ($world->stage as $stage) {
$rowData = array();
// Each attribute name and values on current stage object
foreach ($stage->attributes() as $name => $value) {
$rowData["$name"] = "$value";
}
// Populate XML assoc array
$stagesData['stages'][] = $rowData;
}
} }
// Populate XML assoc array
$stagesData['stages'][] = $rowData;
} }
$cache->setContent($stagesData); $cache->setContent($stagesData);
$cache->save(); $cache->save();
@@ -68,7 +83,6 @@ if (user_logged_in() && is_admin($user_data)) {
// Loading config.lua // Loading config.lua
$cache = new Cache('engine/cache/luaconfig'); $cache = new Cache('engine/cache/luaconfig');
$cache->useMemory(false);
if (user_logged_in() && is_admin($user_data)) { if (user_logged_in() && is_admin($user_data)) {
if (isset($_POST['loadConfig']) && isset($_POST['configData'])) { if (isset($_POST['loadConfig']) && isset($_POST['configData'])) {
// Whitelist for values we are interested in // Whitelist for values we are interested in
@@ -106,6 +120,19 @@ if (user_logged_in() && is_admin($user_data)) {
'staminaSystem', 'staminaSystem',
'experienceStages' 'experienceStages'
); );
// TFS 0.3/4 compatibility, convert config value names to TFS 1.0 values
$tfs03to10 = array(
// TFS 0.3/4 TFS 1.0
'rateExperience' => 'rateExp',
'loginPort' => 'loginProtocolPort',
'rateExperienceFromPlayers' => 'experienceByKillingPlayers',
'dailyFragsToRedSkull' => 'killsToRedSkull',
'dailyFragsToBlackSkull' => 'killsToBlackSkull',
'removeRuneCharges' => 'removeChargesFromRunes',
'stairhopDelay' => 'stairJumpExhaustion',
'housePriceEachSquare' => 'housePriceEachSQM',
'idleKickTime' => 'kickIdlePlayerAfterMinutes',
);
// This will be the populated array with filtered relevant data // This will be the populated array with filtered relevant data
$luaConfig = array(); $luaConfig = array();
@@ -141,7 +168,13 @@ if (user_logged_in() && is_admin($user_data)) {
// Remove unnecessary whitespace // Remove unnecessary whitespace
$data[0] = trim($data[0]); $data[0] = trim($data[0]);
$data[1] = trim($data[1]); $data[1] = trim($data[1]);
// TFS 0.3/4 compatibility
if (isset($tfs03to10[$data[0]])) {
$data[0] = $tfs03to10[$data[0]];
if (isset($tfs03to10[$data[1]])) {
$data[1] = $tfs03to10[$data[1]];
}
}
if (in_array($data[0], $whitelist)) { if (in_array($data[0], $whitelist)) {
// Type cast: boolean // Type cast: boolean
if (in_array(strtolower($data[1]), array('true', 'false'))) { if (in_array(strtolower($data[1]), array('true', 'false'))) {
@@ -194,12 +227,7 @@ $stages = false;
<h1>Server Information</h1> <h1>Server Information</h1>
<p>Here you will find all basic information about <b><?php echo $config['site_title']; ?></b></p> <p>Here you will find all basic information about <b><?php echo $config['site_title']; ?></b></p>
<?php <?php if (($stagesData && isset($stagesData['enabled']) && $stagesData['enabled']) || (isset($luaConfig['experienceStages']) && $luaConfig['experienceStages'] === true)): $stages = true; ?>
if (
($stagesData && isset($stagesData['enabled']) && $stagesData['enabled'])
|| (isset($luaConfig['experienceStages']) && $luaConfig['experienceStages'] === true)
):
$stages = true; ?>
<h2>Server rates</h2> <h2>Server rates</h2>
<table class="table tbl-hover"> <table class="table tbl-hover">
<tbody> <tbody>

View File

@@ -2,7 +2,6 @@
// Loading spell list // Loading spell list
$spellsCache = new Cache('engine/cache/spells'); $spellsCache = new Cache('engine/cache/spells');
$spellsCache->useMemory(false);
if (user_logged_in() && is_admin($user_data)) { if (user_logged_in() && is_admin($user_data)) {
if (isset($_GET['update'])) { if (isset($_GET['update'])) {
echo "<p><strong>Logged in as admin, loading engine/XML/spells.xml file and updating cache.</strong></p>"; echo "<p><strong>Logged in as admin, loading engine/XML/spells.xml file and updating cache.</strong></p>";