<?php
#######################################################|#
#|                    HabboMCMS - TheRox
#|                    Powered by HoloCMS 
#|            Copyright 2011-2012 ALL RIGHTS RESERVED
#######################################################|#

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

$allow_guests = false;



$pagename = "Boutique";
$pageid = "boutique";
$body_id = "boutique";

require_once('templates/community_subheader.php');
require_once('templates/community_header.php');
?>
<div id='container'>
<div id='content'>
				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
				
<div id='column1' class='column'><div class='habblet-container '>		
<div class="cbb clearfix activehomes ">
	
<h2 class='title'>Boutique</h2>

	<style type="text/css">
	.vip-odd { background-color: #9ED1E4; }
	.vip-even { background-color: #BBDAE4; }
	</style>
	
	<?php /* VIP */ ?>
	
	<?php $sql = mysql_query("SELECT * FROM boutique WHERE type = 'vip' ORDER BY id ASC");
	while($row = mysql_fetch_assoc($sql)) { ?>

	<table width="100%" class="vip-odd">
	<tr>
		<td width="110" style="padding: 10px;" valign="middle">
		
			<div class="icon" height: 100px; width: 100px;">
				<center><img src="<?php echo $path; ?><?php echo $row['img']; ?> "></center>
			</div>
		
		</td>
		
		<td valign="top" style="text-align: left;">
			<h3><?php echo $row['name']; ?></h3>
			<p>
				<?php echo $row['description']; ?>
			</p>
			
			<div style="border-top: 1px dotted; padding-top: 8px; ">
			
				<div style="float: left; padding-top: 5px;">
					<?php echo $row['price']; ?> Jetons <img src="<?php echo $path ?>/web-gallery/v2/images/vipcoin.gif" style="vertical-align: middle;"></b>
				</div>
				
				<div style="float: right;">
				
				<?php if($myrow['jetons'] >= $row['price']) { ?>	

				<?php if($_GET['id'] == "vip") {
								
					$now_unixtime = time(); //Get the current unix timestamp.
					$vipexpire = ($now_unixtime + $row['plus']);
				
					if($myrow['jetons'] >= $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 jetons = jetons - '".$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());
				
					//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 = "Erreur! Tu possèdes déjà ce badge!";
					$failure = true;
					} else {
					mysql_query("INSERT INTO user_badges (user_id, badge_id) VALUES ('".$my_id."','ACH_VipClub1')");
					}
					
					
					echo"<script> alert('Achat effectué'); </script>";
					
					header("Location: /store");
					//exit;
					} else {
					echo"<script> alert('Erreur! Tu n'as pas asser de jetons'); </script>";
					}
					}
				?>

							
				
				<a href="<?php echo $path; ?>/store?id=vip" class="new-button gray-button" style="margin: 0;"><b>Acheter</b><i></i></a>
				
				<?php } else { ?>
				
				<a href="<?php echo $path; ?>/jetons" class="new-button red-button" style="margin: 0;"><b>Plus de Jetons</b><i></i></a>
				
				<?php } ?>
				<?php } ?>
				</div>
			</div>

		</td>
	</tr>
	</table>

<?php /* 1 */ ?>

	<?php $sql = mysql_query("SELECT * FROM badge WHERE type = 'badge1' ORDER BY id ASC") or die(mysql_error());
	while($row = mysql_fetch_assoc($sql)) { ?>

	<table width="100%" class="vip-even">
	<tr>
		<td width="110" style="padding: 10px;" valign="middle">
		
			<div class="icon" height: 100px; width: 100px;">
				<center><img src="<?php echo $row['img']; ?>"></center>
			</div>
		
		</td>
		
		<td valign="top" style="text-align: left;">
			<h3><?php echo $row['name']; ?></h3>
			<p>
				<?php echo $row['description']; ?>
			</p>
			
			<div style="border-top: 1px dotted; padding-top: 8px; ">
			
				<div style="float: left; padding-top: 5px;">
					<?php echo $row['price']; ?> Jetons <img src="<?php echo $path ?>/web-gallery/v2/images/vipcoin.gif" style="vertical-align: middle;"></b>
				</div>
				
				<div style="float: right;">
				
				<?php if($myrow['jetons'] >= $row['price']) { ?>
				
				<?php if($_GET['id'] == "badge-1") {
				
				
				if($myrow['jetons'] >= $row['price']) {
				
			mysql_query("UPDATE users SET jetons = jetons - '".$row['price']."' WHERE id='".$my_id."'");
					//mysql_query("INSERT INTO `user_badges` (`user_id`, `badge_id`, `badge_slot`) VALUES ('".$my_id."', 'HXY', '0')");
					
				
					//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 ='HXY' AND user_id ='".$my_id."'")) > 0)
					{
					$msg = "Erreur! Tu possèdes déjà ce badge!";
					$failure = true;
					} else {
					mysql_query("INSERT INTO user_badges (user_id, badge_id) VALUES ('".$my_id."','HXY')");
					}
		
					echo"<script> alert('Achat effectué'); </script>";
					
					header("Location: /shopbadge");
					//exit;
					} else {
					echo"<script> alert('Erreur! Tu n'as pas asser de jetons'); </script>";
					}
				}
				?>
				
				<a href="<?php echo $path; ?>/shopbadge?id=badge-1" class="new-button gray-button" style="margin: 0;"><b>Acheter</b><i></i></a>
				
				<?php } else { ?>
				
					<a href="<?php echo $path; ?>/jetons" class="new-button red-button" style="margin: 0;"><b>Plus de Jetons</b><i></i></a>
				
				<?php } ?>
				
				<?php } ?>
				
				</div>
			</div>

		</td>
	</tr>
	</table>
	
	
<?php /* 2 */ ?>

	<?php $sql = mysql_query("SELECT * FROM boutique WHERE type = 'badge2' ORDER BY id ASC") or die(mysql_error());
	while($row = mysql_fetch_assoc($sql)) { ?>

	<table width="100%" class="vip-odd">
	<tr>
		<td width="110" style="padding: 10px;" valign="middle">
		
			<div class="icon" height: 100px; width: 100px;">
				<center><img src="<?php echo $row['img']; ?>"></center>
			</div>
		
		</td>
		
		<td valign="top" style="text-align: left;">
			<h3><?php echo $row['name']; ?></h3>
			<p>
				<?php echo $row['description']; ?>
			</p>
			
			<div style="border-top: 1px dotted; padding-top: 8px; ">
			
				<div style="float: left; padding-top: 5px;">
					<?php echo $row['price']; ?> Jetons <img src="<?php echo $path ?>/web-gallery/v2/images/vipcoin.gif" style="vertical-align: middle;"></b>
				</div>
				
				<div style="float: right;">
				
				<?php if($myrow['jetons'] >= $row['price']) { ?>
				
				<?php if($_GET['id'] == "badge-2") {
				
				
				if($myrow['jetons'] >= $row['price']) {
				
				
			mysql_query("UPDATE users SET jetons = jetons - '".$row['price']."' WHERE id='".$my_id."'");
					//mysql_query("INSERT INTO `user_badges` (`user_id`, `badge_id`, `badge_slot`) VALUES ('".$my_id."', 'BOT', '0')");
					
				
					//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 ='BOT' AND user_id ='".$my_id."'")) > 0)
					{
					$msg = "Erreur! Tu possèdes déjà ce badge!";
					$failure = true;
					} else {
					mysql_query("INSERT INTO user_badges (user_id, badge_id) VALUES ('".$my_id."','BOT')");
					}
		
					echo"<script> alert('Achat effectué'); </script>";
					
					header("Location: /shopbadge");
					//exit;
					} else {
					echo"<script> alert('Erreur! Tu n'as pas asser de jetons'); </script>";
					}
				}
				?>
				
				<a href="<?php echo $path; ?>/shopbadge?id=badge-2" class="new-button gray-button" style="margin: 0;"><b>Acheter</b><i></i></a>
				
				<?php } else { ?>
				
					<a href="<?php echo $path; ?>/jetons" class="new-button red-button" style="margin: 0;"><b>Plus de Jetons</b><i></i></a>
				
				<?php } ?>
				
				<?php } ?>
				
				</div>
			</div>

		</td>
	</tr>
	</table>
	
<?php /* 3 */ ?>

	<?php $sql = mysql_query("SELECT * FROM boutique WHERE type = 'mobi3' ORDER BY id ASC") or die(mysql_error());
	while($row = mysql_fetch_assoc($sql)) { ?>

	<table width="100%" class="vip-even">
	<tr>
		<td width="110" style="padding: 10px;" valign="middle">
		
			<div class="icon" height: 100px; width: 100px;">
				<center><img src="<?php echo $path; ?><?php echo $row['img']; ?> "></center>
			</div>
		
		</td>
		
		<td valign="top" style="text-align: left;">
			<h3><?php echo $row['name']; ?></h3>
			<p>
				<?php echo $row['description']; ?>
			</p>
			
			<div style="border-top: 1px dotted; padding-top: 8px; ">
			
				<div style="float: left; padding-top: 5px;">
					<?php echo $row['price']; ?> Jetons <img src="<?php echo $path ?>/web-gallery/v2/images/vipcoin.gif" style="vertical-align: middle;"></b>
				</div>
				
				<div style="float: right;">
				
				<?php if($myrow['jetons'] >= $row['price']) { ?>
				
				<?php if($_GET['id'] == "badge-3") {
				
				
				if($myrow['jetons'] >= $row['price']) {
				
				//$id = mysql_fetch_assoc(mysql_query("SELECT id_generator FROM item_id_generator"));	
				//$id2 = $id['id_generator'] + 100000;
		
				//mysql_query("UPDATE item_id_generator SET id_generator = '".$id2."'");
				$resultat1 = rand(103300000000000,104000000000000);
			    $temps_actuelle = time();
				mysql_query("INSERT INTO items (id,user_id,base_item) VALUES ('".$resultat1."','".$my_id."','".$row['baseitem']."')"); 
				mysql_query("UPDATE users SET jetons = jetons - '".$row['price']."' WHERE id='".$my_id."'");
		
					echo"<script> alert('Achat effectué'); </script>";
					
					header("Location: /store");
					//exit;
					} else {
					echo"<script> alert('Erreur! Tu n'as pas asser de jetons'); </script>";
					}
				}
				?>
				
				<a href="<?php echo $path; ?>/store?id=badge-3" class="new-button gray-button" style="margin: 0;"><b>Acheter</b><i></i></a>
				
				<?php } else { ?>
				
					<a href="<?php echo $path; ?>/jetons" class="new-button red-button" style="margin: 0;"><b>Plus de Jetons</b><i></i></a>
				
				<?php } ?>
				
				<?php } ?>
				
				</div>
			</div>

		</td>
	</tr>
	</table>

<?php /* 4 */ ?>

	<?php $sql = mysql_query("SELECT * FROM boutique WHERE type = 'mobi4' ORDER BY id ASC") or die(mysql_error());
	while($row = mysql_fetch_assoc($sql)) { ?>

	<table width="100%" class="vip-odd">
	<tr>
		<td width="110" style="padding: 10px;" valign="middle">
		
			<div class="icon" height: 100px; width: 100px;">
				<center><img src="<?php echo $path; ?><?php echo $row['img']; ?> "></center>
			</div>
		
		</td>
		
		<td valign="top" style="text-align: left;">
			<h3><?php echo $row['name']; ?></h3>
			<p>
				<?php echo $row['description']; ?>
			</p>
			
			<div style="border-top: 1px dotted; padding-top: 8px; ">
			
				<div style="float: left; padding-top: 5px;">
					<?php echo $row['price']; ?> Jetons <img src="<?php echo $path ?>/web-gallery/v2/images/vipcoin.gif" style="vertical-align: middle;"></b>
				</div>
				
				<div style="float: right;">
				
				<?php if($myrow['jetons'] >= $row['price']) { ?>
				
				<?php if($_GET['id'] == "badge-4") {
				
				
				if($myrow['jetons'] >= $row['price']) {
				
				//$id = mysql_fetch_assoc(mysql_query("SELECT id_generator FROM item_id_generator"));	
				//$id2 = $id['id_generator'] + 100000;
		
				//mysql_query("UPDATE item_id_generator SET id_generator = '".$id2."'");
				$resultat1 = rand(103300000000000,104000000000000);
			    $temps_actuelle = time();
				mysql_query("INSERT INTO items (id,user_id,base_item) VALUES ('".$resultat1."','".$my_id."','".$row['baseitem']."')"); 
				mysql_query("UPDATE users SET jetons = jetons - '".$row['price']."' WHERE id='".$my_id."'");
		
					echo"<script> alert('Achat effectué'); </script>";
					
					header("Location: /store");
					//exit;
					} else {
					echo"<script> alert('Erreur! Tu n'as pas asser de jetons'); </script>";
					}
				}
				?>
				
				<a href="<?php echo $path; ?>/store?id=badge-4" class="new-button gray-button" style="margin: 0;"><b>Acheter</b><i></i></a>
				
				<?php } else { ?>
				
					<a href="<?php echo $path; ?>/jetons" class="new-button red-button" style="margin: 0;"><b>Plus de Jetons</b><i></i></a>
				
				<?php } ?>
				
				<?php } ?>
				
				</div>
			</div>

		</td>
	</tr>
	</table>

<?php /* 5 */ ?>

	<?php $sql = mysql_query("SELECT * FROM boutique WHERE type = 'mobi5' ORDER BY id ASC") or die(mysql_error());
	while($row = mysql_fetch_assoc($sql)) { ?>

	<table width="100%" class="vip-even">
	<tr>
		<td width="110" style="padding: 10px;" valign="middle">
		
			<div class="icon" height: 100px; width: 100px;">
				<center><img src="<?php echo $path; ?><?php echo $row['img']; ?> "></center>
			</div>
		
		</td>
		
		<td valign="top" style="text-align: left;">
			<h3><?php echo $row['name']; ?></h3>
			<p>
				<?php echo $row['description']; ?>
			</p>
			
			<div style="border-top: 1px dotted; padding-top: 8px; ">
			
				<div style="float: left; padding-top: 5px;">
					<?php echo $row['price']; ?> Jetons <img src="<?php echo $path; ?>/web-gallery/v2/images/vipcoin.gif" style="vertical-align: middle;"></b>
				</div>
				
				<div style="float: right;">
				
				<?php if($myrow['jetons'] >= $row['price']) { ?>
				
				<?php if($_GET['id'] == "badge-5") {
				
				
				if($myrow['jetons'] >= $row['price']) {
				
				//$id = mysql_fetch_assoc(mysql_query("SELECT id_generator FROM item_id_generator"));	
				//$id2 = $id['id_generator'] + 100000;
		
				//mysql_query("UPDATE item_id_generator SET id_generator = '".$id2."'");
				$resultat1 = rand(103300000000000,104000000000000);
			    $temps_actuelle = time();
				mysql_query("INSERT INTO items (id,user_id,base_item) VALUES ('".$resultat1."','".$my_id."','".$row['baseitem']."')"); 
				mysql_query("UPDATE users SET jetons = jetons - '".$row['price']."' WHERE id='".$my_id."'");
		
					echo"<script> alert('Achat effectué'); </script>";
					
					header("Location: /store");
					//exit;
					} else {
					echo"<script> alert('Erreur! Tu n'as pas asser de jetons'); </script>";
					}
				}
				?>
				
				<a href="<?php echo $path; ?>/store?id=badge-5" class="new-button gray-button" style="margin: 0;"><b>Acheter</b><i></i></a>
				
				<?php } else { ?>
				
					<a href="<?php echo $path; ?>/jetons" class="new-button red-button" style="margin: 0;"><b>Plus de Jetons</b><i></i></a>
				
				<?php } ?>
				
				<?php } ?>
				
				</div>
			</div>

		</td>
	</tr>
	</table>


</div>
</div>
</div>
	
				<script type='text/javascript'>if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
			 
				<div id="column2" class="column">
				<div class="habblet-container ">		
						<div class="cbb clearfix brown ">
	
							<h2 class="title">Ton compte <?php echo $shortname; ?>
							</h2>
						<div id="purse-habblet">
                                                    <?php if($logged_in){ ?>
	<form method="post" action="#" id="voucher-form">
<ul>
    <li class="even icon-purse">
        <div>En ce moment tu as:</div>
        <span class="purse-balance-amount"><?php echo $myrow['jetons']; ?> Jetons</span>
        <div class="purse-tx"><a href="../transactions.php">Transactions de compte</a></div>
    </li>
</ul>
<div id="purse-redeem-result">
</div>	</form>
        <?php } else { ?>
        <div class="box-content">Tu dois &ecirc;tre connect&eacute; pour voir ton compte.</div>
        <?php } ?>
</div>

<script type="text/javascript">
	new PurseHabblet();
</script>
	
						
					</div>
				</div>
				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
			 
				<div class='habblet-container '>		
						<div class='cbb clearfix orange '>
	
							<h2 class='title'>Jetons</h2>
						<div id='credits-promo' class='box-content credits-info'>
    <div class='credit-info-text clearfix'>
    <p><img class="credits-image" src="<?php echo $path ?>/web-gallery/v2/images/credits_permission.png" align="left" width="114" height="136"/>
    Les Jetons sont la monnaie payante de l'hotel. Tu peux les utiliser pour acheter toutes sortes de choses, des extra rares, des badges, une adh&eacute;sion au Club VIP</p>
</div>
	
						
					</div>
				</div>
				<script type='text/javascript'>if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
			 
							 
</div>

<script type="text/javascript">
HabboView.run();
</script>	
				</div>
</div><br>
<div id="footer">

<p><a href="index.php" target="_self">Homepage</a> | <a href="./disclaimer.php" target="_self">Terms of Service</a> | <a href="./privacy.php" target="_self">Privacy Policy</a></p>

<p>BobbaStory est un projet ind&eacute;pendant, &agrave; but non lucratif &copy 2009-2011 <br />Habbo est une marque d&eacute;pos&eacute;e de Sulake Corporation. Tous droits r&eacute;serv&eacute;s &agrave; leur propri&eacute;taire respectif(s).<br />Nous ne sommes pas approuv&eacute;, affili&eacute;s, ou offertes par Sulake Corporation LTD.</p>

</div>