* @author Slawkens * @copyright 2017 MyAAC * @version 0.4.2 * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Houses'; if(!fieldExist('name', 'houses')) { echo 'Houses list is not available on this server.'; return; } $rent = trim(strtolower($config['lua']['houseRentPeriod'])); if($rent != 'yearly' && $rent != 'monthly' && $rent != 'weekly' && $rent != 'daily') $rent = 'never'; $state = ''; $order = ''; $type = ''; ?>
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']; $title = $house['name'] . ' - ' . $title; echo '
'; $img_path = 'images/houses/' . $houseId . '.gif'; if(file_exists($img_path)) echo ''; else echo ''; echo ' ' . $house['name'] . '
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'; echo '.

The house has a size of ' . $house['size'] . ' square meters.'; if($rent != 'never') echo ' The ' . $rent . ' rent is ' . $house['rent'] . ' gold and will be debited to the bank account on ' . $config['lua']['serverName'] . '.'; $houseOwner = $house['owner']; if($houseOwner > 0) { $guild = NULL; echo '

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); echo '.'; if($rent != 'never' && $house['paid'] > 0) { $who = ''; if($guild) $who = $guild->getName(); else { $player = $ots->createObject('Player'); $player->load($houseOwner); if($player->isLoaded()) { $sexs = array('She', 'He'); $who = $sexs[$player->getSex()]; } } echo ' ' . $who . ' has paid the rent until ' . date("M d Y, H:i:s", $house['paid']) . ' CEST.'; } } echo '
'; } else echo 'House with name ' . $houseName . ' does not exists.'; } else { echo ' Here you can see the list of all available houses, flats' . (tableExist('guild', 'houses') ? ' or guildhall' : '') . '. Click on any view button to get more information about a house or adjust the search criteria and start a new search.

'; if(isset($config['lua']['houseCleanOld'])) { $cleanOld = (int)(eval('return ' . $config['lua']['houseCleanOld'] . ';') / (24 * 60 * 60)); if($cleanOld > 0 || $rent != 'never') { echo '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 '; echo 'depo in same city where you have house!'; } else echo '.'; echo '

'; } } echo '
'; if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && (isset($_POST['type']) || !tableExist('guild', 'houses'))) { $order = $_POST['order']; $orderby = '`name`'; if(!empty($order)) { if($order == 'size') $orderby = '`size`'; else if($order == 'rent') $orderby = '`rent`'; } $town = 'town'; if(fieldExist('town_id', 'houses')) $town = 'town_id'; else if(fieldExist('townid', 'houses')) $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' && !fieldExist('guild', 'houses')) $type = 'all'; if(!empty($type) && $type != 'all') $whereby .= ' AND `guild` ' . ($type == 'guildhalls' ? '!' : '') . '= 0'; $houses_info = $db->query('SELECT * FROM `houses` WHERE ' . $whereby. ' ORDER BY ' . $orderby); echo ' '; if($houses_info->rowCount() > 0) { echo ' '; } else echo ''; echo ''; $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']); $rows = 1; foreach($houses_info->fetchAll() as $house) { $owner = isset($players[$house['id']]) ? $players[$house['id']] : array(); echo ''; $rows++; } echo '
Available ' . ($type == 'guildhalls' ? 'Guildhalls' : 'Houses and Flats').' in '.$config['towns'][$_POST['town']].' on '.$config['lua']['serverName'].'
Name Size Rent Status  No ' . ($type == 'guildhalls' ? 'guildhalls' : 'houses') . ' with specified criterias.
'.$house['name'].' '.$house['size'].' sqm '.$house['rent'].' gold '; if(fieldExist('guild', 'houses') && $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 '
'. '

'; } echo '
'; if(fieldExist('guild', 'houses')) { echo ' '; } echo '
House Search
Town Status Order
'; $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 '
'; } echo '






all
houses and flats
guildhalls

'; } echo '
'; ?>