<?PHP
#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|
#|                                                                        #|
#|         JabboCMS - Website and Content Management System               #|
#|         Copyright © 2011 Jor.dan. All rights reserved.                 #|
#|																		  #|
#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|

include("../global.php");

	if(!session_is_registered(username))
	{
		Redirect("".$url."/index.php");
		exit();
	}
	
	if($user['rank'] < 4) {
	Redirect("".$url."/index.php");
	exit();
	}
	
$pseudo = Securise($_POST['pseudo']);
$credits = Securise($_POST['credits']);
$do = Securise($_GET['do']);
	if($do == "credits")
		{
			$sql = mysql_query("SELECT id FROM users WHERE username = '".$pseudo."'");
			$row = mysql_num_rows($sql);
			if($row > 0) {
			
			$base = "CODE-";
			for($i = 1; $i <= 10; $i++):
			$base = $base . rand(0,10);
			endfor;
			$base = $base . "-CREDITS";
				mysql_query("INSERT INTO cms_stafflog (pseudo,action,date) VALUES ('".$user['username']."','Création d\'un compte crédis à ".$pseudo."','".FullDate('full')."')");
				mysql_query("INSERT INTO cms_vouchers (username,code,value) VALUES ('".$pseudo."','".$base."','".$credits."')");
				echo '<div id="ok1">&nbsp; Le code cr&eacute;dits &agrave; &eacute;t&eacute; cr&eacute;e: <b>'.$base.'</b> d\'une valeur de: <b>'.$credits.'</b> pour &nbsp;&nbsp;l\'utilisateur:<b> '.$pseudo.'</b></div>.';
				
			} else {
				echo '<div id="pasok">Le compte <b>'.$pseudo.'</b> n\'existe pas.</div>';
			}
				
		}
			
?>
<link href="./template/style.css" rel="stylesheet" type="text/css"><body>
 <p><span class="HEADLINE">Code Cr&eacute;dits</span><br>
 Ici tu pourras donner &agrave; la personne de ton choix <b>1</b> code qui lui servira &agrave; gagner des cr&eacute;dits en rentrant le code depuis la page cr&eacute;dits du site.<br><br><form name='editor' method='post' action="?do=credits">
<td width='100' class='tbl'><b>Pseudo:</b><br></td>
<td width='80%' class='tbl'><input type='text' name='pseudo' value='' class='text' style='width: 240px'><br></td>
<br>
<td width='80%' class='tbl'><select name="credits" id="credits" class="select"><option value="7">7 Credits</option><option value="14">14 Credits</option><option value="50">50 Credits</option><option value="100">100 Credits</option><option value="250">250 Credits</option><option value="500">500 Credits</option><option value="750">750 Credits</option><option value="1000">1000 Credits</option><option value="1500">1500 Credits</option><option value="3000">3000 Credits</option><option value="5000">5000 Credits</option><option value="10000">10000 Credits</option><option value="30000">30000 Credits</option></select>
<tr>
<td align='center' colspan='2' class='tbl'>
<input type='submit' name='submit' value='Ex&eacute;cuter' class='submit'></form>
</tr>
<br>
</body>
</html>

</tr>