value('user_id') && $session->value('membersarea') != 'Active') { header_redirect('login.php?redirect=auction_details.php?auction_id=' . $_REQUEST['auction_id'] . '&guest=1'); } else { require ('global_header.php'); $item = new item(); $item->setts = &$setts; $item->layout = &$layout; //$template->set('fees', $fees); $template->set('session', $session); $template->set('item', $item); $actions_array = array('buy_out_confirm', 'buy_out_submit', 'buy_out_success', 'buy_out_error'); $action = (in_array($_REQUEST['action'], $actions_array)) ? $_REQUEST['action'] : 'buy_out_confirm'; $item_details = $db->get_sql_row("SELECT a.*, di.url FROM " . DB_PREFIX . "auctions a LEFT JOIN " . DB_PREFIX . "digital_item di ON di.auction_id=a.auction_id WHERE a.auction_id='" . intval($_REQUEST['auction_id']) . "'"); $user_details = $db->get_sql_row("SELECT u.*, c.name AS country_name, c.country_phone_code, s.name AS state_name FROM " . DB_PREFIX . "users u LEFT JOIN " . DB_PREFIX . "countries s ON u.state=s.id LEFT JOIN " . DB_PREFIX . "countries c ON c.id=u.country WHERE user_id=" . $session->value('user_id')); $user = new user(); $address = $user->full_address($user_details); $template->set('user_details', $user_details); $template->set('address', $address); $quantity = ($_REQUEST['quantity']) ? $_REQUEST['quantity'] : 1; $comment = $_REQUEST['comment']; $blocked_user = blocked_user($session->value('user_id'), $item_details['owner_id']); if($item_details['listing_type'] == 'free_item' && !$user_details['mail_activated'] && !$setts['email_unverified_free_item']) { $action = 'buy_out_error'; } if (($user_details['day_buy_sequence'] >= $setts['day_buy_sequence_limit']) && $setts['day_buy_sequence_limit'] != 0 ) { if((CURRENT_TIME - $user_details['day_first_buy_time']) <= 86400) { $action = 'buy_out_error'; } else { $db->query("UPDATE " . DB_PREFIX . "users SET day_first_buy_time=0, day_buy_sequence=0 WHERE user_id='" . $session->value('user_id') . "'"); } } if ($session->is_set('buyout_id') || $session->value('user_id') == $item_details['owner_id'] || $blocked_user) { $action = 'buy_out_error'; } if (empty($user_details['name']) || empty($user_details['address']) || empty($user_details['city']) || empty($user_details['state']) || empty($user_details['zip_code']) || empty($user_details['phone'])) { $action = 'buy_out_error'; $no_ui = 1; } if ($quantity>$item_details['quantity'] && !$setts['quantity_unlimited']) { $action = 'buy_out_confirm'; $template->set('buy_out_error_message', '

' . MSG_NOT_ENOUGH_QUANTITY_BUYOUT . '

'); } if ($action == 'buy_out_submit') { $bid_loop = 1; $bid_placement_time = time(); // we will wait for 5 seconds and then place the bid, even if bid_in_progress = 1; while ($bid_loop == 1) { $bid_loop = $db->get_sql_field("SELECT bid_in_progress FROM " . DB_PREFIX . "auctions WHERE auction_id='" . $item_details['auction_id'] . "'",'bid_in_progress'); $bid_current_time = time(); $bid_loop = (($bid_current_time - $bid_placement_time) > 5) ? 0 : $bid_loop; if ($bid_loop) { sleep(1);## PHP Pro Bid v6.00 we dont want to create a huge load on the database. } } $mark_in_progress = $db->query("UPDATE " . DB_PREFIX . "auctions SET bid_in_progress=1 WHERE auction_id='" . $item_details['auction_id'] . "'");## PHP Pro Bid v6.00 we will assign the winner, and then close the auction if the case. if(empty($user_details['day_first_buy_time'])) { $first_buy_time = $db->query("UPDATE " . DB_PREFIX . "users SET day_first_buy_time='" . CURRENT_TIME . "' WHERE user_id='" . $session->value('user_id') . "'"); } $day_buy_sequence = $user_details['day_buy_sequence'] + 1; $buy_sequence = $db->query("UPDATE " . DB_PREFIX . "users SET day_buy_sequence='".$day_buy_sequence."' WHERE user_id='" . $session->value('user_id') . "'"); $session->set('buyout_id', $_REQUEST['auction_id']); if($item_details['listing_type'] == 'free_item') { $purchase_result = $item->assign_winner($item_details, 'free_item', $session->value('user_id'), $quantity, null, $comment); } if($item_details['listing_type'] == 'buy_out') { $purchase_result = $item->assign_winner($item_details, 'buy_out', $session->value('user_id'), $quantity, null, $comment); } if ($purchase_result['auction_close']) { $item->close($item_details); } $unmark_in_progress = $db->query("UPDATE " . DB_PREFIX . "auctions SET bid_in_progress=0 WHERE auction_id='" . $item_details['auction_id'] . "'"); $action = 'buy_out_success'; } $template->set('item_details', $item_details); (string) $buy_out_page_content = null; if (!$item_details || $action == 'buy_out_error') { $template->set('buy_out_header_message', header5(MSG_ERROR)); if ($blocked_user) { $buy_out_page_content = block_reason($session->value('user_id'), $item_details['owner_id']); } else if ($item_details['listing_type'] == 'free_item' && !$user_details['mail_activated'] && !$setts['email_unverified_free_item']) { $buy_out_page_content = '
' . MSG_EMAIL_VERIFICATION_ERROR . '


'; } else if ($user_details['day_buy_sequence'] >= $setts['day_buy_sequence_limit'] && (CURRENT_TIME - $user_details['day_first_buy_time']) <= 86400) { $buy_out_page_content = '
' . MSG_PURCHASE_TOO_MUCH_ERROR . '


'; } else if ($session->is_set('buyout_id')) { $buy_out_page_content = '

' . MSG_DOUBLE_POST_ERROR . '

'; } else if ($no_ui) { header_redirect('members_area.php?page=account§ion=editinfo'); } else { $buy_out_page_content = '

' . MSG_CANT_BUYOUT_ITEM . '

'; } } else if ($action == 'buy_out_confirm') { //$template->set('buy_out_header_message', header5(GMSG_BUYOUT)); if (!empty($item_details['direct_payment'])) { $dp_methods = $item->select_direct_payment($item_details['direct_payment'], $user_details['user_id'], true, true); $template->set('direct_payment_methods_display', $db->implode_array($dp_methods, ', ')); } if (!empty($item_details['payment_methods'])) { $offline_payments = $item->select_offline_payment($item_details['payment_methods'], true, true); $template->set('offline_payment_methods_display', $db->implode_array($offline_payments, ', ')); } $tax = new tax(); $auction_tax = $tax->auction_tax($item_details['owner_id'], $setts['enable_tax'], $session->value('user_id')); $template->set('auction_tax', $auction_tax); $template->set('quantity', $quantity); $template->set('comment', $comment); $template->set('action', 'buy_out_submit'); /* warn if the seller doesnt ship in the buyers location */ $shipping_locations_warning = null; if ($user_details['pc_shipping_locations'] == 'local') { $buyer_details = $db->get_sql_row("SELECT country, state FROM " . DB_PREFIX . "users WHERE user_id='" . $session->value('user_id') . "'"); $loc_details = user_location($user_details['user_id'], $buyer_details['country'], $buyer_details['state']); if (!$loc_details['valid']) { $shipping_locations_warning = '' . MSG_SHIPPING_LOCATION_UNSUPPORTED_WARNING . ''; } } $template->set('shipping_locations_warning', $shipping_locations_warning); if($mobile_device) { $buy_out_page_content = $template->process('buy_out_confirm_mobile.tpl.php'); } else { $buy_out_page_content = $template->process('buy_out_confirm.tpl.php'); } } else if ($action == 'buy_out_success') { //$template->set('buy_out_header_message', header5(MSG_PURCHASE_SUCCESS)); $buy_out_success_message = '

' . MSG_PURCHASE_SUCCESS_EXPL . '

'. '

[ ' . MSG_CONTINUE_SHOPPING . ' ]

'; $template->set('buy_out_success_message', $buy_out_success_message); $direct_payment_box = $item->direct_payment_box($item_details, $session->value('user_id'), $purchase_result['winner_id']); $template->set('direct_payment_box', $direct_payment_box[0]); $template->set('quantity', $quantity); $template->set('comment', $comment); if($mobile_device) { $buy_out_page_content = $template->process('buy_out_success_mobile.tpl.php'); } else { $buy_out_page_content = $template->process('buy_out_success.tpl.php'); } } $template->set('buy_out_page_content', $buy_out_page_content); $template_output .= $template->process('buy_out.tpl.php'); include_once ('global_footer.php'); echo $template_output; } ?>