Edite members space
- Change Signin, Profil
This commit is contained in:
ccunatbrule
2023-02-12 14:27:14 +01:00
parent 67ce37f4d0
commit 9fe23f6c3f
28 changed files with 170 additions and 138 deletions

View File

@@ -11,8 +11,8 @@ if (!isset($_POST['pseudo'])) { //Page de formulaire
<h2>Connexion</h2>
<form method="post" action="connexion.php">
<br><fieldset>
<label class="labelI" for="pseudo">Pseudo :</label><input name="pseudo" type="text" id="pseudo" /><br>
<label class="labelI" for="password">Password :</label><input type="password" name="password" id="password" />
<label class="labelI" for="pseudo">Pseudo :</label><br><input name="pseudo" type="text" id="pseudo" /><br>
<label class="labelI" for="password">Mot de passe :</label><br><input type="password" name="password" id="password" />
</fieldset><br>
<p class="btns"><input type="submit" value="Connexion" class="button-3" /></p>
</form>

View File

@@ -13,13 +13,56 @@ function erreur($err='')
</section>
</div>');
}
function move_avatar($avatar)
function edit_avatar($avatar, $pseudo)
{
$extension_upload = strtolower(substr( strrchr($avatar['name'], '.') ,1));
$name = time();
$nomavatar = str_replace(' ','',$name).".".$extension_upload;
$name = "./images/avatars/".str_replace(' ','',$name).".".$extension_upload;
move_uploaded_file($avatar['tmp_name'],$name);
return $nomavatar;
if (isset ($avatar)){
$imagename = $avatar['name'];// exemple.png
$source = $avatar['tmp_name'];// /volume1/@tmp/phpiES0qN
$locate = "./images/avatars/".$pseudo."/";
$dir = $locate."img_user.jpeg";
move_uploaded_file($source,$dir);
changeToJpeg($dir,$dir);
resize_avatar($dir,$dir);
$rdir = substr($dir,1);
return $rdir;
}
}
function changeToJpeg($source, $dir)
{
$ext = substr($_FILES['avatar']['type'],6); //jpeg
switch($ext) {
case 'jpg':
$image = imagecreatefromjpeg($source);
break;
case 'jpeg':
$image = imagecreatefromjpeg($source);
break;
case 'png':
$image = imagecreatefrompng($source);
break;
case 'gif':
$image = imagecreatefromgif($source);
break;
default:
throw new Exception('Unknown image type.');
}
imagejpeg($image, $dir);
}
function resize_avatar($dir,$out )
{
list($width, $height) = getimagesize($dir);
$modwidth = 150; //target width
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight);
$image = imagecreatefromjpeg($dir);
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $out);
}
?>

View File

@@ -12,15 +12,23 @@ if (empty($_POST['pseudo'])) // Si on la variable est vide, on peut considérer
<h2>Inscription</h2>
<form method="post" action="inscription.php" enctype="multipart/form-data">
<label class="labelI" >*Pseudo</label><br><input name="pseudo" type="text" id="pseudo" placeholder=" Entre 3 à 15 caractères"/><br><br>
<label class="labelI" for="password">*Mot de Passe :</label><input type="password" name="password" id="password" />
<label class="labelI" for="confirm">*Confirmer :</label><input type="password" name="confirm" id="confirm" /><br>
<label class="labelI" for="password">*Mot de Passe :</label><input type="password" name="password" id="password" placeholder="Mot de passe"/>
<label class="labelI" for="confirm">*Confirmer :</label><input type="password" name="confirm" id="confirm" placeholder="Confirmation"/><br>
</fieldset>
<label class="labelI" for="email">*Votre adresse email :</label><br><input type="text" name="email" id="email" /><br>
<label class="labelI" for="email">*Votre adresse email :</label><br><input type="email" name="email" id="email" placeholder="email@mail.fr"/><br>
</fieldset>
<label class="labelI" for="localisation">Localisation :</label><br><input type="text" name="localisation" id="localisation" /><br>
<label class="labelI" for="localisation">Localisation :</label><br><input type="text" name="localisation" id="localisation" placeholder="Adresse" /><br>
<label class="labelI" for="prenom">Prenom :</label><br><input type="text" name="prenom" id="prenom" placeholder="Prénom"/><br>
<label class="labelI" for="nom">Nom :</label><br><input type="text" name="nom" id="nom" placeholder="Nom"/><br>
<label class="labelI" for="sexe">Sexe :</label><br>
<div><input type="radio" id="femme" name="sexe" value="FEMME" checked><label for="femme">Femme</label>
<input type="radio" id="homme" name="sexe" value="HOMME"><label for="homme">Homme</label></div>
<label class="labelI" for="age">Age :</label><br><input type="number" name="age" id="age" min="5" max="90" placeholder="Age"/><br>
<fieldset>
<label class="labelI" for="galop">Galop :</label><br><input type="number" name="galop" id="galop" min="0" max="7" placeholder="1 à 7"/><br>
</fieldset>
<fieldset><legend class="colorbold marg3 pad1">Profil sur le forum</legend>
<label for="avatar">Choisissez votre avatar :</label><br><input type="file" name="avatar" id="avatar" /><br>(Taille max : 10Ko)
<label for="avatar">Choisissez votre avatar :</label><br><input type="file" name="avatar" id="avatar" accept=".png, .jpg, .jpeg, gif" /><br>
</fieldset><br>
<p class="btns"><input type="submit" value="S'inscrire" class="button-3"/></p><br>
<p>Les champs précédés d'un * sont obligatoires</p>
@@ -33,15 +41,17 @@ if (empty($_POST['pseudo'])) // Si on la variable est vide, on peut considérer
else //On est dans le cas traitement
{
$pseudo_erreur1 = NULL;$pseudo_erreur2 = NULL;
$email_erreur1 = NULL;$email_erreur2 = NULL;
$avatar_erreur = NULL;$avatar_erreur1 = NULL;
$avatar_erreur2 = NULL;$avatar_erreur3 = NULL;
$email_erreur1 = NULL;
$mdp_erreur = NULL;
$avatar_erreur3 = NULL;
//On récupère les variables
$i = 0;
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png' );
$pseudo=$_POST['pseudo'];
$email = $_POST['email'];
$localisation = $_POST['localisation'];
$prenom = $_POST['prenom'];
$nom = $_POST['nom'];
$pass = /*md5*/($_POST['password']);
$confirm = /*md5*/($_POST['confirm']);
//Verification des champs formulaire
@@ -67,43 +77,12 @@ else //On est dans le cas traitement
$email_erreur1 = "Votre adresse email est déjà utilisée par un membre";
$i++;
}
if (!preg_match("#^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-z]{2,4}$#", $email) || empty($email))
$extension_upload = strtolower(substr( strrchr($_FILES['avatar']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$email_erreur2 = "Votre adresse email n'a pas un format valide";
$avatar_erreur3 = "Extension de l'avatar incorrecte";
$i++;
}
if (!empty($_FILES['avatar']['size']))
{
$maxsize = 10024; //Poid de l'image
$maxwidth = 100; //Largeur de l'image
$maxheight = 100; //Longueur de l'image
//Liste des extensions valides
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'bmp' );
if ($_FILES['avatar']['error'] > 0)
{
$avatar_erreur = "Erreur lors du transfert de l'avatar : ";
}
if ($_FILES['avatar']['size'] > $maxsize)
{
$i++;
$avatar_erreur1 = "Le fichier est trop gros : (<strong>".$_FILES['avatar']['size']." Octets</strong> contre <strong>".$maxsize." Octets</strong>)";
}
$image_sizes = getimagesize($_FILES['avatar']['tmp_name']);
if ($image_sizes[0] > $maxwidth OR $image_sizes[1] > $maxheight)
{
$i++;
$avatar_erreur2 = "Image trop large ou trop longue :
(<strong>".$image_sizes[0]."x".$image_sizes[1]."</strong> contre <strong>".$maxwidth."x".$maxheight."</strong>)";
}
$extension_upload = strtolower(substr( strrchr($_FILES['avatar']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$i++;
$avatar_erreur3 = "Extension de l'avatar incorrecte";
}
}
if ($i==0)
{
?>
@@ -113,7 +92,6 @@ else //On est dans le cas traitement
<p>Cliquez <a href="./espace_membre.php">ici</a> pour revenir dans votre espace membre</p>
</div>
<?php
$nomavatar=(!empty($_FILES['avatar']['size']))?move_avatar($_FILES['avatar']):'';
post_Registre();
//Et on définit les variables de sessions
$_SESSION['pseudo'] = $pseudo;
@@ -126,11 +104,10 @@ else //On est dans le cas traitement
<div class="text-center"><h2>Inscription interrompue</h2><br>
<h5><?php echo $i; ?> erreurs se sont produites lors de votre incription</h5><br>
<ul>
<p><?php echo $email_erreur1; $email_erreur2; ?></p>
<p><?php echo $email_erreur1; ?></p>
<p><?php echo $pseudo_erreur1; $pseudo_erreur2; ?></p>
<p><?php echo $avatar_erreur1; $avatar_erreur2; ?></p>
<p><?php echo $avatar_erreur3; $avatar_erreur; ?></p>
<p><?php echo $mdp_erreur; ?></p>
<p><?php echo $avatar_erreur3; ?></p>
</ul><br>
<p>Cliquez <a href="./inscription.php">ici</a> pour recommencer</p>
</div>

View File

@@ -14,13 +14,27 @@ switch($action)
<div class="container-fluid">
<section id="content" class="page-content">
<div class="container text-center">
<h2>Profil de <?php echo stripslashes(htmlspecialchars($data['pseudo'])); ?></h2><br>
<img src=".<?php echo $data['imageeleve']; ?>" alt="Acun avatar" /><br>
<p class="text-2" ><strong>Adresse E-Mail : </strong>
<a class=link2 href="mailto:<?php echo stripslashes($data['adressemail']); ?>"> <?php echo stripslashes(htmlspecialchars($data['adressemail'])); ?></a><br/><br>
Ce membre est inscrit depuis le <strong><?php echo date('d-m-Y', strtotime(str_replace('/','-',$data['dateenregistre']))); ?></strong><br/><br/>
<strong>Localisation : </strong> <?php echo stripslashes(htmlspecialchars($data['adresse'])); ?>
</p>
<h2>Profil</h2><br>
<strong>Pseudo</strong><br>
<?php echo stripslashes(htmlspecialchars($data['pseudo'])); ?><br><br>
<strong>Avatar</strong><br>
<img src=".<?php echo $data['imageeleve']; ?>" alt="Acun avatar" /><br><br>
<p class="text-2" >
<strong>Email</strong><br>
<a class=link2 href="mailto:<?php echo stripslashes($data['adressemail']); ?>"> <?php echo stripslashes(htmlspecialchars($data['adressemail'])); ?></a><br/>
<strong>Prénom</strong><br>
<?php echo stripslashes(htmlspecialchars($data['prenom'])); ?><br>
<strong>Nom</strong><br>
<?php echo stripslashes(htmlspecialchars($data['nom'])); ?><br>
<strong>Age</strong><br>
<?php echo stripslashes(htmlspecialchars($data['age'])); ?><br>
<strong>Galop</strong><br>
<?php echo stripslashes(htmlspecialchars($data['galop'])); ?><br>
<strong>Adresse</strong><br>
<?php echo stripslashes(htmlspecialchars($data['adresse'])); ?><br><br>
<strong>Inscrit depuis :</strong><br>
<?php echo date('d F Y', strtotime(str_replace('/','-',$data['dateenregistre']))); ?><br/><br/>
</p>
</div>
</section>
</div>
@@ -41,31 +55,40 @@ switch($action)
<form method="post" action="profil.php?action=modifier" enctype="multipart/form-data">
<h2>Edition du profil de <?php echo stripslashes(htmlspecialchars($data['pseudo']));?></h2><br>
<fieldset>
<label class="labelI" for="password">*Mot de passe<br>Nouveau mot de passe</label><br>
<h3 class="labelI" for="password">Mot de passe</h3>
<label class="labelI" for="password">Nouveau mot de passe</label><br>
<input type="password" name="password" id="password" /><br>
<label class="labelI" for="confirm">*Confirmation du mot de passe</label><br>
<input type="password" name="confirm" id="confirm" /><br>
</fieldset><br>
<fieldset><legend class=colorbold marg3 pad1>Contacts</legend>
</fieldset><br><br>
<fieldset><h2 class=colorbold marg3 pad1>Contacts</h2>
<label class="labelI" for="email">Adresse email</label><br>
<input type="text" name="email" id="email" value="<?php echo stripslashes($data['adressemail']); ?>" /><br>
</fieldset><br>
<fieldset><legend class=colorbold marg3 pad1>Informations supplémentaires</legend>
</fieldset><br><br>
<fieldset><h2 class=colorbold marg3 pad1>Informations supplémentaires</h2>
<label class="labelI" for="prenom">Prénom</label><br>
<input type="text" name="prenom" id="prenom" readonly="readonly" value="<?php echo stripslashes($data['prenom']); ?>" /><br>
<label class="labelI" for="nom">Nom</label><br>
<input type="text" name="nom" id="nom" readonly="readonly" value="<?php echo stripslashes($data['nom']); ?>" /><br>
<label class="labelI" for="age">Age</label><br>
<input type="number" name="age" id="age" readonly="readonly" value="<?php echo stripslashes($data['age']); ?>" /><br>
<label class="labelI" for="galop">Galop</label><br>
<input type="number" name="galop" id="galop" readonly="readonly" value="<?php echo stripslashes($data['galop']); ?>" /><br>
<label class="labelI" for="localisation">Localisation</label><br>
<input type="text" name="localisation" id="localisation" value="<?php echo stripslashes($data['adresse']); ?>" />
</fieldset><br>
<fieldset><legend class=colorbold marg3 pad1>Profil sur le forum</legend>
Avatar actuel <img src=".<?php echo $data['imageeleve'];?>" alt="pas d avatar" /><br><br>
<label class="labelI" for="avatar">Changer mon avatar</label><br>
<input type="file" name="avatar" id="avatar" /><br>(Taille max : 10 ko)<br><br>
<label><input type="checkbox" name="delete" value="Delete" /> Supprimer mon avatar</label>
</fieldset><br><br>
<fieldset><h2 class=colorbold marg3 pad1>Profil sur le forum</h2>
<label class="labelI" for="avatar">Avatar actuel</label><br>
<img src=".<?php echo $data['imageeleve'];?>" alt="pas d avatar" /><br><br>
<strong class="labelI" for="avatar">Nouvelle image : </strong>
<input type="file" name="avatar" id="avatar" accept=".png, .jpg, .jpeg, gif" /><br><br>
<strong><input type="checkbox" name="delete" value="Delete" /> Supprimer mon avatar</strong>
</fieldset><br>
<p>
<input type="submit" value="Modifier mon profil" class="button-3"/><br>
<input type="hidden" id="sent" name="sent" value="1" />
</p><br>
<p>Les champs avec une * sont obligatoires</p><br>
<strong>Les champs avec une * sont obligatoires</strong><br><br>
</form>
</div>
</section>
@@ -77,10 +100,6 @@ switch($action)
//On déclare les variables
$mdp_erreur = NULL;
$email_erreur1 = NULL;
$email_erreur2 = NULL;
$avatar_erreur = NULL;
$avatar_erreur1 = NULL;
$avatar_erreur2 = NULL;
$avatar_erreur3 = NULL;
//Encore et toujours notre belle variable $i :p
$i = 0;
@@ -89,6 +108,7 @@ switch($action)
$localisation = $_POST['localisation'];
$pass = /*md5*/($_POST['password']);
$confirm = /*md5*/($_POST['confirm']);
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png' );
//Vérification des champs du formulaire
if ($pass != $confirm || empty($confirm) || empty($pass))
{
@@ -104,52 +124,19 @@ switch($action)
$email_erreur1 = "Votre adresse email est déjà utilisé par un membre";
$i++;
}
if (!preg_match("#^[a-z0-9A-Z._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $email) || empty($email))
{
$email_erreur2 = "Votre nouvelle adresse E-Mail n'a pas un format valide";
$i++;
}
}
if (!empty($_FILES['avatar']['size']))
$data = get_Pseudo();
$extension_upload = strtolower(substr( strrchr($_FILES['avatar']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$maxsize = 30072; //Poid de l'image
$maxwidth = 100; //Largeur de l'image
$maxheight = 150; //Longueur de l'image
//Liste des extensions valides
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'bmp' );
if ($_FILES['avatar']['error'] > 0)
{
$avatar_erreur = "Erreur lors du tranfsert de l'avatar : ";
}
if ($_FILES['avatar']['size'] > $maxsize)
{
$i++;
$avatar_erreur1 = "Le fichier est trop gros :
(<strong>".$_FILES['avatar']['size']." Octets</strong>
contre <strong>".$maxsize." Octets</strong>)";
}
$image_sizes = getimagesize($_FILES['avatar']['tmp_name']);
if ($image_sizes[0] > $maxwidth OR $image_sizes[1] > $maxheight)
{
$i++;
$avatar_erreur2 = "Image trop large ou trop longue :
(<strong>".$image_sizes[0]."x".$image_sizes[1]."</strong> contre
<strong>".$maxwidth."x".$maxheight."</strong>)";
}
$extension_upload = strtolower(substr( strrchr($_FILES['avatar']['name'], '.') ,1));
if (!in_array($extension_upload,$extensions_valides) )
{
$i++;
$avatar_erreur3 = "Extension de l'avatar incorrecte";
}
$i++;
$avatar_erreur3 = "Extension de l'avatar incorrecte";
}
if ($i == 0) // Si $i est vide, il n'y a pas d'erreur sur l'avatar
{
if (!empty($_FILES['avatar']['size']))
{
post_UpdateAvatar();
post_UpdateAvatar($data['pseudo']);
}
if (isset($_POST['delete']))
{