<? 
include ('logue.php'); 
include ('entete2.php');
include ('entete.php');
include ('ressource.php');

echo"
<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>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"principal\">
<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td width=\"100\" rowspan=\"2\" valign=\"middle\">
       <div align=\"center\">
         <input name=\"page\" value=\"" . $PHP_SELF . "\" type=\"hidden\" id=\"page\">
         <select name=\"idcolo\" onchange=submit()>";
include ('colo2.php'); 

/* 
// test admin only
if($idlogin !== "1") {
echo"Profil désactivé pour raison de sécurité, merci de votre comprehension.";
exit;
}
*/

$sql = "SELECT design, vacance, login, mail , password , permmail FROM matgraph_users WHERE id='$idlogin'";
$res = mysql_query($sql)or die('erreur sql<br>'.$sql.'<br>'.mysql_error());
$row = mysql_fetch_array($res); 
echo"<div align=\"center\"><form name=\"form1\" method=\"post\" action=\"profil_action.php\" target=\"_parent\">
  <table width=\"618\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" bordercolor=\"#000000\" style=\"font-family:trebuchet ms,sans-serif; font-size: 9pt ;\">
    <tr style =\"background-color:#222222;\">
      <td colspan=\"2\"><div align=\"center\"><strong>Profil : </strong></div></td>
    </tr>
    <tr>
      <td width=\"58%\">Pseudo : </td>
      <td width=\"42%\">$row[login]</td>
    </tr>
    <tr style =\"background-color:#111111;\">
      <td>Ancien mot de pass : </td>
      <td><input type=\"password\" name=\"Ex_pass\"></td>
    </tr>
    <tr>
      <td>Nouveau mot de pass : </td>
      <td><input type=\"password\" name=\"New_pass\"></td>
    </tr>
    <tr style =\"background-color:#111111;\">
      <td>R&eacute;p&eacute;ter le nouveau mot de pass :</td>
      <td><input type=\"password\" name=\"New_pass2\"></td>
    </tr>
    <tr>
      <td>Adresse email : </td>
      <td><input name=\"New_email\" type=\"text\" value=\"$row[mail]\"></td>
    </tr>
    <tr style =\"background-color:#111111;\">
      <td>Design : </td>
      <td><select name=\"design\">
	  <option value=\"1\""; if($row[design] =="1") { echo" selected";} echo">Bleu Planet</option>
      <option value=\"2\""; if($row[design] =="2") { echo" selected";} echo">Terra</option>
	  <option value=\"3\""; if($row[design] =="3") { echo" selected";} echo">Atlante</option>
	  <option value=\"4\""; if($row[design] =="4") { echo" selected";} echo">Alpha</option>
	  <option value=\"5\""; if($row[design] =="5") { echo" selected";} echo">Cyber espace</option>
	  <option value=\"7\""; if($row[design] =="7") { echo" selected";} echo">Asgard</option>
		</select>
		 ou <input type=\"text\" name=\"design_url\" value=\"";
		 if(preg_match('(http://)',$row['design'])){
		 	echo $row['design'];
		 }
		 echo "\" /></td>
    </tr>";
    /*echo"<tr>
      <td>Permettre aux autres joueurs de voir votre adresse email : </td>
      <td><select name=\"New_permmail\">";
if($row[permmail] == "OUI") {
        echo"<option value=\"OUI\" selected>OUI</option>
        <option value=\"NON\">NON</option>"; }
else {
echo"<option value=\"OUI\">OUI</option>
        <option value=\"NON\" selected>NON</option>"; }
      echo"</select></td>
    </tr>;*/
	echo"<tr>
      <td>Activer le mode \"pause\" : </td>
      <td><select name=\"vacance\">";
if($row[vacance] != "0000-00-00 00:00:00") {
        echo"<option value=\"OUI\" selected>OUI</option>
        <option value=\"NON\">NON</option>"; }
else {
echo"<option value=\"OUI\">OUI</option>
        <option value=\"NON\" selected>NON</option>"; }
      echo"</select></td>
    </tr>";
    
$req = "SELECT date FROM matgraph_suppression WHERE idlogin= $idlogin limit 1";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);
echo"<tr style =\"background-color:#111111;\">
      <td>Supprimer le compte : </td>
      <td><select name=\"suppression\">";
if ( $num > 0 )
{
	While ( $row = mysql_fetch_array($res) )
	{
		echo"<option value=\"OUI\" selected>OUI ( le ".strftime("%Y-%m-%d", time()+ 604800)." )</option>
    <option value=\"NON\">NON</option>";
	}
}
else
{
	echo"<option value=\"OUI\">OUI</option>
  <option value=\"NON\" selected>NON</option>";
	
}
echo"</select></td>
    </tr>";
	/*
	echo"<tr>
      <td>Newslettre</td>
      <td align=\"left\">";
$req = "SELECT id FROM matgraph_newsletter WHERE adresse='$row[mail]' ORDER by id ASC";
$res = mysql_query($req) or die('Erreur SQL! <br>'.$req.'<br>'.mysql_error());
$num = mysql_num_rows($res);

if($num > 0) {
echo"<a href=\"newsletter_desinscire.php\" target=\"_parent\">Se déinscrire</a>"; }
else {
echo"<a href=\"newsletter_inscire.php\" target=\"_parent\">S'inscrire</a>"; }

$inscrits = mysql_query("SELECT COUNT(*) AS nbre_inscrits FROM matgraph_newsletter");
$nbre_inscrits = mysql_fetch_array($inscrits); 
echo ' (' . $nbre_inscrits['nbre_inscrits'] . ' inscrits)';
 echo"</td>
    </tr>";
	*/
    echo"<tr>
      <td height=\"41\" colspan=\"2\"><div align=\"center\">
        <input type=\"submit\" name=\"Submit\" value=\"Sauvegarder\">
      </div></td>
    </tr>
  </table>
</form>";
$req2 = "SELECT * FROM matgraph_changementlogin WHERE idlogin = $idlogin ORDER by id ASC";
$res2 = mysql_query($req2) or die('Erreur SQL! <br>'.$req2.'<br>'.mysql_error());
$num2 = mysql_num_rows($res2);
if($num2 == 0)
{
echo"<br><br> <a href=\"profil_changepseudo.php\" target=\"_parent\">Changer de pseudo</a></div>";
}
else
{
	$row2 = mysql_fetch_array($res2);
	echo"Changement de pseudo souhaité : $row2[login]
	<br><a href=\"profil_changepseudo_annuler.php\" target=\"_parent\"> Annuler </a></div>";
	
}
?>



