• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[ACC GESIOR]New houses.php [0.3+]

I will make function to auction at site.

An option to make the minimum starting bid would be cool too... Just a quick visualization in my head...

PHP:
$minimumbid = $getHouseSize() * 10

if $playerbid < $minimumbid
echo Must bid a minium of $minimumbid.
else
-- code for placing bid
 
Hmmmm...
I me don't running Button [Add News] and [Add Ticker]
Help Please... acc maker by Gęsior 0.3

Nie Działają mi przyciski {Add News) oraz (Add Ticker)
Acc maker By Gęsior 0.3 Beta layout zmieniony na Paxton v1
 
Nice but, why on my ot players say recidence lol or the houses city's are lol or venore can someone help me?????????'
 
My script

This is my script for Houses.php -- only for those with VIP system

<?PHP
$main_content .= '<form method="post" action=""><table>';
if(count($config['site']['worlds']) > 1)
{
if(isset($_POST['world']) and is_numeric($_POST['world']))
{
$wid = (int) $_POST['world'];
$wid = '<option value='.$wid.'>'.$config['site']['worlds'][$wid].'</option>';
}
$select_w .= '<tr><td>Select World:</td><td><select name="world" onchange="submit()">'.$wid.'';
$i=1;
foreach($config['site']['worlds'] as $id => $world_n)
{
if($_POST['world'] != $id)
{
$worlds[$i] .= '<option value="'.$id.'">'.$world_n.'</option>';
}
if($id == (int) $_POST['world'])
{
$world_id = $id;
$world_name = $world_n;
}
$i++;
}

$main_content .= ''.$select_w.'';
for($i=0;$i <= count($config['site']['worlds']); $i++)
{
$main_content .= ''.$worlds[$i].'';
}
$main_content .= '</td></tr></select>';
}

if(!isset($world_id))
{
$world_id = 0;
$world_name = $config['server']['serverName'];
}

if(count($towns_list) > 1)
{
if(isset($_POST['town']) and is_numeric($_POST['town']))
{
$pid = (int) $_POST['town'];
$pid = '<option value='.$pid.'>'.$towns_list[$world_id][$pid].'</option>';
}
else
{
$pid = '<option value="all">All</option>';
$all=true;
}
$select .= '<tr><td>Select City:</td><td><select name="town" onchange="submit()">'.$pid.'';
$i=1;
foreach($towns_list[$world_id] as $id => $town_n)
{
if($_POST['town'] != $id)
{
$towns[$i] .= '<option value="'.$id.'">'.$town_n.'</option>';
}
if($id == (int) $_POST['town'])
{
$town_id = $id;
$town_name = $town_n;
}
$i++;
}

$main_content .= ''.$select.'';
for($i=1;$i <= count($towns_list[$world_id]); $i++)
{
$main_content .= ''.$towns[$i].'';
}
if(!$all)
$main_content .= '<option value="all">All</option>';

$main_content .= '</td></tr></select>';
}
if(isset($town_id))
{
$a_status = array(1 => "Empty", "Rented", "All");

if(isset($_POST['status']) and is_numeric($_POST['status']))
{
$sid = (int) $_POST['status'];
$sid = '<option value='.$sid.'>'.$a_status[$sid].'</option>';
if($_POST['status'] == 1)
$s[1] = true;
elseif($_POST['status'] == 2)
$s[2] = true;
elseif($_POST['status'] == 3)
$s[3] = true;
}
$main_content .= '<tr><td>Select by status:</td><td><select name="status" onchange="submit()">'.$sid.'';
if(!$s[3])
$main_content .= '<option value="3">All</opyion>';
if(!$s[2])
$main_content .= '<option value="2">Rented</option>';
if(!$s[1])
$main_content .= '<option value="1">Empty</option>';
$main_content .= '</td></tr></select>';

}

$main_content .= '</table></form>';

if(isset($_POST['status']))
{
if($_POST['status'] == 1)
$stat = "and `owner` = ''";
elseif($_POST['status'] == 2)
$stat = "and `owner` > 0";
}

if(!isset($town_id))
{
$houses_info = $SQL->query("SELECT * FROM `houses` WHERE `world_id` = ".$world_id." ORDER BY `town` , `name`");
$towns_all = true;
}

$main_content .= '<h2><center>Houses on '.$config['site']['worlds'][(int) $_GET['world']].'</h2></center>';
$main_content .= '<center><table WIDTH=90%><tr bgcolor="'.$config['site']['vdarkborder'].'"><td><font color="white"><b>Address</b></font></td><td><font color="white"><b>Size</b></font></td><td><font color="white"><b>Price</b></font></td><td><font color="white"><b>City</b></font></td><td><font color="white"><b>Status</b></font></td></tr>';
$number_of_rows = 1;
if(!$towns_all)
$houses_info = $SQL->query("SELECT * FROM `houses` WHERE `world_id` = ".$world_id." and `town` = ".$town_id." ".$stat." ORDER BY `name`");
$players_info = $SQL->query("SELECT `houses`.`id` AS `houseid` , `players`.`name` AS `ownername` , `accounts`.`vip_days` AS `vip_days` , `accounts`.`lastday` AS `lastlogin` 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'], 'days' => $player['vip_days'], 'last' => $player['lastlogin']);
foreach($houses_info->fetchAll() as $house)
{
$owner = $players[$house['id']];
if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
$main_content .= '<tr bgcolor="'.$bgcolor.'"><td>'.$house['name'].'</td><td align="right" width="35">'.$house['size'].'</td><td align="right" width="65">'.($house['price'] / 1000).'k gp</td><td>'.$towns_list[(int) $house['world_id']][(int) $house['town']].'</td><td>';
if(!empty($owner['name']))
{
if($owner['deleted'] > 0)
$status='<font color=red><b>[DELETED]</b></font>';

if(isPremium($owner['days'], $owner['last']))
{
$main_content .= 'Rented by <a href="?subtopic=characters&name='.urlencode($owner['name']).'">'.$owner['name'].'</a>'.$status.'<font color=green><b> [VIP]</b></font>';
}
else
{
$main_content .= 'Rented by <a href="?subtopic=characters&name='.urlencode($owner['name']).'">'.$owner['name'].'</a>'.$status.' (FACC)';
}
}
else
{
$main_content .= 'Vazia';
}
$main_content .= '</td></tr>';
}
$main_content .= '</TABLE></center>';
?>

This is Screem...

topico.jpg
 

houses.php
PHP:
<?PHP
##-- world --##
$houses_world = (int) $_POST['world'];
if(count($config['site']['worlds']) > 1)
{
        $colspan = 4;
        foreach($config['site']['worlds'] as $world_idd => $world_names)
        {
                if($world_idd == $houses_world)
                {
                        $world_id = $world_idd;
                        $world_name = $world_names;
                }
        }
}
if(!isset($world_id))
{
        $colspan = 3;
        $world_id = 0;
        $world_name = $config['server']['serverName'];
}
##-- town --##
$houses_town = (int) $_POST['town'];
if(count($towns_list[$world_id]) > 0)
{
        foreach($towns_list[$world_id] as $town_ids => $town_names)
        {
                if($town_ids == $houses_town)
                {
                        $town_id = $town_ids;
                        $town_name = $town_names;
                }
        }
}
##-- owner --##
$houses_owner = (int) $_POST['owner'];
if($houses_owner == 0)
{
        $owner_sql = '';
}
elseif($houses_owner == 1)
{
        $owner_sql = ' AND owner = 0';
}
elseif($houses_owner == 2)
{
        $owner_sql = ' AND owner > 0';
}
##-- order --##
$houses_order = (int) $_POST['order'];
if($houses_order == 0)
{
        $order_sql = 'name';
}
elseif($houses_order == 1)
{
        $order_sql = 'size';
}
elseif($houses_order == 2)
{
        $order_sql = 'rent';
}
##-- status --##
$houses_status = (int) $_POST['status'];
if($houses_status == 0)
{
        $status_sql = ' AND guild = 0';
        $status_name = 'Houses and Flats';
}
elseif($houses_status == 1)
{
        $status_sql = ' AND guild = 1';
        $status_name = 'Guildhalls';
}
##-- List Houses --##
$id = (int) $_GET['show'];
if(empty($id))
{
        $main_content .= 'Here you can see the list of all available houses, flats 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($houses_town > 0)
        {
                $main_content .= '<table border=0 cellspacing=1 cellpadding=4 width=100%>
                        <tr bgcolor="'.$config['site']['vdarkborder'].'" class=white>
                                <td colspan=5><b>Available '.$status_name.' in '.$town_name.' on '.$world_name.'</b></td>
                        </tr>
                        <tr bgcolor="'.$config['site']['darkborder'].'">
                                <td width=24%><b>Name</b></td><td width=11%><b>Size</b></td><td width=15%><b>Rent</b></td><td width=30%><b>Status</b></td><td width=20%></td>
                        </tr>';
                        $houses_sql = $SQL->query('SELECT * FROM houses WHERE world_id = '.$world_id.' AND town = '.$town_id.''.$owner_sql.''.$status_sql.' ORDER BY '.$order_sql.' DESC')->fetchAll();
                        $counter = 0;
                        foreach($houses_sql as $house)
                        {
                                if(is_int($counter / 2))
                                        $bgcolor = $config['site']['lightborder'];
                                else
                                        $bgcolor = $config['site']['darkborder'];
                                $counter++;
                                if($house['owner'] == 0)
                                {
                                        $owner = 'Empty';
                                }
                                elseif($house['owner'] > 0)
                                {
                                        $player = $ots->createObject('Player');
                                        $player->load($house['owner']);
                                        $owner = 'Rented by <a href="?subtopic=characters&name='.urlencode($player->getName()).'">'.$player->getName().'</a>';
                                }
                                $main_content .= '<tr bgcolor="'.$bgcolor.'">
                                        <td>'.$house['name'].'</td>
                                        <td>'.$house['size'].' sqm</td>
                                        <td>'.$house['rent'].' gold</td>
                                        <td>'.$owner.'</td>
                                        <td><a href="index.php?subtopic=houses&show='.$house['id'].'"><image src="'.$layout_name.'/images/buttons/sbutton_view.gif"</a></td>
                                </tr>';
                        }
                $main_content .= '</table><br>';
        }
        $main_content .= '<form action="?subtopic=houses" method="post">
                <table border=0 cellspacing=1 cellpadding=4 width=100%>
                        <tr bgcolor="'.$config['site']['vdarkborder'].'" class=white>
                                <td colspan='.$colspan.'><font color="white"><b>House Search</b></font></td>
                        </tr>
                        <tr bgcolor="'.$config['site']['darkborder'].'">';
                                if(count($config['site']['worlds']) > 1)
                                        $main_content .= '<td width=25%><b>World</b></td>';
                                $main_content .= '<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['site']['darkborder'].'">';
                                if(count($config['site']['worlds']) > 1)
                                {
                                        $main_content .= '<td valign=top rowspan=2><select name="world"><option value="">(choose world)</option>';
                                                foreach($config['site']['worlds'] as $id => $world_n)
                                                {
                                                        $main_content .= '<option value="'.$id.'" ';
                                                        if($houses_world == $id)
                                                                $main_content .= 'SELECTED';
                                                        $main_content .= '>'.$world_n.'</option>';
                                                }
                                        $main_content .= '</select></td>';
                                }
                                $main_content .= '<td valign=top rowspan=2>';
                                        foreach($towns_list[$world_id] as $id => $town_n)
                                        {
                                                $main_content .= '<input type="radio" name="town" value="'.$id.'" ';
                                                if($houses_town == $id)
                                                        $main_content .= 'checked="checked" ';
                                                $main_content .= '>'.$town_n.'<br>';
                                        }
                                $main_content .= '</td>
                                <td valign=top>
                                        <input type="radio" name="owner" value="0" ';
                                        if($houses_owner == 0)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>all states<br>
                                        <input type="radio" name="owner" value="1" ';
                                        if($houses_owner == 1)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>empty<br>
                                        <input type="radio" name="owner" value="2" ';
                                        if($houses_owner == 2)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>rented<br>
                                </td>
                                <td valign=top rowspan=2>
                                        <input type="radio" name="order" value="0" ';
                                        if($houses_order == 0)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>by name<br>
                                        <input type="radio" name="order" value="1" ';
                                        if($houses_order == 1)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>by size<br>
                                        <input type="radio" name="order" value="2" ';
                                        if($houses_order == 2)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>by rent<br>
                                </td>
                        </tr>
                        <tr bgcolor="'.$config['site']['darkborder'].'">
                                <td valign=top>
                                        <input type="radio" name="status" value="0" ';
                                        if($houses_status == 0)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>houses and flats<br>
                                        <input type="radio" name="status" value="1" ';
                                        if($houses_status == 1)
                                                $main_content .= 'checked="checked" ';
                                        $main_content .= '>guildhalls<br>
                                </td>
                        </tr>
                        <tr>
                                <td colspan='.$colspan.'><br><center><input type=image name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/sbutton_submit.gif" BORDER=0 WIDTH=120 HEIGHT=18></center></td>
                        </tr>
                </table>
        </form>';
}
##-- Show House --##
else
{
        $house = $SQL->query('SELECT * FROM houses WHERE id = '.$id.'')->fetch();
        if($house['doors'] == 0)
                $door = '1 door';
        else
                $door = $house['doors'] + 1 .' doors';
        if($house['beds'] == 0)
                $bed = '1 bed';
        else
                $bed = $house['beds'].' beds';
        if($house['owner'] > 0)
        {
                $player = $ots->createObject('Player');
                $player->load($house['owner']);
                if($house['paid'] > 0)
                        $paid = ' and paid until <b>Feb 08 2011, 23:58:43'.date("M j Y, H:i:s", $house['paid']).' CET</b>';
                $owner = '<br>The house is currently rented by <a href="?subtopic=characters&name='.urlencode($player->getName()).'">'.$player->getName().'</a>'.$paid.'.';
        }
        $main_content .= '<table border=0 cellspacing=1 cellpadding=4 width=100%>
                <tr>
                        <td></td>
                        <td>
                                <b>'.$house['name'].'</b><br><br>
                                This house is located in <b>'.$towns_list[$house['world_id']][$house['town']].'</b>.<br>
                                It has '.$door.' and '.$bed.' on size of <b>'.$house['size'].' square meters</b>.<br>
                                The weekly rent is <b>'.$house['rent'].' gold</b> and will be debited to the bank account on <b>'.$world_name.'</b>.<br>
                                '.$owner.'
                        </td>
                </tr>
                <tr>
                        <td colspan=2></td>
                </tr>
        </table>';
}
?>
*Security
 
Last edited:
It's not that hard to remove the SQL injection possibility in that script though. :p
 
PHP:
$houses_world = (int) $_POST['world'];
It cause there cannot be sql injection because it's int data. Then script is safe : )
 
Can someone help me with houses.php?
PHP Fatal error: Call to a member function createObject() on null in /var/www/pages/houses.php on line 108

That line:
$player = $ots->createObject('Player');
 
Can someone help me with houses.php?
PHP Fatal error: Call to a member function createObject() on null in /var/www/pages/houses.php on line 108

That line:
$player = $ots->createObject('Player');

You don't use this script, do you? There is no such line in this file.

Anyway, the solution is, replace this line with this:
Code:
$player = new Player();
 
Back
Top