<?php
include ('logue.php'); 
include ('entete2.php');
include ('ressource.php');
include ('entete.php');
echo"
<STYLE TYPE=text/css>
.Style1 {color: #0000FF}
.Style2 {color: #FF0000}
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>";
echo"<div align=\"center\"><form name=\"colo\" method=\"post\" action=\"colonie.php\" target=\"_parent\">
<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'); 

$sql2 = "SELECT ally,statut FROM matgraph_users WHERE id='$idlogin'";
$res2 = db_mysql_Query($sql2)or die('erreur sql<br>'.$sql2.'<br>'.mysql_error());
$row2 = mysql_fetch_array($res2); 

if($row2[ally] == "no") {
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("ally_index.php");
	-->
	</script>';
	exit;
}

if($row2[statut] == "-1") {
	echo '<script language="javascript" type="text/javascript">
	<!--
	window.location.replace("ally_index.php");
	-->
	</script>';
	exit;
}

$requete = "UPDATE matgraph_users SET ally='no',statut='0' WHERE id='$idlogin'";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());

$requete = "SELECT idfondateur,nom,tag FROM matgraph_ally WHERE id='".$row2['ally']."'";
$resultat = db_mysql_Query($requete);
$row3 = mysql_fetch_array($resultat);

$sujet = "Un membre a quitté votre alliance";
$msg = "Le membre nommé ".$login." a quitté votre alliance ".$row3[1]." [".$row3[2]."] le ". date('j/m/Y \à H:i:s',time() .".";
$requete = "INSERT INTO matgraph_msgally VALUES ('', now(), 'non', '".$row3[0]."', '$sujet', '$msg')";
$resultat = db_mysql_Query($requete)or die('erreur sql<br>'.$requete.'<br>'.mysql_error());


echo '<script language="javascript" type="text/javascript">
<!--
window.location.replace("apercu.php");
-->
</script>';
?>
