Merge pull request #78 from whiteblXK/master

Houses page, guilds list to twig
This commit is contained in:
slawkens 2019-05-04 22:51:27 +02:00 committed by GitHub
commit 30b231cfdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 570 additions and 396 deletions

View File

@ -123,7 +123,8 @@ else {
'/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
'/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'),
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2')
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'),
'/^houses\/view\/?$/' => array('subtopic' => 'houses', 'page' => 'view')
);
foreach($rules as $rule => $redirect) {

View File

@ -1,126 +1,39 @@
<?php
/**
* List of guilds
*
* @package MyAAC
* @author Gesior <jerzyskalski@wp.pl>
* @author Slawkens <slawkens@gmail.com>
* @author whiteblXK
* @copyright 2019 MyAAC
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$guilds_list = new OTS_Guilds_List();
if(!isset($_REQUEST['preview']))
$_REQUEST['preview'] = 1;
$guilds_list->orderBy("name");
//echo 'Guilds needs to have atleast 4 members, otherwise it will be deleted automatically after 4 days.<BR/><BR/>Guild statistics are self-updated once per 3 days.<BR/><BR/>';
//echo '<A HREF="?subtopic=guilds&preview=1">Normal preview</A> / <A HREF="?subtopic=guilds&preview=2">Advanced ranks & statistics</A><BR/><BR/>
echo '
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN='.($_REQUEST['preview'] == 2 ? '7' : '3').' class="white"><B>Active Guilds on '.$config['lua']['serverName'].'</B></TD></TR>
<TR BGCOLOR='.$config['darkborder'].' '.($_REQUEST['preview'] == 2 ? 'ALIGN="CENTER"' : '' ).'>';
if($_REQUEST['preview'] == 2) {
echo '
<TD WIDTH=50><B><A HREF="?subtopic=guilds&preview=2&order=rank">Rank</A></B></TD>
<TD WIDTH=32><B>Logo</B></TD>
<TD WIDTH=200><B><A HREF="?subtopic=guilds&preview=2&order=name">Guild name</A></B></TD>';
/*
<TD WIDTH=10><B><A HREF="?subtopic=guilds&preview=2&order=total_members">Members</A></B></TD>
<TD WIDTH=10><B><A HREF="?subtopic=guilds&preview=2&order=total_level">Total level</A></B></TD>
<TD WIDTH=10><B><A HREF="?subtopic=guilds&preview=2&order=average_level">Average level</A></B></TD>
<TD WIDTH=10><B><A HREF="?subtopic=guilds&preview=2&order=frags">Frags</A></B></TD>';*/
}
else
echo '
<TD WIDTH=64><B>Logo</B></TD>
<TD WIDTH=100%><B>Description</B></TD>
<TD WIDTH=50><B> </B></TD>';
echo '
</TR>';
$showed_guilds = 0;
if($_REQUEST['preview'] == 2)
$guilds = array();
if(count($guilds_list) > 0)
{
if(count($guilds_list) > 0)
{
foreach($guilds_list as $guild)
{
$guild_logo = $guild->getCustomField('logo_name');
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo))
$guild_logo = "default.gif";
echo '<TR class="moduleRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'?subtopic=guilds&action=show&guild='.$guild->getName().'\'"';
echo ' BGCOLOR="' . getStyle($showed_guilds++) . '"><TD ALIGN="CENTER">'.($show_ranks ? $showed_guilds.'.' : '-').'</TD><TD ALIGN="CENTER"><A HREF="?subtopic=guilds&action=show&guild='.$guild->getName().'"><IMG STYLE="border: none" SRC="images/guilds/' .$guild_logo.'" WIDTH=32 HEIGHT=32></A></TD>
<TD valign="top"><B>'.$guild->getName().'</B><BR/>';
if(admin())
echo '<br /><a href="?subtopic=guilds&action=delete_by_admin&guild='.$guild->getName().'">Delete this guild (for ADMIN only!)</a>';
echo '</TD>';
//<TD ALIGN="CENTER">'.$guild->getCustomField('total_members').'</TD><TD ALIGN="CENTER">'.$guild->getCustomField('total_level').'</TD><TD ALIGN="CENTER">';
//if($guild->getCustomField('total_members') > 0)
// echo ceil($guild->getCustomField('total_level')/$guild->getCustomField('total_members'));
//echo '</TD><TD>'.$guild->getCustomField('frags').'</TD>
echo '</TR>';
}
}
else
echo '<TR BGCOLOR='.$config['lightborder'].'><TD ALIGN="CENTER">-</TD><TD><IMG SRC="images/guilds/' . 'default.gif" WIDTH=64 HEIGHT=64></TD>
<TD valign="top" align="center"><B>Create guild</B><BR/>Actually there is no guild on server.' . ($logged ? ' Create first! Press button "Create Guild".' : '') . '</TD>
<TD colspan="4">';
if($logged)
echo '
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=create" METHOD=post><TR><TD>
<INPUT TYPE=image NAME="Create Guild" ALT="Create Guild" SRC="'.$template_path.'/images/global/buttons/sbutton_createguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE>';
echo '
</TD></TR>';
}
else
{
if(count($guilds_list) > 0)
{
foreach($guilds_list as $guild)
{
$guild_logo = $guild->getCustomField('logo_name');
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo))
$guild_logo = "default.gif";
foreach ($guilds_list as $guild) {
$guild_logo = $guild->getCustomField('logo_name');
if (empty($guild_logo) || !file_exists('images/guilds/' . $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);
echo '<TR BGCOLOR="' . getStyle($showed_guilds++) . '"><TD><IMG SRC="images/guilds/' . $guild_logo.'" WIDTH=64 HEIGHT=64></TD>
<TD valign="top"><B>'.$guild->getName().'</B><BR/>'.$description.'';
if(admin())
echo '<br /><a href="?subtopic=guilds&action=delete_by_admin&guild='.$guild->getName().'">Delete this guild (for ADMIN only!)</a>';
echo '</TD><TD><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="' . getGuildLink($guild->getName(), false) . '" METHOD=post><TR><TD>
<INPUT TYPE=image NAME="View" ALT="View" SRC="'.$template_path.'/images/global/buttons/sbutton_view.gif" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE>
</TD></TR>';
}
}
else
echo '<TR BGCOLOR='.$config['lightborder'].'><TD><IMG SRC="images/guilds/' . 'default.gif" WIDTH=64 HEIGHT=64></TD>
<TD valign="top"><B>Create guild</B><BR/>Actually there is no guild on server.' . ($logged ? ' Create first! Press button "Create Guild".' : '') . '</TD>
<TD>';
if($logged)
echo '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=create" METHOD=post><TR><TD>
<INPUT TYPE=image NAME="Create Guild" ALT="Create Guild" SRC="'.$template_path.'/images/global/buttons/sbutton_createguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE>';
echo '
</TD></TR>';
}
$guildName = $guild->getName();
$guilds[] = array('name' => $guildName, 'logo' => $guild_logo, 'link' => getGuildLink($guildName, false), 'description' => $description);
}
};
echo '</TABLE><br><br>';
if($logged)
echo '<TABLE BORDER=0 WIDTH=100%><TR><TD ALIGN=center><IMG SRC="'.$template_path.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD><TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=guilds&action=create" METHOD=post><TR><TD>
<INPUT TYPE=image NAME="Create Guild" ALT="Create Guild" SRC="'.$template_path.'/images/global/buttons/sbutton_createguild.png" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE></TD><TD ALIGN=center><IMG SRC="'.$template_path.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD></TR></TABLE>
<BR />If you have any problem with guilds try:
<BR /><a href="?subtopic=guilds&action=cleanup_players">Cleanup players</a> - can\'t join guild/be invited? Can\'t create guild? Try cleanup players.
<BR /><a href="?subtopic=guilds&action=cleanup_guilds">Cleanup guilds</a> - made guild, you are a leader, but you are not on players list? Cleanup guilds!';
else
echo 'Before you can create guild you must login.<br><TABLE BORDER=0 WIDTH=100%><TR><TD ALIGN=center><IMG SRC="'.$template_path.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD><TD ALIGN=center><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><FORM ACTION="?subtopic=accountmanagement&redirect=' . getLink('guilds') . '" METHOD=post><TR><TD>
<INPUT TYPE=image NAME="Login" ALT="Login" SRC="'.$template_path.'/images/global/buttons/sbutton_login.gif" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR></FORM></TABLE></TD><TD ALIGN=center><IMG SRC="'.$template_path.'/images/general/blank.gif" WIDTH=80 HEIGHT=1 BORDER=0<BR></TD></TR></TABLE>';
?>
$twig->display('guilds.list.html.twig', array(
'guilds' => $guilds,
'logged' => isset($logged) ? $logged : false,
'isAdmin' => admin(),
));

View File

@ -5,309 +5,190 @@
* @package MyAAC
* @author Gesior <jerzyskalski@wp.pl>
* @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC
* @author whiteblXK
* @copyright 2019 MyAAC
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Houses';
$errors = array();
if(!$db->hasColumn('houses', 'name')) {
echo '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
));
return;
}
$rent = trim(strtolower($config['lua']['houseRentPeriod']));
if($rent != 'yearly' && $rent != 'monthly' && $rent != 'weekly' && $rent != 'daily')
$rent = 'never';
$rentType = trim(strtolower($config['lua']['houseRentPeriod']));
if($rentType != 'yearly' && $rentType != 'monthly' && $rentType != 'weekly' && $rentType != 'daily')
$rentType = 'never';
$state = '';
$order = '';
$type = '';
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><img src="<?php echo $template_path; ?>/images/general/blank.gif" width="10" height="1" border="0"></td>
<td>
<?php
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);
$house = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId));
if($house->rowCount() > 0)
{
$house = $house->fetch();
$houseId = $house['id'];
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));
$title = $house['name'] . ' - ' . $title;
echo '
<table border="0" cellspacing="1" cellpadding="4">
<tr><td valign="top">';
$img_path = 'images/houses/' . $houseId . '.gif';
if(file_exists($img_path))
echo '<img src="' . $img_path . '">';
else
echo '<img src="images/houses/default.jpg">';
$house = array();
if($selectHouse->rowCount() > 0)
{
$house = $selectHouse->fetch();
$houseId = $house['id'];
echo '
</td>
<td valign="top"><B>' . $house['name'] . '</b><br>This house ';
$houseBeds = $house['beds'];
if($houseBeds > 0)
echo 'has ' . (isset($beds[$houseBeds]) ? $beds[$houseBeds] : $houseBeds) . ' bed' . ($houseBeds > 1 ? 's' : '');
else
echo 'dont have any beds';
$title = $house['name'] . ' - ' . $title;
echo '.<br/><br/>The house has a size of <b>' . $house['size'] . ' square meters</b>.';
$imgPath = 'images/houses/' . $houseId . '.gif';
if(!file_exists($imgPath)) {
$imgPath = 'images/houses/default.jpg';
}
if($rent != 'never')
echo ' The ' . $rent . ' rent is <b>' . $house['rent'] . ' gold</b> and will be debited to the bank account on <b>' . $config['lua']['serverName'] . '</b>.';
$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;
echo '<br/><br/>The house has been rented by ';
if(isset($house['guild']) && $house['guild'] == 1)
{
$guild = new OTS_Guild();
$guild->load($houseOwner);
echo getGuildLink($guild->getName());
}
else
echo 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);
echo '.';
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($rent != '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()];
}
}
echo ' ' . $who . ' has paid the rent until <b>' . date("M d Y, H:i:s", $house['paid']) . ' CEST</b>.';
}
}
$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
));
echo '</TD></TR></TABLE>';
}
else
echo 'House with name ' . $houseName . ' does not exists.';
}
else
{
echo '
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'])) {
$cleanOld = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60));
if($cleanOld > 0 || $rent != 'never')
{
echo '<b>Every morning during global server save there is automatic house cleaning. Server delete house owners who have not logged in last ' . $cleanOld . ' days';
if($rent != 'never')
{
echo ' or have not paid ' . $rent . ' house rent. Remember to leave money for a rent in ';
$bank = getBoolean($config['lua']['bankSystem']);
if($bank)
echo 'your house bank account or ';
if (count($errors) > 0) {
return;
}
}
echo 'depo in same city where you have house!';
}
else
echo '.';
$cleanOldHouse = null;
if(isset($config['lua']['houseCleanOld'])) {
$cleanOldHouse = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60));
}
echo '</b><br/><br/>';
}
}
$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`';
}
echo '<br/>';
$town = 'town';
if($db->hasColumn('houses', 'town_id'))
$town = 'town_id';
else if($db->hasColumn('houses', 'townid'))
$town = 'townid';
if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order'])
&& (isset($_POST['type']) || !$db->hasColumn('houses', 'guild')))
{
$order = $_POST['order'];
$orderby = '`name`';
if(!empty($order))
{
if($order == 'size')
$orderby = '`size`';
else if($order == 'rent')
$orderby = '`rent`';
}
$whereby = '`' . $town . '` = ' .(int)$_POST['town'];
$state = $_POST['state'];
if(!empty($state))
$whereby .= ' AND `owner` ' . ($state == 'free' ? '' : '!'). '= 0';
$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';
$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')
$whereby .= ' AND `guild` ' . ($type == 'guildhalls' ? '!' : '') . '= 0';
if(!empty($type) && $type != 'all')
$whereby .= ' AND `guild` ' . ($type == 'guildhalls' ? '!' : '') . '= 0';
$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']);
echo '
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR='.$config['vdarkborder'].'>
<TD COLSPAN=6 class="white"><B>Available ' . ($type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats').' in '.$config['towns'][$_POST['town']].' on <b>'.$config['lua']['serverName'].'</b></B></TD>
</TR>
<TR BGCOLOR='.$config['darkborder'].'>';
if($houses_info->rowCount() > 0)
{
echo '
<TD WIDTH=40%><B>Name</B></TD>
<TD WIDTH=10%><B>Size</B></TD>
<TD WIDTH=10%><B>Rent</B></TD>
$houses = array();
foreach($houses_info->fetchAll() as $house)
{
$owner = isset($players[$house['id']]) ? $players[$house['id']] : array();
<TD WIDTH=40%><B>Status</B></TD>
<TD>&#160;</TD>';
}
else
echo '<TD>No ' . ($type == 'guildhalls' ? 'guildhalls' : 'houses') . ' with specified criterias.</TD>';
$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';
}
echo '</TR>';
$houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => $house['size'], 'rent' => $house['rent'], 'rentedBy' => $houseRent);
}
$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']);
$housesSearch = true;
}
$rows = 1;
foreach($houses_info->fetchAll() as $house)
{
$owner = isset($players[$house['id']]) ? $players[$house['id']] : array();
echo
'<TR BGCOLOR="'.getStyle($rows).'">
<TD WIDTH="40%"><NOBR>'.$house['name'].'</TD>
<TD WIDTH="10%"><NOBR>'.$house['size'].' sqm</TD>
<TD WIDTH="10%"><NOBR>'.$house['rent'].' gold</TD>
<TD WIDTH="40%"><NOBR>';
if($db->hasColumn('houses', 'guild') && $house['guild'] == 1 && $house['owner'] != 0)
{
$guild = new OTS_Guild();
$guild->load($house['owner']);
echo 'Rented by ' . getGuildLink($guild->getName());
}
else
{
if(!empty($owner['name']))
echo 'Rented by ' . getPlayerLink($owner['name']);
else
echo
'Free';
}
echo '
</TD>
<TD>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<FORM ACTION=?subtopic=houses&page=view METHOD=post>
<TR><TD>
<INPUT TYPE=hidden NAME=house VALUE="'.$house['name'].'">
<INPUT TYPE=image NAME="View" ALT="View" SRC="'.$template_path.'/images/global/buttons/sbutton_view.gif" BORDER=0 WIDTH=120 HEIGHT=18>
</TD></TR>
</FORM>
</TABLE>
</TD>
</TR>';
$rows++;
}
echo
'</TABLE>'.
'<br/><br/>';
}
echo '
<form method="post">
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
<TR BGCOLOR=' . $config['vdarkborder'] . '>
<TD COLSPAN=4 class="white"><B>House Search</B></TD>
</TR>
<TR BGCOLOR=' . $config['darkborder'] . '>
<TD WIDTH=25%><B>Town</B></TD>
<TD WIDTH=25%><B>Status</B></TD>
<TD WIDTH=25%><B>Order</B></TD>
</TR>
<TR BGCOLOR=' . $config['darkborder'] . '>
<TD VALIGN=top ROWSPAN=2>';
$townId = isset($_POST['town']) ? $_POST['town'] : '';
$i = 0;
$checked = false;
foreach($config['towns'] as $id => $name)
{
if($id == 0)
continue;
$i++;
if(((empty($townId) && !empty($name)) || $id == $townId) && !$checked)
{
$add = 'CHECKED';
$checked = true;
}
else
$add = '';
if(!empty($name))
echo '<INPUT TYPE=radio NAME="town" id="town_' . $id . '" VALUE="'.$id.'" '.$add.'><label for="town_' . $id . '"> '.$name.'</label><BR>';
}
echo '
</TD>
<TD VALIGN=top>
<INPUT TYPE=radio NAME="state" id="state_all" VALUE="" '.(empty($state) ? 'CHECKED' : '').'><label for="state_all"> all states</label><br/>
<INPUT TYPE=radio NAME="state" id="state_free" VALUE="free" '.($state == 'free' ? 'CHECKED' : '').'><label for="state_free"> free</label><br/>
<INPUT TYPE=radio NAME="state" id="state_rented" VALUE="rented" '.($state == 'rented' ? 'CHECKED' : '').'><label for="state_rented"> rented</label><br/>
</TD>
<TD VALIGN=top ROWSPAN=2>
<INPUT TYPE=radio NAME="order" id="order_name" VALUE="" '.(empty($order) ? 'CHECKED' : '').'><label for="order_name"> by name</label><br/>
<INPUT TYPE=radio NAME="order" id="order_size" VALUE="size" '.($order == 'size' ? 'CHECKED' : '').'><label for="order_size"> by size</label><br/>
<INPUT TYPE=radio NAME="order" id="order_rent" VALUE="rent" '.($order == 'rent' ? 'CHECKED' : '').'><label for="order_rent"> by rent</label><br/>
</TD>
</TR>';
if($db->hasColumn('houses', 'guild')) {
echo '
<TR BGCOLOR='.$config['darkborder'].'>
<TD VALIGN=top>
<INPUT TYPE=radio NAME="type" VALUE="" '.(empty($type) ? 'CHECKED' : '').'> all<BR>
<INPUT TYPE=radio NAME="type" VALUE="houses" '.($type == 'houses' ? 'CHECKED' : '').'> houses and flats<BR>
<INPUT TYPE=radio NAME="type" VALUE="guildhalls" '.($type == 'guildhalls' ? 'CHECKED' : '').'> guildhalls<BR>
</TD>
</TR>';
}
echo '
</TABLE>
<BR>
<CENTER>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD>
' . $twig->render('buttons.submit.html.twig') . '
</TD></TR></FORM></TABLE>
</CENTER>';
}
echo '
</TD>
<TD><IMG SRC="'.$template_path.'/images/general/blank.gif" WIDTH=10 HEIGHT=1 BORDER=0></TD>
</TR>
</TABLE>
';
?>
$guild = $db->hasTable('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
));

View File

@ -98,12 +98,12 @@ $twig->display('serverinfo.html.twig', array(
'redSkullLength' => $redSkullLength,
'blackSkull' => $blackSkull,
'blackSkullLength' => $blackSkullLength,
'dailyFragsToRedSkull' => isset($config['lua']['dailyFragsToRedSkull']) ? $config['lua']['dailyFragsToRedSkull'] : $config['lua']['kills_per_day_red_skull'],
'weeklyFragsToRedSkull' => isset($config['lua']['weeklyFragsToRedSkull']) ? $config['lua']['weeklyFragsToRedSkull'] : $config['lua']['kills_per_week_red_skull'],
'monthlyFragsToRedSkull' => isset($config['lua']['monthlyFragsToRedSkull']) ? $config['lua']['monthlyFragsToRedSkull'] : $config['lua']['kills_per_month_red_skull'],
'dailyFragsToBlackSkull' => isset($config['lua']['dailyFragsToBlackSkull']) ? $config['lua']['dailyFragsToBlackSkull'] : isset($config['lua']['kills_per_day_black_skull']) ? $config['lua']['kills_per_day_black_skull'] : null,
'weeklyFragsToBlackSkull' => isset($config['lua']['weeklyFragsToBlackSkull']) ? $config['lua']['weeklyFragsToBlackSkull'] : isset($config['lua']['kills_per_week_black_skull']) ? $config['lua']['kills_per_week_black_skull'] : null,
'monthlyFragsToBlackSkull' => isset($config['lua']['monthlyFragsToBlackSkull']) ? $config['lua']['monthlyFragsToBlackSkull'] : isset($config['lua']['kills_per_month_black_skull']) ? $config['lua']['kills_per_month_black_skull'] : null,
'dailyFragsToRedSkull' => isset($config['lua']['dailyFragsToRedSkull']) ? $config['lua']['dailyFragsToRedSkull'] : (isset($config['lua']['kills_per_day_red_skull']) ? $config['lua']['kills_per_day_red_skull'] : null),
'weeklyFragsToRedSkull' => isset($config['lua']['weeklyFragsToRedSkull']) ? $config['lua']['weeklyFragsToRedSkull'] : (isset($config['lua']['kills_per_week_red_skull']) ? $config['lua']['kills_per_week_red_skull'] : null),
'monthlyFragsToRedSkull' => isset($config['lua']['monthlyFragsToRedSkull']) ? $config['lua']['monthlyFragsToRedSkull'] : (isset($config['lua']['kills_per_month_red_skull']) ? $config['lua']['kills_per_month_red_skull'] : null),
'dailyFragsToBlackSkull' => isset($config['lua']['dailyFragsToBlackSkull']) ? $config['lua']['dailyFragsToBlackSkull'] : (isset($config['lua']['kills_per_day_black_skull']) ? $config['lua']['kills_per_day_black_skull'] : null),
'weeklyFragsToBlackSkull' => isset($config['lua']['weeklyFragsToBlackSkull']) ? $config['lua']['weeklyFragsToBlackSkull'] : (isset($config['lua']['kills_per_week_black_skull']) ? $config['lua']['kills_per_week_black_skull'] : null),
'monthlyFragsToBlackSkull' => isset($config['lua']['monthlyFragsToBlackSkull']) ? $config['lua']['monthlyFragsToBlackSkull'] : (isset($config['lua']['kills_per_month_black_skull']) ? $config['lua']['kills_per_month_black_skull'] : null),
'banishmentLength' => isset($config['lua']['banishment_length']) ? eval('return (' . $config['lua']['banishment_length'] . ') / (24 * 60 * 60);') : null,
'finalBanishmentLength' => isset($config['lua']['final_banishment_length']) ? eval('return (' . $config['lua']['final_banishment_length'] . ') / (24 * 60 * 60);') : null,
'ipBanishmentLength' => isset($config['lua']['ip_banishment_length']) ? eval('return (' . $config['lua']['ip_banishment_length'] . ') / (24 * 60 * 60);') : null,

View File

@ -0,0 +1,160 @@
<div class="TableContainer">
<div class="CaptionContainer">
<div class="CaptionInnerContainer">
<span class="CaptionEdgeLeftTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionBorderTop" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionVerticalLeft" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<div class="Text">Active Guilds on {{ config.lua.serverName }}</div>
<span class="CaptionVerticalRight" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<span class="CaptionBorderBottom" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionEdgeLeftBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
</div>
</div>
<table class="Table3" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="InnerTableContainer">
<table style="width:100%;">
<tbody>
<tr>
<td>
<div class="TableContentContainer">
<table class="TableContent" width="100%">
<tbody>
{% if guilds|length > 0 %}
<tr bgcolor="{{ config.vdarkborder }}">
<td width="64"><b>Logo</b></td>
<td><b>Description</b></td>
<td width="12%"><b>&nbsp;</b></td>
</tr>
{% set i = 0 %}
{% for guild in guilds %}
{% set i = i + 1 %}
<tr bgcolor="{{ getStyle(i) }}">
<td>
<img src="images/guilds/{{ guild.logo }}" width="64" height="64">
</td>
<td>
<span{% if guild.description is not empty %} valign="top"{% endif %}>
<b>{{ guild.name }}</b>{% if isAdmin %}<a href="?subtopic=guilds&action=delete_by_admin&guild={{ guild.name }}"> - Delete this guild (for ADMIN only!)</a>{% endif %}
</span>
{% if guild.description is not empty %}
<br>
<span>{{ guild.description }}</span>
{% endif %}
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td style="border:0px;">
<form action="{{ guild.link }}" method="post">
<button name="View" alt="View" class="btn btn-secondary" src="{{ template_path }}/images/global/buttons/sbutton_view.gif" style="width: 100%; height: 20px;">
View
</button>
</form>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
{% endfor %}
{% else %}
<tr bgcolor="{{ config.lightborder }}">
<td valign="top">
<b>Create Guild</b>
<br/>
Actually there is no guild on server.{% if logged %} Create first! Press button "Create Guild"{% endif %}
</td>
{% if logged %}
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<form action="?subtopic=guilds&action=create" method=post>
<tr>
<td>
<button name="Create Guild" alt="Create Guild" class="btn btn-secondary" style="width: 100%; height: 20px;">Create Guild</button>
</td>
</tr>
</form>
</table>
</td>
{% endif %}
</tr>
{% endif %}
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tbody>
<tr>
<td align="center">
<img src="{{ template_path }}images/general/blank.gif" width="80" height="1" border="0">
</td>
<td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
{% if logged %}
<form action="?subtopic=guilds&action=create" method=post>
<tr>
<td>
<input type="image" name="Create Guild" alt="Create Guild" src="{{ template_path }}/images/global/buttons/sbutton_createguild.png" border=0 style="width: 120px; height: 18px;">
</td>
</tr>
</form>
{% else %}
<b>Before you can create guild you must login.</b>
<br/>
<form action="?subtopic=accountmanagement&redirect={{ getLink('guilds') }}" method=post>
<tr>
<td>
<input type="image" name="Login" alt="Login" src="{{ template_path }}/images/global/buttons/sbutton_login.gif" border=0 style="width: 120px; height: 18px;">
</td>
</tr>
</form>
{% endif %}
</tbody>
</table>
{% if logged %}
<br/>
If you have any problem with guilds try:
<br/>
<a href="?subtopic=guilds&action=cleanup_players">Cleanup players</a> - can\'t join guild/be invited? Can\'t create guild? Try cleanup players.
<br/>
<a href="?subtopic=guilds&action=cleanup_guilds">Cleanup guilds</a> - made guild, you are a leader, but you are not on players list? Cleanup guilds!';
{% endif %}
</td>
<td align="center">
<img src="{{ template_path }}/images/general/blank.gif" width="80" height="1" border="0">
</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,168 @@
<div class="TableContainer">
{% if errors is not empty %}
{% for error in errors %}
<p class="error">{{ error }}</p>
{% endfor %}
{% else %}
<table class="Table1" cellpadding="0" cellspacing="0" style="background-color: {{ config.lightborder }}">
<div class="CaptionContainer">
<div class="CaptionInnerContainer">
<span class="CaptionEdgeLeftTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionBorderTop" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionVerticalLeft" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<div class="Text" >House Search</div>
<span class="CaptionVerticalRight" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<span class="CaptionBorderBottom" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionEdgeLeftBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
</div>
</div>
<tr>
<td>
<div class="InnerTableContainer">
Here you can see the list of all available houses, flats{{ guildString }}.
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 cleanOldHouse is not empty or rentType != 'never' %}
Every morning during global server save there is automatic house cleaning. Server delete house owners who have not logged in last {{ cleanOldHouse }} days{% if rentType != 'never' %} or have not paid {{ rentType }} house rent. Remember to leave money for a rent in {% if config.lua.bankSystem is not empty %}your house bank or {% else %}depo in same city where you have house!{% endif %}{% else %}.{% endif %}
<br><br>
{% endif %}
{% if houses is not empty or housesSearch %}
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tbody>
<tr bgcolor="{{ config.vdarkborder }}">
<td colspan="6" class="white"><b>Available {{ houseType }}{% if townName is not empty %} in {{ townName }}{% endif %} on <b>{{ config.lua.serverName }}</b></b></td>
</tr>
<tr bgcolor="{{ config.darkborder }}">
{% if houses is not empty %}
<td width="40%"><b>Name</b></td>
<td width="10%"><b>Size</b></td>
<td width="10%"><b>Rent</b></td>
<td width="40%"><b>Status</b></td>
<td>&nbsp;</td>
{% elseif housesSearch %}
<td>No {{ houseType }} with specified criterias.</td>
{% endif %}
</tr>
{% if houses is not empty %}
{% set i = 0 %}
{% for house in houses %}
{% set i = i + 1 %}
<tr bgcolor="{{ getStyle(i) }}">
<td width="40%">
{{ house.name }}
</td>
<td width="10%">
{{ house.size }}
</td>
<td width="10%">
{{ house.rent }} golds
</td>
<td width="40%">
{{ house.rentedBy|raw }}
</td>
<td>
<form action="{{ getLink('houses/view') }}" method="post">
<input type="hidden" name="house" value="{{ house.name }}">
<button name="View" alt="View" class="btn btn-secondary" width="120" height="18">View</button>
</form>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
<br>
{% endif %}
<form action="{{ getLink('houses') }}" method="post">
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tbody>
<tr bgcolor="{{ config.vdarkborder }}">
<td colspan="4" class="white"><b>House Search</b></td>
</tr>
<tr bgcolor="{{ config.darkborder }}">
<td width="25%"><b>Town</b></td>
<td width="25%"><b>Status</b></td>
<td width="25%"><b>Order</b></td>
</tr>
<tr bgcolor="{{ config.darkborder }}">
<td valign="top" rowspan="2">
{% set checked = false %}
{% for id, name in config.towns if id > 0 %}
{% if ((townId is empty and name is not empty) or id == townId) and not checked %}
{% set variable = "checked" %}
{% set checked = true %}
{% else %}
{% set variable = "" %}
{% endif %}
<input type="radio" name="town" id="town_{{ id }}" value="{{ id }}"{% if variable is defined %} {{ variable }}{% endif %}>
<label for="town_{{ id }}"> {{ name }}</label>
<br>
{% endfor %}
</td>
<td valign="top">
<input type="radio" name="state" id="state_all" value=""{% if state is empty %} checked{% endif %}>
<label for="state_all">all states</label><br>
<input type="radio" name="state" id="state_free" value="free"{% if state == 'free' %} checked{% endif %}>
<label for="state_free">free</label><br>
<input type="radio" name="state" id="state_rented" value="rented"{% if state == 'rented' %} checked{% endif %}>
<label for="state_rented">rented</label><br>
</td>
<td valign="top" rowspan="2">
<input type="radio" name="order" id="order_name" value=""{% if order is empty %} checked{% endif %}>
<label for="order_name"> by name</label><br>
<input type="radio" name="order" id="order_size" value="size"{% if order == 'size' %} checked{% endif %}>
<label for="order_size"> by size</label><br>
<input type="radio" name="order" id="order_rent" value="rent"{% if order == 'rent' %} checked{% endif %}>
<label for="order_rent"> by rent</label><br>
</td>
</tr>
<tr bgcolor="{{ config.darkborder }}">
<td valign="top">
<input type="radio" name="type" value=""{% if type is empty %} checked{% endif %}> all<br>
<input type="radio" name="type" value="houses"{% if type == 'houses' %} checked{% endif %}> houses and flats<br>
<input type="radio" name="type" value="guildhalls"{% if type == 'guildhalls' %} checked{% endif %}> guildhalls<br>
</td>
</tr>
</tbody>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr align="center">
<td>
{{ include('buttons.submit.html.twig') }}
</td>
</tr>
</tbody>
</table>
</form>
</div>
</td>
</tr>
</table>
{% endif %}
</div>

View File

@ -0,0 +1,51 @@
<div class="TableContainer">
{% if errors is not empty %}
{% for error in errors %}
<p class="error">{{ error }}</p>
{% endfor %}
{% else %}
<table class="Table1" cellpadding="0" cellspacing="0" style="background-color: {{ config.lightborder }}">
<div class="CaptionContainer">
<div class="CaptionInnerContainer">
<span class="CaptionEdgeLeftTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionBorderTop" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionVerticalLeft" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<div class="Text" >{{ houseName }}</div>
<span class="CaptionVerticalRight" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<span class="CaptionBorderBottom" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionEdgeLeftBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
</div>
</div>
<tr>
<td>
<div class="InnerTableContainer">
<table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr style="display: inline-flex;">
<td><img src="{{ imgPath }}"></td>
<td>
{{ bedsMessage }} and has a size of <b>{{ houseSize }} square meters</b>.
{% if rentType != 'never' %}
The {{ rentType }} is <b>{{ houseRent }} gold</b> and will be debited to the bank account on <b>{{ config.lua.serverName }}</b>.
{% endif %}
<br>
{% if owner is not empty %}
The house has been rented by <b>{{ owner|raw }}</b>.
{% else %}
No one has bought this house yet.
{% endif %}
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
{% endif %}
</div>
<br><br>