<?php

include('../core.php');
include('../includes/session.php');

$id = FilterText($_POST['optionNumber']);

$sql = mysql_query("SELECT * FROM cms_marktplatz WHERE id = '".$id."' LIMIT 1");
$row = mysql_fetch_assoc($sql);

if($myrow['vip_points'] < $row['vip_points']){ $error = "Bolts"; }


if(isset($error)){
	$msg ="<img src=\"".$path."/web-gallery/v2/images/frank_welcome.png\" style=\"margin: 10px;\" align=\"left\">
		<p>Ops... cosa succede?</p>
 		<p>Non hai abbastanza <b>".$error."</b> per comprare questo distintivo.<br></p>
 		<p>Ti servono piu' <b>".$error."</b>, contatta un Amministratore o acquista le Promozioni</a><br></p>";
}elseif($myrow['online'] == '0'){
		$check2 = mysql_query("SELECT * FROM user_badges WHERE user_id = '".$my_id."' AND badge_id = '".$row['image']."'");
		$check = mysql_num_rows($check2);
                if($check < 1){
			mysql_query("INSERT INTO user_badges (user_id,badge_id,badge_slot) VALUES ('".$my_id."','".$row['image']."','0')");
			mysql_query("UPDATE users SET vip_points = vip_points - '".$row['vip_points']."' WHERE id = '".$my_id."'") or die(mysql_error());
			$msg = "Hai acquistato <b>".$row['image']."</b> con successo!";
			SendMUS("updatepoints", $my_id);
		}else{
			$msg = "Hai gia' questo distintivo!";
		}
} else {
$msg = "<img src=\"".$path."/web-gallery/v2/images/frank_welcome.png\" align=\"right\">Devi essere offline per comprare questo distintivo.<br><br>Per favore esci dall'hotel dall'hotel.<br><br><br>";
}

?>

<div id="hc_confirm_box">


<p><?php echo $msg; ?></p>
<p>
<a href="#" class="new-button" onclick="habboclub.closeSubscriptionWindow(); return false;">
<b>Continua</b><i></i></a>
</p>

</div>

<div class="clear"></div>