示例#1
0
文件: houses.php 项目: aottibia/www
        </table></td></tr></table><br />';
        if ($house['owner'] == 0 && ($house['bid_end'] > time() || $house['bid_end'] == 0)) {
            // bid button
            $main_content .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><TD><center><a href="index.php?subtopic=houses&action=bid&house=' . $house['id'] . '"><img src="' . $layout_name . '/images/buttons/sbutton_bid.gif" BORDER=0 /></a></center></TD><TD><center><a href="index.php?subtopic=houses&town=' . (int) $house['town_id'] . '&owner=' . ($house['owner'] > 0 ? 1 : 0) . '&order=0&status=0"><img src="' . $layout_name . '/images/buttons/sbutton_back.gif" BORDER=0 /></a></center></TD></TR></TABLE>';
        } else {
            $main_content .= '<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%><TR><TD><center><a href="index.php?subtopic=houses&town=' . (int) $house['town_id'] . '&owner=' . ($house['owner'] > 0 ? 1 : 0) . '&order=0&status=0"><img src="' . $layout_name . '/images/buttons/sbutton_back.gif" BORDER=0 /></a></center></TD></TR></TABLE>';
        }
    }
} elseif ($action == 'bid') {
    if (Visitor::isLogged()) {
        $houseOwned = $SQL->query('SELECT `houses`.`id` house_id, `players`.`id` owner_id FROM `houses`, `players` WHERE `players`.`id` = `houses`.`owner` AND `players`.`account_id` = ' . Visitor::getAccount()->getID() . ' LIMIT 1')->fetch();
        if ($houseOwned === false) {
            if (isset($_REQUEST['house'])) {
                $house = new House((int) $_REQUEST['house']);
                if ($house->isLoaded()) {
                    if ($house->getOwner() == 0) {
                        if ($house->getBidEnd() == 0 || $house->getBidEnd() > time()) {
                            $houseBidded = $SQL->query('SELECT `houses`.`id` house_id, `players`.`id` bidder_id FROM `houses`, `players` WHERE `players`.`id` = `houses`.`highest_bidder` AND `players`.`account_id` = ' . Visitor::getAccount()->getID())->fetch();
                            if ($houseBidded === false || $houseBidded['house_id'] == $house->getID()) {
                                $bidded = false;
                                if (isset($_REQUEST['do_bid'])) {
                                    if (isset($_REQUEST['bid']) && isset($_REQUEST['bidder'])) {
                                        $bidder = new Player($_REQUEST['bidder']);
                                        $bid = (int) $_REQUEST['bid'];
                                        if ($bidder->isLoaded() && $bidder->getAccountID() == Visitor::getAccount()->getID()) {
                                            if ($bidder->getBalance() >= $bid) {
                                                // jesli przebija swoja oferte to nie musi dawac wiecej
                                                // moze tylko zmieniac postac ktora zostanie, a nawet obnizac maksymalna
                                                if ($bid > 0 && ($bid > $house->getBid() || $houseBidded !== false)) {
                                                    // jesli przebija sam siebie to nie podnosi ceny aktualnej
                                                    if ($houseBidded === false) {