<?php
/*================================================================+\
|| # PHPRetro - An extendable virtual hotel site and management
|+==================================================================
|| # Copyright (C) 2009 Yifan Lu. All rights reserved.
|| # http://www.yifanlu.com
|| # Parts Copyright (C) 2009 Meth0d. All rights reserved.
|| # http://www.meth0d.org
|| # All images, scripts, and layouts
|| # Copyright (C) 2009 Sulake Ltd. All rights reserved.
|+==================================================================
|| # PHPRetro is provided "as is" and comes without
|| # warrenty of any kind. PHPRetro is free software!
|| # License: GNU Public License 3.0
|| # http://opensource.org/licenses/gpl-license.php
\+================================================================*/

require_once('./includes/core.php');
require_once('./includes/session.php');
$id = $input->FilterText($_GET['id']);
$page['id'] = "boutique";
$page['name'] = "Boutique";
$page['bodyid'] = "boutique";
$page['cat'] = "boutique";
require_once('./templates/community_header.php');
?>
<div id="container"><div id="container">
	<div id="content" style="position: relative" class="clearfix">
    <div id="column1" class="column">
			     		
				<div class="habblet-container ">		
						<div class="cbb clearfix blue ">
								</h2>
<div id="credits-promo" class="box-content credits-info">
     
							<h2 class="title">La Boutique
							</h2><br>


							<?php
							$boutiques = mysql_query("SELECT * FROM cms_boutique ORDER BY ID LIMIT 0,50");
							while($boutique = mysql_fetch_array($boutiques)) { ?>
							
							
							<li class="odd">
							<img src="<?php echo $boutique['images'];  ?>" align="left">
							<p>
							
							<b><?php echo $boutique['titre']; ?></b><br>
							
							<i><?php echo $boutique['description']; ?></i><br>
										<u>Prix:</u> <b><?php echo $boutique['pixels']; ?></b> Pixels.
							
							<form action="boutique?id=buy" method="post">
						<p>
<?php
$pixel = mysql_query("SELECT pixels FROM users WHERE id = '".$user->id."' ");
while($pixels = mysql_fetch_array($pixel)) {
if ($pixels['pixels'] >= 50) { ?>


 <input type="hidden" value="<?php echo $boutique['tid']; ?>" name="tids" /> <br><br><p align="right"><input type="submit" value="ACHETER" /></p>
</p>
<?php } else { ?>
~ <input type="text" disabled="true" value="<?php echo $boutique['tid']; ?>" name="tids" /> ~ <br><br><p align="right"><input disabled="true" type="submit" disabled="true" value="ACHETER" /></p>

<font color="red">Pour pouvoir acheter tu doit avoir 50 Pixels au minimum!</font>
</p>
<?php } } ?>
</form>
							</li>

							</p>
						
							
							
							
							<br>
						<?php } ?>
						
					
						
					<?php
$pixel = mysql_query("SELECT pixels FROM users WHERE id = '".$user->id."' ");
while($pixels = mysql_fetch_array($pixel)) {
if ($pixels['pixels'] >= 50) { ?>
	
						<?php
if($id == 'buy'){
$tid = mysql_real_escape_string(htmlspecialchars($_POST['tids']));
?>
<?php 
mysql_query("INSERT INTO furniture (tid,ownerid) VALUES ('".$tid."', '".$user->id."') ");
mysql_query("UPDATE users SET pixels = pixels - 50 WHERE id = '".$user->id."' ");
?>
<SCRIPT language="Javascript">

<!--
alert("Bravo tu as acheter le Mobis avec Succes ( REGARDE DANS TA MAINS )");

// -->

</SCRIPT>

<meta http-equiv="refresh" content="0;URL=boutique">
<?php } ?>
 <?php  } else {  ?>
<meta http-equiv="refresh" content="300;URL=boutique">
<?php } } ?>
						
					</div>
</div
				</div>
				

				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
			 


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

				<script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
				<div id="column2" class="column">
			     		
<?php $lang->addLocale("redeem.voucher"); ?>
				<div class="habblet-container ">		
						<div class="cbb clearfix orange ">
	
							<h2 class="title">Mes Pixels!
							</h2>
						<div id="purse-habblet">
<?php if($user->id > 0){ ?>
	<form method="post" action="<?php echo PATH; ?>/credits" id="voucher-form">

<ul>
    <li class="even icon-purse">
        <div><?php echo $lang->loc['you.have']; ?></div>
        <span class="purse-balance-amount"><?php $pixel = mysql_query("SELECT pixels FROM users WHERE id = '".$user->id."'");
        while($pixels = mysql_fetch_array($pixel)) { ?><?php echo $pixels['pixels']; ?> Pixels<?php } ?></span>
        
    </li>

   
</ul>
<div id="purse-redeem-result">
</div>	</form>
<?php }else{ ?>
<div class="box-content"><?php echo $lang->loc['need.logon.purse']; ?></div>
<?php } ?>
</div>

<script type="text/javascript">
	new PurseHabblet();
</script>
	
						
					</div>
				</div>
				
				<div id="column2" class="column">
				<div class="habblet-container ">		
						<div class="cbb clearfix green ">
	
							<h2 class="title">Besoin d'aide?
							</h2>

						<div id="credits-promo" class="box-content credits-info">

    <div class="credit-info-text clearfix">
       
<i>N'oublie pas que la Monnaie Payante est les PIXELS, tu peut en achet&eacute; 150 pour seulement 1 Webopass!</i><br><br>

Quesqu'il arrive si je change le <b>Num&eacute;ro</b> qui me demande? Il se pourrais qu'il y'aurais une erreur SQL, et que vous perdiez 50 Pixels dans le vide! Donc ouvrez les Yeux! Prenez aucun risque celà peut être a vos risque et p&eacute;rils!
    </div> </div>
	
    <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
	 </div>
	
	
						
					
					

				</div>

</div>

<?php
if($user->user('rank') == 7) { ?>
<div id="column2" class="column">
				
<div class="habblet-container ">		
						<div class="cbb clearfix red ">
	
							<h2 class="title">Administration
							</h2>
<div id="credits-promo" class="box-content credits-info">
    <div class="credit-info-text clearfix">
    					
<form action="boutique?id=add" method="post">
<p>
<u>Tid du Mobis:</u><br><br>
<input type="text" name="tid" /><br><br>
<u>Nom du mobis:</u><br><br>
<input type="text" name="titre" /><br><br>
<u>Description du mobis:</u><br><br>
<input type="text" name="description" /><br><br>
<u>Prix du mobis:</u><br><br>
<input type="text" name="pixels" value="50" disabled="true" /><br><br>
<u>Image du mobis:</u><br><br>
<input type="text" name="images" /><br><br>
<input type="submit" value="Valider" /><br><br>
</form>

<?php
if($id == 'add'){ 
$tid = mysql_real_escape_string(htmlspecialchars($_POST['tid']));
$titre = mysql_real_escape_string(htmlspecialchars($_POST['titre']));
$description = mysql_real_escape_string(htmlspecialchars($_POST['description']));
$pixels = mysql_real_escape_string(htmlspecialchars($_POST['pixels']));
$images = mysql_real_escape_string(htmlspecialchars($_POST['images']));

mysql_query("INSERT INTO cms_boutique (tid, titre, description, pixels, images)
    VALUES ('$tid', '$titre', '$description', '50', '$images') ");

echo "Bravo Moblier mis avec Succ&eacute;s!";

   }  ?>
       
    </div>
    
</div>


	
						
					</div>

				</div><?php } ?>
<script type="text/javascript">
HabboView.run();
</script>
<script type="text/javascript">
HabboView.run();

</script>

