<?php
require_once("passe/conf.php");
Error_Reporting(1);
@set_magic_quotes_runtime(0);
// sessions
if($active_session=="1")
{
session_start();
$id=addslashes($_SESSION["id"]);
}
else
{
$id=addslashes($_GET["id"]);
}
// fin sessions
$db_link=connect_db();
$droits=verif_login($id);
verif_admin();
switch($_POST['action']) {
/*-----------------------------------------------------------------*/
/* AJOUT DANS MySQL */
/*-----------------------------------------------------------------*/
case "add";
// CONNEXION A LA BASE DE DONNEE
// TEST SUR LES VALEURS SAISIES
if($_POST["new_pseudo"]==""){ echo "<center>Il faut choisir un pseudo !!</center>";exit; }
if($_POST["new_password"]==""){ echo "<center>Il faut choisir un mot de passe</center>";exit; }
if($_POST["email1"]==""){ echo "<center>Il faut rentrer le mail !</center>";exit; }
if($_POST["destination1"]==""){ echo "<center>Il faut rentrer la destination !</center>";exit; }
if($_POST["new_password"]!=$_POST["new_password2"]){ echo "<center>Vous avez mal confirmé le mot de passe</center>";exit; }
// Test sur la cohérence des droits d'administration et la page de redirection
if($_POST["droits"]==1 && $_POST["destination1"]!="protec/admin.php")
{
echo "<center>Si vous définissez ce membre comme étant un administrateur, l'url de destination doit être 'ADMINISTRATION' !!</center>";exit;
}
if($_POST["droits"]==0 && $_POST["destination1"]=="protec/admin.php")
{
echo "<center>Si vous définissez ce membre comme n'étant PAS un administrateur, l'url de destination ne doit PAS être 'ADMINISTRATION' !!</center>";exit;
}
// Test sur les champs optionnels
// Le nom
if($aff_nom==1)
{
$nom=addslashes($_POST[nom]);
if($aff_nom_obl==1)
{
if($nom==""){ echo "<center><br><br>Vous devez entrer votre nom !!<br><br></center>";include 'footer.php';exit; }
}
$suite_requete_a=" ,nom";
$suite_requete_b=" ,'$nom'";
}
// Le prénom
if($aff_prenom==1)
{
$prenom=addslashes($_POST[prenom]);
if($aff_prenom_obl==1)
{
if($prenom==""){ echo "<center><br><br>Vous devez entrer votre prenom !!<br><br></center>";include 'footer.php';exit; }
}
$suite_requete_a.=" ,prenom";
$suite_requete_b.=" ,'$prenom'";
}
// L'adresse
if($aff_adresse==1)
{
$adresse=addslashes($_POST[adresse]);
if($aff_adresse_obl==1)
{
if($adresse==""){ echo "<center><br><br>Vous devez entrer votre adresse !!<br><br></center>";include 'footer.php';exit; }
}
$suite_requete_a.=" ,adresse";
$suite_requete_b.=" ,'$adresse'";
}
// La date de naissance
if($aff_date_naissance==1)
{
$date_naissance=addslashes($_POST[date_naissance]);
if($aff_date_naissance_obl==1)
{
if($date_naissance==""){ echo "<center><br><br>Vous devez entrer votre date de naissance !!<br><br></center>";include 'footer.php';exit; }
}
$suite_requete_a.=" ,date_naissance";
$suite_requete_b.=" ,'$date_naissance'";
}
// Le pays
if($aff_pays==1)
{
$pays1=addslashes($_POST[pays1]);
if($aff_pays_obl==1)
{
if($pays1==""){ echo "<center><br><br>Vous devez entrer votre Pays !!<br><br></center>";include 'footer.php';exit; }
}
$suite_requete_a.=" ,pays";
$suite_requete_b.=" ,'$pays1'";
}
// test du mail
function EmailOK($ceciestlemail)
{
return( ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.
'@'.
'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',
$ceciestlemail) );
}
if(!EmailOK($_POST['email1']))
{
echo "<br><br><br><br><center><b><font size=\"2\" face=\"Verdana, Arial\" color=\"#cc0000\">ATTENTION : L'email n'est pas correct ! </font><br><br><a href='javascript:history.back(1)'><br><font face=\"Verdana, Arial\" size=\"2\" color=\"#000000\">Retour</font></center></a>";exit;
}
$new_pseudo=htmlentities(addslashes($_POST["new_pseudo"]));
$new_password=htmlentities(addslashes($_POST["new_password"]));
$url1=htmlentities(addslashes($_POST["url1"]));
$destination1=htmlentities(addslashes($_POST["destination1"]));
$remarques1=htmlentities(addslashes($_POST["remarques1"]));
$email1=htmlentities(addslashes($_POST["email1"]));
$actif=htmlentities(addslashes($_POST["actif"]));
if(eregi("#", $new_pseudo) || eregi("#", $new_password) || eregi("#", $email1) || eregi("#", $url1) || eregi("#", $pays1)){ echo "Les caracteres speciaux ne sont pas authorisés.";exit; }
// ON VERIFIE SI CE PSEUDO EXISTE DEJA
$requete=mysql_db_query($sql_bdd,"select * from membre where pseudo=\"$new_pseudo\"",$db_link);
$num=mysql_num_rows($requete);
if($num!=0)
{
echo "<center>Ce pseudo existe déjà, Il faut en choisir un autre</center>";exit;
}
else
{
// CREATION D'UN IDENTIFIANT ALEATOIRE
$taille = 40;
$lettres = "abcdefghijklmnopqrstuvwxyz0123456789";
srand(time());
for ($i=0;$i<$taille;$i++)
{
$id2.=substr($lettres,(rand()%(strlen($lettres))),1);
}
// ON RECHERCHE L'ID MAXIMUM DE LA TABLE
$requete=mysql_db_query($sql_bdd,"select max(id_membre) as maxi from membre",$db_link);
$row=mysql_fetch_assoc($requete);
$idmax=$row["maxi"];
// INSERTION DANS LA TABLE
if ($_POST[Divx]==1){ $Divx=1; } else{ $Divx=0; }
if($_POST[mailingliste]==1){ $inscription=1; } else{ $inscription=0; }
$idnew=$idmax+1;
$rek="insert into membre ( `id_membre` , `id` , `droits` , `date_inscription` , `pseudo` , `passe` , `url` , `Divx` , `destination` , `remarques` , `email` , `heure_session` , `actif` $suite_requete_a , mailingliste)
values ($idnew,\"$id2\", \"$_POST[droits]\", \"$_POST[Divx]\", NOW(), \"$new_pseudo\",\"$new_password\",\"$url1\",\"$destination1\",\"$remarques1\",\"$email1\",NOW(), $actif $suite_requete_b , $inscription)";
$requete=mysql_db_query($sql_bdd,$rek,$db_link) or die (mysql_error().$rek);
if($_POST["envoi_mail"]=="1")
{
if($_POST["droits"]=="1"){ $role="administrateur"; } else{ $role="utilisateur"; }
mail($email1, "Votre compte a été créé sur $nom_site", "Bonjour $new_pseudo, \n\nL'administrateur de $nom_site vous a créé un compte $role.\n\nVous pouvez donc vous connecter sur $chemin_formulaire/login.htm avec vos logins : \n\nPseudo : $new_pseudo \nPasse : $new_password \n\n Vos informations : \n\nAdresse de votre site : $url1 \nVotre pays : $pays1 \nVotre E-mail : $email1 \n\nNous sommes heureux de vous compter parmis nos membres.\nCordialement, l'équipe de $nom_site \n\nScript de zone membre réalisé par Paul Leal Alves\nhttp://www.scriptsgratuits.com\nhttp://www.apreslamort.net\nhttp://www.vol-de-quad.com ", "FROM: $votre_email");
}
// REDIRECTION VERS LA PAGE D'ENTREE DE L'ESPACE MEMBRE
if($active_session=="1"){ header("Location:creation_compte.php?cle=$idnew"); }
else { header("Location:creation_compte.php?id=".$id."&cle=$idnew"); }
}
// DECONNEXION MYSQL
close();
break;
default;
include 'entete.php';
?>
<style type="text/css">
<!--
.Style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
}
.Style3 {color: #0000FF}
-->
</style>
<center>
<h2>Nouveau membre</h2>
<form action="adduser.php<?php if($active_session!="1"){ echo "?id=".$id; } ?>" method="post">
<table border="0" align="center" cellpadding="2" cellspacing="2" class="bordure2">
<tr>
<td align="right"><strong><font face="Verdana, Arial">Choisissez un pseudo
*</font></strong></td>
<td align="left">
<input type="text" name="new_pseudo"> </td>
</tr>
<tr bgcolor="#FFCC99">
<td align="right"><strong><font face="Verdana, Arial">Faire de ce membre
un administrateur ?</font></strong></td>
<td align="left"> <select name="droits" size="1">
<option value="1">Oui</option>
<option value="0" selected>Non</option>
</select>
<img src="images/interrogation2.gif" width="16" height="16" alt="Si vous selectionnez OUI, vous devez selectionner ADMINISTRATION comme url de destination ci-dessous"> </td>
</tr>
<tr>
<td align="right"><font face="Verdana, Arial"><strong>URL de destination</strong>
(la page cible)</font></td>
<td align="left"><select name="destination1">
<?php
if ($dir = opendir("../destination")) {
while($file = readdir($dir)) {
if(!in_array($file, array(".","..")))
{
echo "<option value=\"$file\">$file</option>";
}
}
closedir($dir);
}
?><option value="protec/admin.php">ADMINISTRATION</option></select></td>
</tr>
<tr>
<td align="right"><span class="Style1">Accès à quelle(s) partie(s) du site ?</span></td>
<td align="left"><label>
<strong><span class="Style3"><em>Rubrique films</em> :</span></strong><br />
<br />
<input name="Divx" type="checkbox" id="Divx" value="1" />
Divx
<input name="Dvd" type="checkbox" id="DVD" value="1" />
DVD<br />
<br />
<span class="Style3"><em><strong>Rubrique jeux :</strong></em></span><br />
<br />
<input name="Wii" type="checkbox" id="Wii" value="1" />
Wii
<input name="DS" type="checkbox" id="DS" value="1" />
DS
<input name="PC" type="checkbox" id="PC" value="1" />
PC<br />
<br />
<span class="Style3"><em><strong>Rubrique logiciels :</strong></em></span><br />
<br />
<input name="PC2" type="checkbox" id="PC2" value="1" />
PC
<input name="Mac" type="checkbox" id="Mac" value="1" />
Mac
<input name="Linux" type="checkbox" id="Linux" value="1" />
Linux<br />
<br />
</label></td>
</tr>
<tr>
<td align="right"><strong><font face="Verdana, Arial">Choisissez un mot
de passe *</font></strong></td>
<td align="left"> <input type="password" name="new_password"> </td>
</tr>
<tr>
<td align="right"><strong><font face="Verdana, Arial">Confirmez le mot
de passe *</font></strong></td>
<td align="left"> <input type="password" name="new_password2"> </td>
</tr>
<?php if($aff_nom==1){ ?>
<tr>
<td align="right"><strong>Nom
<?php if($aff_nom_obl==1){ ?>
<strong>*</strong>
<?php } ?>
</strong></td>
<td align="left"> <font size="3">
<input name="nom" type="text" size="20">
</font></td>
</tr>
<?php } ?>
<?php if($aff_prenom==1){ ?>
<tr>
<td align="right"><strong>Prénom
<?php if($aff_prenom_obl==1){ ?>
<strong>*</strong>
<?php } ?>
</strong></td>
<td align="left"><font size="3">
<input name="prenom" type="text" size="20">
</font></td>
</tr>
<?php } ?>
<?php if($aff_date_naissance==1){ ?>
<tr>
<td align="right"><strong>Date de naissance
<?php if($aff_date_naissance_obl==1){ ?>
<strong>*</strong>
<?php } ?>
</strong></td>
<td align="left"><font size="3">
<input name="date_naissance" type="text" size="20">
</font></td>
</tr>
<?php } ?>
<?php if($aff_adresse==1){ ?>
<tr>
<td align="right"><strong>Adresse
<?php if($aff_adresse_obl==1){ ?>
<strong>*</strong>
<?php } ?>
</strong></td>
<td align="left"><font size="3">
<input name="adresse" type="text" size="20">
</font></td>
</tr>
<?php } ?>
<?php if($aff_pays==1){ ?>
<tr>
<td align="right"><strong>Pays
<?php if($aff_pays_obl==1){ ?>
<strong>*</strong>
<?php } ?>
</strong></td>
<td align="left"><font size="3">
<input name="pays1" type="text" size="20">
</font></td>
</tr>
<?php } ?>
<tr>
<td align="right"><strong><font face="Verdana, Arial">Remarques</font></strong></td>
<td align="left"> <textarea name="remarques1" cols="20" rows="3"></textarea> </td>
</tr>
<tr>
<td align="right"><strong><font face="Verdana, Arial">email *</font></strong></td>
<td align="left"> <input type="text" name="email1"> <input type="hidden" name="action" value="add"> </td>
</tr>
<tr>
<td align="right"><strong><font face="Verdana, Arial">Adresse du site</font></strong></td>
<td align="left"> <input type="text" name="url1"> </td>
</tr>
<tr>
<td align="right"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Souhaitez-vous
que le nouveau membre <br>
reçoive un email avec ses nouveaux codes ?</font></strong></td>
<td align="left"> <select name="envoi_mail" size="1">
<option value="1" selected>Oui</option>
<option value="0">Non</option>
</select></td>
</tr>
<tr>
<td align="right"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Rendre
ce compte actif ?</font></strong></td>
<td align="left"><select name="actif" size="1">
<option value="1" selected>Oui</option>
<option value="0">Non</option>
</select></td>
</tr>
<tr>
<td align="right"><strong>Inscription à la Newsletter</strong></td>
<td align="left"> <input name="mailingliste" type="checkbox" value="1" checked="checked"></td>
</tr>
<tr>
<td colspan="2" align="center"> <input name="submit" type="submit" value="Envoyer"> </td>
</tr>
</table>
<br>
</form>
</center>
<?php
include ("footer.php");
break;
}
?> |