Merge branch 'develop' into feature/settings

This commit is contained in:
slawkens
2023-05-08 13:05:22 +02:00
76 changed files with 1590 additions and 1509 deletions

View File

@@ -26,11 +26,11 @@ if(empty($new_password) && empty($new_password2) && empty($old_password)) {
else
{
if(empty($new_password) || empty($new_password2) || empty($old_password)){
$errors[] = "Please fill in form.";
$errors[] = 'Please fill in form.';
}
$password_strlen = strlen($new_password);
if($new_password != $new_password2) {
$errors[] = "The new passwords do not match!";
$errors[] = 'The new passwords do not match!';
}
if(empty($errors)) {
@@ -41,9 +41,12 @@ else
/** @var OTS_Account $account_logged */
$old_password = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $old_password);
if($old_password != $account_logged->getPassword()) {
$errors[] = "Current password is incorrect!";
$errors[] = 'Current password is incorrect!';
}
$hooks->trigger(HOOK_ACCOUNT_CHANGE_PASSWORD_POST);
}
if(!empty($errors)){
//show errors
$twig->display('error_box.html.twig', array('errors' => $errors));
@@ -51,12 +54,10 @@ else
//show form
$twig->display('account.change_password.html.twig');
}
else
{
else {
$org_pass = $new_password;
if(USE_ACCOUNT_SALT)
{
if(USE_ACCOUNT_SALT) {
$salt = generateRandomString(10, false, true, true);
$new_password = $salt . $new_password;
$account_logged->setCustomField('salt', $salt);
@@ -68,17 +69,18 @@ else
$account_logged->logAction('Account password changed.');
$message = '';
if($config['mail_enabled'] && $config['send_mail_when_change_password'])
{
if($config['mail_enabled'] && $config['send_mail_when_change_password']) {
$mailBody = $twig->render('mail.password_changed.html.twig', array(
'new_password' => $org_pass,
'ip' => get_browser_real_ip(),
));
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Changed password", $mailBody))
$message = '<br/><small>Your new password were send on email address <b>'.$account_logged->getEMail().'</b>.</small>';
else
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Changed password", $mailBody)) {
$message = '<br/><small>Your new password were send on email address <b>' . $account_logged->getEMail() . '</b>.</small>';
}
else {
$message = '<br/><p class="error">An error occurred while sending email. For Admin: More info can be found in system/logs/mailer-error.log</p>';
}
}
$twig->display('success.html.twig', array(

View File

@@ -26,8 +26,13 @@ if(config('account_create_character_create')) {
}
$account_type = 'number';
if(USE_ACCOUNT_NAME) {
$account_type = 'name';
if (config('account_login_by_email')) {
$account_type = 'Email Address';
}
else {
if(USE_ACCOUNT_NAME) {
$account_type = 'name';
}
}
$errors = array();
@@ -156,9 +161,12 @@ if($save)
if(empty($errors))
{
$hasBeenCreatedByEMail = false;
$new_account = new OTS_Account();
if (config('account_login_by_email')) {
$new_account->createWithEmail($email);
$hasBeenCreatedByEMail = true;
}
else {
if(USE_ACCOUNT_NAME)
@@ -175,7 +183,6 @@ if($save)
$new_account->setPassword(encrypt($password));
$new_account->setEMail($email);
$new_account->unblock();
$new_account->save();
if(USE_ACCOUNT_SALT)
@@ -247,14 +254,21 @@ if($save)
$character_created = $createCharacter->doCreate($character_name, $character_sex, $character_vocation, $character_town, $new_account, $errors);
if (!$character_created) {
error('There was an error creating your character. Please create your character later in account management page.');
error(implode(' ', $errors));
}
}
if($config['account_create_auto_login']) {
$_POST['account_login'] = USE_ACCOUNT_NAME ? $account_name : $account_id;
if(config('account_create_auto_login')) {
if ($hasBeenCreatedByEMail) {
$_POST['account_login'] = $email;
}
else {
$_POST['account_login'] = USE_ACCOUNT_NAME ? $account_name : $account_id;
}
$_POST['password_login'] = $password2;
require SYSTEM . 'login.php';
require PAGES . 'account/login.php';
header('Location: ' . getLink('account/manage'));
}

View File

@@ -1,4 +1,15 @@
<?php
/**
* Login
*
* @package MyAAC
* @author Gesior <jerzyskalski@wp.pl>
* @author Slawkens <slawkens@gmail.com>
* @copyright 2023 MyAAC
* @link https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Login';
// new login with data from form
if(!$logged && isset($_POST['account_login'], $_POST['password_login']))
@@ -37,7 +48,7 @@ if(!$logged && isset($_POST['account_login'], $_POST['password_login']))
}
if (!config('account_login_by_email') || config('account_login_by_email_fallback')) {
if(USE_ACCOUNT_NAME) {
if(USE_ACCOUNT_NAME || USE_ACCOUNT_NUMBER) {
$account_logged->find($login_account);
} else {
$account_logged->load($login_account, true);
@@ -48,7 +59,7 @@ if(!$logged && isset($_POST['account_login'], $_POST['password_login']))
&& (!isset($t) || $t['attempts'] < 5)
)
{
setSession('account', $account_logged->getNumber());
setSession('account', $account_logged->getId());
setSession('password', encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $login_password));
if($remember_me) {
setSession('remember_me', true);

View File

@@ -40,7 +40,7 @@ elseif($action == 'step1' && $action_type == 'email')
{
if($account->getCustomField('email_next') < time())
echo 'Please enter e-mail to account with this character.<BR>
<form action="?subtopic=lostaccount&action=sendcode" method=post>
<form action="' . getLink('account/lost') . '?action=sendcode" method=post>
<input type=hidden name="character">
<table cellspacing=1 cellpadding=4 border=0 width=100%>
<TR><TD BGCOLOR="'.$config['vdarkborder'].'" class="white"><B>Please enter e-mail to account</B></TD></TR>
@@ -68,7 +68,7 @@ elseif($action == 'step1' && $action_type == 'email')
else
echo 'Invalid player name format. If you have other characters on account try with other name.';
echo '<BR /><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%><TR><TD><div style="text-align:center">
<a href="?subtopic=lostaccount" border="0"><IMG SRC="'.$template_path.'/images/global/buttons/sbutton_back.gif" NAME="Back" ALT="Back" BORDER=0 WIDTH=120 HEIGHT=18></a></div>
<a href="' . getLink('account/lost') . '" border="0"><IMG SRC="'.$template_path.'/images/global/buttons/sbutton_back.gif" NAME="Back" ALT="Back" BORDER=0 WIDTH=120 HEIGHT=18></a></div>
</TD></TR></FORM></TABLE></TABLE>';
}
elseif($action == 'sendcode')
@@ -95,8 +95,8 @@ elseif($action == 'sendcode')
<p>Account name: '.$account->getName().'</p>
<br />
To do so, please click this link:
<p><a href="' . BASE_URL . '?subtopic=lostaccount&action=checkcode&code='.$newcode.'&character='.urlencode($nick).'">'.BASE_URL.'/?subtopic=lostaccount&action=checkcode&code='.$newcode.'&character='.urlencode($nick).'</a></p>
<p>or open page: <i>' . BASE_URL . '?subtopic=lostaccount&action=checkcode</i> and in field "code" write <b>'.$newcode.'</b></p>
<p><a href="' . getLink('account/lost') . '?action=checkcode&code='.$newcode.'&character='.urlencode($nick).'">'.BASE_URL.'/?subtopic=lostaccount&action=checkcode&code='.$newcode.'&character='.urlencode($nick).'</a></p>
<p>or open page: <i>' . getLink('account/lost') . '?action=checkcode</i> and in field "code" write <b>'.$newcode.'</b></p>
<br/>
<p>If you did not request a password change, you may ignore this message and your password will remain unchanged.';
@@ -131,7 +131,7 @@ elseif($action == 'sendcode')
else
echo 'Invalid player name format. If you have other characters on account try with other name.';
echo '<BR /><TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%><TR><TD><div style="text-align:center">
<a href="?subtopic=lostaccount&action=step1&action_type=email&nick='.urlencode($nick).'" border="0"><IMG SRC="'.$template_path.'/images/global/buttons/sbutton_back.gif" NAME="Back" ALT="Back" BORDER=0 WIDTH=120 HEIGHT=18></a></div>
<a href="' . getLink('account/lost') . '?action=step1&action_type=email&nick='.urlencode($nick).'" border="0"><IMG SRC="'.$template_path.'/images/global/buttons/sbutton_back.gif" NAME="Back" ALT="Back" BORDER=0 WIDTH=120 HEIGHT=18></a></div>
</TD></TR></FORM></TABLE></TABLE>';
}
elseif($action == 'step1' && $action_type == 'reckey')
@@ -150,7 +150,7 @@ elseif($action == 'step1' && $action_type == 'reckey')
if(!empty($account_key))
{
echo 'If you enter right recovery key you will see form to set new e-mail and password to account. To this e-mail will be send your new password and account name.<BR>
<FORM ACTION="?subtopic=lostaccount&action=step2" METHOD=post>
<FORM ACTION="' . getLink('account/lost') . '?action=step2" METHOD=post>
<TABLE CELLSPACING=1 CELLPADDING=4 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="'.$config['vdarkborder'].'" class="white"><B>Please enter your recovery key</B></TD></TR>
<TR><TD BGCOLOR="'.$config['darkborder'].'">

View File

@@ -86,7 +86,7 @@ $twig->display('account.management.html.twig', array(
'email_request' => $email_request,
'email_new_time' => $email_new_time,
'email_new' => isset($email_new) ? $email_new : '',
'account' => USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId(),
'account' => (USE_ACCOUNT_NAME ? $account_logged->getName() : (USE_ACCOUNT_NUMBER ? $account_logged->getNumber() : $account_logged->getId())),
'account_email' => $account_email,
'account_created' => $account_created,
'account_status' => $account_status,

View File

@@ -201,8 +201,7 @@ if($player->isLoaded() && !$player->isDeleted())
unset($storage);
}
if($config['characters']['equipment']) {
global $db;
if($config['characters']['equipment'] && $db->hasTable('player_items') && $db->hasColumn('player_items', 'pid') && $db->hasColumn('player_items', 'sid') && $db->hasColumn('player_items', 'itemtype')) {
$eq_sql = $db->query('SELECT `pid`, `itemtype` FROM player_items WHERE player_id = '.$player->getId().' AND (`pid` >= 1 and `pid` <= 10)');
$equipment = array();
foreach($eq_sql as $eq)
@@ -285,7 +284,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
$deaths[] = array('time' => $death['date'], 'description' => $description . '.');
}
}
} else {
} else if ($db->hasColumn('player_deaths', 'time') && $db->hasColumn('player_deaths', 'level') && $db->hasColumn('player_deaths', 'killed_by') && $db->hasColumn('player_deaths', 'is_player')) {
$mostdamage = '';
if($db->hasColumn('player_deaths', 'mostdamage_by'))
$mostdamage = ', `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`';

View File

@@ -101,14 +101,15 @@ if(isset($_GET['image']))
return;
}
$images =
$db->query('SELECT `id`, `comment`, `image`, `author`, `thumb`' .
$images = Cache::remember('gallery_' . ($canEdit ? '1' : '0'), 60, function () use ($db, $canEdit) {
return $db->query('SELECT `id`, `comment`, `image`, `author`, `thumb`' .
($canEdit ? ', `hidden`, `ordering`' : '') .
' FROM `' . TABLE_PREFIX . 'gallery`' .
(!$canEdit ? ' WHERE `hidden` != 1' : '') .
' ORDER BY `ordering`;');
' ORDER BY `ordering`;')->fetchAll(PDO::FETCH_ASSOC);
});
$last = $images->rowCount();
$last = count($images);
if(!$last)
{
?>

View File

@@ -19,23 +19,23 @@ $guilds_list->orderBy("name");
$guilds = array();
if(count($guilds_list) > 0)
{
foreach ($guilds_list as $guild) {
$guild_logo = $guild->getCustomField('logo_name');
if (empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
$guild_logo = "default.gif";
foreach ($guilds_list as $guild) {
$guild_logo = $guild->getCustomField('logo_name');
if (empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
$guild_logo = "default.gif";
$description = $guild->getCustomField('description');
$description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count);
if ($count < $config['guild_description_lines_limit'])
$description = wordwrap(nl2br($description), 60, "<br />", true);
$description = $guild->getCustomField('description');
$description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count);
if ($count < $config['guild_description_lines_limit'])
$description = wordwrap(nl2br($description), 60, "<br />", true);
$guildName = $guild->getName();
$guilds[] = array('name' => $guildName, 'logo' => $guild_logo, 'link' => getGuildLink($guildName, false), 'description' => $description);
}
$guildName = $guild->getName();
$guilds[] = array('name' => $guildName, 'logo' => $guild_logo, 'link' => getGuildLink($guildName, false), 'description' => $description);
}
};
$twig->display('guilds.list.html.twig', array(
'guilds' => $guilds,
'logged' => isset($logged) ? $logged : false,
'isAdmin' => admin(),
'guilds' => $guilds,
'logged' => isset($logged) ? $logged : false,
'isAdmin' => admin(),
));

View File

@@ -49,78 +49,78 @@ $players_from_account_in_guild = array();
$players_from_account_ids = array();
if($logged)
{
$account_players = $account_logged->getPlayers();
foreach($account_players as $player)
{
$players_from_account_ids[] = $player->getId();
$player_rank = $player->getRank();
if($player_rank->isLoaded())
{
foreach($rank_list as $rank_in_guild)
{
if($guild_owner->isLoaded() && $rank_in_guild->isLoaded() && $player_rank->isLoaded() &&
$rank_in_guild->getId() == $player_rank->getId())
{
$players_from_account_in_guild[] = $player->getName();
if($guild_owner->getId() == $player->getId())
{
$guild_vice = true;
$guild_leader = true;
}
else if($player_rank->getLevel() > 1)
{
$guild_vice = true;
$level_in_guild = $player_rank->getLevel();
}
}
}
}
}
$account_players = $account_logged->getPlayers();
foreach($account_players as $player)
{
$players_from_account_ids[] = $player->getId();
$player_rank = $player->getRank();
if($player_rank->isLoaded())
{
foreach($rank_list as $rank_in_guild)
{
if($guild_owner->isLoaded() && $rank_in_guild->isLoaded() && $player_rank->isLoaded() &&
$rank_in_guild->getId() == $player_rank->getId())
{
$players_from_account_in_guild[] = $player->getName();
if($guild_owner->getId() == $player->getId())
{
$guild_vice = true;
$guild_leader = true;
}
else if($player_rank->getLevel() > 1)
{
$guild_vice = true;
$level_in_guild = $player_rank->getLevel();
}
}
}
}
}
}
//show guild page
$guild_logo = $guild->getCustomField('logo_name');
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
$guild_logo = "default.gif";
$guild_logo = "default.gif";
$description = $guild->getCustomField('description');
$description_with_lines = str_replace(array("\r\n", "\n", "\r"), '<br />', $description, $count);
if($count < $config['guild_description_lines_limit'])
$description = wordwrap(nl2br($description), 60, "<br />", true);
$description = wordwrap(nl2br($description), 60, "<br />", true);
//$description = $description_with_lines;
$guild_owner = $guild->getOwner();
if($guild_owner->isLoaded())
$guild_owner_name = $guild_owner->getName();
$guild_owner_name = $guild_owner->getName();
$guild_members = array();
foreach($rank_list as $rank)
{
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($db->hasColumn('players', 'rank_id'))
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
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($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();
if($players_with_rank_number > 0)
{
$members = array();
foreach($players_with_rank as $result)
{
$player = new OTS_Player();
$player->load($result['id']);
if(!$player->isLoaded())
continue;
$players_with_rank_number = $players_with_rank->rowCount();
if($players_with_rank_number > 0)
{
$members = array();
foreach($players_with_rank as $result)
{
$player = new OTS_Player();
$player->load($result['id']);
if(!$player->isLoaded())
continue;
$members[] = $player;
}
$members[] = $player;
}
$guild_members[] = array(
'rank_name' => $rank->getName(),
'rank_level' => $rank->getLevel(),
'members' => $members
);
}
$guild_members[] = array(
'rank_name' => $rank->getName(),
'rank_level' => $rank->getLevel(),
'members' => $members
);
}
}
include(SYSTEM . 'libs/pot/InvitesDriver.php');
@@ -129,37 +129,39 @@ $invited_list = $guild->listInvites();
$show_accept_invite = 0;
if($logged && count($invited_list) > 0)
{
foreach($invited_list as $invited_player)
{
if(count($account_players) > 0)
{
foreach($account_players as $player_from_acc)
{
if($player_from_acc->isLoaded() && $invited_player->isLoaded() && $player_from_acc->getName() == $invited_player->getName())
$show_accept_invite++;
}
}
}
foreach($invited_list as $invited_player)
{
if(count($account_players) > 0)
{
foreach($account_players as $player_from_acc)
{
if($player_from_acc->isLoaded() && $invited_player->isLoaded() && $player_from_acc->getName() == $invited_player->getName())
$show_accept_invite++;
}
}
}
}
$useGuildNick = false;
if($db->hasColumn('players', 'guildnick'))
$useGuildNick = true;
$useGuildNick = true;
$twig->display('guilds.view.html.twig', array(
'logo' => $guild_logo,
'guild_name' => $guild_name,
'description' => $description,
'guild_owner' => $guild_owner->isLoaded() ? $guild_owner : null,
'guild_creation_date' => $guild->getCreationData(),
'guild_members' => $guild_members,
'players_from_account_ids' => $players_from_account_ids,
'players_from_account_in_guild' => $players_from_account_in_guild,
'level_in_guild' => $level_in_guild,
'isLeader' => $guild_leader,
'isVice' => $guild_vice,
'logged' => $logged,
'invited_list' => $invited_list,
'show_accept_invite' => $show_accept_invite,
'useGuildNick' => $useGuildNick
'logo' => $guild_logo,
'guild' => $guild,
'guild_id' => $guild->getId(),
'guild_name' => $guild_name,
'description' => $description,
'guild_owner' => $guild_owner->isLoaded() ? $guild_owner : null,
'guild_creation_date' => $guild->getCreationData(),
'guild_members' => $guild_members,
'players_from_account_ids' => $players_from_account_ids,
'players_from_account_in_guild' => $players_from_account_in_guild,
'level_in_guild' => $level_in_guild,
'isLeader' => $guild_leader,
'isVice' => $guild_vice,
'logged' => $logged,
'invited_list' => $invited_list,
'show_accept_invite' => $show_accept_invite,
'useGuildNick' => $useGuildNick
));

View File

@@ -14,17 +14,17 @@ $title = 'Houses';
$errors = array();
if(!$db->hasColumn('houses', 'name')) {
$errors[] = 'Houses list is not available on this server.';
$errors[] = 'Houses list is not available on this server.';
$twig->display('houses.html.twig', array(
'errors' => $errors
));
$twig->display('houses.html.twig', array(
'errors' => $errors
));
return;
}
$rentType = trim(strtolower($config['lua']['houseRentPeriod']));
if($rentType != 'yearly' && $rentType != 'monthly' && $rentType != 'weekly' && $rentType != 'daily')
$rentType = 'never';
$rentType = 'never';
$state = '';
$order = '';
@@ -32,116 +32,116 @@ $type = '';
if(isset($_GET['page']) && $_GET['page'] == 'view' && isset($_REQUEST['house']))
{
$beds = array("", "one", "two", "three", "fourth", "fifth");
$houseName = $_REQUEST['house'];
$houseId = (Validator::number($_REQUEST['house']) ? $_REQUEST['house'] : -1);
$selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId));
$beds = array("", "one", "two", "three", "fourth", "fifth");
$houseName = $_REQUEST['house'];
$houseId = (Validator::number($_REQUEST['house']) ? $_REQUEST['house'] : -1);
$selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId));
$house = array();
if($selectHouse->rowCount() > 0)
{
$house = $selectHouse->fetch();
$houseId = $house['id'];
$house = array();
if($selectHouse->rowCount() > 0)
{
$house = $selectHouse->fetch();
$houseId = $house['id'];
$title = $house['name'] . ' - ' . $title;
$title = $house['name'] . ' - ' . $title;
$imgPath = 'images/houses/' . $houseId . '.gif';
if(!file_exists($imgPath)) {
$imgPath = 'images/houses/default.jpg';
}
$imgPath = 'images/houses/' . $houseId . '.gif';
if(!file_exists($imgPath)) {
$imgPath = 'images/houses/default.jpg';
}
$bedsMessage = null;
$houseBeds = $house['beds'];
if($houseBeds > 0)
$bedsMessage = 'House have ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : '');
else
$bedsMessage = 'This house dont have any beds';
$bedsMessage = null;
$houseBeds = $house['beds'];
if($houseBeds > 0)
$bedsMessage = 'House have ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : '');
else
$bedsMessage = 'This house dont have any beds';
$houseOwner = $house['owner'];
if($houseOwner > 0)
{
$guild = NULL;
$owner = null;
if(isset($house['guild']) && $house['guild'] == 1)
{
$guild = new OTS_Guild();
$guild->load($houseOwner);
$owner = getGuildLink($guild->getName());
}
else
$owner = getCreatureName($houseOwner);
$houseOwner = $house['owner'];
if($houseOwner > 0)
{
$guild = NULL;
$owner = null;
if(isset($house['guild']) && $house['guild'] == 1)
{
$guild = new OTS_Guild();
$guild->load($houseOwner);
$owner = getGuildLink($guild->getName());
}
else
$owner = getCreatureName($houseOwner);
if($rentType != 'never' && $house['paid'] > 0)
{
$who = '';
if($guild)
$who = $guild->getName();
else
{
$player = new OTS_Player();
$player->load($houseOwner);
if($player->isLoaded())
{
$sexs = array('She', 'He');
$who = $sexs[$player->getSex()];
}
}
$owner .= ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.';
}
}
}
else
$errors[] = 'House with name ' . $houseName . ' does not exists.';
if($rentType != 'never' && $house['paid'] > 0)
{
$who = '';
if($guild)
$who = $guild->getName();
else
{
$player = new OTS_Player();
$player->load($houseOwner);
if($player->isLoaded())
{
$sexs = array('She', 'He');
$who = $sexs[$player->getSex()];
}
}
$owner .= ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.';
}
}
}
else
$errors[] = 'House with name ' . $houseName . ' does not exists.';
$twig->display('houses.view.html.twig', array(
'errors' => $errors,
'imgPath' => isset($imgPath) ? $imgPath : null,
'houseName' => isset($house['name']) ? $house['name'] : null,
'bedsMessage' => isset($bedsMessage) ? $bedsMessage : null,
'houseSize' => isset($house['size']) ? $house['size'] : null,
'houseRent' => isset($house['rent']) ? $house['rent'] : null,
'owner' => isset($owner) ? $owner : null,
'rentType' => isset($rentType) ? $rentType : null
));
$twig->display('houses.view.html.twig', array(
'errors' => $errors,
'imgPath' => isset($imgPath) ? $imgPath : null,
'houseName' => isset($house['name']) ? $house['name'] : null,
'bedsMessage' => isset($bedsMessage) ? $bedsMessage : null,
'houseSize' => isset($house['size']) ? $house['size'] : null,
'houseRent' => isset($house['rent']) ? $house['rent'] : null,
'owner' => isset($owner) ? $owner : null,
'rentType' => isset($rentType) ? $rentType : null
));
if (count($errors) > 0) {
return;
}
if (count($errors) > 0) {
return;
}
}
$cleanOldHouse = null;
if(isset($config['lua']['houseCleanOld'])) {
$cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60));
$cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60));
}
$housesSearch = false;
if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && (isset($_POST['type']) || !$db->hasColumn('houses', 'guild')))
{
$townName = $config['towns'][$_POST['town']];
$order = $_POST['order'];
$orderby = '`name`';
if(!empty($order))
{
if($order == 'size')
$orderby = '`size`';
else if($order == 'rent')
$orderby = '`rent`';
}
$townName = $config['towns'][$_POST['town']];
$order = $_POST['order'];
$orderby = '`name`';
if(!empty($order))
{
if($order == 'size')
$orderby = '`size`';
else if($order == 'rent')
$orderby = '`rent`';
}
$town = 'town';
if($db->hasColumn('houses', 'town_id'))
$town = 'town_id';
else if($db->hasColumn('houses', 'townid'))
$town = 'townid';
$town = 'town';
if($db->hasColumn('houses', 'town_id'))
$town = 'town_id';
else if($db->hasColumn('houses', 'townid'))
$town = 'townid';
$whereby = '`' . $town . '` = ' .(int)$_POST['town'];
$state = $_POST['state'];
if(!empty($state))
$whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0';
$whereby = '`' . $town . '` = ' .(int)$_POST['town'];
$state = $_POST['state'];
if(!empty($state))
$whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0';
$type = isset($_POST['type']) ? $_POST['type'] : NULL;
if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild'))
$type = 'all';
$type = isset($_POST['type']) ? $_POST['type'] : NULL;
if($type == 'guildhalls' && !$db->hasColumn('houses', 'guild'))
$type = 'all';
if (!empty($type) && $type != 'all')
{
@@ -158,49 +158,51 @@ if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) &&
}
}
$houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby);
$houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby);
$players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`");
$players = array();
foreach($players_info->fetchAll() as $player)
$players[$player['houseid']] = array('name' => $player['ownername']);
$players_info = $db->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` FROM `houses` , `players` , `accounts` WHERE `players`.`id` = `houses`.`owner` AND `accounts`.`id` = `players`.`account_id`");
$players = array();
foreach($players_info->fetchAll() as $player)
$players[$player['houseid']] = array('name' => $player['ownername']);
$houses = array();
foreach($houses_info->fetchAll() as $house)
{
$owner = isset($players[$house['id']]) ? $players[$house['id']] : array();
$hasTilesColumn = $db->hasColumn('houses', 'tiles');
$houseRent = null;
if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0)
{
$guild = new OTS_Guild();
$guild->load($house['owner']);
$houseRent = 'Rented by ' . getGuildLink($guild->getName());
}
else
{
if(!empty($owner['name']))
$houseRent = 'Rented by ' . getPlayerLink($owner['name']);
else
$houseRent = 'Free';
}
$houses = array();
foreach($houses_info->fetchAll() as $house)
{
$owner = isset($players[$house['id']]) ? $players[$house['id']] : array();
$houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => $house['size'], 'rent' => $house['rent'], 'rentedBy' => $houseRent);
}
$houseRent = null;
if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0)
{
$guild = new OTS_Guild();
$guild->load($house['owner']);
$houseRent = 'Rented by ' . getGuildLink($guild->getName());
}
else
{
if(!empty($owner['name']))
$houseRent = 'Rented by ' . getPlayerLink($owner['name']);
else
$houseRent = 'Free';
}
$housesSearch = true;
$houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => ($hasTilesColumn ? $house['tiles'] : $house['size']), 'rent' => $house['rent'], 'rentedBy' => $houseRent);
}
$housesSearch = true;
}
$guild = $db->hasColumn('houses', 'guild') ? ' or guildhall' : '';
$twig->display('houses.html.twig', array(
'state' => $state,
'order' => $order,
'type' => $type,
'houseType' => $type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats',
'townName' => isset($townName) ? $townName : null,
'townId' => isset($_POST['town']) ? $_POST['town'] : null,
'guild' => $guild,
'cleanOldHouse' => isset($cleanOld) ? $cleanOld : null,
'housesSearch' => $housesSearch,
'houses' => isset($houses) ? $houses : null
));
'state' => $state,
'order' => $order,
'type' => $type,
'houseType' => $type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats',
'townName' => isset($townName) ? $townName : null,
'townId' => isset($_POST['town']) ? $_POST['town'] : null,
'guild' => $guild,
'cleanOldHouse' => isset($cleanOld) ? $cleanOld : null,
'housesSearch' => $housesSearch,
'houses' => isset($houses) ? $houses : null
));