• 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!

Windows Znote house.php/houses.php help

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
365
Solutions
5
Reaction score
86
Location
Mexico Missouri
I have changed the layout on my houses.php file to better suit the look I am going for. It now uses Radio Buttons, instead of a dropdown list. However, when I click on a town name, and hit submit, I get this message (which is located in house.php)
Code:
No house selected.
Go back to the house list and select a house for further details.

I have around 120 houses in 2 different towns. Does anyone know what I need to do to get it to show the town list? Here is what I had to do to get it to show the above message. Any other option just returned it to houses.php and nothing showed up at all.

Code:
<form method="post" action="house.php">

Any help is appreciated.
 
Solution
@WibbenZ apparently I made 3 threads on this same topic. I have posted the solution in the main thread I listed a couple hours ago. I didnt see any point in 2 more pointless threads about the same thing being on here, so I requested them deleted.

EDIT - I made a mistake. Forget this post

House.php
Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(3);
}

$house = getValue($_GET['id']);

if ($house !== false && $config['TFSVersion'] === 'TFS_10') {
    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='$house';")...
I have changed the layout on my houses.php file to better suit the look I am going for. It now uses Radio Buttons, instead of a dropdown list. However, when I click on a town name, and hit submit, I get this message (which is located in house.php)
Code:
No house selected.
Go back to the house list and select a house for further details.

I have around 120 houses in 2 different towns. Does anyone know what I need to do to get it to show the town list? Here is what I had to do to get it to show the above message. Any other option just returned it to houses.php and nothing showed up at all.

Code:
<form method="post" action="house.php">

Any help is appreciated.
How do you expect people to help you if you provide no code of the problem?
 
house.php

Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(3);
}

$house = getValue($_GET['id']);

if ($house !== false && $config['TFSVersion'] === 'TFS_10') {
    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='$house';");
    $minbid = $config['houseConfig']['minimumBidSQM'] * $house['size'];
    if ($house['owner'] > 0) $house['ownername'] = user_name($house['owner']);

    //data_dump($house, false, "Data");

    //////////////////////
    // Bid on house logic
    $bid_char = &$_POST['char'];
    $bid_amount = &$_POST['amount'];
    if ($bid_amount && $bid_char) {
        $bid_char = (int)$bid_char;
        $bid_amount = (int)$bid_amount;
        $player = mysql_select_single("SELECT `id`, `account_id`, `name`, `level`, `balance` FROM `players` WHERE `id`='$bid_char' LIMIT 1;");
        // Does player have or need premium?
        $premstatus = $config['houseConfig']['requirePremium'];
        if ($premstatus) {
            $premstatus = mysql_select_single("SELECT `premdays` FROM `accounts` WHERE `id`='".$player['account_id']."' LIMIT 1;");
            $premstatus = ($premstatus['premdays'] > 0) ? true : false;
        } else $premstatus = true;
        if ($premstatus) {
            // Can player have or bid on more houses?
            $pHouseCount = mysql_select_single("SELECT COUNT('id') AS `value` FROM `houses` WHERE ((`highest_bidder`='$bid_char' AND `owner`='$bid_char') OR (`highest_bidder`='$bid_char') OR (`owner`='$bid_char')) AND `id`!='".$house['id']."' LIMIT 1;");
            if ($pHouseCount['value'] < $config['houseConfig']['housesPerPlayer']) {
                // Is character level high enough?
                if ($player['level'] >= $config['houseConfig']['levelToBuyHouse']) {
                    // Can player afford this bid?
                    if ($player['balance'] > $bid_amount) {
                        // Is bid higher than previous bid?
                        if ($bid_amount > $house['bid']) {
                            // Is bid higher than lowest bid?
                            if ($bid_amount > $minbid) {
                                // Should only apply to external players, allowing a player to up his pledge without
                                // being forced to pay his full previous bid. 
                                if ($house['highest_bidder'] != $player['id']) $lastbid = $house['bid'] + 1;
                                else {
                                    $lastbid = $house['last_bid'];
                                    echo "<b><font color='green'>You have raised the house pledge to ".$bid_amount."gp!</font></b><br>";
                                }
                                // Has bid already started?
                                if ($house['bid_end'] > 0) {
                                    if ($house['bid_end'] > time()) {
                                        mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
                                        $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
                                    }
                                } else {
                                    $lastbid = $minbid + 1;
                                    $bidend = time() + $config['houseConfig']['auctionPeriod'];
                                    mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid', `bid_end`='$bidend' WHERE `id`='". $house['id'] ."' LIMIT 1;");
                                    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
                                }
                                echo "<b><font color='green'>You have the highest bid on this house!</font></b>";
                            } else echo "<b><font color='red'>You need to place a bid that is higher or equal to {$minbid}gp.</font></b>";
                        } else {
                            // Check if current bid is higher than last_bid
                            if ($bid_amount > $house['last_bid']) {
                                // Should only apply to external players, allowing a player to up his pledge without
                                // being forced to pay his full previous bid.
                                if ($house['highest_bidder'] != $player['id']) {
                                    $lastbid = $bid_amount + 1;
                                    mysql_update("UPDATE `houses` SET `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
                                    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
                                    echo "<b><font color='orange'>Unfortunately your bid was not higher than previous bidder.</font></b>";
                                } else {
                                    echo "<b><font color='orange'>You already have a higher pledge on this house.</font></b>";
                                }
                            } else {
                                echo "<b><font color='red'>Too low bid amount, someone else has a higher bid active.</font></b>";
                            }
                        }
                    } else echo "<b><font color='red'>You don't have enough money to bid this high.</font></b>";
                } else echo "<b><font color='red'>Your character is to low level, must be higher level than ", $config['houseConfig']['levelToBuyHouse']-1 ," to buy a house.</font></b>";
            } else echo "<b><font color='red'>You cannot have more houses.</font></b>";
        } else echo "<b><font color='red'>You need premium account to purchase houses.</font></b>";
    }

    // HTML structure and logic
    ?>
    <h1>House: <?php echo $house['name']; ?></h1>
    <ul>
        <li><b>Town</b>: 
        <?php
        $town_name = &$config['towns'][$house['town_id']];
        echo "<a href='houses.php?id=". $house['town_id'] ."'>". ($town_name ? $town_name : 'Specify town id ' . $house['town_id'] . ' name in config.php first.') ."</a>";
        ?></li>
        <li><b>Size</b>: <?php echo $house['size']; ?></li>
        <li><b>Beds</b>: <?php echo $house['beds']; ?></li>
        <li><b>Owner</b>: <?php
        if ($house['owner'] > 0) echo "<a href='characterprofile.php?name=". $house['ownername'] ."' target='_BLANK'>". $house['ownername'] ."</a>";
        else echo "Available for auction.";
        ?></li>
        <li><b>Rent</b>: <?php echo $house['rent']; ?></li>
    </ul>
    <?php
    // AUCTION MARKUP INIT
    if ($house['owner'] == 0) {
        ?>
        <h2>This house is up on auction!</h2>
        <?php
        if ($house['highest_bidder'] == 0) echo "<b>This house don't have any bidders yet.</b>";
        else {
            $bidder = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='". $house['highest_bidder'] ."' LIMIT 1;");
            echo "<b>This house have bidders! If you want this house, now is your chance!</b>";
            echo "<br><b>Active bid:</b> ". $house['last_bid'] ."gp";
            echo "<br><b>Active bid by:</b> <a href='characterprofile.php?name=". $bidder['name'] ."' target='_BLANK'>". $bidder['name'] ."</a>";
            echo "<br><b>Bid will end on:</b> ". getClock($house['bid_end'], true);
        }

        if ($house['bid_end'] == 0 || $house['bid_end'] > time()) {
            if (user_logged_in()) {
                // Your characters, indexed by char_id
                $yourChars = mysql_select_multi("SELECT `id`, `name`, `balance` FROM `players` WHERE `account_id`='". $user_data['id'] ."';");
                if ($yourChars !== false) {
                    $charData = array();
                    foreach ($yourChars as $char) {
                        $charData[$char['id']] = $char;
                    }
                    ?>
                    <form action="" method="post">
                        <select name="char">
                            <?php
                            foreach ($charData as $id => $char) {
                                echo "<option value='$id'>". $char['name'] ." [". $char['balance'] ."]</option>";
                            }
                            ?>
                        </select>
                        <input type="text" name="amount" placeholder="Min bid: <?php echo $minbid + 1; ?>">
                        <input type="submit" value="Bid on this house">
                    </form>
                    <?php
                } else echo "<br>You need a character to bid on this house.";
            } else echo "<br>You need to login before you can bid on houses.";
        } else echo "<br><b>Bid has ended! House transaction will proceed next server restart assuming active bidder have sufficient balance.</b>";
    }
} else {
    ?>
    <h1>No house selected.</h1>
    <p>Go back to the <a href="houses.php">house list</a> and select a house for further details.</p>
    <?php
}
include 'layout/overall/footer.php'; ?>

I have made some changes to the house files, and changed the way the house list is called upon. Basically, I made radio selections instead of drop box selections.

When I try to load a town, i get this,
No house selected.
Go back to the house list and select a house for further details.

I am having an issue figuring out how the house.php and houses.php are connected, so I do not know how to fix this.

Mods, this can be deleted. I forgot I had another thread about this, and that has been fixed on the other thread.

Other thread here, with answer to question : Znote AAC-Having an issue with a code

Mods, close this. Another forgotten thread created for the same issue.

Edit, I got 2 issues confused with each other. Dont close this
 
Last edited by a moderator:
Mods, this can be deleted. I forgot I had another thread about this, and that has been fixed on the other thread.

Other thread here, with answer to question : Znote AAC-Having an issue with a code

We don't delete threads because it's solved, but it's good that you posted the answer to the problem, so others can find it easiers via ex google seraches.

Mods, close this. Another forgotten thread created for the same issue. Solved here :Znote AAC-Having an issue with a code

We don't delete threads because it's solved, but it's good that you posted the answer to the problem, so others can find it easiers via ex google seraches.
 
Last edited:
@WibbenZ apparently I made 3 threads on this same topic. I have posted the solution in the main thread I listed a couple hours ago. I didnt see any point in 2 more pointless threads about the same thing being on here, so I requested them deleted.

EDIT - I made a mistake. Forget this post

House.php
Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(3);
}

$house = getValue($_GET['id']);

if ($house !== false && $config['TFSVersion'] === 'TFS_10') {
    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='$house';");
    $minbid = $config['houseConfig']['minimumBidSQM'] * $house['size'];
    if ($house['owner'] > 0) $house['ownername'] = user_name($house['owner']);

    //data_dump($house, false, "Data");

    //////////////////////
    // Bid on house logic
    $bid_char = &$_POST['char'];
    $bid_amount = &$_POST['amount'];
    if ($bid_amount && $bid_char) {
        $bid_char = (int)$bid_char;
        $bid_amount = (int)$bid_amount;
        $player = mysql_select_single("SELECT `id`, `account_id`, `name`, `level`, `balance` FROM `players` WHERE `id`='$bid_char' LIMIT 1;");
        // Does player have or need premium?
        $premstatus = $config['houseConfig']['requirePremium'];
        if ($premstatus) {
            $premstatus = mysql_select_single("SELECT `premdays` FROM `accounts` WHERE `id`='".$player['account_id']."' LIMIT 1;");
            $premstatus = ($premstatus['premdays'] > 0) ? true : false;
        } else $premstatus = true;
        if ($premstatus) {
            // Can player have or bid on more houses?
            $pHouseCount = mysql_select_single("SELECT COUNT('id') AS `value` FROM `houses` WHERE ((`highest_bidder`='$bid_char' AND `owner`='$bid_char') OR (`highest_bidder`='$bid_char') OR (`owner`='$bid_char')) AND `id`!='".$house['id']."' LIMIT 1;");
            if ($pHouseCount['value'] < $config['houseConfig']['housesPerPlayer']) {
                // Is character level high enough?
                if ($player['level'] >= $config['houseConfig']['levelToBuyHouse']) {
                    // Can player afford this bid?
                    if ($player['balance'] > $bid_amount) {
                        // Is bid higher than previous bid?
                        if ($bid_amount > $house['bid']) {
                            // Is bid higher than lowest bid?
                            if ($bid_amount > $minbid) {
                                // Should only apply to external players, allowing a player to up his pledge without
                                // being forced to pay his full previous bid. 
                                if ($house['highest_bidder'] != $player['id']) $lastbid = $house['bid'] + 1;
                                else {
                                    $lastbid = $house['last_bid'];
                                    echo "<b><font color='green'>You have raised the house pledge to ".$bid_amount."gp!</font></b><br>";
                                }
                                // Has bid already started?
                                if ($house['bid_end'] > 0) {
                                    if ($house['bid_end'] > time()) {
                                        mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
                                        $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
                                    }
                                } else {
                                    $lastbid = $minbid + 1;
                                    $bidend = time() + $config['houseConfig']['auctionPeriod'];
                                    mysql_update("UPDATE `houses` SET `highest_bidder`='". $player['id'] ."', `bid`='$bid_amount', `last_bid`='$lastbid', `bid_end`='$bidend' WHERE `id`='". $house['id'] ."' LIMIT 1;");
                                    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
                                }
                                echo "<b><font color='green'>You have the highest bid on this house!</font></b>";
                            } else echo "<b><font color='red'>You need to place a bid that is higher or equal to {$minbid}gp.</font></b>";
                        } else {
                            // Check if current bid is higher than last_bid
                            if ($bid_amount > $house['last_bid']) {
                                // Should only apply to external players, allowing a player to up his pledge without
                                // being forced to pay his full previous bid.
                                if ($house['highest_bidder'] != $player['id']) {
                                    $lastbid = $bid_amount + 1;
                                    mysql_update("UPDATE `houses` SET `last_bid`='$lastbid' WHERE `id`='". $house['id'] ."' LIMIT 1;");
                                    $house = mysql_select_single("SELECT `id`, `owner`, `paid`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE `id`='". $house['id'] ."';");
                                    echo "<b><font color='orange'>Unfortunately your bid was not higher than previous bidder.</font></b>";
                                } else {
                                    echo "<b><font color='orange'>You already have a higher pledge on this house.</font></b>";
                                }
                            } else {
                                echo "<b><font color='red'>Too low bid amount, someone else has a higher bid active.</font></b>";
                            }
                        }
                    } else echo "<b><font color='red'>You don't have enough money to bid this high.</font></b>";
                } else echo "<b><font color='red'>Your character is to low level, must be higher level than ", $config['houseConfig']['levelToBuyHouse']-1 ," to buy a house.</font></b>";
            } else echo "<b><font color='red'>You cannot have more houses.</font></b>";
        } else echo "<b><font color='red'>You need premium account to purchase houses.</font></b>";
    }
   

    // HTML structure and logic
    ?>
<table border="0" cellspacing="0" cellpadding="4">
    <tbody>
        <tr height="500">
            <td valign="top" bgcolor="eee8dc">
                <?php 
                    echo '<img width="150" height="150" align="left" src="layout/images/houses/Thralkeld/' .$house["id"]. '.png">';
                ?>
            </td>
            <td valign="top" bgcolor="eee8dc">
                <b><font size="3" color='black'><?php echo $house['name']; ?></font></b>
                <br>   
                <font color="black">This house has <?php echo $house['beds']; ?> bed(s).

<br>
<br>
<br>
        <p>The house has a size of <b><?php echo $house['size']; ?> square meters</b>. The monthly rent is <b><?php echo $house['rent']; ?> gold</b> and will be debited to the players bank account.</p> <br>
       
                <?php
                if ($house['owner'] > 0) echo "The house has been rented by <b><a href='characterprofile.php?name=". $house['ownername'] ."' target='_self'><font color='blue'>". $house['ownername'] ."</font></a>.";
                elseif ($house['highest_bidder'] == 0) echo "The house is currently being auctioned. No bid has been submitted so far.";
                 
        else {
            $bidder = mysql_select_single("SELECT `name` FROM `players` WHERE `id`='". $house['highest_bidder'] ."' LIMIT 1;");
            echo "<p>The house is currently being auctioned. The auction will end at <?php echo '<br><b></b> ". getClock($house['bid_end'], true);
            echo ". The highest bid so far is <b> ". $house['last_bid'] ."gp </b>";
            echo " and has been submitted by <b><a href='characterprofile.php?name=". $bidder['name'] ."' target='_self'><b><font color='blue'>". $bidder['name'] ."</font></a>.";
   
        }
?>
            <br><br><br><br><br><br><a href="#" onclick="history.go(-1)"><center><img src="layout/images/buttons/back.png"><center></a>
            </td>
        </tr>
    </tbody>
</table>
    <?php
    // AUCTION MARKUP INIT
    if ($house['owner'] == 0) {
           
        ?>


        <br>
        <br>
        <br>

   
        </ul></font>
<br>
<br>
<br>
<br>
<br>
<br>

<?php
       

        if ($house['bid_end'] == 0 || $house['bid_end'] > time()) {
            if (user_logged_in()) {
                // Your characters, indexed by char_id
                $yourChars = mysql_select_multi("SELECT `id`, `name`, `balance` FROM `players` WHERE `account_id`='". $user_data['id'] ."';");
                if ($yourChars !== false) {
                    $charData = array();
                    foreach ($yourChars as $char) {
                        $charData[$char['id']] = $char;
                    }
                    ?>
                    <form action="" method="post">
                        <select name="char">
                            <?php
                            foreach ($charData as $id => $char) {
                                echo "<option value='$id'>". $char['name'] ." </option>";
                            }
                            ?>
                        </select>
                        <input type="text" name="amount" placeholder="Min bid: <?php echo $minbid + 1; ?>">
                        <input type="submit" value="Place Bid">
                    </form>
                    <?php
                } else echo "<br>You need a character to bid on this house.";
            } else echo "<br>You need to login before you can bid on houses.";
        } else echo "<br><b>Bid has ended! House transaction will proceed next server restart assuming active bidder have sufficient balance.</b>";
    }
} else {
    ?>
   
    <h1>No house selected.</h1>
    <p>Go back to the <a href="houses.php">house list</a> and select a house for further details.</p>
<?php
}
include 'layout/overall/footer.php'; ?>

houses.php
Code:
<?php
require_once 'engine/init.php';
include 'layout/overall/header.php';

if ($config['log_ip'])
    znote_visitor_insert_detailed_data(3);

if (empty($_POST) === false && $config['TFSVersion'] === 'TFS_03') {

    /* Token used for cross site scripting security */
    if (isset($_POST['token']) && Token::isValid($_POST['token'])) {
       
        $townid = (int)$_POST['selected'];
        $cache = new Cache('engine/cache/houses');
        $array = array();
        if ($cache->hasExpired()) {
            $tmp = fetchAllHouses_03();
            $cache->setContent($tmp);
            $cache->save();
           
            foreach ($tmp as $t) {
                if ($t['town'] == $townid) $array[] = $t;
            }
            $array = isset($array) ? $array : false;
        } else {
            $tmp = $cache->load();
            foreach ($tmp as $t) {
                if ($t['town'] == $townid) $array[] = $t;
            }
            $array = isset($array) ? $array : false;
        }
       
        // Design and present the list
        if ($array) {
            ?>
            <h2>
                <?php echo ucfirst(town_id_to_name($townid)); ?> house list.
            </h2>
            <table id="housesTable" class="table table-striped">
                <tr class="yellow">
                    <th>Name:</th>
                    <th>Size:</th>
                    <th>Doors:</th>
                    <th>Beds:</th>
                    <th>Price:</th>
                    <th>Owner:</th>
                   
                </tr>
                    <?php
                    foreach ($array as $value) {
                        echo '<tr>';
                        echo "<td>". $value['name'] ."</td>";
                        echo "<td>". $value['size'] ."</td>";
                        echo "<td>". $value['doors'] ."</td>";
                        echo "<td>". $value['beds'] ."</td>";
                        echo "<td>". $value['price'] ."</td>";
                        if ($value['owner'] == 0)
                            echo "<td>None</td>";
                        else {
                            $data = user_character_data($value['owner'], 'name');
                            echo '<td><a href="characterprofile.php?name='. $data['name'] .'">'. $data['name'] .'</a></td>';
                        }
                        echo '</tr>';
                    }
                    ?>
            </table>
            <?php
        } else {
            echo 'Empty list, it appears no houses are listed in this town.';
        }
        //Done.
    } else {
        echo 'Token appears to be incorrect.<br><br>';
        //Token::debug($_POST['token']);
        echo 'Please clear your web cache/cookies <b>OR</b> use another web browser<br>';
    }
} else {
    if (empty($_POST) === true && $config['TFSVersion'] === 'TFS_03') {
        if ($config['allowSubPages'])
            header('Location: sub.php?page=houses');
        else
            echo 'Sub page system disabled.';
    } else if ($config['TFSVersion'] === 'TFS_02') {
        $house = $config['house'];
        if (!is_file($house['house_file'])) {
            echo("<h3>House file not found</h3><p>FAILED TO LOCATE/READ FILE AT:<br><font color='red'>". $house['house_file'] ."</font><br><br>LINUX users: Make sure www-data have read access to file.<br>WINDOWS users: Learn to write correct file path.</p>");
            exit();
        }

        // Load and cache SQL house data:
        $cache = new Cache('engine/cache/houses/sqldata');
        if ($cache->hasExpired()) {
            $house_query = mysql_select_multi('SELECT `players`.`name`, `houses`.`id` FROM `players`, `houses` WHERE `houses`.`owner` = `players`.`id`;');
           
            $cache->setContent($house_query);
            $cache->save();
        } else
            $house_query = $cache->load();

        $sqmPrice = $house['price_sqm'];
        $house_load = simplexml_load_file($house['house_file']);
        if ($house_query !== false && $house_load !== false) {
            ?>
            <h2>House list</h2>
            <table>
                <tr class="yellow">
                    <td><b>House</b></td>
                    <td><b>Location</b></td>
                    <td><b>Owner</b></td>
                    <td><b>Size</b></td>
                    <td><b>Rent</b></td>
                </tr>

                <?php
                //execute code.
                foreach($house_query as $row)
                    $house_info[(int)$row['id']] = '<a href="characterprofile.php?name='. $row['name'] .'">'. $row['name'] .'</a>';

                foreach ($house_load as $house_fetch){
                    $house_price = (int)$house_fetch['size'] * $sqmPrice;
                    ?>
                    <tr>
                        <td><?php echo htmlspecialchars($house_fetch['name']); ?></td>
                        <td>
                            <?php
                            if (isset($config['towns'][(int)$house_fetch['townid']])) echo htmlspecialchars($config['towns'][(int)$house_fetch['townid']]);
                            else echo '(Missing town)';
                            ?>
                        </td>
                        <td>
                            <?php
                            if (isset($house_info[(int)$house_fetch['houseid']])) echo $house_info[(int)$house_fetch['houseid']];
                            else echo 'None [Available]';
                            ?>
                        </td>
                        <td><?php echo $house_fetch['size']; ?></td>
                        <td><?php echo $house_price; ?></td>
                    </tr>
                    <?php
                }
                ?>
            </table>
            <?php
        } else echo '<p><font color="red">Something is wrong with the cache.</font></p>';
    } else if ($config['TFSVersion'] === 'TFS_10') {
        // Fetch values
        $querystring_id = &$_GET['id'];
        $townid = ($querystring_id) ? (int)$_GET['id'] : $config['houseConfig']['HouseListDefaultTown'];
        $towns = $config['towns'];

        $order = &$_GET['order'];
        $type = &$_GET['type'];

        // Create Search house box
        ?>
       
        <?php
        if(!in_array($order, $order_allowed))
            $order = 'id';

        if(!in_array($type, $type_allowed))
            $type = 'desc';

        // Create or fetch data from cache
        /*$cache = new Cache('engine/cache/houses/houses-' . $order . '-' . $type);
        $houses = array();
        if ($cache->hasExpired()) {*/
            $houses = array();
            $query = "SELECT `id`, `owner`, `paid`, `warnings`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses` WHERE 1 ".($_GET["state"] === 'auctioned' ? 'AND `owner`=\'0\'' : ($_GET["state"] === 'all' ? '' : 'AND `owner`>\'0\' '))." ".($_GET["type_"] === 'guildhalls' ? "AND `beds` > '2' " : " AND `beds` < '3'")." ORDER BY {$order} {$type};";
            $houses = mysql_select_multi($query);//"SELECT `id`, `owner`, `paid`, `warnings`, `name`, `rent`, `town_id`, `size`, `beds`, `bid`, `bid_end`, `last_bid`, `highest_bidder` FROM `houses`  ORDER BY {$order} {$type};");
            if ($houses !== false) {
                // Fetch player names
                $playerlist = array();

                foreach ($houses as $h)
                    if ($h['owner'] > 0)
                        $playerlist[] = $h['owner'];

                if (!empty($playerlist)) {
                    $ids = join(',', $playerlist);
                    $tmpPlayers = mysql_select_multi("SELECT `id`, `name` FROM players WHERE `id` IN ($ids);");

                    // Sort $tmpPlayers by player id
                    $tmpById = array();
                    foreach ($tmpPlayers as $p)
                        $tmpById[$p['id']] = $p['name'];

                    for ($i = 0; $i < count($houses); $i++)
                        if ($houses[$i]['owner'] > 0)
                            $houses[$i]['ownername'] = $tmpById[$houses[$i]['owner']];
                }
                /*$cache->setContent($houses);
                $cache->save();*/
            }
        /*} else
            $houses = $cache->load();*/

        if ($houses !== false || !empty($houses)) {
            // Intialize stuff
            //data_dump($houses, false, "House data");
            ?>
           
            <table border="4">
                <tr height="48">
                    <td bgcolor="eee8dc">
                        <font color="black">Here you can see the list of all available houses, flats or guildhalls. Click on any view button to get more information about a house or adjust the search criteria and start a new search.
                    </td>
                </tr>
            </table>   
           
                        <form action="" method="get" >
            <table border="0" cellspacing="1" cellpadding="4" width="100%">
                <tbody>
                    <tr bgcolor="#800000">
                        <td colspan="4" class="white">
                            <b><font color="eee8dc">House Search</b>
                        </td>
                    </tr>
                    <tr bgcolor="eee8dc">   
                        <td width="33%">
                            <b><font color="black">Town</b>
                        </td>
                        <td width="33%">
                            <b><font color="black">Status</b>
                        </td>
                        <td width="33%">
                            <b><font color="black">Order</b>
                        </td>
                    </tr>
                    <tr    bgcolor="eee8dc">
                        <td valign="top" rowspan="2">
                        <?php
                            foreach ($towns as $id => $name)
                                if($id > 1) echo '<input '. ($id == 2 ? 'checked' : '') .' type="radio" name="id" value="'. $id .'"' . ($townid != $id ?: ' selected') . '><font color="black">'. $name . '<br>';
                        ?>
                        </td>   
                        <td valign="top">
                            <input type="radio" name="state" value="all" checked><font color="black"> all states <br>
                            <input type="radio" name="state" value="auctioned"><font color="black"> auctioned <br>
                            <input type="radio" name="state" value="rented"><font color="black"> rented <br>
                        </td>
                        <td valign="top" rowspan="2">
                        <?php
                        $order_allowed = array('name', 'size', 'beds', 'rent');
                        foreach($order_allowed as $o)
                            echo '<input type="radio" name="order" value="' . $o . '"' . ($o != $order ?: ' selected') . ( $o === 'id' ? ' checked' : '' ).'><font color="black"> by '. $o .'<br>';
                        ?>
                        </td>
                    </tr>   
                    <tr bgcolor="eee8dc">
                        <td valign="top">
                            <input type="radio" name="type_" value="houses" checked><font color="black"> houses and flats <br>
                            <input type="radio" name="type_" value="guildhalls"><font color="black"> guildhalls <br>
                        </td>
                    </tr>
                </tbody>
            </table>   
            <br><center>
            <table border="0" cellspacing="0" cellpadding="0"></table>
                <tbody>
                    <tr>
                        <td>
                            <input type="image" alt="Submit" src="layout/images/buttons/submit.png">
                        </td>
                    </tr>
                </tbody>
            </table><br></center>
        </form>
            <table border="0" cellspacing="1" cellpadding="4" width="100%">
                <tr bgcolor="#8000000">
                    <td width="30%">
                        <b><font color="eee8dc">Name</b>
                    </td>   
                    <td width="10%">
                        <b><font color="eee8dc">Size</b>
                    </td>   
                    <td width="10%">
                        <b><font color="eee8dc">Rent</b>
                    </td>   
                    <td width="30%">
                        <b><font color="eee8dc">Status</b>
                    </td>
               
                    <td width="30%">
                        <b><font color="eee8dc"></b>
                    </td>
                   
                   
                </tr>
                <?php
                foreach ($houses as $house) {
                    if ($house['town_id'] == $townid) {
                        ?>
                        <tr>
                            <td bgcolor="eee8dc"><font color="black"><?php echo  $house['name'] ; ?></td>
                            <td bgcolor="eee8dc"><font color='black'><?php echo $house['size']; ?> sqm</td>
                           
                            <td bgcolor="eee8dc"><font color='black'><?php echo $house['rent']; ?> gold</td>
                            <?php
                            // Status:
                            if ($house['owner'] != 0)
                                echo "<td bgcolor='eee8dc'><font color='black'>rented</a></td>";
                            else
                                echo ($house['highest_bidder'] == 0 ? '<td bgcolor="eee8dc"><font color="black">auctioned (no bid yet)</td>' : '<td bgcolor="eee8dc"><font color="black">auctioned (' . $house["bid"]. ' gold, ' . (0 + date('d', $house["bid_end"] - strtotime(date('m/d/Y ')))). ' days left) </td>')
                            ?>
                           
                            <?php 
                echo '<td bgcolor="eee8dc"><a href="house.php?id='. $house['id'] .'"><img align="center" src="layout/images/buttons/view.gif"></a></td>';
                            ?>
                           
                        </tr>
                        <?php
                    }
                }
                ?>
            </table>
            <br>
            <br>


            <?php
        } else
            echo '<table border="0" cellspacing="1" cellpadding="4" width="100%">
                <tbody>
                    <tr bgcolor="#800000">
                        <td colspan="4" class="white">
                            <b><font color="eee8dc">House Search</b>
                        </td>
                    </tr>
                    <tr bgcolor="eee8dc">   
                        <td width="33%">
                            <b><font color="black">Town</b>
                        </td>
                        <td width="33%">
                            <b><font color="black">Status</b>
                        </td>
                        <td width="33%">
                            <b><font color="black">Order</b>
                        </td>
                    </tr>
                   
                    <tr bgcolor="eee8dc">
                        <td valign="top">
                            <input type="radio" name="type_" value="houses" checked><font color="black"> houses and flats <br>
                            <input type="radio" name="type_" value="guildhalls"><font color="black"> guildhalls <br>
                        </td>
                    </tr>
                    </tbody>
                    </table>
                    <br><center>
            <table border="0" cellspacing="0" cellpadding="0"></table>
                <tbody>
                    <tr>
                        <td>
                            <input type="image" alt="Submit" src="layout/images/buttons/submit.png">
                        </td>
                    </tr>
                </tbody>
            </table><br></center>';
    } // End TFS 1.0 logic
}
include 'layout/overall/footer.php'; ?>

Replace both files with those listed above. The issue was fixed the other night. Thanks to @Bogart
 
Last edited by a moderator:
Solution

No what I was saying is that it's good that you posted what you found to be the solution, I didn't tell you to edit it :p (rule #8)
Most people change the topic and info to "nvm solved" and that makes it pretty hard to find a solution via ex the serach function or google.

What I was telling is that we don't remove thread just because you solved them, (once again rule #8) and that is to once again make it easier via seraches.

@WibbenZ apparently I made 3 threads on this same topic. I have posted the solution in the main thread I listed a couple hours ago. I didnt see any point in 2 more pointless threads about the same thing being on here, so I requested them deleted.

EDIT - I made a mistake. Forget this post

Replace both files with those listed above. The issue was fixed the other night. Thanks to @Bogart

Please read the rules; Rules for the Support board
#2

Oh okay, ill delete those threads in that case.
 
Back
Top