<?php
$allow_guests = false;

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

$pagename = "VIP CLUB";
$pageid = "vipclub";
$body_id = "vipclub";

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

$p = Filter($_GET['p']);
$sql = mysql_query("SELECT * FROM boutique WHERE type = 'vip' ORDER BY id ASC");
	while($row = mysql_fetch_assoc($sql)) {
            
if($p == "check") {
        $now_unixtime = time(); //Get the current unix timestamp.
            $vipexpire = ($now_unixtime + $row['plus']);
            if($myrow['piks'] >= $row['price']) { // Si le client à plus de 10 

            if(mysql_num_rows(mysql_query("SELECT timestamp_expire FROM user_subscriptions WHERE subscription_id = 'habbo_vip' AND user_id = '".$my_id."'")) > 0)
            {
            mysql_query("UPDATE user_subscriptions SET timestamp_expire = timestamp_expire + '".$row['plus']."' WHERE user_id = '".$my_id."' AND subscription_id = 'habbo_vip'") or die(mysql_error());
            ;
            } else {
           mysql_query("INSERT INTO user_subscriptions (user_id,subscription_id,timestamp_activated,timestamp_expire) VALUES ('".$my_id."','habbo_vip', '".$now_unixtime."', '".$vipexpire."')") or die(mysql_error());
            }

            mysql_query("UPDATE users SET piks = piks - '".$row['price']."' WHERE id='".$my_id."'");
            mysql_query("INSERT INTO `user_badges` (`user_id`, `badge_id`, `badge_slot`) VALUES ('".$my_id."', 'ACH_VipClub1', '0')");
            mysql_query("UPDATE users SET rank='2', vip = '1' WHERE id ='" . $my_id . "'")or die(mysql_error());
            mysql_query("UPDATE users SET credits = credits + '1000000' WHERE id = '".$my_id."'") or die (mysql_error());
            mysql_query("UPDATE users SET activity_points = activity_points + '33000' WHERE id = '".$my_id."'") or die (mysql_error());
            //vérifie si le badge existe déjà pour l'user.
            if(mysql_num_rows(mysql_query("SELECT null FROM user_badges WHERE badge_id ='ACH_VipClub1' AND user_id ='".$my_id."'")) > 0)
            {
            $msg = "<div class=\"alert\"><img src='".$path."/web-gallery/v2/images/shop/icon-error.gif' /> Erreur! Tu possèdes déjà ce badge!</div>";
            $failure = true;
            } else {
            mysql_query("INSERT INTO user_badges (user_id, badge_id) VALUES ('".$my_id."','ACH_VipClub1')");
            }

            $a = "<div class=\"alert\"><img src='".$path."/web-gallery/v2/images/shop/icon-good.gif' /> Achat effectué avec succès!</div>";

            //exit;
            } else {
            $a = "<div class=\"alert\"><img src='".$path."/web-gallery/v2/images/shop/icon-error.gif' /> Erreur! Tu n'as pas assez de piks!</div>";
            }
            }
    


?>
<div id="container" >
    <div class="shop" style="position: absolute;">
        <div class="title blue">Boutique</div> 
        
        <?php if(isset($a)) { echo $a; } ?>
        
         <p class="about-shop">
             <img style="margin-right: 13px;" src="http://www.habbox.com/images/calvin/archive/images/icons/me_effects_active.gif" align="right"/>
             Hey <b><?php echo $name; ?>!</b>, Tu n'es pas encore <u>Célèbre</u>?<br />
         <b>Achète un abonnement VIP et deviens célèbre dès maintenant! </b>
      <br />
    <u>Duration du VIP CLUB:</u> 1 mois (renouvelable). <img src="<?php echo $path; ?>/web-gallery/images/shop/icon_star.gif" /></p>
         
         <div class="offre first">
           <img align="right" src="<?php echo $path;?>/web-gallery/images/shop/bb_red_yellow_blue.gif" /> 
           <h2 class="offre-title">Vip Club I </h2>
                       <img src="<?php echo $path; ?>/web-gallery/images/shop/figure_vip_promo.gif" align="right" />
             <div class="price">
                <div>
                    <br /><br />
                <b><?php echo $row['price']; ?> <br />Piks </b>
                </div>
            </div>

            <div class="text"> 
                <p>Le <u>VIP CLUB</u>, est un bon moyen de profiter de tous les avantages de Habbo Hotel, il te permet d'avoir
                plusieurs avantages sur le Site ainsi que l'Hôtel.</p>
            </div>
            
                <?php if($piks >= $row['price']) { ?>
            <a href="?p=check" class="about">J'achète!</a>
            <?php } else { ?>
            <div class="no-piks">
                Vous n'avez pas assez de Piks!
            </div>

            <?php } ?>
            <div class="clear"></div>

        </div>

        <div class="offre first">
           <img align="right" src="<?php echo $path;?>/web-gallery/images/shop/bb_red_yellow_blue.gif" /> 
           <h2 class="offre-title">Vip Premium</h2>
                      <img src="<?php echo $path; ?>/web-gallery/images/shop/figure_vip_promo.gif" align="right" />
  <div class="price">
                <div>
                    <br /><br />
                    <b>??? <br />Piks </b>
                </div>
            </div>


            <div class="text"> 
                <p>Le <u>VIP CLUB PREMIUM</u>, te permet de profiter le double d'avantages que le 
                <b>CLUB VIP I</b>. Offre bientôt disponible.</p>
            </div>
            
                <a href="#" class="about-no-piks">[x] Bientôt</a>
                <div class="clear"></div>
            <?php } ?>
        </div>
        
    

    
    </div>
    
      
    

    
</div>
 




