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


require_once('../global.php');
if($hkzone !== true){ header("Location: index.php?throwBack=true"); exit; }
if(!session_is_registered(acp)){ header("Location: index.php?p=login"); exit; }

		function FullDate($str)
			{
				$H = date('H');
				$i = date('i');
				$s = date('s');
				$m = date('m');
				$d = date('d');
				$Y = date('Y');
				$j = date('j');
				$n = date('n');
				
				switch ($str)
					{
						case "day":
							$str = $j;
							break;
						case "month":
							$str = $m;
							break;
						case "year":
							$str = $Y;
							break;
						case "today":
							$str = $d;
							break;
						case "full":
							$str = date('d-m-Y H:i:s',mktime($H,$i,$s,$m,$d,$Y));
							break;
						case "datehc":
							$str = "".$j."-".$n."-".$Y."";
							break;
						default:
							$str = date('d-m-Y',mktime($m,$d,$Y));
							break;
					}
					
				return $str;
			}

$pagename = "Bannir un Utilisateur";

$pseudo = Filter($_POST['name']);
$raison = Filter($_POST['reason']);
$date = Filter($_POST['date']);
$name = explode(";", $pseudo);
$nbr = count($name);


$do = Filter($_GET['do']);

$date_ac = time();
$date_calcul = $date * 3600;
$date_ban = $date_ac + $date_calcul;

	if($do == "ban") {
		
	if(isset($pseudo) && isset($raison)) {
		if(!empty($pseudo) && !empty($raison) && !empty($date)) {
	
	for($n = 0; $n < $nbr; $n++):
		$sql = mysql_query("SELECT id FROM users WHERE username = '".$name[$n]."'");
		$row = mysql_num_rows($sql);
		if($row > 0) {
				mysql_query("INSERT INTO cms_stafflog (pseudo,action,date) VALUES ('".$user['username']."','Banissement de: ".$name[$n]." pour raison: ".$raison."','".FullDate('full')."')");
				mysql_query("INSERT INTO bans (bantype,value,reason,expire,added_by,added_date,appeal_state) VALUES ('user','".$name[$n]."','".$raison."','".$date_ban."','".$myrow['username']."','".FullDate('full')."','0')") or die(mysql_error());
					$msg = "&nbsp; Le compte <b>".$name[$n]."</b> &agrave; &eacute;t&eacute; bannis pour la raison suivante: <b>".$raison."</b>";
					} else {
					$msg = "&nbsp; Le compte <b>".$name[$n]."</b> n\'existe pas.";
					}	
					endfor;
					} else {
					$msg = "&nbsp; Les champs ne sont pas tous remplie.";
					}
			} 
	}

@include('subheader.php');
@include('header.php');
?>
<table cellpadding='0' cellspacing='8' width='100%' id='tablewrap'>
<tr> <td width='22%' valign='top' id='leftblock'>
 <div>
 <!-- LEFT CONTEXT SENSITIVE MENU -->
<?php @include('usermenu.php'); ?>
 <!-- / LEFT CONTEXT SENSITIVE MENU -->
 </div>
 </td>
 <td width='78%' valign='top' id='rightblock'>
 <div><!-- RIGHT CONTENT BLOCK -->
 
<?php if(isset($msg)){ ?><p><strong><?php echo $msg; ?></strong></p><?php } ?>
 
<form name='editor' method='post' action='index.php?p=ban&do=ban'>

<div class='tableborder'>
<div class='tableheaderalt'>Bannir un Utilisateur</div>

<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Pseudo</b>
<div class='graytext'>Entre le pseudonyme du Habbo.</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='name' value="<?php echo htmlentities($_POST['username']); ?>" size='30' class='textinput'></td>
</tr>
<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Raison</b>
<div class='graytext'>La raison de cette interdiction qui sera présentée à l'utilisateur.</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='reason' value="<?php echo htmlentities($_POST['reason']); ?>" size='50' class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Date du Bannissement</b></td>
<td class='tablerow2'  width='60%'  valign='middle'><select name="date" id="lenght" class="select"><option value="1">1 Heures</option><option value="2">2 Heures</option><option value="3">3 Heures</option><option value="4">4 Heures</option><option value="5">5 Heures</option><option value="6">6 Heures</option><option value="7">7 Heures</option><option value="8">8 Heures</option><option value="9">9 Heures</option><option value="10">10 Heures</option><option value="11">11 Heures</option><option value="12">12 Heures</option><option value="13">13 Heures</option><option value="14">14 Heures</option><option value="15">15 Heures</option><option value="16">16 Heures</option><option value="17">17 Heures</option><option value="18">18 Heures</option><option value="19">19 Heures</option><option value="20">20 Heures</option><option value="21">21 Heures</option><option value="22">22 Heures</option><option value="23">23 Heures</option><option value="24">24 Heures</option><option value="100008">4167 Jours</option></select>
</td>
</tr>

<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='Executer!' class='realbutton' accesskey='s'></td></tr>
</form></table></div><br />	 </div><!-- / RIGHT CONTENT BLOCK -->
	 </td></tr>
</table>
</div><!-- / OUTERDIV -->
<div align='center'><br />
<?php
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
printf('Time: %.3f', $totaltime);
?>
</div>