<?php
$allow_guests = false;

require_once('global.php');
require_once('INC/class.session.php');

$pagename = "Rares";
$pageid = "rares";
$body_id = "rares";

//require_once('templates/community_subheader.php');
require_once('templates/shop_header.php');


$rare = Filter($_GET['buyrare']);

$sql = mysql_query("SELECT * FROM shop_rares ORDER by id ASC");

if(isset($_GET['buyrare']))
{
	$getRareCost = mysql_query("SELECT * FROM shop_rares WHERE base_item = '" . $rare . "'");
	$rareCost = mysql_fetch_assoc($getRareCost);
	
		if($myrow['piks'] < $rareCost['price'])
		{
			$msg = "<div class=\"alert\"><img src='".$path."/web-gallery/v2/images/shop/icon-error.gif' /> Vous n'avez pas assez de Piks. <a href='piks'>«En acheter plus»</a>.</div>";
		}
		else
		{
			$resultat1 = rand(10330000,10400000);
			$temps_actuelle = time();
			mysql_query("INSERT INTO items (id,user_id,base_item,extra_data) VALUES ('".$resultat1."','".$my_id."','".$rare."','0')");
                        mysql_query("UPDATE users SET piks = piks - " . $rareCost['price'] . " WHERE username = '" . $myrow['username'] . "'");
			     $msg = "<div class=\"alert\"><img src='".$path."/web-gallery/v2/images/shop/icon-good.gif' /> Tu viens d'acheter un rare, pour <u>".$rareCost['price']." Piks</u>.</div>";
		}
	}

    
?>
<div id="container">
    <div class="shop">
        <div class="title blue">Boutique - Rares (<?php echo $piks; ?><img src="<?php echo $path; ?>/web-gallery/v2/images/vipcoin.gif" />)</div> 
        <?php if(isset($msg)) echo $msg; ?>
        <?php if($myrow['online'] == "0") { ?>
        <div class="offre general">
            <img align="right" src="<?php echo $path;?>/web-gallery/images/shop/bb_red_yellow_blue.gif" /> 
            <h2 class="offre-title">Pack rares [I] </h2>
            
           <?php 	while($RARE = mysql_fetch_assoc($sql)) { ?>
        

        <?php 
		echo 
        '<div class="badges-content">'.
        '<img src="'.$path.'/web-gallery/images/shop/icon_avaliable.gif" align="right" /> 
                    <p>
                   
<a href="?buyrare='.$RARE['base_item'].'">
                <img align="right" src="http://habbo.ma/web-gallery/images/shop/rares/' . $RARE['image'] . '.gif"></a>
            <b>Nom du Rare:</b> '.$RARE['name'].' <br/>
            <b>Seulement:</b> '.$RARE['price'].'  Piks  <br />                   
            
 </p>' . '</div>';

            ?>
                
              
                
            
            
            <?php }  } else { echo "
             <div class=\"alert\"><img src='".$path."/web-gallery/v2/images/shop/icon-error.gif' /> 
                 Vous devez être déconnecté du client pour acheter un rare.</div>

" ; }?>
            
           
            
            
        
     <p class="info"><img src="<?php echo  $path; ?>/web-gallery/images/shop/icon_10.gif" /> Pour acheter un rare, vous devez cliquer sur l'image.</p>
    
        
        </div>
        </div>
    </div>
   

<script>
    $(".badges-content").click(function () {
      $(this).toggleClass("selected");
    });
</script>
<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script></div>

<!--[if lt IE 7]>
<script type="text/javascript">
Pngfix.doPngImageFix();
</script>
<![endif]--> 
<script type="text/javascript"> 
    HabboView.run(); 
</script> 

<?php //include('templates/community_footer.php'); ?>