37 Commits
1.6 ... v2

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

bigint was way too big for these values, thanks to @divinity76
2021-12-09 02:46:25 +01:00
Evil Puncker
3d42e8a7ec Fixed variable type for powergamers script (#492)
exp history should be able to store negative values, yes
online time shouldn't
2021-12-09 02:46:15 +01:00
Zbizu
ee351e7ada TFS 1.5 protocol 12 support 2021-12-09 02:25:05 +01:00
Znote
9b6d8d93d8 Characterprofile cleanup 2021-11-22 18:03:52 +01:00
Znote
b482b77d7b Add logout history to online list and cleanup 2021-11-22 16:41:27 +01:00
Znote
a7fed3bfe3 paypal ipn cacert update 2021-09-22 10:40:48 +02:00
Znote
d914c93085 Fix spells cache 2021-07-31 20:19:41 +02:00
Znote
f7445bb89a myaccount - cleanup, optimize and fixes 2021-07-25 03:59:03 +02:00
Znote
ae07a0f421 tiny css adjustment 2021-07-25 03:56:56 +02:00
Znote
bc76e8cb65 Fix img clipping in news feed 2021-07-24 05:16:32 +02:00
Znote
9898bb27f5 minor adjustment to aside character search 2021-07-24 04:36:51 +02:00
Znote
f011f782bd layout aside cleanup 2021-07-24 04:36:19 +02:00
Znote
f896b59e36 Remove obsolete premium handling 2021-07-24 03:28:40 +02:00
Znote
0e941b2c1e serverinfo cleanup, fix cache, query optimizations 2021-07-24 02:35:26 +02:00
Znote
8f5487db2b Admin - executed SQL queries overlay
Allow admins to see executed SQL queries overlay
Useful for testing and optimizing query usage on website
2021-07-24 01:56:03 +02:00
Znote
9e790a71f6 Fix #371 - fast APCu memory caching support 2021-07-24 00:34:54 +02:00
Znote
ac2b909805 Cleanup houses 2021-07-22 21:37:21 +02:00
Znote
400497bd25 Tag branch as Znote AAC 2.0_DEV, PHP requirement 7.2 2021-07-22 20:25:26 +02:00
Znote
8a71f19db0 guild validations 2021-07-22 17:02:27 +02:00
Znote
e40e811b72 Better guild validations
Vice leaders were able to do a bit more things than they should have
2021-07-22 16:58:00 +02:00
Znote
2ec9cfbff4 guilds.php cleanup 2021-07-22 15:30:03 +02:00
41 changed files with 3788 additions and 3337 deletions

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,14 @@
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.

View File

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

View File

@@ -1,12 +1,14 @@
<?php <?php
// Verify the PHP version, gives tutorial if fail. // Verify the PHP version, gives tutorial if fail.
if (version_compare(phpversion(), '5.3.3', '<')) die('PHP 5.3.3 or higher is required'); if (version_compare(phpversion(), '7.2', '<')) die('PHP version 7.2 or higher is required.');
if (!isset($filepath)) $filepath = '../'; if (!isset($filepath)) $filepath = '../';
$version = '1.5_SVN'; $version = '2.0_DEV';
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,6 +54,7 @@ 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,7 +11,6 @@ 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 ($config['ServerEngine'] == 'TFS_10') {
if (!$loadOutfits) { if (!$loadOutfits) {
$profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin'); $profile_data = user_character_data($user_id, 'account_id', 'name', 'level', 'group_id', 'vocation', 'health', 'healthmax', 'experience', 'mana', 'manamax', 'sex', 'lastlogin');
} else { // Load outfits } else { // Load outfits
@@ -27,21 +26,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
$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');
$guild_exist = false; $guild_exist = false;
@@ -82,10 +66,29 @@ 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 group_id_to_name($profile_data['group_id']); ?></td> <td><?php echo $position; ?></td>
</tr>
<?php endif;
// pending deletion?
$deletion_time = mysql_select_single("SELECT `time` FROM `znote_deleted_characters` WHERE `character_name`='{$name}' AND `done` = '0' LIMIT 1;");
if ($deletion_time !== false): ?>
<tr>
<td colspan="2" style="color: red;">Flagged for deletion by owner after <?php echo $deletion_time['time']; ?>.</td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<!-- Player male / female --> <!-- Player male / female -->
@@ -124,19 +127,9 @@ 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`, `{$column_town_id}` AS `town_id` SELECT `id`, `owner`, `name`, `town_id` AS `town_id`
FROM `houses` FROM `houses`
WHERE `owner` = {$user_id}; WHERE `owner` = {$user_id};
"); ");
@@ -149,7 +142,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
</tr> </tr>
<?php endforeach; <?php endforeach;
} }
}
?> ?>
<!-- Display player status --> <!-- Display player status -->
<tr class="status_<?php echo ($profile_data['online']) ? 'online' : 'offline'; ?>"> <tr class="status_<?php echo ($profile_data['online']) ? 'online' : 'offline'; ?>">
@@ -180,16 +172,13 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
AND `pid`<'11' AND `pid`<'11'
"); ");
$soulStamina = (in_array($config['ServerEngine'], ['TFS_10'])) $soulStamina = " `soul`, `stamina`,";
? " `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 = (in_array($config['ServerEngine'], ['TFS_10'])) $player_query = "
? /* true */ "SELECT SELECT
`health`, `healthmax`, `health`, `healthmax`,
`mana`, `manamax`, `mana`, `manamax`,
`cap`, `cap`,
@@ -205,31 +194,8 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
`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,'',',');
@@ -252,9 +218,8 @@ 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,430], [325,328,335,367],
[432,463,465,472,512], //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
//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(
@@ -262,9 +227,8 @@ 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,431], [324,329,336,366],
[433,464,466,471,513], //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
//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;
@@ -411,11 +375,15 @@ 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;
@@ -711,7 +679,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
</thead> </thead>
<tbody> <tbody>
<?php <?php
if ($config['ServerEngine'] == 'TFS_10') {
$deaths = mysql_select_multi(" $deaths = mysql_select_multi("
SELECT SELECT
`player_id`, `player_id`,
@@ -770,63 +737,6 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
</tr> </tr>
<?php <?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>
<?php
}
}
?> ?>
</tbody> </tbody>
</table> </table>
@@ -893,14 +803,6 @@ 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
@@ -909,7 +811,7 @@ if (isset($_GET['name']) === true && empty($_GET['name']) === false) {
`p`.`level`, `p`.`level`,
`p`.`vocation`, `p`.`vocation`,
`p`.`lastlogin`, `p`.`lastlogin`,
{$select_online} CASE WHEN `l`.`player_id` IS NULL THEN 0 else 1 END as `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`
@@ -917,7 +819,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`
{$join_online} LEFT JOIN `players_online` as `l` ON `p`.`id` = `l`.`player_id`
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-10-92.242492/ // host yourself: https://otland.net/threads/item-images-12-80-for-website.279319/
'imageServer' => 'https://outfit-images.ots.me/animatedOutfits1099/animoutfit.php' 'imageServer' => 'https://outfit-images.ots.me/1285/animoutfit.php'
); );
// Show advanced inventory data in character profile // Show advanced inventory data in character profile
@@ -657,15 +657,27 @@
'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 to update? // How often do you want highscores (cache) to update?
$config['cache_lifespan'] = 5; // 60 * 15; // 15 minutes. $config['cache'] = array(
// 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']) { if ($char_count >= $config['max_characters'] && !is_admin($user_data)) {
$errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.'; $errors[] = 'Your account is not allowed to have more than '. $config['max_characters'] .' characters.';
} }
if (validate_ip(getIP()) === false && $config['validate_IP'] === true) { if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
<?php <?php
$time = time(); $time = time();
if (!isset($version)) $version = '1.5_SVN'; if (!isset($version)) $version = '2.0_DEV';
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 = '1.5_SVN'; SET @znote_version = '2.0_DEV';
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

@@ -5,6 +5,8 @@
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';
@@ -15,8 +17,22 @@
* @return void * @return void
**/ **/
public function __construct($file) { public function __construct($file) {
$cfg = config('cache');
$this->setExpiration($cfg['lifespan']);
if (function_exists('apcu_fetch')) {
$this->_canMemory = true;
$this->_memory = $cfg['memory'];
}
$this->_file = $file . self::EXT; $this->_file = $file . self::EXT;
$this->setExpiration(config('cache_lifespan'));
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>
");
} }
@@ -32,6 +48,23 @@
} }
/**
* Enable or disable memory RAM storage.
*
* @param bool $bool
* @access public
* @return bool $status
**/
public function useMemory($bool) {
if ($bool and $this->_canMemory) {
$this->_memory = true;
return true;
}
$this->_memory = false;
return false;
}
/** /**
* Set the content you'd like to cache. * Set the content you'd like to cache.
* *
@@ -40,15 +73,7 @@
* @return void * @return void
**/ **/
public function setContent($content) { public function setContent($content) {
switch (strtolower(gettype($content))) { $this->_content = (!$this->_memory && strtolower(gettype($content)) == 'array') ? json_encode($content) : $content;
case 'array':
$this->_content = json_encode($content);
break;
default:
$this->_content = $content;
break;
}
} }
@@ -59,10 +84,12 @@
* @return boolean * @return boolean
**/ **/
public function hasExpired() { public function hasExpired() {
if ($this->_memory) {
return !apcu_exists($this->_file);
}
if (is_file($this->_file) && time() < filemtime($this->_file) + $this->_lifespan) { if (is_file($this->_file) && time() < filemtime($this->_file) + $this->_lifespan) {
return false; return false;
} }
return true; return true;
} }
@@ -74,6 +101,18 @@
**/ **/
public function remainingTime() { public function remainingTime() {
$remaining = 0; $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;
}
if (!$this->hasExpired()) { if (!$this->hasExpired()) {
$remaining = (filemtime($this->_file) + $this->_lifespan) - time(); $remaining = (filemtime($this->_file) + $this->_lifespan) - time();
} }
@@ -88,6 +127,9 @@
* @return void * @return void
**/ **/
public function save() { public function save() {
if ($this->_memory) {
return apcu_store($this->_file, $this->_content, $this->_lifespan);
}
$handle = fopen($this->_file, 'w'); $handle = fopen($this->_file, 'w');
fwrite($handle, $this->_content); fwrite($handle, $this->_content);
fclose($handle); fclose($handle);
@@ -101,6 +143,9 @@
* @return mixed * @return mixed
**/ **/
public function load() { public function load() {
if ($this->_memory) {
return apcu_fetch($this->_file);
}
if (!is_file($this->_file)) { if (!is_file($this->_file)) {
return false; return false;
} }

View File

@@ -231,7 +231,7 @@ function validate_name($string) {
// Checks if an IPv4(or localhost IPv6) address is valid // Checks if an IPv4(or localhost IPv6) address is valid
function validate_ip($ip) { function validate_ip($ip) {
$ipL = safeIp2Long($ip); $ipL = safeIp2Long($ip);
$ipR = long2ip($ipL); $ipR = long2ip((int)$ipL);
if ($ip === $ipR) { if ($ip === $ipR) {
return true; return true;
@@ -422,10 +422,8 @@ function output_errors($errors) {
return '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>'; return '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>';
} }
// Resize images // Resize images and create image
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);
@@ -443,7 +441,8 @@ 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);
@@ -452,71 +451,43 @@ function resize_imagex($file, $width, $height) {
return true; return true;
} }
// Guild logo upload security // Validate guild logo
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']
);
$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') {
header('Location: guilds.php?error=Only gif images are accepted, you uploaded:['.$image_data['type'].'].&name='. $_GET['name']);
exit();
}
// 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']); $check = getimagesize($image_data['tmp']);
if (!$check) {
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']); header('Location: guilds.php?error=Uploaded image is invalid.&name='. $_GET['name']);
exit(); exit();
} }
} else { if ($check['mime'] !== 'image/gif') {
header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$check['mime'].'].&name='. $_GET['name']);
header('Location: guilds.php?error=Only gif images are accepted, you uploaded:['.$image_data['type'].'].&name='. $_GET['name']);
exit(); exit();
} }
$path_info = pathinfo($image_data['name']);
if ($path_info['extension'] !== 'gif') {
header('Location: guilds.php?error=Only gif images accepted, you uploaded:['.$path_info['extension'].'].&name='. $_GET['name']);
exit();
} }
// Check guild logo // Resize image
function logo_exists($guild) { if (resize_imagex($image_data, 100, 100)) {
$guild = sanitize($guild); header('Location: guilds.php?name='. $_GET['name']);
if (file_exists('engine/guildimg/'.$guild.'.gif')) { exit();
echo'engine/guildimg/'.$guild.'.gif';
} else {
echo'engine/guildimg/default@logo.gif';
} }
} }

View File

@@ -143,7 +143,18 @@ function support_list03() {
// NEWS // NEWS
function fetchAllNews() { function fetchAllNews() {
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;"); 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;
");
} }
// HOUSES // HOUSES
@@ -250,62 +261,6 @@ 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;
@@ -326,158 +281,12 @@ 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 = 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;
@@ -497,13 +306,6 @@ 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;
@@ -522,7 +324,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;
} }
@@ -530,7 +332,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;
} }
@@ -573,18 +375,6 @@ 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
// //
@@ -861,16 +651,30 @@ 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;
if (config('ServerEngine') == 'TFS_10') { $characters = mysql_select_multi("
$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"); SELECT
if ($characters !== false) { `p`.`id`,
for ($i = 0; $i < count($characters); $i++) { `p`.`name`,
$characters[$i]['online'] = ($characters[$i]['online'] > 0) ? 1 : 0; `p`.`level`,
//unset($characters[$i]['id']); `p`.`vocation`,
} `p`.`town_id`,
} `p`.`lastlogin`,
`gm`.`rank_id`,
} 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"); `zp`.`hide_char`,
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);
@@ -910,15 +714,11 @@ 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('ServerEngine') !== 'OTHIRE') {
if (config('client') < 780) { 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`" : ""; $outfits = ($outfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
} 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`, `p`.`lookaddons` AS `addons`" : "";
} }
} else {
$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();
@@ -956,59 +756,30 @@ 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 ($tfs == 'TFS_10') {
if ($flags === false) { // In this case we only need to query players table if ($flags === false) { // In this case we only need to query players table
$v = str_replace('`p`.', '', $v); $v = str_replace('`p`.', '', $v);
$outfits = str_replace('`p`.', '', $outfits); $outfits = str_replace('`p`.', '', $outfits);
$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 `name`, `vocation`, `lastlogout`, `skill_club` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `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 `name`, `vocation`, `lastlogout`, `skill_sword` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `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 `name`, `vocation`, `lastlogout`, `skill_axe` AS `value` $outfits FROM `players` WHERE `group_id` < $g $v ORDER BY `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 `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`, `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 `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`, `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 `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`, `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 `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`, `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 `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`, `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 `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 } 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][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 `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][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 `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][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 `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][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 `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][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 `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][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 `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][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 `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][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 `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;"); $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 { // 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;");
}
} }
} }
} }
@@ -1114,37 +885,14 @@ 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("
if (config('ServerEngine') !== 'OTHIRE') { UPDATE `accounts`
if ($tfs_10_hasPremDays) { SET `premium_ends_at` = GREATEST(`premium_ends_at`, UNIX_TIMESTAMP()) + ({$days} * 86400)
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}'; 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.
function user_character_change_gender($name) { function user_character_change_gender($name) {
@@ -1447,19 +1195,8 @@ 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() {
if (config('ServerEngine') == 'TFS_10') {
$online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;"); $online = mysql_select_single("SELECT COUNT(`player_id`) AS `value` FROM `players_online`;");
return ($online !== false) ? $online['value'] : 0; 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)!
@@ -1736,33 +1473,4 @@ 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(), '5.6', '<')) die('PHP version 5.6 or higher is required.'); <?php if (version_compare(phpversion(), '7.2', '<')) die('PHP version 7.2 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 = '1.5_SVN'; $version = '2.0_DEV';
$aacQueries = 0; $aacQueries = 0;
$accQueriesData = array(); $accQueriesData = array();
@@ -50,25 +50,10 @@ 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 = getSession('user_id'); $session_user_id = (int)getSession('user_id');
if ($config['ServerEngine'] !== 'OTHIRE') {
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 = 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; $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();

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['owner'] != $session_user_id) { if(!$ticketData || $ticketData['owner'] != $session_user_id) {
echo 'You can not view this ticket!'; echo 'You can not view this ticket!';
include 'layout/overall/footer.php'; include 'layout/overall/footer.php';
die; die;

130
house.php
View File

@@ -4,12 +4,22 @@ 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 && $config['ServerEngine'] === 'TFS_10') { if ($house !== false) {
$house_SQL = "SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='$house';"; $house_SQL = "
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) $house['ownername'] = user_name($house['owner']); if ($house['owner'] == 0) unset($house['ownername']);
if ($config['houseConfig']['shopPoints']['enabled']) { if ($config['houseConfig']['shopPoints']['enabled']) {
$house['points'] = $house['size']; $house['points'] = $house['size'];
@@ -28,19 +38,36 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
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("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;"); $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 ($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?
@@ -55,17 +82,51 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
// 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;");
$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'] ."';"); mysql_update("
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;");
$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'] ."';"); mysql_update("
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']) {
@@ -73,8 +134,21 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
// 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;");
$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'] ."';"); mysql_update("
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>";
@@ -103,8 +177,22 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
if ($account_points >= $house['points']) { if ($account_points >= $house['points']) {
$bid_char = (int)$bid_char; $bid_char = (int)$bid_char;
$player = mysql_select_single("SELECT `id`, `account_id`, `name`, `level` FROM `players` WHERE `id`='$bid_char' LIMIT 1;"); $player = 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 `id`, `account_id`, `name`, `level`
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
@@ -177,12 +265,12 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
<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>
@@ -198,17 +286,17 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
<?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) {
@@ -219,7 +307,7 @@ if ($house !== false && $config['ServerEngine'] === 'TFS_10') {
<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,182 +5,6 @@ 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);
if (empty($_POST) === false && $config['ServerEngine'] === 'TFS_03') {
/* Token used for cross site scripting security */
if (isset($_POST['token']) && Token::isValid($_POST['token'])) {
$townid = (int)$_POST['selected'];
$cache = new Cache('engine/cache/houses');
$array = array();
if ($cache->hasExpired()) {
$tmp = fetchAllHouses_03();
$cache->setContent($tmp);
$cache->save();
foreach ($tmp as $t) {
if ($t['town'] == $townid) $array[] = $t;
}
$array = isset($array) ? $array : false;
} else {
$tmp = $cache->load();
foreach ($tmp as $t) {
if ($t['town'] == $townid) $array[] = $t;
}
$array = isset($array) ? $array : false;
}
// Design and present the list
if ($array) {
$guild_support = (isset($array[0]['guild'])) ? true : false;
?>
<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>
</tr>
<?php
foreach ($array as $value) {
echo '<tr>';
echo "<td>". $value['name'] ."</td>";
echo "<td>". $value['size'] ."</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>';
}
?>
</table>
<?php
} else {
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 // Fetch values
$querystring_id = &$_GET['id']; $querystring_id = &$_GET['id'];
$townid = ($querystring_id) ? (int)$_GET['id'] : $config['houseConfig']['HouseListDefaultTown']; $townid = ($querystring_id) ? (int)$_GET['id'] : $config['houseConfig']['HouseListDefaultTown'];
@@ -243,8 +67,17 @@ if (empty($_POST) === false && $config['ServerEngine'] === 'TFS_03') {
// Create or fetch data from cache // Create or fetch data from cache
$cache = new Cache('engine/cache/houses/houses-' . $order . '-' . $type); $cache = new Cache('engine/cache/houses/houses-' . $order . '-' . $type);
$houses = array(); $houses = array();
if ($cache->hasExpired()) { 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};");
$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) { if ($houses !== false) {
// Fetch player names // Fetch player names
$playerlist = array(); $playerlist = array();
@@ -314,8 +147,8 @@ if (empty($_POST) === false && $config['ServerEngine'] === 'TFS_03') {
</table> </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,6 +15,7 @@ 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,6 +11,7 @@
include 'layout/widgets/charactersearch.php'; include 'layout/widgets/charactersearch.php';
include 'layout/widgets/topplayers.php'; include 'layout/widgets/topplayers.php';
include 'layout/widgets/highscore.php'; include 'layout/widgets/highscore.php';
if ($config['powergamers']['enabled']) include 'layout/widgets/powergamers.php';
include 'layout/widgets/serverinfo.php'; include 'layout/widgets/serverinfo.php';
if ($config['ServerEngine'] !== 'TFS_02') include 'layout/widgets/houses.php'; if ($config['ServerEngine'] !== 'TFS_02') include 'layout/widgets/houses.php';
if ($follow["enabled"]): ?> if ($follow["enabled"]): ?>

View File

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

View File

@@ -14,10 +14,57 @@
<!-- <!--
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,6 +4,7 @@ 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,6 +30,8 @@
</li> </li>
<?php <?php
$new = 0; $new = 0;
$cache = new Cache('engine/cache/asideFeedbackCount');
if ($cache->hasExpired()) {
$cat = 4; //Category ID for feedback section $cat = 4; //Category ID for feedback section
$threads = mysql_select_multi("SELECT `id`, `player_id` FROM `znote_forum_threads` WHERE `forum_id`='$cat' AND `closed`='0';"); $threads = mysql_select_multi("SELECT `id`, `player_id` FROM `znote_forum_threads` WHERE `forum_id`='$cat' AND `closed`='0';");
if ($threads !== false) { if ($threads !== false) {
@@ -49,6 +51,11 @@
if (!$response) $new++; if (!$response) $new++;
} }
} }
$cache->setContent($new);
$cache->save();
} else {
$new = $cache->load();
}
?> ?>
<li> <li>
<a href='forum.php?cat=4'>Feedback: [<?php echo $new; ?>] new</a> <a href='forum.php?cat=4'>Feedback: [<?php echo $new; ?>] new</a>

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,17 +3,13 @@
Town list / houses Town list / houses
</div> </div>
<div class="body"> <div class="body">
<form action="houses.php" method="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "post"; else echo "get" ;?>"> <form action="houses.php" method="get">
<select name="<?php if ($config['ServerEngine'] !== 'TFS_10') echo "selected"; else echo "id" ;?>"> <select name="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 if ($config['ServerEngine'] !== 'OTHIRE') echo $user_data['name']; else echo $user_data['id'];?>. Welcome, <?php echo $user_data['name']; ?>.
</div> </div>
<div class="body"> <div class="body">
<ul class="linkbuttons"> <ul class="linkbuttons">

View File

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

View File

@@ -1,34 +1,27 @@
<?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>
<?php <li><a href="onlinelist.php">Players online: <?php echo $asideServerInfo['online']; ?></a></li>
$status = true; <li>Registered accounts: <?php echo $asideServerInfo['accounts'];?></li>
if ($config['status']['status_check']) { <li>Registered players: <?php echo $asideServerInfo['players'];?></li>
@$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,7 +7,11 @@
<?php <?php
$cache = new Cache('engine/cache/topPlayer'); $cache = new Cache('engine/cache/topPlayer');
if ($cache->hasExpired()) { if ($cache->hasExpired()) {
$players = mysql_select_multi('SELECT `name`, `level`, `experience` FROM `players` WHERE `group_id` < ' . $config['highscore']['ignoreGroupId'] . ' ORDER BY `level` DESC, `experience` DESC LIMIT 5;'); $players = mysql_select_multi("
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`, `premdays`'; $fields = '`id`, `premium_ends_at`';
if ($config['twoFactorAuthenticator']) $fields .= ', `secret`'; if ($config['twoFactorAuthenticator']) $fields .= ', `secret`';
$account = false; $account = false;
@@ -213,8 +213,10 @@ 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;
if (isset($account['secret']) && strlen($account['secret']) > 5) $sessionKey .= "\n".$token."\n".floor(time() / 30); $sessionKey .= (isset($account['secret']) && strlen($account['secret']) > 5) ? "\n".$token : "\n";
$sessionKey .= "\n".floor(time() / 30);
$freePremium = (isset($config['freePremium'])) ? $config['freePremium'] : true;
$response = array( $response = array(
'session' => array( 'session' => array(
'fpstracking' => false, 'fpstracking' => false,
@@ -226,8 +228,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['premdays'] > 0) ? true : false, 'ispremium' => ($account['premium_ends_at'] > time() || $freePremium) ? true : false,
'premiumuntil' => time() + ($account['premdays'] * 86400), 'premiumuntil' => $account['premium_ends_at'],
'status' => 'active' 'status' => 'active'
), ),
'playdata' => array( 'playdata' => array(
@@ -239,7 +241,13 @@ if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0" && $config['ServerEngine'] === '
'externalport' => $gameserver['port'], 'externalport' => $gameserver['port'],
'previewstate' => 0, 'previewstate' => 0,
'location' => 'ALL', 'location' => 'ALL',
'pvptype' => 'pvp', // 0 - open pvp
// 1 - optional
// 2 - hardcore
// 3 - retro open pvp
// 4 - retro hardcore pvp
// 5 and higher - (unknown)
'pvptype' => 0,
'externaladdressunprotected' => $gameserver['ip'], 'externaladdressunprotected' => $gameserver['ip'],
'externaladdressprotected' => $gameserver['ip'], 'externaladdressprotected' => $gameserver['ip'],
'externalportunprotected' => $gameserver['port'], 'externalportunprotected' => $gameserver['port'],

View File

@@ -5,7 +5,15 @@ 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('SELECT `character_name` FROM `znote_deleted_characters` WHERE `done` = 0 AND `id` = ' . $undelete_id . ' AND `original_account_id` = ' . $session_user_id . ' AND NOW() < `time`'); $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`
");
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/>';
@@ -52,7 +60,7 @@ if (isset($_GET['authenticate']) && $config['mailserver']['myaccount_verify_emai
$verify_account_id = (int)$session_user_id; $verify_account_id = (int)$session_user_id;
$user = mysql_select_single("SELECT `id`, `activekey`, `active_email` FROM `znote_accounts` WHERE `account_id`='{$verify_account_id}' LIMIT 1;"); $user = mysql_select_single("SELECT `id`, `activekey`, `active_email` FROM `znote_accounts` WHERE `account_id`='{$verify_account_id}' LIMIT 1;");
if ($user !== false) { if ($user !== false) {
$thisurl = config('site_url') . "myaccount.php"; $thisurl = config('site_url') . "/myaccount.php";
$thisurl .= "?authenticate&u=".$verify_account_id."&k=".$user['activekey']; $thisurl .= "?authenticate&u=".$verify_account_id."&k=".$user['activekey'];
$mailer = new Mail($config['mailserver']); $mailer = new Mail($config['mailserver']);
@@ -93,7 +101,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 (user_character_account_id($char_name) === $session_user_id) { if ((int)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.';
} }
@@ -103,7 +111,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 (user_character_account_id($char_name) === $session_user_id) { if ((int)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;
@@ -111,21 +119,13 @@ if (!empty($_POST['selected_character'])) {
// DELETE character // DELETE character
case 'delete_character': case 'delete_character':
if (user_character_account_id($char_name) === $session_user_id) { if ((int)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 ($config['ServerEngine'] === 'TFS_10') {
if (!user_is_online_10($charid)) { if (!user_is_online_10($charid)) {
if (guild_leader_gid($charid) === false) user_delete_character_soft($charid); 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 is leader of a guild, you must disband the guild or change leadership before deleting character.';
} else echo 'Character must be offline first.'; } 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,10 +137,8 @@ if (!empty($_POST['selected_character'])) {
$newname = isset($_POST['newName']) ? getValue($_POST['newName']) : ''; $newname = isset($_POST['newName']) ? getValue($_POST['newName']) : '';
$player = false; $player = false;
if ($config['ServerEngine'] === 'TFS_10') {
$player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'"); $player = mysql_select_single("SELECT `id`, `account_id` FROM `players` WHERE `name` = '$oldname'");
$player['online'] = (user_is_online_10($player['id'])) ? 1 : 0; $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) {
@@ -204,13 +202,11 @@ if (!empty($_POST['selected_character'])) {
// Change character sex // Change character sex
case 'change_gender': case 'change_gender':
if (user_character_account_id($char_name) === $session_user_id) { if ((int)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);
if ($config['ServerEngine'] == 'TFS_10') {
$chr_data['online'] = user_is_online_10($char_id) ? 1 : 0; $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.");
@@ -254,7 +250,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 (user_character_account_id($char_name) === $session_user_id) { if ((int)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 -->
@@ -303,21 +299,12 @@ if ($render_page) {
?> ?>
<div id="myaccount"> <div id="myaccount">
<h1>My account</h1> <h1>My account</h1>
<p>Welcome to your account page, <?php if ($config['ServerEngine'] !== 'OTHIRE') echo $user_data['name']; else echo $user_data['id']; ?><br> <p>Welcome to your account page, <?php echo $user_data['name']; ?><br>
<?php if ($config['ServerEngine'] !== 'OTHIRE') { <?php
if ($user_data['premdays'] != 0) { // Todo: If premdays is less than 2, inform how many hours are left.
echo 'You have ' .$user_data['premdays']. ' remaining premium account days.'; if ($user_data['premdays'] != 0) echo "You have {$user_data['premdays']} remaining premium account days.";
} else { else echo 'You are free account.';
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) {
@@ -328,7 +315,7 @@ if ($render_page) {
endif; ?> endif; ?>
</p> </p>
<?php <?php
if ($config['ServerEngine'] === 'TFS_10' && $config['twoFactorAuthenticator']) { if ($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
@@ -343,17 +330,27 @@ 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>LEVEL</th><th>VOCATION</th><th>TOWN</th><th>LAST LOGIN</th><th>STATUS</th><th>HIDE</th> <th>NAME</th>
<th>LEVEL</th>
<th>VOCATION</th>
<th>TOWN</th>
<th>LAST LOGIN</th>
<th>STATUS</th>
<th>HIDE</th>
</tr> </tr>
<?php <?php
$characters = array(); foreach ($char_array as $value): ?>
foreach ($char_array as $value) { <tr>
// characters: [0] = name, [1] = level, [2] = vocation, [3] = town_id, [4] = lastlogin, [5] = online <td><a href="characterprofile.php?name=<?php echo $value['name']; ?>"><?php echo $value['name']; ?></a></td>
echo '<tr>'; <td><?php echo $value['level']; ?></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['vocation']; ?></td>
echo '</tr>'; <td><?php echo $value['town_id']; ?></td>
$characters[] = $value['name']; <td><?php echo $value['lastlogin']; ?></td>
} <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-->
@@ -362,15 +359,9 @@ 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 <?php foreach ($char_array as $character): ?>
for ($i = 0; $i < $char_count; $i++) { <option value="<?php echo $character['name']; ?>"><?php echo $character['name']; ?></option>
if (user_character_hide($characters[$i]) == 1) { <?php endforeach; ?>
echo '<option value="'. $characters[$i] . '">'. $characters[$i] .'</option>';
} else {
echo '<option value="'. $characters[$i] . '">'. $characters[$i] .'</option>';
}
}
?>
</select> </select>
</td> </td>
<td> <td>
@@ -395,7 +386,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,32 +1,27 @@
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?> <?php require_once 'engine/init.php'; include 'layout/overall/header.php';
<h1>Who is online?</h1> $history = array(
<?php "enabled" => true,
"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['ServerEngine'] != 'OTHIRE') {
if ($config['client'] < 780) { 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`" : ""; $outfitQuery = ($loadOutfits) ? ", `p`.`lookbody` AS `body`, `p`.`lookfeet` AS `feet`, `p`.`lookhead` AS `head`, `p`.`looklegs` AS `legs`, `p`.`looktype` AS `type`" : "";
} 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`, `p`.`lookaddons` AS `addons`" : "";
} }
} else {
$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.
$cache = new Cache('engine/cache/onlinelist'); $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
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`;"); $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();
@@ -35,9 +30,63 @@ if ($cache->hasExpired()) {
} }
// End cache // End cache
if (!empty($array) && $array !== false) { // 5 minute logout history cache
?> 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>"; ?>
@@ -47,12 +96,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" onclick="javascript:window.location.href='<?php echo $url; ?>'"> <tr class="special">
<?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; ?>
@@ -62,13 +111,53 @@ 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> </table>
<?php <?php
} else { else:
echo 'Nobody is online.';
}
?> ?>
<?php include 'layout/overall/footer.php'; ?> <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>
<?php
endif;
}
include 'layout/overall/footer.php'; ?>

View File

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

View File

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

View File

@@ -27,6 +27,7 @@ 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>";
@@ -35,12 +36,10 @@ 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)
if ($config['ServerEngine'] == 'TFS_10')
foreach ($stagesXML->config->attributes() as $name => $value) foreach ($stagesXML->config->attributes() as $name => $value)
$stagesData["$name"] = "$value"; $stagesData["$name"] = "$value";
// Load stage levels // Load stage levels
// Each stage XML object // Each stage XML object
if ($config['ServerEngine'] == 'TFS_10') {
foreach ($stagesXML->stage as $stage) { foreach ($stagesXML->stage as $stage) {
$rowData = array(); $rowData = array();
// Each attribute name and values on current stage object // Each attribute name and values on current stage object
@@ -50,20 +49,6 @@ if (user_logged_in() && is_admin($user_data)) {
// Populate XML assoc array // Populate XML assoc array
$stagesData['stages'][] = $rowData; $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;
}
}
}
$cache->setContent($stagesData); $cache->setContent($stagesData);
$cache->save(); $cache->save();
} }
@@ -83,6 +68,7 @@ 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
@@ -120,19 +106,6 @@ 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();
@@ -168,13 +141,7 @@ 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'))) {
@@ -227,7 +194,12 @@ $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 if (($stagesData && isset($stagesData['enabled']) && $stagesData['enabled']) || (isset($luaConfig['experienceStages']) && $luaConfig['experienceStages'] === true)): $stages = true; ?> <?php
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,6 +2,7 @@
// 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>";