<?php
include ('logue.php');
include ('entete2.php');
$sql = "SELECT rang FROM matgraph_axxadmin WHERE idjoueur = $idlogin";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res);
if($row['rang'] <= 0 || $_GET['pass'] != '1a05ds6f756fd4g56f4gB') {
	echo '<center><br /><br /><img src="http://ysbx.free.fr/Tu%20sors.jpg"></center>';
	exit;
}
include ('entete.php');

echo"
<BODY TEXT=\"#ffffff\">
<BODY LINK=\"#ffffff\">
<BODY VLINK=\"#ffffff\">
<BODY ALINK=\"#ffffff\">
<body bgcolor=\"#000000\">
<style>
input {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
textarea {
border:1px solid #7E7E7E;
background-color:#000000;
font-family:'trebuchet ms',sans-serif;
color:white;
}
select, option {
background-color:#000000;
color:white;
}
</style>
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
</STYLE>";

$type = $_POST["type"];
$page = (intval($_POST["page"]) - 1 )*50;




echo"<form name=\"stat\" id=\"stat\" method=\"post\" action=\"#\" target=\"_parent\">
  <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
    <tr style =\"background-color:#222222;\">
      <td>Voir : </td>
      <td><select name=\"type\">
        <option value=\"all\"";
if($type == "all") {echo" selected"; }
		echo">tout</option>
		<option value=\"averto\"";
if($type == "averto") {echo" selected"; }
		echo">Avertissement</option>
        <option value=\"guerre\"";
if($type == "guerre") {echo" selected"; }
		echo">Guerre</option>
        <option value=\"multi\"";
if($type == "multi") {echo" selected"; }
		echo">Multi</option>
        <option value=\"pass\"";
if($type == "pass") {echo" selected"; }
		echo">Changement pass</option>
        <option value=\"login\"";
if($type == "login") {echo" selected"; }
		echo">Connection</option>	
        <option value=\"ban\"";
if($type == "ban") {echo" selected"; }
		echo">Ban</option>	
        <option value=\"oubli\"";
if($type == "oubli") {echo" selected"; }
		echo">Oubli push/multi</option>		
            </select> <select name=\"page\">";

$reqtotal = "SELECT COUNT(*) FROM matgraph_logadmin";
$restotal = mysql_query($reqtotal) or die('Erreur SQL! <br>'.$reqtotal.'<br>'.mysql_error());
$numtotal = mysql_result($restotal,0);	

for ($i = 1; $i <= ceil($numtotal / 3); $i++) {
   echo" <option value=\"".$i."\""; if ($page == $i) { echo" selected"; } echo">Page ". $i ."</option>";
}

echo"</select> <input type=\"submit\" name=\"Submit\" value=\"Voir\"></td>
    </tr>
  </table>
</form>";

switch($type) {
	case 'ban' :
		$deb = "action LIKE 'Ajout ban%' OR action LIKE 'Supr ban%'";
		break;
	case 'averto' :
		$deb = "action LIKE 'Ajout averto%' OR action LIKE 'Supr averto%'";
		break;
	case 'guerre' :
		$deb = "action LIKE 'Ajout guerre%' OR action LIKE 'Supr guerre%'";
		break;
	case 'multi' :
		$deb = "action LIKE 'Ajout multi%' OR action LIKE 'Supr multi%'";
		break;
	case 'pass' :
		$deb = "action LIKE 'Supr change pass%' OR action LIKE 'Confirm change pass%' OR action LIKE 'Propose change pass%'";
		break;
	case 'login' :
		$deb = "action LIKE 'Connection%'";
		break;
	case 'oubli' :
		$deb = "action LIKE 'Oubli push/multi%'";
		break;
	default :
		$deb = "1";
}
if (isset($_POST["page"])) {
	$req = "SELECT * FROM matgraph_logadmin WHERE ".$deb." ORDER BY date DESC limit $page,50";
	$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
	$num = mysql_num_rows($res);
	if ( $num > 0 ) {
	echo"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
	  <tr style =\"background-color:#222222;\">
	    <td align=\"center\"><b>Mdj</b></td>
	    <td align=\"center\"><b>Date</b></td>
			<td align=\"center\"><b>Action</b></td>
	  </tr>";
		While ( $row = mysql_fetch_array($res) ) {
	echo"	<tr";if (($i/2) == ceil($i/2)){echo' style ="background-color:#111111;"' ;}echo">
			<td align=\"center\">".$row['mdj']."</td>
			<td align=\"center\">".$row['date']."</td>
	  	<td align=\"center\">".$row['action']."</td>
	  </tr>";
	  $i++;
		}
	echo '</table>';
	} else {
		echo '<center> Aucun résultat.</center>';
	}
}
?>