mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 09:44:55 +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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user