mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-25 16:59:21 +02:00
* cache $db->hasTable and $db->hasColumn functions
* changed tableExist and fieldExist to $db->hasTable(table) + $db->hasColumn(table, column) * new configurable: database_log - can log database queries and show in website source when logged as super admin * removed debug_level configurable, enabled by default when logged on super admin * added OTS_Account:getCountry() * added posibility to load OTS_Player partially, and without skills * (internal) changed depracated $ots->createObject() functions with their OTS_ equivalents * (internal) removed unused code
This commit is contained in:
parent
31537687c1
commit
1025fad0e6
2
TODO
2
TODO
@ -14,10 +14,8 @@
|
||||
* should the link blink?
|
||||
* cache:
|
||||
* hooks
|
||||
* fieldExist and tableExist functions
|
||||
* Menus in templates
|
||||
* move highscores to twig
|
||||
* $db->hasTable(table) + $db->hasColumn(table, column)
|
||||
* migrations: option to downgrade the database
|
||||
* hooks: login + logout
|
||||
|
||||
|
@ -46,8 +46,6 @@ $config = array(
|
||||
// footer
|
||||
'footer' => ''/*'<br/>Your Server © 2016. All rights reserved.'*/,
|
||||
|
||||
'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both, 4 - memory usage, 5 - load time & memory usage, 6 - queries & memory usage, 7 - all
|
||||
|
||||
'language' => 'en', // default language (currently only 'en' available)
|
||||
'language_allow_change' => false,
|
||||
|
||||
@ -65,6 +63,7 @@ $config = array(
|
||||
'database_user' => '',
|
||||
'database_password' => '',
|
||||
'database_name' => '',
|
||||
'database_log' => false, // should database queries be logged and displayed in the page source? They will be included at the end of the .html source of the page
|
||||
|
||||
// multiworld system (only TFS 0.3)
|
||||
'multiworld' => false, // use multiworld system?
|
||||
|
19
index.php
19
index.php
@ -423,15 +423,18 @@ else
|
||||
die('ERROR: Cannot load template.');
|
||||
}
|
||||
|
||||
$super = superAdmin();
|
||||
echo '<!-- MyAAC ' . MYAAC_VERSION . ' :: http://www.my-aac.org/ -->' . "\n";
|
||||
if(($config['debug_level'] & 1) == 1)
|
||||
echo '<!-- Generated in :: ' . round(microtime(true) - START_TIME, 4) . ' -->';
|
||||
|
||||
if(($config['debug_level'] & 2) == 2)
|
||||
echo "\n" . '<!-- Queries done :: ' . $db->queries() . ' -->';
|
||||
|
||||
if(($config['debug_level'] & 4) == 4 && function_exists('memory_get_peak_usage'))
|
||||
echo "\n" . '<!-- Peak memory usage: ' . convert_bytes(memory_get_peak_usage(true)) . ' -->';
|
||||
if($super) {
|
||||
echo '<!-- Generated in: ' . round(microtime(true) - START_TIME, 4) . 'ms -->';
|
||||
echo PHP_EOL . '<!-- Queries done: ' . $db->queries() . ' -->';
|
||||
if(function_exists('memory_get_peak_usage')) {
|
||||
echo PHP_EOL . '<!-- Peak memory usage: ' . convert_bytes(memory_get_peak_usage(true)) . ' -->';
|
||||
}
|
||||
}
|
||||
|
||||
if($config['database_log'] && $super) {
|
||||
echo PHP_EOL . '<!-- Database Queries Done by MyAAC:' . PHP_EOL . $db->getLog() . '-->';
|
||||
}
|
||||
$hooks->trigger(HOOK_FINISH);
|
||||
?>
|
||||
|
@ -5,8 +5,8 @@ require(SYSTEM . 'libs/pot/OTS.php');
|
||||
$ots = POT::getInstance();
|
||||
require(SYSTEM . 'database.php');
|
||||
|
||||
if(tableExist('accounts'))
|
||||
define('USE_ACCOUNT_NAME', fieldExist('name', 'accounts'));
|
||||
if($db->hasTable('accounts'))
|
||||
define('USE_ACCOUNT_NAME', $db->hasColumn('accounts', 'name'));
|
||||
else
|
||||
define('USE_ACCOUNT_NAME', false);
|
||||
?>
|
@ -47,23 +47,23 @@ if(!$error) {
|
||||
success($locale['step_database_importing']);
|
||||
require(BASE . 'install/includes/database.php');
|
||||
|
||||
if(!tableExist('accounts')) {
|
||||
if(!$db->hasTable('accounts')) {
|
||||
$locale['step_database_error_table'] = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
|
||||
error($locale['step_database_error_table']);
|
||||
$error = true;
|
||||
}
|
||||
else if(!tableExist('players')) {
|
||||
else if(!$db->hasTable('players')) {
|
||||
$locale['step_database_error_table'] = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
|
||||
error($locale['step_database_error_table']);
|
||||
$error = true;
|
||||
}
|
||||
else if(!tableExist('guilds')) {
|
||||
else if(!$db->hasTable('guilds')) {
|
||||
$locale['step_database_error_table'] = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
|
||||
error($locale['step_database_error_table']);
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if(tableExist(TABLE_PREFIX . 'account_actions')) {
|
||||
if($db->hasTable(TABLE_PREFIX . 'account_actions')) {
|
||||
$locale['step_database_error_table_exist'] = str_replace('$TABLE$', TABLE_PREFIX . 'account_actions', $locale['step_database_error_table_exist']);
|
||||
warning($locale['step_database_error_table_exist']);
|
||||
}
|
||||
@ -85,7 +85,7 @@ if(!$error) {
|
||||
}
|
||||
|
||||
if(!$error) {
|
||||
if(fieldExist('key', 'accounts')) {
|
||||
if($db->hasColumn('accounts', 'key')) {
|
||||
if(query("ALTER TABLE `accounts` MODIFY `key` VARCHAR(64) NOT NULL DEFAULT '';"))
|
||||
success($locale['step_database_modifying_field'] . ' accounts.key...');
|
||||
}
|
||||
@ -94,75 +94,75 @@ if(!$error) {
|
||||
success($locale['step_database_adding_field'] . ' accounts.key...');
|
||||
}
|
||||
|
||||
if(!fieldExist('blocked', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'blocked')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `blocked` TINYINT(1) NOT NULL DEFAULT FALSE COMMENT 'internal usage' AFTER `key`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.blocked...');
|
||||
}
|
||||
|
||||
if(!fieldExist('created', 'accounts')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `created` INT(11) NOT NULL DEFAULT 0 AFTER `" . (fieldExist('group_id', 'accounts') ? 'group_id' : 'blocked') . "`;"))
|
||||
if(!$db->hasColumn('accounts', 'created')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `created` INT(11) NOT NULL DEFAULT 0 AFTER `" . ($db->hasColumn('accounts', 'group_id') ? 'group_id' : 'blocked') . "`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.created...');
|
||||
}
|
||||
|
||||
if(!fieldExist('rlname', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'rlname')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `rlname` VARCHAR(255) NOT NULL DEFAULT '' AFTER `created`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.rlname...');
|
||||
}
|
||||
|
||||
if(!fieldExist('location', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'location')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `location` VARCHAR(255) NOT NULL DEFAULT '' AFTER `rlname`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.location...');
|
||||
}
|
||||
|
||||
if(!fieldExist('country', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'country')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `country` VARCHAR(3) NOT NULL DEFAULT '' AFTER `location`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.country...');
|
||||
}
|
||||
|
||||
if(fieldExist('page_lastday', 'accounts')) {
|
||||
if($db->hasColumn('accounts', 'page_lastday')) {
|
||||
if(query("ALTER TABLE `accounts` CHANGE `page_lastday` `web_lastlogin` INT(11) NOT NULL DEFAULT 0;")) {
|
||||
$tmp = str_replace('$FIELD$', 'accounts.page_lastday', $locale['step_database_changing_field']);
|
||||
$tmp = str_replace('$FIELD_NEW$', 'accounts.web_lastlogin', $tmp);
|
||||
success($tmp);
|
||||
}
|
||||
}
|
||||
else if(!fieldExist('web_lastlogin', 'accounts')) {
|
||||
else if(!$db->hasColumn('accounts', 'web_lastlogin')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `web_lastlogin` INT(11) NOT NULL DEFAULT 0 AFTER `country`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.web_lastlogin...');
|
||||
}
|
||||
|
||||
if(!fieldExist('web_flags', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'web_flags')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `web_flags` INT(11) NOT NULL DEFAULT 0 AFTER `web_lastlogin`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.web_flags...');
|
||||
}
|
||||
|
||||
if(!fieldExist('email_hash', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'email_hash')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email_hash` VARCHAR(32) NOT NULL DEFAULT '' AFTER `web_flags`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.email_hash...');
|
||||
}
|
||||
|
||||
if(!fieldExist('email_verified', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'email_verified')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email_verified` TINYINT(1) NOT NULL DEFAULT 0 AFTER `email_hash`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.email_verified...');
|
||||
}
|
||||
|
||||
if(!fieldExist('email_new', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'email_new')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email_new` VARCHAR(255) NOT NULL DEFAULT '' AFTER `email_hash`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.email_new...');
|
||||
}
|
||||
|
||||
if(!fieldExist('email_new_time', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'email_new_time')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email_new_time` INT(11) NOT NULL DEFAULT 0 AFTER `email_new`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.email_new_time...');
|
||||
}
|
||||
|
||||
if(!fieldExist('email_code', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'email_code')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email_code` VARCHAR(255) NOT NULL DEFAULT '' AFTER `email_new_time`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.email_code...');
|
||||
}
|
||||
|
||||
if(fieldExist('next_email', 'accounts')) {
|
||||
if(!fieldExist('email_next', 'accounts')) {
|
||||
if($db->hasColumn('accounts', 'next_email')) {
|
||||
if(!$db->hasColumn('accounts', 'email_next')) {
|
||||
if(query("ALTER TABLE `accounts` CHANGE `next_email` `email_next` INT(11) NOT NULL DEFAULT 0;")) {
|
||||
$tmp = str_replace('$FIELD$', 'accounts.next_email', $locale['step_database_changing_field']);
|
||||
$tmp = str_replace('$FIELD_NEW$', 'accounts.email_next', $tmp);
|
||||
@ -170,45 +170,45 @@ if(!$error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!fieldExist('email_next', 'accounts')) {
|
||||
else if(!$db->hasColumn('accounts', 'email_next')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `email_next` INT(11) NOT NULL DEFAULT 0 AFTER `email_code`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.email_next...');
|
||||
}
|
||||
|
||||
if(!fieldExist('premium_points', 'accounts')) {
|
||||
if(!$db->hasColumn('accounts', 'premium_points')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `premium_points` INT(11) NOT NULL DEFAULT 0 AFTER `email_next`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.premium_points...');
|
||||
}
|
||||
|
||||
if(!fieldExist('description', 'guilds')) {
|
||||
if(!$db->hasColumn('guilds', 'description')) {
|
||||
if(query("ALTER TABLE `guilds` ADD `description` TEXT NOT NULL;"))
|
||||
success($locale['step_database_adding_field'] . ' guilds.description...');
|
||||
}
|
||||
|
||||
if(fieldExist('logo_gfx_name', 'guilds')) {
|
||||
if($db->hasColumn('guilds', 'logo_gfx_name')) {
|
||||
if(query("ALTER TABLE `guilds` CHANGE `logo_gfx_name` `logo_name` VARCHAR( 255 ) NOT NULL DEFAULT 'default.gif';")) {
|
||||
$tmp = str_replace('$FIELD$', 'guilds.logo_gfx_name', $locale['step_database_changing_field']);
|
||||
$tmp = str_replace('$FIELD_NEW$', 'guilds.logo_name', $tmp);
|
||||
success($tmp);
|
||||
}
|
||||
}
|
||||
else if(!fieldExist('logo_name', 'guilds')) {
|
||||
else if(!$db->hasColumn('guilds', 'logo_name')) {
|
||||
if(query("ALTER TABLE `guilds` ADD `logo_name` VARCHAR( 255 ) NOT NULL DEFAULT 'default.gif';"))
|
||||
success($locale['step_database_adding_field'] . ' guilds.logo_name...');
|
||||
}
|
||||
|
||||
if(!fieldExist('created', 'players')) {
|
||||
if(!$db->hasColumn('players', 'created')) {
|
||||
if(query("ALTER TABLE `players` ADD `created` INT(11) NOT NULL DEFAULT 0;"))
|
||||
success($locale['step_database_adding_field'] . ' players.created...');
|
||||
}
|
||||
|
||||
if(!fieldExist('deleted', 'players') && !fieldExist('deletion', 'players')) {
|
||||
if(!$db->hasColumn('players', 'deleted') && !$db->hasColumn('players', 'deletion')) {
|
||||
if(query("ALTER TABLE `players` ADD `deleted` TINYINT(1) NOT NULL DEFAULT 0;"))
|
||||
success($locale['step_database_adding_field'] . ' players.comment...');
|
||||
}
|
||||
|
||||
if(fieldExist('hide_char', 'players')) {
|
||||
if(!fieldExist('hidden', 'players')) {
|
||||
if($db->hasColumn('players', 'hide_char')) {
|
||||
if(!$db->hasColumn('players', 'hidden')) {
|
||||
if(query("ALTER TABLE `players` CHANGE `hide_char` `hidden` TINYINT(1) NOT NULL DEFAULT 0;")) {
|
||||
$tmp = str_replace('$FIELD$', 'players.hide_char', $locale['step_database_changing_field']);
|
||||
$tmp = str_replace('$FIELD_NEW$', 'players.hidden', $tmp);
|
||||
@ -216,12 +216,12 @@ if(!$error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!fieldExist('hidden', 'players')) {
|
||||
else if(!$db->hasColumn('players', 'hidden')) {
|
||||
if(query("ALTER TABLE `players` ADD `hidden` TINYINT(1) NOT NULL DEFAULT 0;"))
|
||||
success($locale['step_database_adding_field'] . ' players.hidden...');
|
||||
}
|
||||
|
||||
if(!fieldExist('comment', 'players')) {
|
||||
if(!$db->hasColumn('players', 'comment')) {
|
||||
if(query("ALTER TABLE `players` ADD `comment` TEXT NOT NULL;"))
|
||||
success($locale['step_database_adding_field'] . ' players.comment...');
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ else {
|
||||
|
||||
$password = $_SESSION['var_password'];
|
||||
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
|
||||
if($config_salt_enabled)
|
||||
{
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
@ -77,9 +77,9 @@ else {
|
||||
|
||||
$account_used->setCustomField('web_flags', FLAG_ADMIN + FLAG_SUPER_ADMIN);
|
||||
$account_used->setCustomField('country', 'us');
|
||||
if(fieldExist('group_id', 'accounts'))
|
||||
if($db->hasColumn('accounts', 'group_id'))
|
||||
$account_used->setCustomField('group_id', $groups->getHighestId());
|
||||
if(fieldExist('type', 'accounts'))
|
||||
if($db->hasColumn('accounts', 'type'))
|
||||
$account_used->setCustomField('type', 5);
|
||||
|
||||
if(!$player_db->isLoaded())
|
||||
@ -116,7 +116,7 @@ else {
|
||||
}
|
||||
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$insert_into_players = "INSERT INTO `players` (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `lastlogout`, `balance`, `$deleted`, `created`, `hidden`, `comment`) VALUES ";
|
||||
|
@ -60,4 +60,16 @@ function check_guild_name($name, &$errors = '') {
|
||||
function news_place() {
|
||||
return tickers();
|
||||
}
|
||||
|
||||
function tableExist($table)
|
||||
{
|
||||
global $db;
|
||||
return $db->hasTable($table);
|
||||
}
|
||||
|
||||
function fieldExist($field, $table)
|
||||
{
|
||||
global $db;
|
||||
return $db->hasColumn($table, $field);
|
||||
}
|
||||
?>
|
@ -76,13 +76,17 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
if(isset($config['lua']['useMD5Passwords']) && getBoolean($config['lua']['useMD5Passwords']))
|
||||
$config['database_encryption'] = 'md5';
|
||||
|
||||
if(!isset($config['database_log'])) {
|
||||
$config['database_log'] = false;
|
||||
}
|
||||
|
||||
try {
|
||||
$ots->connect(POT::DB_MYSQL,
|
||||
array(
|
||||
$ots->connect(array(
|
||||
'host' => $config['database_host'],
|
||||
'user' => $config['database_user'],
|
||||
'password' => $config['database_password'],
|
||||
'database' => $config['database_name']
|
||||
'database' => $config['database_name'],
|
||||
'log' => $config['database_log']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ function getPlayerLink($name, $generate = true)
|
||||
|
||||
if(is_numeric($name))
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load(intval($name));
|
||||
if($player->isLoaded())
|
||||
$name = $player->getName();
|
||||
@ -302,22 +302,6 @@ function encrypt($str)
|
||||
return $str;
|
||||
}
|
||||
|
||||
function tableExist($table)
|
||||
{
|
||||
global $db, $config;
|
||||
$query = $db->query("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `TABLE_SCHEMA` = " . $db->quote($config['database_name']) . " AND `TABLE_NAME` = " . $db->quote($table) . ";");
|
||||
return $query->rowCount() > 0;
|
||||
}
|
||||
|
||||
function fieldExist($field, $table)
|
||||
{
|
||||
global $db;
|
||||
if(count($db->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $field . "'")->fetchAll()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//delete player with name
|
||||
function delete_player($name)
|
||||
{
|
||||
@ -376,9 +360,9 @@ function delete_guild($id)
|
||||
|
||||
global $db, $ots;
|
||||
foreach($rank_list as $rank_in_guild) {
|
||||
if(tableExist('guild_members'))
|
||||
if($db->hasTable('guild_members'))
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `guild_members`.`rank_id` as `rank_id` FROM `players`, `guild_members` WHERE `guild_members`.`rank_id` = ' . $rank_in_guild->getId() . ' AND `players`.`id` = `guild_members`.`player_id` ORDER BY `name`;');
|
||||
else if(tableExist('guild_membership'))
|
||||
else if($db->hasTable('guild_membership'))
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `guild_membership`.`rank_id` as `rank_id` FROM `players`, `guild_membership` WHERE `guild_membership`.`rank_id` = ' . $rank_in_guild->getId() . ' AND `players`.`id` = `guild_membership`.`player_id` ORDER BY `name`;');
|
||||
else
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank_in_guild->getId() . ' AND `deleted` = 0;');
|
||||
@ -386,7 +370,7 @@ function delete_guild($id)
|
||||
$players_with_rank_number = $players_with_rank->rowCount();
|
||||
if($players_with_rank_number > 0) {
|
||||
foreach($players_with_rank as $result) {
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($result['id']);
|
||||
if(!$player->isLoaded())
|
||||
continue;
|
||||
@ -563,7 +547,7 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false)
|
||||
|
||||
if(is_numeric($killer))
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($killer);
|
||||
if($player->isLoaded())
|
||||
{
|
||||
@ -971,10 +955,10 @@ function getTopPlayers($limit = 5) {
|
||||
if($fetch_from_db)
|
||||
{
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$is_tfs10 = tableExist('players_online');
|
||||
$is_tfs10 = $db->hasTable('players_online');
|
||||
$players = $db->query('SELECT `id`, `name`, `level`, `experience`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . $config['highscores_groups_hidden'] . ' AND `id` NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll();
|
||||
|
||||
if($is_tfs10) {
|
||||
|
@ -164,7 +164,7 @@ require_once(SYSTEM . 'libs/pot/OTS.php');
|
||||
$ots = POT::getInstance();
|
||||
require_once(SYSTEM . 'database.php');
|
||||
|
||||
define('USE_ACCOUNT_NAME', fieldExist('name', 'accounts'));
|
||||
define('USE_ACCOUNT_NAME', $db->hasColumn('accounts', 'name'));
|
||||
// load vocation names
|
||||
$tmp = '';
|
||||
if($cache->enabled() && $cache->fetch('vocations', $tmp)) {
|
||||
|
@ -29,50 +29,6 @@
|
||||
*/
|
||||
class POT
|
||||
{
|
||||
/**
|
||||
* MySQL driver.
|
||||
*/
|
||||
const DB_MYSQL = 1;
|
||||
/**
|
||||
* SQLite driver.
|
||||
*/
|
||||
const DB_SQLITE = 2;
|
||||
/**
|
||||
* PostgreSQL driver.
|
||||
*
|
||||
* @version 0.0.4
|
||||
* @since 0.0.4
|
||||
*/
|
||||
const DB_PGSQL = 3;
|
||||
/**
|
||||
* ODBC driver.
|
||||
*
|
||||
* @version 0.0.4
|
||||
* @since 0.0.4
|
||||
*/
|
||||
const DB_ODBC = 4;
|
||||
|
||||
/**
|
||||
* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.
|
||||
*/
|
||||
const VOCATION_NONE = 0;
|
||||
/**
|
||||
* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.
|
||||
*/
|
||||
const VOCATION_SORCERER = 1;
|
||||
/**
|
||||
* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.
|
||||
*/
|
||||
const VOCATION_DRUID = 2;
|
||||
/**
|
||||
* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.
|
||||
*/
|
||||
const VOCATION_PALADIN = 3;
|
||||
/**
|
||||
* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.
|
||||
*/
|
||||
const VOCATION_KNIGHT = 4;
|
||||
|
||||
/**
|
||||
* North.
|
||||
*/
|
||||
@ -401,15 +357,13 @@ class POT
|
||||
* </p>
|
||||
*
|
||||
* @version 0.1.3
|
||||
* @param int|null $driver Database driver type.
|
||||
* @param array $params Connection info.
|
||||
* @throws E_OTS_Generic When driver is not supported or not supported.
|
||||
* @throws LogicException When PDO extension is not loaded.
|
||||
* @throws PDOException On PDO operation error.
|
||||
* @example examples/quickstart.php quickstart.php
|
||||
* @tutorial POT/Basics.pkg#basics.database
|
||||
*/
|
||||
public function connect($driver, $params)
|
||||
public function connect($params)
|
||||
{
|
||||
// checks if PDO extension is loaded
|
||||
if( !extension_loaded('PDO') )
|
||||
@ -417,47 +371,7 @@ class POT
|
||||
throw new LogicException();
|
||||
}
|
||||
|
||||
// $params['driver'] option instead of $driver
|
||||
if( !isset($driver) )
|
||||
{
|
||||
if( isset($params['driver']) )
|
||||
{
|
||||
$driver = $params['driver'];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new E_OTS_Generic(E_OTS_Generic::CONNECT_NO_DRIVER);
|
||||
}
|
||||
}
|
||||
unset($params['driver']);
|
||||
|
||||
// switch() structure provides us further flexibility
|
||||
switch($driver)
|
||||
{
|
||||
// MySQL database
|
||||
case self::DB_MYSQL:
|
||||
$this->db = new OTS_DB_MySQL($params);
|
||||
break;
|
||||
|
||||
// SQLite database
|
||||
case self::DB_SQLITE:
|
||||
$this->db = new OTS_DB_SQLite($params);
|
||||
break;
|
||||
|
||||
// SQLite database
|
||||
case self::DB_PGSQL:
|
||||
$this->db = new OTS_DB_PostgreSQL($params);
|
||||
break;
|
||||
|
||||
// SQLite database
|
||||
case self::DB_ODBC:
|
||||
$this->db = new OTS_DB_ODBC($params);
|
||||
break;
|
||||
|
||||
// unsupported driver
|
||||
default:
|
||||
throw new E_OTS_Generic(E_OTS_Generic::CONNECT_INVALID_DRIVER);
|
||||
}
|
||||
$this->db = new OTS_DB_MySQL($params);
|
||||
|
||||
$this->db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
|
||||
// $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
@ -41,6 +41,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
private $data = array('email' => '', 'blocked' => false, 'rlname' => '','location' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
|
||||
public static $cache = array();
|
||||
/**
|
||||
* Creates new account.
|
||||
*
|
||||
@ -167,10 +168,16 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @param int $id Account number.
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function load($id)
|
||||
public function load($id, $fresh = false)
|
||||
{
|
||||
if(!$fresh && isset(self::$cache[$id])) {
|
||||
$this->data = self::$cache[$id];
|
||||
return;
|
||||
}
|
||||
|
||||
// SELECT query on database
|
||||
$this->data = $this->db->query('SELECT `id`, ' . (fieldExist('name', 'accounts') ? '`name`,' : '') . '`password`, `email`, ' . $this->db->fieldName('blocked') . ', ' . $this->db->fieldName('rlname') . ', ' . $this->db->fieldName('location') . ', ' . $this->db->fieldName('web_flags') . ', ' . (fieldExist('premdays', 'accounts') ? $this->db->fieldName('premdays') . ',' : '') . (fieldExist('lastday', 'accounts') ? $this->db->fieldName('lastday') . ',' : (fieldExist('premend', 'accounts') ? $this->db->fieldName('premend') . ',' : '')) . $this->db->fieldName('created') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . (int) $id)->fetch();
|
||||
$this->data = $this->db->query('SELECT `id`, ' . ($this->db->hasColumn('accounts', 'name') ? '`name`,' : '') . '`password`, `email`, `blocked`, `rlname`, `location`, `country`, `web_flags`, ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays`, ' : '') . ($this->db->hasColumn('accounts', 'lastday') ? '`lastday`, ' : ($this->db->hasColumn('accounts', 'premend') ? '`premend`,' : '')) . '`created` FROM `accounts` WHERE `id` = ' . (int) $id)->fetch();
|
||||
self::$cache[$id] = $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +195,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
public function find($name)
|
||||
{
|
||||
// finds player's ID
|
||||
$id = $this->db->query('SELECT ' . $this->db->fieldName('id') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($name) )->fetch();
|
||||
$id = $this->db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $this->db->quote($name) )->fetch();
|
||||
|
||||
// if anything was found
|
||||
if( isset($id['id']) )
|
||||
@ -208,7 +215,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
public function findByEMail($email)
|
||||
{
|
||||
// finds player's ID
|
||||
$id = $this->db->query('SELECT ' . $this->db->fieldName('id') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('email') . ' = ' . $this->db->quote($email) )->fetch();
|
||||
$id = $this->db->query('SELECT `id` FROM `accounts` WHERE `email` = ' . $this->db->quote($email) )->fetch();
|
||||
|
||||
// if anything was found
|
||||
if( isset($id['id']) )
|
||||
@ -250,7 +257,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
$field = 'lastday';
|
||||
if(fieldExist('premend', 'accounts')) { // othire
|
||||
if($this->db->hasColumn('accounts', 'premend')) { // othire
|
||||
$field = 'premend';
|
||||
if(!isset($this->data['premend'])) {
|
||||
$this->data['premend'] = 0;
|
||||
@ -258,7 +265,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE `accounts` SET ' . (fieldExist('name', 'accounts') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . (fieldExist('premdays', 'accounts') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
$this->db->query('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -302,6 +309,16 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
return $this->data['location'];
|
||||
}
|
||||
|
||||
public function getCountry()
|
||||
{
|
||||
if( !isset($this->data['country']) )
|
||||
{
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
return $this->data['country'];
|
||||
}
|
||||
|
||||
public function getWebFlags()
|
||||
{
|
||||
if( !isset($this->data['web_flags']) )
|
||||
@ -375,34 +392,6 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
return $this->data['created'];
|
||||
}
|
||||
/**
|
||||
* @version 0.1.0
|
||||
* @since 0.0.4
|
||||
* @return OTS_Group Group of which current account is member (currently random group).
|
||||
* @throws E_OTS_NotLoaded If account is not loaded.
|
||||
* @deprecated 0.0.6 There is no more group_id field in database.
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
if( !isset($this->data['id']) )
|
||||
{
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
// loads default group
|
||||
$groups = new OTS_Groups_List();
|
||||
$groups->rewind();
|
||||
return $groups->current();
|
||||
}
|
||||
|
||||
/**
|
||||
* @version 0.0.6
|
||||
* @param OTS_Group $group Group to be a member.
|
||||
* @deprecated 0.0.6 There is no more group_id field in database.
|
||||
*/
|
||||
public function setGroup(OTS_Group $group)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Name.
|
||||
@ -772,13 +761,13 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
if(tableExist('account_bans')) {
|
||||
if($this->db->hasTable('account_bans')) {
|
||||
$ban = $this->db->query('SELECT `expires_at` FROM `account_bans` WHERE `account_id` = ' . $this->data['id'] . ' AND (`expires_at` > ' . time() .' OR `expires_at` = -1) ORDER BY `expires_at` DESC')->fetch();
|
||||
$this->data['banned'] = isset($ban['expires_at']);
|
||||
$this->data['banned_time'] = $ban['expires_at'];
|
||||
}
|
||||
else if(tableExist('bans')) {
|
||||
if(fieldExist('active', 'bans')) {
|
||||
else if($this->db->hasTable('bans')) {
|
||||
if($this->db->hasColumn('bans', 'active')) {
|
||||
$ban = $this->db->query('SELECT `active`, `expires` FROM `bans` WHERE (`type` = 3 OR `type` = 5) AND `active` = 1 AND `value` = ' . $this->data['id'] . ' AND (`expires` > ' . time() .' OR `expires` = -1) ORDER BY `expires` DESC')->fetch();
|
||||
$this->data['banned'] = $ban['active'];
|
||||
$this->data['banned_time'] = $ban['expires'];
|
||||
@ -830,20 +819,28 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
public function getGroupId()
|
||||
{
|
||||
global $db;;
|
||||
if(fieldExist('group_id', 'accounts')) {
|
||||
if(isset($this->data['group_id'])) {
|
||||
return $this->data['group_id'];
|
||||
}
|
||||
|
||||
global $db;
|
||||
if($db->hasColumn('accounts', 'group_id')) {
|
||||
$query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
|
||||
// if anything was found
|
||||
if(isset($query['group_id']))
|
||||
if(isset($query['group_id'])) {
|
||||
$this->data['group_id'] = $query['group_id'];
|
||||
return $query['group_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->db->query('SELECT `group_id` FROM `players` WHERE `account_id` = ' . (int) $this->getId() . ' ORDER BY `group_id` DESC LIMIT 1');
|
||||
if($query->rowCount() == 1)
|
||||
{
|
||||
$query = $query->fetch();
|
||||
$this->data['group_id'] = $query['group_id'];
|
||||
return $query['group_id'];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,9 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
*/
|
||||
private $queries = 0;
|
||||
|
||||
protected $logged = false;
|
||||
private $log = '';
|
||||
|
||||
/**
|
||||
* Query-quoted field name.
|
||||
*
|
||||
@ -96,6 +99,10 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
|
||||
public function query($query)
|
||||
{
|
||||
if($this->logged) {
|
||||
$this->log .= $query . PHP_EOL;
|
||||
}
|
||||
|
||||
$this->queries++;
|
||||
//echo $query . PHP_EOL;
|
||||
return parent::query($query);
|
||||
@ -235,6 +242,10 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
public function queries() {
|
||||
return $this->queries;
|
||||
}
|
||||
|
||||
public function getLog() {
|
||||
return $this->log;
|
||||
}
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
@ -24,6 +24,8 @@
|
||||
*/
|
||||
class OTS_DB_MySQL extends OTS_Base_DB
|
||||
{
|
||||
private $has_table_cache = array();
|
||||
private $has_column_cache = array();
|
||||
/**
|
||||
* Creates database connection.
|
||||
*
|
||||
@ -92,9 +94,48 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
$this->prefix = $params['prefix'];
|
||||
}
|
||||
|
||||
if( isset($params['log']) )
|
||||
{
|
||||
$this->logged = true;
|
||||
}
|
||||
|
||||
global $cache, $config;
|
||||
if($cache->enabled()) {
|
||||
$tmp = null;
|
||||
$need_revalidation = true;
|
||||
if($cache->fetch('database_checksum', $tmp) && $tmp) {
|
||||
$tmp = unserialize($tmp);
|
||||
if(sha1($config['database_host'] . '.' . $config['database_name']) == $tmp) {
|
||||
$need_revalidation = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$need_revalidation) {
|
||||
$tmp = null;
|
||||
if($cache->fetch('database_tables', $tmp) && $tmp) {
|
||||
$this->has_table_cache = unserialize($tmp);
|
||||
}
|
||||
|
||||
$tmp = null;
|
||||
if($cache->fetch('database_columns', $tmp) && $tmp) {
|
||||
$this->has_column_cache = unserialize($tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct('mysql:' . implode(';', $dns), $user, $password);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
global $cache, $config;
|
||||
if($cache->enabled()) {
|
||||
$cache->set('database_tables', serialize($this->has_table_cache));
|
||||
$cache->set('database_columns', serialize($this->has_column_cache));
|
||||
$cache->set('database_checksum', serialize(sha1($config['database_host'] . '.' . $config['database_name'])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query-quoted field name.
|
||||
*
|
||||
@ -133,6 +174,23 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function hasTable($name) {
|
||||
if(isset($this->has_table_cache[$name])) {
|
||||
return $this->has_table_cache[$name];
|
||||
}
|
||||
|
||||
global $config;
|
||||
return ($this->has_table_cache[$name] = $this->query("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `TABLE_SCHEMA` = " . $this->quote($config['database_name']) . " AND `TABLE_NAME` = " . $this->quote($name) . " LIMIT 1;")->rowCount() > 0);
|
||||
}
|
||||
|
||||
public function hasColumn($table, $column) {
|
||||
if(isset($this->has_column_cache[$table . '.' . $column])) {
|
||||
return $this->has_column_cache[$table . '.' . $column];
|
||||
}
|
||||
|
||||
return ($this->has_column_cache[$table . '.' . $column] = count($this->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "'")->fetchAll()) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
@ -490,7 +490,7 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
// creates filter
|
||||
$filter = new OTS_SQLFilter();
|
||||
$filter->compareField('group_id', (int) $this->data['id']);
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($this->db->hasColumn('players', 'deletion'))
|
||||
$filter->compareField('deletion', 0);
|
||||
else
|
||||
$filter->compareField('deleted', 0);
|
||||
|
@ -31,9 +31,8 @@ class OTS_Groups_List implements IteratorAggregate, Countable
|
||||
*/
|
||||
public function __construct($file = '')
|
||||
{
|
||||
if(tableExist('groups')) { // read groups from database
|
||||
global $db;
|
||||
|
||||
global $db;
|
||||
if($db->hasTable('groups')) { // read groups from database
|
||||
foreach($db->query('SELECT `id`, `name`, `access` FROM `groups`;') as $group)
|
||||
{
|
||||
$info = array();
|
||||
|
@ -122,13 +122,13 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
public function load($id)
|
||||
{
|
||||
$ownerid = 'ownerid';
|
||||
if(fieldExist('owner_id', 'guilds'))
|
||||
if($this->db->hasColumn('guilds', 'owner_id'))
|
||||
$ownerid = 'owner_id';
|
||||
|
||||
$creationdata = 'creationdata';
|
||||
if(fieldExist('creationdate', 'guilds'))
|
||||
if($this->db->hasColumn('guilds', 'creationdate'))
|
||||
$creationdata = 'creationdate';
|
||||
else if(fieldExist('creation_time', 'guilds'))
|
||||
else if($this->db->hasColumn('guilds', 'creation_time'))
|
||||
$creationdata = 'creation_time';
|
||||
|
||||
// SELECT query on database
|
||||
@ -177,13 +177,13 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
public function save()
|
||||
{
|
||||
$ownerid = 'ownerid';
|
||||
if(fieldExist('owner_id', 'guilds'))
|
||||
if($this->db->hasColumn('guilds', 'owner_id'))
|
||||
$ownerid = 'owner_id';
|
||||
|
||||
$creationdata = 'creationdata';
|
||||
if(fieldExist('creationdate', 'guilds'))
|
||||
if($this->db->hasColumn('guilds', 'creationdate'))
|
||||
$creationdata = 'creationdate';
|
||||
else if(fieldExist('creation_time', 'guilds'))
|
||||
else if($this->db->hasColumn('guilds', 'creation_time'))
|
||||
$creationdata = 'creation_time';
|
||||
|
||||
// updates existing guild
|
||||
|
@ -344,7 +344,7 @@ class OTS_GuildRank extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// creates filter
|
||||
if(fieldExist('rank_id', 'players')) {
|
||||
if($this->db->hasColumn('players', 'rank_id')) {
|
||||
$filter = new OTS_SQLFilter();
|
||||
$filter->compareField('rank_id', (int) $this->data['id']);
|
||||
}
|
||||
|
@ -129,14 +129,14 @@ class OTS_Player extends OTS_Row_DAO
|
||||
* @param int $id Player's ID.
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function load($id)
|
||||
public function load($id, $fields = null, $load_skills = true)
|
||||
{
|
||||
global $__load;
|
||||
|
||||
if(!isset($__load['loss_experience']))
|
||||
{
|
||||
$loss = '';
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
if($this->db->hasColumn('players', 'loss_experience')) {
|
||||
$loss = ', `loss_experience`, `loss_mana`, `loss_skills`';
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
if(!isset($__load['loss_items']))
|
||||
{
|
||||
$loss_items = '';
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
if($this->db->hasColumn('players', 'loss_items')) {
|
||||
$loss_items = ', `loss_items`, `loss_containers`';
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
if(!isset($__load['guild_info']))
|
||||
{
|
||||
$guild_info = '';
|
||||
if(!tableExist('guild_members') && fieldExist('guildnick', 'players')) {
|
||||
if(!$this->db->hasTable('guild_members') && $this->db->hasColumn('players', 'guildnick')) {
|
||||
$guild_info = ', `guildnick`, `rank_id`';
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
if(!isset($__load['skull_type']))
|
||||
{
|
||||
$skull_type = 'skull';
|
||||
if(fieldExist('skull_type', 'players')) {
|
||||
if($this->db->hasColumn('players', 'skull_type')) {
|
||||
$skull_type = 'skull_type';
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
if(!isset($__load['skull_time']))
|
||||
{
|
||||
$skull_time = 'skulltime';
|
||||
if(fieldExist('skull_time', 'players')) {
|
||||
if($this->db->hasColumn('players', 'skull_time')) {
|
||||
$skull_time = 'skull_time';
|
||||
}
|
||||
|
||||
@ -184,31 +184,56 @@ class OTS_Player extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
if(!isset($__load['blessings'])) {
|
||||
$__load['blessings'] = fieldExist('blessings', 'players');
|
||||
$__load['blessings'] = $this->db->hasColumn('players', 'blessings');
|
||||
}
|
||||
if(!isset($__load['direction'])) {
|
||||
$__load['direction'] = fieldExist('direction', 'players');
|
||||
$__load['direction'] = $this->db->hasColumn('players', 'direction');
|
||||
}
|
||||
if(!isset($__load['stamina'])) {
|
||||
$__load['stamina'] = fieldExist('stamina', 'players');
|
||||
$__load['stamina'] = $this->db->hasColumn('players', 'stamina');
|
||||
}
|
||||
if(!isset($__load['world_id'])) {
|
||||
$__load['world_id'] = fieldExist('world_id', 'players');
|
||||
$__load['world_id'] = $this->db->hasColumn('players', 'world_id');
|
||||
}
|
||||
if(!isset($__load['online'])) {
|
||||
$__load['online'] = fieldExist('online', 'players');
|
||||
$__load['online'] = $this->db->hasColumn('players', 'online');
|
||||
}
|
||||
if(!isset($__load['deletion'])) {
|
||||
$__load['deletion'] = fieldExist('deletion', 'players');
|
||||
$__load['deletion'] = $this->db->hasColumn('players', 'deletion');
|
||||
}
|
||||
if(!isset($__load['promotion'])) {
|
||||
$__load['promotion'] = fieldExist('promotion', 'players');
|
||||
$__load['promotion'] = $this->db->hasColumn('players', 'promotion');
|
||||
}
|
||||
if(!isset($__load['marriage'])) {
|
||||
$__load['marriage'] = fieldExist('marriage', 'players');
|
||||
$__load['marriage'] = $this->db->hasColumn('players', 'marriage');
|
||||
}
|
||||
|
||||
global $db;
|
||||
if(isset($fields)) { // load only what we wish
|
||||
if(in_array('promotion', $fields)) {
|
||||
if(!$this->db->hasColumn('players', 'promotion')) {
|
||||
unset($fields[array_search('promotion')]);
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array('deleted', $fields)) {
|
||||
if($this->db->hasColumn('players', 'deletion')) {
|
||||
unset($fields[array_search('deleted')]);
|
||||
$fields[] = 'deletion';
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array('online', $fields)) {
|
||||
if(!$this->db->hasColumn('players', 'online')) {
|
||||
unset($fields[array_search('online')]);
|
||||
}
|
||||
}
|
||||
$this->data = $this->db->query('SELECT ' . implode(', ', $fields) . ' FROM `players` WHERE `id` = ' . (int)$id)->fetch();
|
||||
}
|
||||
else {
|
||||
// SELECT query on database
|
||||
$this->data = $this->db->query('SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`' . ($this->db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `save`, `conditions`, `' . $__load['skull_time'] . '` as `skulltime`, `' . $__load['skull_type'] . '` as `skull`' . $__load['guild_info'] . ', `town_id`' . $__load['loss_experience'] . $__load['loss_items'] . ', `balance`' . ($__load['blessings'] ? ', `blessings`' : '') . ($__load['direction'] ? ', `direction`' : '') . ($__load['stamina'] ? ', `stamina`' : '') . ($__load['world_id'] ? ', `world_id`' : '') . ($__load['online'] ? ', `online`' : '') . ', `' . ($__load['deletion'] ? 'deletion' : 'deleted') . '`' . ($__load['promotion'] ? ', `promotion`' : '') . ($__load['marriage'] ? ', `marriage`' : '') . ', `comment`, `created`, `hidden` FROM `players` WHERE `id` = ' . (int)$id)->fetch();
|
||||
}
|
||||
// SELECT query on database
|
||||
$this->data = $this->db->query('SELECT `id`, `name`, `account_id`, `group_id`, `sex`, `vocation`, `experience`, `level`, `maglevel`, `health`, `healthmax`, `mana`, `manamax`, `manaspent`, `soul`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`' . (fieldExist('lookaddons', 'players') ? ', `lookaddons`' : '') . ', `posx`, `posy`, `posz`, `cap`, `lastlogin`, `lastlogout`, `lastip`, `save`, `conditions`, `' . $__load['skull_time'] . '` as `skulltime`, `' . $__load['skull_type'] . '` as `skull`' . $__load['guild_info'] . ', `town_id`' . $__load['loss_experience'] . $__load['loss_items'] . ', `balance`' . ($__load['blessings'] ? ', `blessings`' : '') . ($__load['direction'] ? ', `direction`' : '') . ($__load['stamina'] ? ', `stamina`' : '') . ($__load['world_id'] ? ', `world_id`' : '') . ($__load['online'] ? ', `online`' : '') . ', `' . ($__load['deletion'] ? 'deletion' : 'deleted') . '`' . ($__load['promotion'] ? ', `promotion`' : '') . ($__load['marriage'] ? ', `marriage`' : '') . ', `comment`, `created`, `hidden` FROM `players` WHERE `id` = ' . (int)$id)->fetch();
|
||||
|
||||
if(!isset($this->data['guildnick']) || $this->data['guildnick'])
|
||||
$this->data['guildnick'] = '';
|
||||
@ -222,9 +247,9 @@ class OTS_Player extends OTS_Row_DAO
|
||||
$this->data['vocation'] += ($this->data['promotion'] * $config['vocations_amount']);
|
||||
}
|
||||
// loads skills
|
||||
if( $this->isLoaded() )
|
||||
if( $this->isLoaded() && $load_skills)
|
||||
{
|
||||
if(fieldExist('skill_fist', 'players')) {
|
||||
if($this->db->hasColumn('players', 'skill_fist')) {
|
||||
|
||||
$skill_ids = array(
|
||||
'skill_fist' => POT::SKILL_FIST,
|
||||
@ -252,7 +277,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
$this->skills[$id] = array('value' => $skills[$name], 'tries' => $skills[$name . '_tries']);
|
||||
}
|
||||
}
|
||||
else if(tableExist('player_skills')) {
|
||||
else if($this->db->hasTable('player_skills')) {
|
||||
foreach( $this->db->query('SELECT ' . $this->db->fieldName('skillid') . ', ' . $this->db->fieldName('value') . ', ' . $this->db->fieldName('count') . ' FROM ' . $this->db->tableName('player_skills') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'])->fetchAll() as $skill)
|
||||
{
|
||||
$this->skills[ $skill['skillid'] ] = array('value' => $skill['value'], 'tries' => $skill['count']);
|
||||
@ -272,7 +297,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
public function find($name)
|
||||
{
|
||||
// finds player's ID
|
||||
$id = $this->db->query('SELECT ' . $this->db->fieldName('id') . ' FROM ' . $this->db->tableName('players') . ' WHERE ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($name) )->fetch();
|
||||
$id = $this->db->query('SELECT `id` FROM `players` WHERE `name` = ' . $this->db->quote($name) )->fetch();
|
||||
|
||||
// if anything was found
|
||||
if( isset($id['id']) )
|
||||
@ -304,12 +329,12 @@ class OTS_Player extends OTS_Row_DAO
|
||||
public function save()
|
||||
{
|
||||
$skull_type = 'skull';
|
||||
if(fieldExist('skull_type', 'players')) {
|
||||
if($this->db->hasColumn('players', 'skull_type')) {
|
||||
$skull_type = 'skull_type';
|
||||
}
|
||||
|
||||
$skull_time = 'skulltime';
|
||||
if(fieldExist('skull_time', 'players')) {
|
||||
if($this->db->hasColumn('players', 'skull_time')) {
|
||||
$skull_time = 'skull_time';
|
||||
}
|
||||
|
||||
@ -350,37 +375,37 @@ class OTS_Player extends OTS_Row_DAO
|
||||
if( isset($this->data['id']) )
|
||||
{
|
||||
$loss = '';
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
if($this->db->hasColumn('players', 'loss_experience')) {
|
||||
$loss = ', `loss_experience` = ' . $this->data['loss_experience'] . ', `loss_mana` = ' . $this->data['loss_mana'] . ', `loss_skills` = ' . $this->data['loss_skills'];
|
||||
}
|
||||
|
||||
$loss_items = '';
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
if($this->db->hasColumn('players', 'loss_items')) {
|
||||
$loss_items = ', `loss_items` = ' . $this->data['loss_items'] . ', `loss_containers` = ' . $this->data['loss_containers'];
|
||||
}
|
||||
|
||||
$guild_info = '';
|
||||
if(!tableExist('guild_members') && fieldExist('guildnick', 'players')) {
|
||||
if(!$this->db->hasTable('guild_members') && $this->db->hasColumn('players', 'guildnick')) {
|
||||
$guild_info = ', `guildnick` = ' . $this->db->quote($this->data['guildnick']) . ', ' . $this->db->fieldName('rank_id') . ' = ' . $this->data['rank_id'];
|
||||
}
|
||||
|
||||
$direction = '';
|
||||
if(fieldExist('direction', 'players')) {
|
||||
if($this->db->hasColumn('players', 'direction')) {
|
||||
$direction = ', `direction` = ' . $this->db->quote($this->data['direction']);
|
||||
}
|
||||
|
||||
$blessings = '';
|
||||
if(fieldExist('blessings', 'players')) {
|
||||
if($this->db->hasColumn('players', 'blessings')) {
|
||||
$blessings = ', `blessings` = ' . $this->db->quote($this->data['blessings']);
|
||||
}
|
||||
|
||||
$stamina = '';
|
||||
if(fieldExist('stamina', 'players')) {
|
||||
if($this->db->hasColumn('players', 'stamina')) {
|
||||
$stamina = ', `stamina` = ' . $this->db->quote($this->data['stamina']);
|
||||
}
|
||||
|
||||
$lookaddons = '';
|
||||
if(fieldExist('lookaddons', 'players')) {
|
||||
if($this->db->hasColumn('players', 'lookaddons')) {
|
||||
$lookaddons = ', `lookaddons` = ' . $this->db->quote($this->data['lookaddons']);
|
||||
}
|
||||
|
||||
@ -392,56 +417,56 @@ class OTS_Player extends OTS_Row_DAO
|
||||
{
|
||||
$loss = '';
|
||||
$loss_data = '';
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
if($this->db->hasColumn('players', 'loss_experience')) {
|
||||
$loss = ', `loss_experience`, `loss_mana`, `loss_skills`';
|
||||
$loss_data = ', ' . $this->data['loss_experience'] . ', ' . $this->data['loss_mana'] . ', ' . $this->data['loss_skills'];
|
||||
}
|
||||
|
||||
$loss_items = '';
|
||||
$loss_items_data = '';
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
if($this->db->hasColumn('players', 'loss_items')) {
|
||||
$loss_items = ', `loss_items`, `loss_containers`';
|
||||
$loss_items_data = ', ' . $this->data['loss_items'] . ', ' . $this->data['loss_containers'];
|
||||
}
|
||||
|
||||
$guild_info = '';
|
||||
$guild_info_data = '';
|
||||
if(!tableExist('guild_members') && fieldExist('guildnick', 'players')) {
|
||||
if(!$this->db->hasTable('guild_members') && $this->db->hasColumn('players', 'guildnick')) {
|
||||
$guild_info = ', `guildnick`, `rank_id`';
|
||||
$guild_info_data = ', ' . $this->db->quote($this->data['guildnick']) . ', ' . $this->data['rank_id'];
|
||||
}
|
||||
|
||||
$promotion = '';
|
||||
$promotion_data = '';
|
||||
if(fieldExist('promotion', 'players')) {
|
||||
if($this->db->hasColumn('players', 'promotion')) {
|
||||
$promotion = ', `promotion`';
|
||||
$promotion_data = ', ' . $this->data['promotion'];
|
||||
}
|
||||
|
||||
$direction = '';
|
||||
$direction_data = '';
|
||||
if(fieldExist('direction', 'players')) {
|
||||
if($this->db->hasColumn('players', 'direction')) {
|
||||
$direction = ', `direction`';
|
||||
$direction_data = ', ' . $this->data['direction'];
|
||||
}
|
||||
|
||||
$blessings = '';
|
||||
$blessings_data = '';
|
||||
if(fieldExist('blessings', 'players')) {
|
||||
if($this->db->hasColumn('players', 'blessings')) {
|
||||
$blessings = ', `blessings`';
|
||||
$blessings_data = ', ' . $this->data['blessings'];
|
||||
}
|
||||
|
||||
$stamina = '';
|
||||
$stamina_data = '';
|
||||
if(fieldExist('stamina', 'players')) {
|
||||
if($this->db->hasColumn('players', 'stamina')) {
|
||||
$stamina = ', `stamina`';
|
||||
$stamina_data = ', ' . $this->data['stamina'];
|
||||
}
|
||||
|
||||
$lookaddons = '';
|
||||
$lookaddons_data = '';
|
||||
if(fieldExist('lookaddons', 'players')) {
|
||||
if($this->db->hasColumn('players', 'lookaddons')) {
|
||||
$lookaddons = ', `lookaddons`';
|
||||
$lookaddons_data = ', ' . $this->data['lookaddons'];
|
||||
}
|
||||
@ -453,7 +478,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
// updates skills - doesn't matter if we have just created character - trigger inserts new skills
|
||||
if(fieldExist('skill_fist', 'players')) { // tfs 1.0
|
||||
if($this->db->hasColumn('players', 'skill_fist')) { // tfs 1.0
|
||||
$set = '';
|
||||
|
||||
$skill_ids = array(
|
||||
@ -477,7 +502,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
|
||||
$skills = $this->db->query('UPDATE `players` SET ' . $set . ' WHERE `id` = ' . $this->data['id']);
|
||||
}
|
||||
else if(tableExist('player_skills')) {
|
||||
else if($this->db->hasTable('player_skills')) {
|
||||
foreach($this->skills as $id => $skill)
|
||||
{
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('player_skills') . ' SET ' . $this->db->fieldName('value') . ' = ' . $skill['value'] . ', ' . $this->db->fieldName('count') . ' = ' . $skill['tries'] . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('skillid') . ' = ' . $id);
|
||||
@ -513,7 +538,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
return $this->data['hidden'];
|
||||
return $this->data['hidden'] == 1;
|
||||
}
|
||||
|
||||
public function setHidden($hidden)
|
||||
@ -523,7 +548,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
|
||||
public function getMarriage()
|
||||
{
|
||||
if(!fieldExist('marriage', 'players'))
|
||||
if(!$this->db->hasColumn('players', 'marriage'))
|
||||
return '';
|
||||
|
||||
if( !isset($this->data['marriage']) )
|
||||
@ -725,7 +750,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
public function isDeleted()
|
||||
{
|
||||
$field = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($this->db->hasColumn('players', 'deletion'))
|
||||
$field = 'deletion';
|
||||
|
||||
if( !isset($this->data[$field]) )
|
||||
@ -743,7 +768,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
|
||||
public function isOnline()
|
||||
{
|
||||
if(tableExist('players_online')) // tfs 1.0
|
||||
if($this->db->hasTable('players_online')) // tfs 1.0
|
||||
{
|
||||
$query = $this->db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $this->data['id']);
|
||||
return $query->rowCount() > 0;
|
||||
@ -1833,7 +1858,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
public function loadRank()
|
||||
{
|
||||
$table = 'guild_membership';
|
||||
if(tableExist('guild_members'))
|
||||
if($this->db->hasTable('guild_members'))
|
||||
$table = 'guild_members';
|
||||
|
||||
$ranks = $this->db->query('SELECT `rank_id`, `nick` FROM `' . $table . '` WHERE `player_id` = ' . $this->db->quote($this->getID()))->fetch();
|
||||
@ -1869,11 +1894,11 @@ class OTS_Player extends OTS_Row_DAO
|
||||
public function setGuildNick($guildnick)
|
||||
{
|
||||
$this->data['guildnick'] = (string) $guildnick;
|
||||
if(tableExist('guild_members'))
|
||||
if($this->db->hasTable('guild_members'))
|
||||
$this->db->query('UPDATE `guild_members` SET `nick` = ' . $this->db->quote($this->data['guildnick']) . ' WHERE `player_id` = ' . $this->getId());
|
||||
else if(tableExist('guild_membership'))
|
||||
else if($this->db->hasTable('guild_membership'))
|
||||
$this->db->query('UPDATE `guild_membership` SET `nick` = ' . $this->db->quote($this->data['guildnick']) . ' WHERE `player_id` = ' . $this->getId());
|
||||
else if(fieldExist('guildnick', 'players'))
|
||||
else if($this->db->hasColumn('players', 'guildnick'))
|
||||
$this->db->query('UPDATE `players` SET `guildnick` = ' . $this->db->quote($this->data['guildnick']) . ' WHERE `id` = ' . $this->getId());
|
||||
}
|
||||
|
||||
@ -1908,21 +1933,21 @@ class OTS_Player extends OTS_Row_DAO
|
||||
public function getRank()
|
||||
{
|
||||
$rank_id = 0;
|
||||
if(tableExist('guild_members')) {
|
||||
if($this->db->hasTable('guild_members')) {
|
||||
$query = $this->db->query('SELECT `rank_id` FROM `guild_members` WHERE `player_id`= ' . $this->data['id'] . ' LIMIT 1;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$rank_id = $query['rank_id'];
|
||||
}
|
||||
}
|
||||
else if(tableExist('guild_membership')) {
|
||||
else if($this->db->hasTable('guild_membership')) {
|
||||
$query = $this->db->query('SELECT `rank_id` FROM `guild_membership` WHERE `player_id`= ' . $this->data['id'] . ' LIMIT 1;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$rank_id = $query['rank_id'];
|
||||
}
|
||||
}
|
||||
else if(fieldExist('rank_id', 'players')) {
|
||||
else if($this->db->hasColumn('players', 'rank_id')) {
|
||||
$query = $this->db->query('SELECT `rank_id` FROM `players` WHERE `id`= ' . $this->data['id'] . ';')->fetch();
|
||||
$rank_id = $query['rank_id'];
|
||||
}
|
||||
@ -1944,10 +1969,10 @@ class OTS_Player extends OTS_Row_DAO
|
||||
{
|
||||
if( isset($rank_id) && isset($guild)) {
|
||||
if($rank_id == 0) {
|
||||
if(tableExist('guild_membership')) {
|
||||
if($this->db->hasTable('guild_membership')) {
|
||||
$this->db->query('DELETE FROM `guild_membership` WHERE `player_id` = ' . $this->getId());
|
||||
}
|
||||
else if(tableExist('guild_members')) {
|
||||
else if($this->db->hasTable('guild_members')) {
|
||||
$this->db->query('DELETE FROM `guild_members` WHERE `player_id` = ' . $this->getId());
|
||||
}
|
||||
else {
|
||||
@ -1956,7 +1981,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(tableExist('guild_membership')) {
|
||||
if($this->db->hasTable('guild_membership')) {
|
||||
$query = $this->db->query('SELECT `player_id` FROM `guild_membership` WHERE `player_id` = ' . $this->getId() . ' LIMIT 1;');
|
||||
if($query->rowCount() == 1)
|
||||
$this->db->query('UPDATE `guild_membership` SET `guild_id` = ' . (int)$guild . ', `rank_id` = ' . (int)$rank_id . ' WHERE `player_id` = ' . $this->getId());
|
||||
@ -1964,7 +1989,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
$this->db->query('INSERT INTO `guild_membership` (`player_id`, `guild_id`, `rank_id`, `nick`) VALUES (' . $this->db->quote($this->getId()) . ', ' . $this->db->quote($guild) . ', ' . $this->db->quote($rank_id) . ', ' . $this->db->quote('') . ')');
|
||||
}
|
||||
}
|
||||
else if(tableExist('guild_members')) {
|
||||
else if($this->db->hasTable('guild_members')) {
|
||||
$query = $this->db->query('SELECT `player_id` FROM `guild_members` WHERE `player_id` = ' . $this->getId() . ' LIMIT 1;');
|
||||
if($query->rowCount() == 1)
|
||||
$this->db->query('UPDATE `guild_members` SET `rank_id` = ' . (int)$rank_id . ' WHERE `player_id` = ' . $this->getId());
|
||||
|
@ -296,7 +296,7 @@ class Validator
|
||||
}
|
||||
|
||||
//check if was namelocked previously
|
||||
if(tableExist('player_namelocks') && fieldExist('name', 'player_namelocks')) {
|
||||
if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) {
|
||||
$namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
|
||||
if($namelock->rowCount() > 0) {
|
||||
self::$lastError = 'Character with this name has been namelocked.';
|
||||
|
@ -58,13 +58,13 @@ else
|
||||
$t = isset($tmp[$ip]) ? $tmp[$ip] : NULL;
|
||||
}
|
||||
|
||||
$account_logged = $ots->createObject('Account');
|
||||
$account_logged = new OTS_Account();
|
||||
if(USE_ACCOUNT_NAME)
|
||||
$account_logged->find($login_account);
|
||||
else
|
||||
$account_logged->load($login_account);
|
||||
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
|
||||
if($account_logged->isLoaded() && encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $login_password) == $account_logged->getPassword()
|
||||
&& (!isset($t) || $t['attempts'] < 5)
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
if(!fieldExist('ordering', TABLE_PREFIX . 'hooks'))
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'hooks', 'ordering'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `ordering` INT(11) NOT NULL DEFAULT 0 AFTER `file`;");
|
||||
|
||||
if(!tableExist(TABLE_PREFIX . 'admin_menu'))
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'admin_menu'))
|
||||
$db->query("
|
||||
CREATE TABLE `myaac_admin_menu`
|
||||
(
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// add new item_id field for runes
|
||||
if(!fieldExist('item_id', TABLE_PREFIX . 'spells'))
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'spells', 'item_id'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` ADD `item_id` INT(11) NOT NULL DEFAULT 0 AFTER `conjure_count`;");
|
||||
|
||||
// change unique index from spell to name
|
||||
@ -12,7 +12,7 @@ $db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` ADD UNIQUE INDEX (`name`);"
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` MODIFY `type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - conjure, 3 - rune';");
|
||||
|
||||
// new items table
|
||||
if(!tableExist(TABLE_PREFIX . 'items'))
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'items'))
|
||||
$db->query("
|
||||
CREATE TABLE `" . TABLE_PREFIX . "items`
|
||||
(
|
||||
@ -25,7 +25,7 @@ CREATE TABLE `" . TABLE_PREFIX . "items`
|
||||
) ENGINE = MyISAM;");
|
||||
|
||||
// new weapons table
|
||||
if(!tableExist(TABLE_PREFIX . 'weapons'))
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'weapons'))
|
||||
$db->query("
|
||||
CREATE TABLE `" . TABLE_PREFIX . "weapons`
|
||||
(
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
if(fieldExist('spell', TABLE_PREFIX . 'spells'))
|
||||
if($db->hasColumn(TABLE_PREFIX . 'spells', 'spell'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN `spell`;");
|
||||
?>
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// change monsters.file_path field to loot
|
||||
if(fieldExist('file_path', TABLE_PREFIX . 'monsters')) {
|
||||
if($db->hasColumn(TABLE_PREFIX . 'monsters', 'file_path')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `file_path` `loot` VARCHAR(5000);");
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ $db->query("UPDATE `" . TABLE_PREFIX . "monsters` SET `loot` = '';");
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` DROP COLUMN `gfx_name`;");
|
||||
|
||||
// rename hide_creature to hidden
|
||||
if(fieldExist('hide_creature', TABLE_PREFIX . 'monsters')) {
|
||||
if($db->hasColumn(TABLE_PREFIX . 'monsters', 'hide_creature')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `hide_creature` `hidden` TINYINT(1) NOT NULL DEFAULT 0;");
|
||||
}
|
||||
?>
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
// add new forum.guild and forum.access fields
|
||||
if(!fieldExist('guild', TABLE_PREFIX . 'forum_boards')) {
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'forum_boards', 'guild')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `guild` TINYINT(1) NOT NULL DEFAULT 0 AFTER `closed`;");
|
||||
}
|
||||
|
||||
if(!fieldExist('access', TABLE_PREFIX . 'forum_boards')) {
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'forum_boards', 'access')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `access` TINYINT(1) NOT NULL DEFAULT 0 AFTER `guild`;");
|
||||
}
|
||||
?>
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if(!tableExist('myaac_menu')) {
|
||||
if(!$db->hasTable('myaac_menu')) {
|
||||
$db->query("
|
||||
CREATE TABLE `myaac_menu`
|
||||
(
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
if(!fieldExist('id', TABLE_PREFIX . 'monsters'))
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'id'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `id` int(11) NOT NULL AUTO_INCREMENT primary key FIRST;");
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
if(fieldExist('cities', TABLE_PREFIX . 'spells'))
|
||||
if($db->hasColumn(TABLE_PREFIX . 'spells', 'cities'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN cities;");
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
if(!fieldExist('enabled', TABLE_PREFIX . 'hooks'))
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'hooks', 'enabled'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `enabled` INT(1) NOT NULL DEFAULT 1;");
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
if(fieldExist('name', TABLE_PREFIX . 'screenshots'))
|
||||
if($db->hasColumn(TABLE_PREFIX . 'screenshots', 'name'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "screenshots` DROP `name`;");
|
||||
?>
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
if(tableExist(TABLE_PREFIX . 'forum_sections'))
|
||||
if($db->hasTable(TABLE_PREFIX . 'forum_sections'))
|
||||
$db->query('RENAME TABLE `' . TABLE_PREFIX . 'forum_sections` TO `' . TABLE_PREFIX . 'forum_boards`;');
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'forum_boards` WHERE `ordering` > 0;');
|
||||
|
@ -94,17 +94,18 @@ if($save) {
|
||||
{
|
||||
if($newchar_sex == "0")
|
||||
$char_to_copy->setLookType(136);
|
||||
$player = $ots->createObject('Player');
|
||||
|
||||
$player = new OTS_Player();
|
||||
$player->setName($newchar_name);
|
||||
$player->setAccount($account_logged);
|
||||
//$player->setGroupId($char_to_copy->getGroup()->getId());
|
||||
$player->setGroupId(1);
|
||||
$player->setSex($newchar_sex);
|
||||
$player->setVocation($char_to_copy->getVocation());
|
||||
if(fieldExist('promotion', 'players'))
|
||||
if($db->hasColumn('players', 'promotion'))
|
||||
$player->setPromotion($char_to_copy->getPromotion());
|
||||
|
||||
if(fieldExist('direction', 'players'))
|
||||
if($db->hasColumn('players', 'direction'))
|
||||
$player->setDirection($char_to_copy->getDirection());
|
||||
|
||||
$player->setConditions($char_to_copy->getConditions());
|
||||
@ -113,7 +114,7 @@ if($save) {
|
||||
$player->setRank($char_to_copy->getRank());
|
||||
}
|
||||
|
||||
if(fieldExist('lookaddons', 'players'))
|
||||
if($db->hasColumn('players', 'lookaddons'))
|
||||
$player->setLookAddons($char_to_copy->getLookAddons());
|
||||
|
||||
$player->setTownId($newchar_town);
|
||||
@ -141,12 +142,12 @@ if($save) {
|
||||
$player->setPosY(0);
|
||||
$player->setPosZ(0);
|
||||
$player->setStamina($config['otserv_version'] == TFS_03 ? 151200000 : 2520);
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
if($db->hasColumn('players', 'loss_experience')) {
|
||||
$player->setLossExperience($char_to_copy->getLossExperience());
|
||||
$player->setLossMana($char_to_copy->getLossMana());
|
||||
$player->setLossSkills($char_to_copy->getLossSkills());
|
||||
}
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
if($db->hasColumn('players', 'loss_items')) {
|
||||
$player->setLossItems($char_to_copy->getLossItems());
|
||||
$player->setLossContainers($char_to_copy->getLossContainers());
|
||||
}
|
||||
@ -162,7 +163,7 @@ if($save) {
|
||||
$player->find($newchar_name);
|
||||
|
||||
if($player->isLoaded()) {
|
||||
if(tableExist('player_skills')) {
|
||||
if($db->hasTable('player_skills')) {
|
||||
for($i=0; $i<7; $i++) {
|
||||
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $i);
|
||||
if($skillExists->rowCount() <= 0) {
|
||||
|
@ -27,7 +27,7 @@ if(isset($_POST['deletecharactersave']) && $_POST['deletecharactersave'] == 1) {
|
||||
//dont show table "delete character" again
|
||||
$show_form = false;
|
||||
//delete player
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$player->setCustomField('deletion', 1);
|
||||
else
|
||||
$player->setCustomField('deleted', 1);
|
||||
|
@ -17,7 +17,7 @@ if($config['account_country'])
|
||||
$groups = new OTS_Groups_List();
|
||||
|
||||
$show_form = true;
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
|
||||
if(!$logged)
|
||||
{
|
||||
if($action == "logout") {
|
||||
@ -74,7 +74,7 @@ $errors = array();
|
||||
$account_registered = '<b><font color="green">Yes</font></b>';
|
||||
}
|
||||
|
||||
$account_created = $account_logged->getCustomField("created");
|
||||
$account_created = $account_logged->getCreated();
|
||||
$account_email = $account_logged->getEMail();
|
||||
$email_new_time = $account_logged->getCustomField("email_new_time");
|
||||
if($email_new_time > 1)
|
||||
|
@ -78,7 +78,7 @@ else if(isset($_REQUEST['search_name'])) {
|
||||
|
||||
$groups = new OTS_Groups_List();
|
||||
if($id > 0) {
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($id);
|
||||
|
||||
if(isset($player) && $player->isLoaded() && isset($_POST['save'])) {// we want to save
|
||||
@ -95,7 +95,7 @@ if($id > 0) {
|
||||
//if(!Validator::newCharacterName($name)
|
||||
// echo_error(Validator::getLastError());
|
||||
|
||||
$player_db = $ots->createObject('Player');
|
||||
$player_db = new OTS_Player();
|
||||
$player_db->find($name);
|
||||
if($player_db->isLoaded() && $player->getName() != $name)
|
||||
echo_error('This name is already used. Please choose another name!');
|
||||
@ -149,7 +149,7 @@ if($id > 0) {
|
||||
verify_number($look_legs, 'Look legs', 11);
|
||||
$look_type = $_POST['look_type'];
|
||||
verify_number($look_type, 'Look type', 11);
|
||||
if(fieldExist('lookaddons', 'players')) {
|
||||
if($db->hasColumn('players', 'lookaddons')) {
|
||||
$look_addons = $_POST['look_addons'];
|
||||
verify_number($look_addons, 'Look addons', 11);
|
||||
}
|
||||
@ -188,7 +188,7 @@ if($id > 0) {
|
||||
$skull_time = $_POST['skull_time'];
|
||||
verify_number($skull_time, 'Skull time', 11);
|
||||
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
if($db->hasColumn('players', 'loss_experience')) {
|
||||
$loss_experience = $_POST['loss_experience'];
|
||||
verify_number($loss_experience, 'Loss experience', 11);
|
||||
$loss_mana = $_POST['loss_mana'];
|
||||
@ -201,13 +201,13 @@ if($id > 0) {
|
||||
verify_number($loss_items, 'Loss items', 11);
|
||||
}
|
||||
|
||||
if(fieldExist('blessings', 'players')) {
|
||||
if($db->hasColumn('players', 'blessings')) {
|
||||
$blessings = $_POST['blessings'];
|
||||
verify_number($blessings, 'Blessings', 2);
|
||||
}
|
||||
$balance = $_POST['balance'];
|
||||
verify_number($balance, 'Balance', 20);
|
||||
if(fieldExist('stamina', 'players')) {
|
||||
if($db->hasColumn('players', 'stamina')) {
|
||||
$stamina = $_POST['stamina'];
|
||||
verify_number($stamina, 'Stamina', 20);
|
||||
}
|
||||
@ -243,7 +243,7 @@ if($id > 0) {
|
||||
$player->setLookHead($look_head);
|
||||
$player->setLookLegs($look_legs);
|
||||
$player->setLookType($look_type);
|
||||
if(fieldExist('lookaddons', 'players'))
|
||||
if($db->hasColumn('players', 'lookaddons'))
|
||||
$player->setLookAddons($look_addons);
|
||||
$player->setPosX($pos_x);
|
||||
$player->setPosY($pos_y);
|
||||
@ -257,19 +257,19 @@ if($id > 0) {
|
||||
$player->setLastIP(ip2long($lastip));
|
||||
$player->setSkull($skull);
|
||||
$player->setSkullTime($skull_time);
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
if($db->hasColumn('players', 'loss_experience')) {
|
||||
$player->setLossExperience($loss_experience);
|
||||
$player->setLossMana($loss_mana);
|
||||
$player->setLossSkills($loss_skills);
|
||||
$player->setLossContainers($loss_containers);
|
||||
$player->setLossItems($loss_items);
|
||||
}
|
||||
if(fieldExist('blessings', 'players'))
|
||||
if($db->hasColumn('players', 'blessings'))
|
||||
$player->setBlessings($blessings);
|
||||
$player->setBalance($balance);
|
||||
if(fieldExist('stamina', 'players'))
|
||||
if($db->hasColumn('players', 'stamina'))
|
||||
$player->setStamina($stamina);
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$player->setCustomField('deletion', $deleted ? '1' : '0');
|
||||
else
|
||||
$player->setCustomField('deleted', $deleted ? '1' : '0');
|
||||
@ -399,7 +399,7 @@ $account = $player->getAccount();
|
||||
Head:<input type="text" name="look_head" size="2" maxlength="11" value="<?php echo $player->getLookHead(); ?>" />
|
||||
Legs:<input type="text" name="look_legs" size="2" maxlength="11" value="<?php echo $player->getLookLegs(); ?>" />
|
||||
Type:<input type="text" name="look_type" size="2" maxlength="11" value="<?php echo $player->getLookType(); ?>" />
|
||||
<?php if(fieldExist('lookaddons', 'players')): ?>
|
||||
<?php if($db->hasColumn('lookaddons', 'players')): ?>
|
||||
Addons:<input type="text" name="look_addons" size="2" maxlength="11" value="<?php echo $player->getLookAddons(); ?>" />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
@ -472,7 +472,7 @@ $account = $player->getAccount();
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if(fieldExist('loss_experience', 'players')): ?>
|
||||
<?php if($db->hasColumn('players', 'loss_experience')): ?>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<table>
|
||||
@ -500,14 +500,14 @@ $account = $player->getAccount();
|
||||
<td colspan="2">
|
||||
<table>
|
||||
<tr style="background-color: transparent;">
|
||||
<?php if(fieldExist('blessings', 'players')): ?>
|
||||
<?php if($db->hasColumn('players', 'blessings')): ?>
|
||||
<td>Blessings:</td>
|
||||
<td><input type="text" name="blessings" size="2" maxlength="2" value="<?php echo $player->getBlessings(); ?>" /></td>
|
||||
<?php endif; ?>
|
||||
<td>Balance:</td>
|
||||
<td><input type="text" name="balance" size="16" maxlength="20" value="<?php echo $player->getBalance(); ?>" /></td>
|
||||
|
||||
<?php if(fieldExist('stamina', 'players')): ?>
|
||||
<?php if($db->hasColumn('players', 'stamina')): ?>
|
||||
<td>Stamina:</td>
|
||||
<td><input type="text" name="stamina" size="16" maxlength="20" value="<?php echo $player->getStamina(); ?>" /></td>
|
||||
<?php endif; ?>
|
||||
@ -520,10 +520,10 @@ $account = $player->getAccount();
|
||||
<table>
|
||||
<tr style="background-color: transparent;">
|
||||
<td><label for="deleted">Deleted:</label></td>
|
||||
<td><input type="checkbox" name="deleted" id="deleted" value="true" <?php echo ($player->getCustomField(fieldExist('deletion', 'players') ? 'deletion' : 'deleted') == '1' ? ' checked' : ''); ?>/></td>
|
||||
<td><input type="checkbox" name="deleted" id="deleted" value="true" <?php echo ($player->getCustomField($db->hasColumn('deletion', 'players') ? 'deletion' : 'deleted') == '1' ? ' checked' : ''); ?>/></td>
|
||||
|
||||
<td><label for="hidden">Hidden:</label></td>
|
||||
<td><input type="checkbox" name="hidden" id="hidden" value="true" <?php echo ($player->getCustomField('hidden') == 1 ? ' checked' : ''); ?>/></td>
|
||||
<td><input type="checkbox" name="hidden" id="hidden" value="true" <?php echo ($player->isHidden() ? ' checked' : ''); ?>/></td>
|
||||
|
||||
<td>Created:</td>
|
||||
<td><input type="text" name="created" id="created" value="<?php echo $player->getCustomField('created'); ?>"/></td>
|
||||
|
@ -170,7 +170,7 @@ function getPlayerNameByAccount($id)
|
||||
global $vowels, $ots, $db;
|
||||
if(is_numeric($id))
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($id);
|
||||
if($player->isLoaded())
|
||||
return $player->getName();
|
||||
|
@ -27,7 +27,7 @@ function retrieve_former_name($name)
|
||||
{
|
||||
global $oldName, $db;
|
||||
|
||||
if(tableExist('player_namelocks') && fieldExist('name', 'player_namelocks')) {
|
||||
if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) {
|
||||
$newNameSql = $db->query('SELECT `name`, `new_name` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
|
||||
if($newNameSql->rowCount() > 0) // namelocked
|
||||
{
|
||||
@ -79,24 +79,27 @@ if($player->isLoaded() && !$player->isDeleted())
|
||||
$rows = 0;
|
||||
|
||||
if($config['characters']['outfit'])
|
||||
$outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
|
||||
$outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . ($db->hasColumn('players', 'lookaddons') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
|
||||
|
||||
$flag = '';
|
||||
if($config['account_country'])
|
||||
$flag = getFlagImage($account->getCustomField('country'));
|
||||
$flag = getFlagImage($account->getCountry());
|
||||
|
||||
$player_sex = 'Unknown';
|
||||
if(isset($config['genders'][$player->getSex()]))
|
||||
$player_sex = strtolower($config['genders'][$player->getSex()]);
|
||||
|
||||
$marriage = new OTS_Player();
|
||||
$marriage->load($player->getMarriage());
|
||||
|
||||
$marital_status = 'single';
|
||||
if($marriage->isLoaded())
|
||||
$marital_status = 'married to ' . getPlayerLink($marriage->getName());
|
||||
|
||||
$frags_enabled = tableExist('player_killers') && $config['characters']['frags'];
|
||||
$marriage_id = $player->getMarriage();
|
||||
if($marriage_id > 0) {
|
||||
$marriage = new OTS_Player();
|
||||
$marriage->load($player->getMarriage(), array('id', 'name'), false);
|
||||
if($marriage->isLoaded()) {
|
||||
$marital_status = 'married to ' . getPlayerLink($marriage->getName());
|
||||
}
|
||||
}
|
||||
|
||||
$frags_enabled = $db->hasTable('player_killers') && $config['characters']['frags'];
|
||||
$frags_count = 0;
|
||||
if($frags_enabled) {
|
||||
$query = $db->query(
|
||||
@ -114,14 +117,14 @@ if($player->isLoaded() && !$player->isDeleted())
|
||||
}
|
||||
|
||||
$town_field = 'town';
|
||||
if(fieldExist('town_id', 'houses'))
|
||||
if($db->hasColumn('houses', 'town_id'))
|
||||
$town_field = 'town_id';
|
||||
else if(fieldExist('townid', 'houses'))
|
||||
else if($db->hasColumn('houses', 'townid'))
|
||||
$town_field = 'townid';
|
||||
else if(!fieldExist('town', 'houses'))
|
||||
else if(!$db->hasColumn('houses', 'town'))
|
||||
$town_field = false;
|
||||
|
||||
if(fieldExist('name', 'houses')) {
|
||||
if($db->hasColumn('houses', 'name')) {
|
||||
$house = $db->query('SELECT `id`, `paid`, `name`' . ($town_field != false ? ', `' . $town_field . '` as `town`' : '') . ' FROM `houses` WHERE `owner` = '.$player->getId())->fetch();
|
||||
if(isset($house['id']))
|
||||
{
|
||||
@ -143,7 +146,7 @@ if($player->isLoaded() && !$player->isDeleted())
|
||||
|
||||
if($config['characters']['skills'])
|
||||
{
|
||||
if(fieldExist('skill_fist', 'players')) {// tfs 1.0+
|
||||
if($db->hasColumn('players', 'skill_fist')) {// tfs 1.0+
|
||||
$skills_db = $db->query('SELECT `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing` FROM `players` WHERE `id` = ' . $player->getId())->fetch();
|
||||
|
||||
$skill_ids = array(
|
||||
@ -230,7 +233,7 @@ if($player->isLoaded() && !$player->isDeleted())
|
||||
|
||||
$dead_add_content = '';
|
||||
$deaths = array();
|
||||
if(tableExist('killers')) {
|
||||
if($db->hasTable('killers')) {
|
||||
$player_deaths = $db->query('SELECT `id`, `date`, `level` FROM `player_deaths` WHERE `player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,10;');
|
||||
if(count($player_deaths))
|
||||
{
|
||||
@ -284,7 +287,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
|
||||
}
|
||||
else {
|
||||
$mostdamage = '';
|
||||
if(fieldExist('mostdamage_by', 'player_deaths'))
|
||||
if($db->hasColumn('player_deaths', 'mostdamage_by'))
|
||||
$mostdamage = ', `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`';
|
||||
$deaths_db = $db->query('SELECT
|
||||
`player_id`, `time`, `level`, `killed_by`, `is_player`' . $mostdamage . '
|
||||
@ -345,15 +348,15 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
|
||||
$signature_url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . urlencode($player->getName()) . '.png';
|
||||
}
|
||||
|
||||
$hidden = $player->getCustomField('hidden');
|
||||
if($hidden != 1) {
|
||||
$hidden = $player->isHidden();
|
||||
if(!$hidden) {
|
||||
// check if account has been banned
|
||||
$bannedUntil = '';
|
||||
$banned = array();
|
||||
if(tableExist('account_bans'))
|
||||
if($db->hasTable('account_bans'))
|
||||
$banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and (`expires_at` > ' . time() . ' OR `expires_at` = -1);');
|
||||
else if (tableExist('bans')) {
|
||||
if (fieldExist('expires', 'bans'))
|
||||
else if ($db->hasTable('bans')) {
|
||||
if ($db->hasColumn('bans', 'expires'))
|
||||
$banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and (`expires` > ' . time() . ' OR `expires` = -1);');
|
||||
else
|
||||
$banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and (`time` > ' . time() . ' OR `time` = -1);');
|
||||
@ -362,8 +365,16 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
|
||||
$bannedUntil = $ban['expires'];
|
||||
}
|
||||
|
||||
$account_players = $account->getPlayersList();
|
||||
$account_players->orderBy('name');
|
||||
$account_players = array();
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `account_id` = ' . $account->getId() . ' ORDER BY `name`')->fetchAll();
|
||||
foreach($query as $p) {
|
||||
$_player = new OTS_Player();
|
||||
$fields = array('id', 'name', 'vocation', 'level', 'online', 'deleted', 'hidden');
|
||||
$_player->load($p['id'], $fields, false);
|
||||
if($_player->isLoaded()) {
|
||||
$account_players[] = $_player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo $twig->render('characters.html.twig', array(
|
||||
@ -373,7 +384,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
|
||||
'flag' => $flag,
|
||||
'oldName' => $oldName,
|
||||
'sex' => $player_sex,
|
||||
'marriage_enabled' => $config['characters']['marriage_info'] && fieldExist('marriage', 'players'),
|
||||
'marriage_enabled' => $config['characters']['marriage_info'] && $db->hasColumn('players', 'marriage'),
|
||||
'marital_status' => $marital_status,
|
||||
'vocation' => $config['vocations'][$player->getVocation()],
|
||||
'frags_enabled' => $frags_enabled,
|
||||
@ -414,11 +425,11 @@ else
|
||||
$search_errors = array();
|
||||
|
||||
$promotion = '';
|
||||
if(fieldExist('promotion', 'players'))
|
||||
if($db->hasColumn('players', 'promotion'))
|
||||
$promotion = ', `promotion`';
|
||||
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$query = $db->query('SELECT `name`, `level`, `vocation`' . $promotion . ' FROM `players` WHERE `name` LIKE ' . $db->quote('%' . $name . '%') . ' AND ' . $deleted . ' != 1;');
|
||||
|
@ -121,7 +121,7 @@ if($save)
|
||||
else
|
||||
$new_account->create(NULL, $account_id);
|
||||
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
|
||||
if($config_salt_enabled)
|
||||
{
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
@ -144,7 +144,7 @@ if($save)
|
||||
}
|
||||
|
||||
if($config['account_premium_days'] && $config['account_premium_days'] > 0) {
|
||||
if(fieldExist('premend', 'accounts')) { // othire
|
||||
if($db->hasColumn('accounts', 'premend')) { // othire
|
||||
$new_account->setCustomField('premend', time() + $config['account_premium_days'] * 86400);
|
||||
}
|
||||
else { // rest
|
||||
|
@ -38,6 +38,7 @@ if(isset($posts[0]['player_id'])) {
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
|
||||
}
|
||||
|
||||
$lookaddons = $db-hasColumn('players', 'lookaddons');
|
||||
$groups = new OTS_Groups_List();
|
||||
foreach($posts as &$post)
|
||||
{
|
||||
@ -50,7 +51,7 @@ foreach($posts as &$post)
|
||||
}
|
||||
|
||||
if($config['characters']['outfit']) {
|
||||
$post['outfit'] = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
|
||||
$post['outfit'] = $config['outfit_images_url'] . '?id=' . $player->getLookType() . ($lookaddons ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
|
||||
}
|
||||
|
||||
$groupName = '';
|
||||
|
@ -11,12 +11,12 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Guilds';
|
||||
|
||||
if(tableExist('guild_members'))
|
||||
if($db->hasTable('guild_members'))
|
||||
define('GUILD_MEMBERS_TABLE', 'guild_members');
|
||||
else
|
||||
define('GUILD_MEMBERS_TABLE', 'guild_membership');
|
||||
|
||||
define('MOTD_EXISTS', fieldExist('motd', 'guilds'));
|
||||
define('MOTD_EXISTS', $db->hasColumn('guilds', 'motd'));
|
||||
|
||||
//show list of guilds
|
||||
if(empty($action)) {
|
||||
|
@ -22,7 +22,7 @@ if(!Validator::guildName($guild_name)) {
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
|
@ -23,7 +23,7 @@ if(empty($errors)) {
|
||||
if(!$logged) {
|
||||
$errors[] = 'You are not logged.';
|
||||
}
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
|
@ -16,7 +16,7 @@ if(!Validator::guildName($guild_name)) {
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
|
@ -21,7 +21,7 @@ else {
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded())
|
||||
$errors[] = 'Guild with name <b>' . $guild_name . '</b> doesn\'t exist.';
|
||||
@ -75,7 +75,7 @@ if($guild_vice)
|
||||
$ranks[$rid]['1'] = $rank->getName();
|
||||
$rid++;
|
||||
|
||||
if(fieldExist('rank_id', 'players'))
|
||||
if($db->hasColumn('players', 'rank_id'))
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
|
||||
else
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `' . GUILD_MEMBERS_TABLE . '`.`rank_id` as `rank_id` FROM `players`, `' . GUILD_MEMBERS_TABLE . '` WHERE `' . GUILD_MEMBERS_TABLE . '`.`rank_id` = ' . $rank->getId() . ' AND `players`.`id` = `' . GUILD_MEMBERS_TABLE . '`.`player_id` ORDER BY `name`;');
|
||||
@ -107,7 +107,7 @@ if($guild_vice)
|
||||
$new_rank = (int) $_REQUEST['rankid'];
|
||||
if(!Validator::characterName($player_name))
|
||||
$change_errors[] = 'Invalid player name format.';
|
||||
$rank = $ots->createObject('GuildRank');
|
||||
$rank = new OTS_GuildRank();
|
||||
$rank->load($new_rank);
|
||||
if(!$rank->isLoaded())
|
||||
$change_errors[] = 'Rank with this ID doesn\'t exist.';
|
||||
@ -115,7 +115,7 @@ if($guild_vice)
|
||||
$change_errors[] = 'You can\'t set ranks with equal or higher level than your.';
|
||||
if(empty($change_errors))
|
||||
{
|
||||
$player_to_change = $ots->createObject('Player');
|
||||
$player_to_change = new OTS_Player();
|
||||
$player_to_change->find($player_name);
|
||||
if(!$player_to_change->isLoaded())
|
||||
$change_errors[] = 'Player with name '.$player_name.'</b> doesn\'t exist.';
|
||||
@ -163,7 +163,7 @@ if($guild_vice)
|
||||
$ranks[$rid]['1'] = $rank->getName();
|
||||
$rid++;
|
||||
|
||||
if(fieldExist('rank_id', 'players'))
|
||||
if($db->hasColumn('players', 'rank_id'))
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
|
||||
else
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `' . GUILD_MEMBERS_TABLE . '`.`rank_id` as `rank_id` FROM `players`, `' . GUILD_MEMBERS_TABLE . '` WHERE `' . GUILD_MEMBERS_TABLE . '`.`rank_id` = ' . $rank->getId() . ' AND `players`.`id` = `' . GUILD_MEMBERS_TABLE . '`.`player_id` ORDER BY `name`;');
|
||||
@ -173,7 +173,7 @@ if($guild_vice)
|
||||
{
|
||||
foreach($players_with_rank as $result)
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($result['id']);
|
||||
if(!$player->isLoaded())
|
||||
continue;
|
||||
|
@ -54,7 +54,7 @@ if($todo == 'save')
|
||||
}
|
||||
|
||||
if(empty($guild_errors)) {
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
if(!$player->isLoaded()) {
|
||||
$guild_errors[] = 'Character <b>'.$name.'</b> doesn\'t exist.';
|
||||
@ -64,7 +64,7 @@ if($todo == 'save')
|
||||
|
||||
if(empty($guild_errors))
|
||||
{
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if($guild->isLoaded()) {
|
||||
$guild_errors[] = 'Guild <b>'.$guild_name.'</b> already exist. Select other name.';
|
||||
|
@ -17,7 +17,7 @@ if(!Validator::guildName($guild_name)) {
|
||||
$guild_errors[] = Validator::getLastError();
|
||||
}
|
||||
if(empty($guild_errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$guild_errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
@ -55,7 +55,7 @@ if(empty($guild_errors)) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fieldExist('rank_id', 'players'))
|
||||
if($db->hasColumn('players', 'rank_id'))
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
|
||||
else
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `' . GUILD_MEMBERS_TABLE . '`.`rank_id` as `rank_id` FROM `players`, `' . GUILD_MEMBERS_TABLE . '` WHERE `' . GUILD_MEMBERS_TABLE . '`.`rank_id` = ' . $rank->getId() . ' AND `players`.`id` = `' . GUILD_MEMBERS_TABLE . '`.`player_id` ORDER BY `name`;');
|
||||
|
@ -22,7 +22,7 @@ if(!Validator::guildName($guild_name)) {
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
|
@ -27,7 +27,7 @@ if(!Validator::characterName($name)) {
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$guilds_list = $ots->createObject('Guilds_List');
|
||||
$guilds_list = new OTS_Guilds_List();
|
||||
|
||||
if(!isset($_REQUEST['preview']))
|
||||
$_REQUEST['preview'] = 1;
|
||||
|
@ -17,7 +17,7 @@ if(!Validator::guildName($guild_name)) {
|
||||
}
|
||||
|
||||
if(empty($guild_errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$guild_errors[] = "Guild with name <b>" . $guild_name . "</b> doesn't exist.";
|
||||
|
@ -16,7 +16,7 @@ if(!Validator::guildName($guild_name)) {
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
|
@ -16,7 +16,7 @@ if(!Validator::guildName($guild_name))
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded())
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
@ -110,9 +110,9 @@ else
|
||||
$showed_players = 1;
|
||||
foreach($rank_list as $rank)
|
||||
{
|
||||
if(tableExist(GUILD_MEMBERS_TABLE))
|
||||
if($db->hasTable(GUILD_MEMBERS_TABLE))
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `' . GUILD_MEMBERS_TABLE . '`.`rank_id` as `rank_id` FROM `players`, `' . GUILD_MEMBERS_TABLE . '` WHERE `' . GUILD_MEMBERS_TABLE . '`.`rank_id` = ' . $rank->getId() . ' AND `players`.`id` = `' . GUILD_MEMBERS_TABLE . '`.`player_id` ORDER BY `name`;');
|
||||
else if(fieldExist('rank_id', 'players'))
|
||||
else if($db->hasColumn('players', 'rank_id'))
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
|
||||
|
||||
$players_with_rank_number = $players_with_rank->rowCount();
|
||||
@ -127,7 +127,7 @@ else
|
||||
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>';
|
||||
foreach($players_with_rank as $result)
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($result['id']);
|
||||
if(!$player->isLoaded())
|
||||
continue;
|
||||
|
@ -85,22 +85,22 @@ else
|
||||
}
|
||||
|
||||
$promotion = '';
|
||||
if(fieldExist('promotion', 'players'))
|
||||
if($db->hasColumn('players', 'promotion'))
|
||||
$promotion = ',promotion';
|
||||
|
||||
$online = '';
|
||||
if(fieldExist('online', 'players'))
|
||||
if($db->hasColumn('players', 'online'))
|
||||
$online = ',online';
|
||||
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$outfit_addons = false;
|
||||
$outfit = '';
|
||||
if($config['highscores_outfit']) {
|
||||
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
|
||||
if(fieldExist('lookaddons', 'players')) {
|
||||
if($db->hasColumn('players', 'lookaddons')) {
|
||||
$outfit .= ', lookaddons';
|
||||
$outfit_addons = true;
|
||||
}
|
||||
@ -108,7 +108,7 @@ if($config['highscores_outfit']) {
|
||||
|
||||
$offset = $_page * $config['highscores_length'];
|
||||
if($skill <= POT::SKILL_LAST) { // skills
|
||||
if(fieldExist('skill_fist', 'players')) {// tfs 1.0
|
||||
if($db->hasColumn('players', 'skill_fist')) {// tfs 1.0
|
||||
$skill_ids = array(
|
||||
POT::SKILL_FIST => 'skill_fist',
|
||||
POT::SKILL_CLUB => 'skill_club',
|
||||
@ -119,10 +119,10 @@ if($skill <= POT::SKILL_LAST) { // skills
|
||||
POT::SKILL_FISH => 'skill_fishing',
|
||||
);
|
||||
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id > 6 AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT 101 OFFSET '.$offset);
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,vocation' . $promotion . $outfit . ', ' . $skill_ids[$skill] . ' as value FROM accounts,players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND accounts.id = players.account_id ORDER BY ' . $skill_ids[$skill] . ' DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id > 6 AND players.id = player_skills.player_id AND player_skills.skillid = '.$skill.' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',value,level,vocation' . $promotion . $outfit . ' FROM accounts,players,player_skills WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id = player_skills.player_id AND player_skills.skillid = '.$skill.' AND accounts.id = players.account_id ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else if($skill == 666 && $config['otserv_version'] == TFS_03) // frags
|
||||
{
|
||||
@ -131,15 +131,15 @@ else if($skill == 666 && $config['otserv_version'] == TFS_03) // frags
|
||||
' WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 AND players.group_id < '.$config['highscores_groups_hidden'].' '.$add_sql.' AND players.id = player_killers.player_id AND accounts.id = players.account_id' .
|
||||
' GROUP BY `player_id`' .
|
||||
' ORDER BY value DESC' .
|
||||
' LIMIT 101 OFFSET '.$offset);
|
||||
' LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
if($skill == POT::SKILL__MAGLEVEL) {
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND players.id > 6 AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',maglevel,level,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND accounts.id = players.account_id ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
}
|
||||
else { // level
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND players.id > 6 AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);
|
||||
$skills = $db->query('SELECT accounts.country, players.id,players.name' . $online . ',level,experience,vocation' . $promotion . $outfit . ' FROM accounts, players WHERE players.id NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND players.' . $deleted . ' = 0 '.$add_sql.' AND players.group_id < '.$config['highscores_groups_hidden'].' AND accounts.id = players.account_id ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset)->fetchAll();
|
||||
$list = 'experience';
|
||||
}
|
||||
}
|
||||
@ -174,13 +174,25 @@ $show_link_to_next_page = false;
|
||||
$i = 0;
|
||||
|
||||
$online_exist = false;
|
||||
if(fieldExist('online', 'players'))
|
||||
if($db->hasColumn('players', 'online'))
|
||||
$online_exist = true;
|
||||
|
||||
$players = array();
|
||||
foreach($skills as $player) {
|
||||
$players[] = $player['id'];
|
||||
}
|
||||
|
||||
if($db->hasTable('players_online')) {
|
||||
$query = $db->query('SELECT `player_id`, 1 FROM `players_online` WHERE `player_id` IN (' . implode(', ', $players) . ')')->fetchAll();
|
||||
foreach($query as $t) {
|
||||
$is_online[$t['player_id']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($skills as $player)
|
||||
{
|
||||
if(!$online_exist) {
|
||||
$query = $db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $player['id']);
|
||||
$player['online'] = $query->rowCount() > 0;
|
||||
if(isset($is_online)) {
|
||||
$player['online'] = (isset($is_online[$player['id']]) ? 1 : 0);
|
||||
}
|
||||
|
||||
if(++$i <= $config['highscores_length'])
|
||||
|
@ -11,7 +11,7 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Houses';
|
||||
|
||||
if(!fieldExist('name', 'houses')) {
|
||||
if(!$db->hasColumn('houses', 'name')) {
|
||||
echo 'Houses list is not available on this server.';
|
||||
return;
|
||||
}
|
||||
@ -87,7 +87,7 @@ $type = '';
|
||||
$who = $guild->getName();
|
||||
else
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player = new OTS_Player();
|
||||
$player->load($houseOwner);
|
||||
if($player->isLoaded())
|
||||
{
|
||||
@ -107,7 +107,7 @@ $type = '';
|
||||
else
|
||||
{
|
||||
echo '
|
||||
Here you can see the list of all available houses, flats' . (tableExist('guild', 'houses') ? ' or guildhall' : '') . '.
|
||||
Here you can see the list of all available houses, flats' . ($db->hasTable('houses', 'guild') ? ' or guildhall' : '') . '.
|
||||
Click on any view button to get more information about a house or adjust
|
||||
the search criteria and start a new search.<br/><br/>';
|
||||
if(isset($config['lua']['houseCleanOld'])) {
|
||||
@ -134,7 +134,7 @@ $type = '';
|
||||
echo '<br/>';
|
||||
|
||||
if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order'])
|
||||
&& (isset($_POST['type']) || !tableExist('guild', 'houses')))
|
||||
&& (isset($_POST['type']) || !$db->hasTable('houses', 'guild')))
|
||||
{
|
||||
$order = $_POST['order'];
|
||||
$orderby = '`name`';
|
||||
@ -147,9 +147,9 @@ $type = '';
|
||||
}
|
||||
|
||||
$town = 'town';
|
||||
if(fieldExist('town_id', 'houses'))
|
||||
if($db->hasColumn('houses', 'town_id'))
|
||||
$town = 'town_id';
|
||||
else if(fieldExist('townid', 'houses'))
|
||||
else if($db->hasColumn('houses', 'townid'))
|
||||
$town = 'townid';
|
||||
|
||||
$whereby = '`' . $town . '` = ' .(int)$_POST['town'];
|
||||
@ -158,7 +158,7 @@ $type = '';
|
||||
$whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0';
|
||||
|
||||
$type = isset($_POST['type']) ? $_POST['type'] : NULL;
|
||||
if($type == 'guildhalls' && !fieldExist('guild', 'houses'))
|
||||
if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild'))
|
||||
$type = 'all';
|
||||
|
||||
if(!empty($type) && $type != 'all')
|
||||
@ -202,7 +202,7 @@ $type = '';
|
||||
<TD WIDTH="10%"><NOBR>'.$house['size'].' sqm</TD>
|
||||
<TD WIDTH="10%"><NOBR>'.$house['rent'].' gold</TD>
|
||||
<TD WIDTH="40%"><NOBR>';
|
||||
if(fieldExist('guild', 'houses') && $house['guild'] == 1 && $house['owner'] != 0)
|
||||
if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0)
|
||||
{
|
||||
$guild = new OTS_Guild();
|
||||
$guild->load($house['owner']);
|
||||
@ -285,7 +285,7 @@ $type = '';
|
||||
</TD>
|
||||
</TR>';
|
||||
|
||||
if(fieldExist('guild', 'houses')) {
|
||||
if($db->hasColumn('houses', 'guild')) {
|
||||
echo '
|
||||
<TR BGCOLOR='.$config['darkborder'].'>
|
||||
<TD VALIGN=top>
|
||||
|
@ -13,9 +13,9 @@ $title = 'Last Kills';
|
||||
|
||||
$players_deaths_count = 0;
|
||||
$players_rows = '';
|
||||
if(tableExist('player_killers')) // tfs 0.3
|
||||
if($db->hasTable('player_killers')) // tfs 0.3
|
||||
{
|
||||
$players_deaths = $db->query('SELECT `player_deaths`.`id`, `player_deaths`.`date`, `player_deaths`.`level`, `players`.`name`' . (fieldExist('world_id', 'players') ? ', `players`.`world_id`' : '') . ' FROM `player_deaths` LEFT JOIN `players` ON `player_deaths`.`player_id` = `players`.`id` ORDER BY `date` DESC LIMIT 0, ' . $config['last_kills_limit']);
|
||||
$players_deaths = $db->query('SELECT `player_deaths`.`id`, `player_deaths`.`date`, `player_deaths`.`level`, `players`.`name`' . ($db->hasColumn('players', 'world_id') ? ', `players`.`world_id`' : '') . ' FROM `player_deaths` LEFT JOIN `players` ON `player_deaths`.`player_id` = `players`.`id` ORDER BY `date` DESC LIMIT 0, ' . $config['last_kills_limit']);
|
||||
if(!empty($players_deaths))
|
||||
{
|
||||
foreach($players_deaths as $death)
|
||||
|
@ -17,7 +17,7 @@ if(!$config['mail_enabled'])
|
||||
return;
|
||||
}
|
||||
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
$config_salt_enabled = $db->hasColumn('accounts', 'salt');
|
||||
$action_type = isset($_REQUEST['action_type']) ? $_REQUEST['action_type'] : '';
|
||||
if($action == '')
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ if($config['account_country'])
|
||||
require(SYSTEM . 'countries.conf.php');
|
||||
|
||||
$promotion = '';
|
||||
if(fieldExist('promotion', 'players'))
|
||||
if($db->hasColumn('players', 'promotion'))
|
||||
$promotion = '`promotion`,';
|
||||
$order = isset($_GET['order']) ? $_GET['order'] : 'name';
|
||||
if(!in_array($order, array('country', 'name', 'level', 'vocation')))
|
||||
@ -26,12 +26,12 @@ else if($order == 'vocation')
|
||||
$order = $promotion . 'vocation ASC';
|
||||
|
||||
$skull_type = 'skull';
|
||||
if(fieldExist('skull_type', 'players')) {
|
||||
if($db->hasColumn('players', 'skull_type')) {
|
||||
$skull_type = 'skull_type';
|
||||
}
|
||||
|
||||
$skull_time = 'skulltime';
|
||||
if(fieldExist('skull_time', 'players')) {
|
||||
if($db->hasColumn('players', 'skull_time')) {
|
||||
$skull_time = 'skull_time';
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ $outfit_addons = false;
|
||||
$outfit = '';
|
||||
if($config['online_outfit']) {
|
||||
$outfit = ', lookbody, lookfeet, lookhead, looklegs, looktype';
|
||||
if(fieldExist('lookaddons', 'players')) {
|
||||
if($db->hasColumn('players', 'lookaddons')) {
|
||||
$outfit .= ', lookaddons';
|
||||
$outfit_addons = true;
|
||||
}
|
||||
@ -51,7 +51,7 @@ if($config['online_vocations']) {
|
||||
$vocs[$id] = 0;
|
||||
}
|
||||
|
||||
if(tableExist('players_online')) // tfs 1.0
|
||||
if($db->hasTable('players_online')) // tfs 1.0
|
||||
$playersOnline = $db->query('SELECT `accounts`.`country`, `players`.`name`, `level`, `vocation`' . $outfit . ', `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull` FROM `accounts`, `players`, `players_online` WHERE `players`.`id` = `players_online`.`player_id` AND `accounts`.`id` = `players`.`account_id` ORDER BY ' . $order);
|
||||
else
|
||||
$playersOnline = $db->query('SELECT `accounts`.`country`, `players`.`name`, `level`, `vocation`' . $outfit . ', ' . $promotion . ' `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull` FROM `accounts`, `players` WHERE `players`.`online` > 0 AND `accounts`.`id` = `players`.`account_id` ORDER BY ' . $order);
|
||||
@ -99,14 +99,14 @@ if($players > 0)
|
||||
if($config['online_record'])
|
||||
{
|
||||
$timestamp = false;
|
||||
if(tableExist('server_record')) {
|
||||
if($db->hasTable('server_record')) {
|
||||
$query =
|
||||
$db->query(
|
||||
'SELECT `record`, `timestamp` FROM `server_record` WHERE `world_id` = ' . (int)$config['lua']['worldId'] .
|
||||
' ORDER BY `record` DESC LIMIT 1');
|
||||
$timestamp = true;
|
||||
}
|
||||
else if(tableExist('server_config')) { // tfs 1.0
|
||||
else if($db->hasTable('server_config')) { // tfs 1.0
|
||||
$query = $db->query('SELECT `value` as `record` FROM `server_config` WHERE `config` = ' . $db->quote('players_record'));
|
||||
}
|
||||
else
|
||||
|
@ -13,7 +13,7 @@ $title = 'Polls';
|
||||
|
||||
/* Polls System By Averatec from pervera.pl & otland.net */
|
||||
|
||||
if(!tableExist('z_polls'))
|
||||
if(!$db->hasTable('z_polls'))
|
||||
$db->query('
|
||||
CREATE TABLE `z_polls` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
@ -26,7 +26,7 @@ CREATE TABLE `z_polls` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;');
|
||||
|
||||
if(!tableExist('z_polls_answers'))
|
||||
if(!$db->hasTable('z_polls_answers'))
|
||||
$db->query('
|
||||
CREATE TABLE `z_polls_answers` (
|
||||
`poll_id` int(11) NOT NULL,
|
||||
@ -35,7 +35,7 @@ $db->query('
|
||||
`votes` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;');
|
||||
|
||||
if(!fieldExist('vote', 'accounts'))
|
||||
if(!$db->hasColumn('accounts', 'vote'))
|
||||
$db->query('ALTER TABLE `accounts` ADD `vote` INT( 11 ) NOT NULL ;');
|
||||
|
||||
function getColorByPercent($percent)
|
||||
|
@ -44,13 +44,13 @@ foreach($groupList as $id => $group)
|
||||
$groupNames = array();
|
||||
foreach($group_members as $member)
|
||||
{
|
||||
if(!admin() && $member->getCustomField('hidden') > 0)
|
||||
if(!admin() && $member->isHidden())
|
||||
continue;
|
||||
|
||||
$members_count++;
|
||||
$flag = '';
|
||||
if($config['account_country'])
|
||||
$flag = getFlagImage($member->getAccount()->getCustomField('country'));
|
||||
$flag = getFlagImage($member->getAccount()->getCountry());
|
||||
|
||||
$tmp = '<tr bgcolor="' . getStyle($i++) . '">';
|
||||
if(!$newStyle)
|
||||
|
@ -103,7 +103,7 @@ function updateStatus() {
|
||||
if($config['online_afk'])
|
||||
{
|
||||
// get amount of players that are currently logged in-game, including disconnected clients (exited)
|
||||
if(tableExist('players_online')) { // tfs 1.x
|
||||
if($db->hasTable('players_online')) { // tfs 1.x
|
||||
$query = $db->query('SELECT COUNT(`player_id`) AS `playersTotal` FROM `players_online`;');
|
||||
}
|
||||
else {
|
||||
|
@ -36,7 +36,7 @@ If you do not want to specify a certain field, just leave it blank.<br/><br/>
|
||||
<td class="LabelV" >Hide Account:</td>
|
||||
<td>
|
||||
<input type="hidden" value="0" name="accountvisible">
|
||||
<input type="checkbox" name="accountvisible" id="accountvisible" value="1" {% if player.getCustomField('hidden') == 1 %}checked="checked"{% endif %}>
|
||||
<input type="checkbox" name="accountvisible" id="accountvisible" value="1" {% if player.isHidden() %}checked="checked"{% endif %}>
|
||||
<label for="accountvisible"> check to hide your account information</label>
|
||||
{% if player.getCustomField('group_id') > 1 %} (you will be also hidden on the Team page!){% endif %}
|
||||
</td>
|
||||
|
@ -315,7 +315,7 @@
|
||||
<!-- SIGNATURE_END -->
|
||||
{% endif %}
|
||||
{{ hook(constant('HOOK_CHARACTERS_AFTER_SIGNATURE')) }}
|
||||
{% if hidden != 1 %}
|
||||
{% if not hidden %}
|
||||
{% set rows = 0 %}
|
||||
<!-- ACCOUNT_INFORMATION -->
|
||||
<br/><br/>
|
||||
@ -324,7 +324,7 @@
|
||||
<td colspan="2" class="white"><b>Account Information</b></td>
|
||||
</tr>
|
||||
|
||||
{% set realName = account.getCustomField('rlname') %}
|
||||
{% set realName = account.getRLName() %}
|
||||
{% if realName is not empty %}
|
||||
{% set rows = rows + 1 %}
|
||||
<tr bgcolor="{{ getStyle(rows) }}">
|
||||
@ -342,7 +342,7 @@
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
{% set realLocation = account.getCustomField('location') %}
|
||||
{% set realLocation = account.getLocation() %}
|
||||
{% if realLocation is not empty %}
|
||||
{% set rows = rows + 1 %}
|
||||
<tr bgcolor="{{ getStyle(rows) }}">
|
||||
@ -354,7 +354,7 @@
|
||||
{% set rows = rows + 1 %}
|
||||
<tr bgcolor="{{ getStyle(rows) }}">
|
||||
<td width="20%">Created:</td>
|
||||
<td>{{ account.getCustomField("created")|date("j F Y, g:i a") }}
|
||||
<td>{{ account.getCreated()|date("j F Y, g:i a") }}
|
||||
{% if bannedUntil matches '/^\\d+$/' or bannedUntil == '-1' %}
|
||||
<font color="red">[Banished {% if bannedUntil == '-1' %}forever{% else %}until {{ bannedUntil|date('d F Y, h:s') }}{% endif %}]</font>
|
||||
{% else %}
|
||||
|
@ -65,7 +65,7 @@
|
||||
|
||||
/** HOUSE **/
|
||||
$town = 'town';
|
||||
if(fieldExist('town_id', 'houses'))
|
||||
if($db->hasColumn('houses', 'town_id'))
|
||||
$town = 'town_id';
|
||||
|
||||
$house = $db->query( 'SELECT `houses`.`name`, `houses`.`' . $town . '` as town FROM `houses` WHERE `houses`.`owner` = '.$player->getId().';' )->fetchAll();
|
||||
|
@ -101,7 +101,7 @@
|
||||
imagefilledrectangle($img, 225, 40, 225, 130, $title); //seperator
|
||||
$posy = 50;
|
||||
|
||||
if(fieldExist('skill_fist', 'players')) {// tfs 1.0+
|
||||
if($db->hasColumn('players', 'skill_fist')) {// tfs 1.0+
|
||||
$skills_db = $db->query('SELECT `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing` FROM `players` WHERE `id` = ' . $player->getId())->fetch();
|
||||
|
||||
$skill_ids = array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user