mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +02:00
some small update
* moved site_closed to database, now you can close your site through admin panel * added option to admin panel: clear cache * added experiencetable_rows configurable * optimized OTS_Account->getGroupId(), now its using like 20 queries less * optimized OTS_Player->load($id) function, should perform faster loading * fixed highscores displaying of group outfits
This commit is contained in:
@@ -852,11 +852,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
public function getGroupId()
|
||||
{
|
||||
global $groups;
|
||||
if(!isset($groups))
|
||||
$groups = new OTS_Groups_List();
|
||||
|
||||
$group_id = 0;
|
||||
global $db;;
|
||||
if(fieldExist('group_id', 'accounts')) {
|
||||
$query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
|
||||
// if anything was found
|
||||
@@ -864,19 +860,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
return $query['group_id'];
|
||||
}
|
||||
|
||||
// finds groups of all characters
|
||||
foreach( $this->getPlayersList() as $player)
|
||||
{
|
||||
$group = $player->getGroup();
|
||||
|
||||
// checks if group's access level is higher then previouls found highest
|
||||
if( $group->getId() > $group_id)
|
||||
{
|
||||
$group_id = $group->getId();
|
||||
}
|
||||
}
|
||||
$db->query('SELECT `group_id` FROM `players` WHERE `account_id` = ' . $this->getId() . ' ORDER BY `group_id` DESC LIMIT 1')->fetch();
|
||||
if(isset($query['group_id']))
|
||||
return $query['group_id'];
|
||||
|
||||
return $group_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -97,6 +97,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
public function query($query)
|
||||
{
|
||||
$this->queries++;
|
||||
//echo $query . PHP_EOL;
|
||||
return parent::query($query);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,21 @@
|
||||
<?php
|
||||
$__load = array();
|
||||
/*
|
||||
'loss_experience' => NULL,
|
||||
'loss_items' => NULL,
|
||||
'guild_info' => NULL,
|
||||
'skull_type' => NULL,
|
||||
'skull_time' => NULL,
|
||||
'blessings' => NULL,
|
||||
'direction' => NULL,
|
||||
'stamina' => NULL,
|
||||
'world_id' => NULL,
|
||||
'online' => NULL,
|
||||
'deletion' => NULL,
|
||||
'promotion' => NULL,
|
||||
'marriage' => NULL
|
||||
);*/
|
||||
|
||||
/**#@+
|
||||
* @version 0.0.1
|
||||
*/
|
||||
@@ -91,7 +108,6 @@ class OTS_Player extends OTS_Row_DAO
|
||||
POT::SKILL_SHIELD => array('value' => 0, 'tries' => 0),
|
||||
POT::SKILL_FISH => array('value' => 0, 'tries' => 0)
|
||||
);
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
@@ -115,33 +131,84 @@ class OTS_Player extends OTS_Row_DAO
|
||||
*/
|
||||
public function load($id)
|
||||
{
|
||||
$loss = '';
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
$loss = ', `loss_experience`, `loss_mana`, `loss_skills`';
|
||||
}
|
||||
|
||||
$loss_items = '';
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
$loss_items = ', `loss_items`, `loss_containers`';
|
||||
}
|
||||
|
||||
$guild_info = '';
|
||||
if(!tableExist('guild_members') && fieldExist('guildnick', 'players')) {
|
||||
$guild_info = ', `guildnick`, `rank_id`';
|
||||
global $__load;
|
||||
|
||||
if(!isset($__load['loss_experience']))
|
||||
{
|
||||
$loss = '';
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
$loss = ', `loss_experience`, `loss_mana`, `loss_skills`';
|
||||
}
|
||||
|
||||
$__load['loss_experience'] = $loss;
|
||||
}
|
||||
|
||||
$skull_type = 'skull';
|
||||
if(fieldExist('skull_type', 'players')) {
|
||||
$skull_type = 'skull_type';
|
||||
if(!isset($__load['loss_items']))
|
||||
{
|
||||
$loss_items = '';
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
$loss_items = ', `loss_items`, `loss_containers`';
|
||||
}
|
||||
|
||||
$__load['loss_items'] = $loss_items;
|
||||
}
|
||||
|
||||
$skull_time = 'skulltime';
|
||||
if(fieldExist('skull_time', 'players')) {
|
||||
$skull_time = 'skull_time';
|
||||
if(!isset($__load['guild_info']))
|
||||
{
|
||||
$guild_info = '';
|
||||
if(!tableExist('guild_members') && fieldExist('guildnick', 'players')) {
|
||||
$guild_info = ', `guildnick`, `rank_id`';
|
||||
}
|
||||
|
||||
$__load['guild_info'] = $guild_info;
|
||||
}
|
||||
|
||||
if(!isset($__load['skull_type']))
|
||||
{
|
||||
$skull_type = 'skull';
|
||||
if(fieldExist('skull_type', 'players')) {
|
||||
$skull_type = 'skull_type';
|
||||
}
|
||||
|
||||
$__load['skull_type'] = $skull_type;
|
||||
}
|
||||
|
||||
if(!isset($__load['skull_time']))
|
||||
{
|
||||
$skull_time = 'skulltime';
|
||||
if(fieldExist('skull_time', 'players')) {
|
||||
$skull_time = 'skull_time';
|
||||
}
|
||||
|
||||
$__load['skull_time'] = $skull_time;
|
||||
}
|
||||
|
||||
if(!isset($__load['blessings'])) {
|
||||
$__load['blessings'] = fieldExist('blessings', 'players');
|
||||
}
|
||||
if(!isset($__load['direction'])) {
|
||||
$__load['direction'] = fieldExist('direction', 'players');
|
||||
}
|
||||
if(!isset($__load['stamina'])) {
|
||||
$__load['stamina'] = fieldExist('stamina', 'players');
|
||||
}
|
||||
if(!isset($__load['world_id'])) {
|
||||
$__load['world_id'] = fieldExist('world_id', 'players');
|
||||
}
|
||||
if(!isset($__load['online'])) {
|
||||
$__load['online'] = fieldExist('online', 'players');
|
||||
}
|
||||
if(!isset($__load['deletion'])) {
|
||||
$__load['deletion'] = fieldExist('deletion', 'players');
|
||||
}
|
||||
if(!isset($__load['promotion'])) {
|
||||
$__load['promotion'] = fieldExist('promotion', 'players');
|
||||
}
|
||||
if(!isset($__load['marriage'])) {
|
||||
$__load['marriage'] = fieldExist('marriage', 'players');
|
||||
}
|
||||
|
||||
// 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`, `' . $skull_time . '` as `skulltime`, `' . $skull_type . '` as `skull`' . $guild_info . ', `town_id`' . $loss . $loss_items . ', `balance`' . (fieldExist('blessings', 'players') ? ', `blessings`' : '') . (fieldExist('direction', 'players') ? ', `direction`' : '') . (fieldExist('stamina', 'players') ? ', `stamina`' : '') . (fieldExist('world_id', 'players') ? ', `world_id`' : '') . (fieldExist('online', 'players') ? ', `online`' : '') . ', `' . (fieldExist('deletion', 'players') ? 'deletion' : 'deleted') . '`' . (fieldExist('promotion', 'players') ? ', `promotion`' : '') . (fieldExist('marriage', 'players') ? ', `marriage`' : '') . ', `comment`, `created`, `hidden` FROM `players` WHERE `id` = ' . (int)$id)->fetch();
|
||||
$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'] = '';
|
||||
@@ -335,7 +402,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
$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')) {
|
||||
|
Reference in New Issue
Block a user