getlisting($_GET['listingId']);
if($listing == null)
{
header("Location: index.php");
exit;
}
if(isset($_GET['action']))
{
switch($_GET['action'])
{
case "buyPost":
if(isset($_SESSION['userId']) && $_SESSION['userId'] != $listing['userId'] && $listing['pricePost'] > 0)
{
$user = $db->getUser($_SESSION['userId']);
if($user['credits'] >= $listing['pricePost'])
{
if($db->createBuyOrder($listing['id'], $_SESSION['userId'], $listing['pricePost'], 1))
{
$success = true;
$message = $l->getString("Order placed! We sent you an e-mail to put you in contact with the vendor.");
}
}
else
{
$error = $l->getString("You don't have enough credits, please buy some here.");
}
}
else
{
$error = $l->getString("You can't place a buy order on this announce.");
}
break;
case "buyPage":
if(isset($_SESSION['userId']) && $_SESSION['userId'] != $listing['userId'] && $listing['pricePage'] > 0)
{
$user = $db->getUser($_SESSION['userId']);
if($user['credits'] >= $listing['pricePage'])
{
if($db->createBuyOrder($listing['id'], $_SESSION['userId'], $listing['pricePage'], 2))
{
$success = true;
$message = $l->getString("Order placed! We sent you an e-mail to put you in contact with the vendor.");
}
}
else
{
$error = $l->getString("You don't have enough credits, please buy some here.");
}
}
else
{
$error = $l->getString("You can't place a buy order on this announce.");
}
break;
}
}
require("includes/header.php");
if(isset($error))
{
echo $error . '
';
}
if($listing['pricePost'] > 0)
echo '' . $l->getString("Buy post for %f", $listing['pricePost']) . '
';
if(!$db->salePageActive($listing['id']))
{
if($listing['pricePage'] > 0)
echo '' . $l->getString("Buy page for %01.2f", $listing['pricePage']) . '
';
}
else
{
echo $l->getString("There already is a buy order on this page.");
}
?>