Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author: TeoL <[email protected]>
- * @version: 1.0
- */
- if(defined('INDEX')){
- if(!empty($_SESSION['id'])){
- if(isset($_POST) && !empty($_POST)){
- $erreurs = array();
- $tableau_sexes = array(1, 2); //1 Homme, 2 Femme
- //$tableau_extensions = array("jpg", "png", "gif");
- $tableau_mimes = array("image/jpeg", "image/png", "image/gif");
- $tableau_exif = array("IMAGETYPE_GIF", "IMAGETYPE_PNG", "IMAGETYPE_JPEG", 1, 2, 3);
- $maxwidth = '150'; //Largeur max
- $maxheight = '150'; //Hauteur max
- $dernier_id_jeux = lastGameId();
- if(empty($_POST['password_actuel']) && !empty($_POST['password_new'])){
- $erreurs[] = "Vous n'avez pas renseigné votre mot de passe actuel.";
- }
- if(isset($_POST['game_1'])){
- if(!ctype_digit($_POST['game_1'])){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- if($_POST['game_1'] < 0 OR $_POST['game_1'] > $dernier_id_jeux){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- }
- if(isset($_POST['game_2'])){
- if(!ctype_digit($_POST['game_2'])){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- if($_POST['game_2'] < 0 OR $_POST['game_2'] > $dernier_id_jeux){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- }
- if(isset($_POST['game_3'])){
- if(!ctype_digit($_POST['game_3'])){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- if($_POST['game_3'] < 0 OR $_POST['game_3'] > $dernier_id_jeux){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- }
- if(!empty($_POST['password_actuel']) && !empty($_POST['password_new'])){
- if(!checkPassword($_SESSION['pseudo'], $pwd)){
- $erreurs[] = "Le mot de passe actuel que vous avez entré est erroné.";
- }
- }
- if(strlen($_FILES['avatar']['tmp_name']) > 0){
- if($_FILES['avatar']['error'] > 0){
- $erreurs[] = "Erreur upload avatar : ".$_FILES['avatar']['error']."";
- }
- if(!in_array($_FILES['avatar']['type'], $tableau_mimes) OR !in_array(exif_imagetype($_FILES['avatar']['tmp_name']), $tableau_exif)){
- $erreurs[] = "Seules les images PNG, JPEG et GIF de maximum 150*150px sont autorisées.";
- }
- //On récupere la taille de l'image (avatar)
- $image_size = getimagesize($_FILES['avatar']['tmp_name']);
- //Puis on regarde si c'est pas trop grand
- if($image_size[0] > $maxwidth OR $image_size[1] > $maxheight){
- $erreurs[] = "Votre avatar est trop grand, il doit être au maximum de 150*150px.";
- }
- }
- if(!in_array($_POST['sexe'], $tableau_sexes)){
- $erreurs[] = "DU HURENSÖHN :@"; //Modification dynamique de la page (FireBug)
- }
- if(!empty($_POST['mail'])){
- if(!preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['mail'])){
- $erreurs[] = "Vous n'avez pas entré une adresse e-mail valide.";
- }
- }
- if(!empty($_POST['password_new'])){
- if(!empty($_POST['password_conf'])){
- if($_POST['password_new'] != $_POST['password_conf']){
- $erreurs[] = "Les deux mots de passe ne correspondent pas.";
- }
- }
- else{
- $erreurs[] = "Vous n'avez pas entré la confirmation du nouveau mot de passe.";
- }
- }
- if(!empty($_POST['steamid'])){
- //On vérifie la syntaxe du SteamID
- if(!preg_match("#^STEAM_0:[0-1]:[0-9]{1,8}$#", $_POST['steamid'])){
- $erreurs[] = "La syntaxe du SteamID n'est pas bonne. ( STEAM_X:Y:Z )";
- }
- }
- if(!empty($_POST['eslid'])){
- //On vérifie la syntaxe de l'esl ID
- if(!preg_match("#^[0-9]{1,15}$#", $_POST['eslid'])){
- $erreurs[] = "La syntaxe de l'ESL ID n'est pas bonne. ( ex: 3465536 )";
- }
- }
- if(!empty($_POST['titre'])){
- if(strlen($_POST['titre']) > 50){
- $erreurs[] = "Votre titre ne doit pas ocntenir plus de 50 caractères.";
- }
- }
- if(!empty($_POST['description'])){
- if(strlen($_POST['description']) > 250){
- $erreurs[] = "Votre résumé ne doit pas contenir plus de 250 caractères.";
- }
- }
- //S'il n'y a pas d'erreurs, on continue
- if(empty($erreurs)){
- $pwd = hash_pwd($_POST['password_actuel'], $_SESSION['pseudo']);
- //On voit si le membre veut la newsletter
- if(isset($_POST['newsletter'])){
- $newsletter = 1;
- }
- else{
- $newsletter = 0;
- }
- //ON UPDATE, ENFIN ! ( mais c'est loin d'être fini :( )
- if(!empty($_POST['password_new'])){
- $pwd = hash_pwd($_POST['password_new'], $_SESSION['pseudo']);
- updatePwd($pwd, $_SESSION['id']); //Updated :)
- }
- if(!empty($_POST['mail'])){
- updateMail($_POST['mail'], $_SESSION['id']); //Updated :)
- }
- if(!empty($_POST['steamid'])){
- $steamid = $_POST['steamid'];
- //On découpe le SteamID
- sscanf(strtoupper($steamid), 'STEAM_%d:%d:%d', $X, $Y, $Z);
- //Puis on calcule le SteamID_64
- $constanteCommunityid = 7656119;
- $communityid = $Z * 2;
- $communityid = $communityid + 7960265728;
- $communityid = $communityid + $Y;
- $steamid64 = $constanteCommunityid.$communityid;
- updateSteam($steamid, $steamid64, $_SESSION['id']); //Updated :)
- }
- if(!empty($_POST['eslid'])){
- updateEsl($_POST['eslid'], $_SESSION['id']); //Updated :)
- }
- if(!empty($_POST['titre'])){
- updateTitle($_POST['titre'], $_SESSION['id']); //Updated :)
- }
- if(!empty($_POST['description'])){
- $_POST['description'] = htmlentities($_POST['description']);
- //NL2BR, normal :)
- $_POST['description'] = nl2br($_POST['description']);
- updateDescription($_POST['description'], $_SESSION['id']); //Updated :)
- }
- if(strlen($_FILES['avatar']['tmp_name']) > 0){
- //On upload l'avatar
- $image_extension = strtolower( substr( strrchr($_FILES['avatar']['name'], '.') ,1) );
- $avatar_name = ''.$_SESSION['pseudo'].'-'.uniqid().'.'.$image_extension.''; //Donne un truc du style teol-454xbx568.jpg
- $img_location = "img/avatars/".$avatar_name; //Endroit de l'upload
- //Si l'upload se passe bien
- if(move_uploaded_file($_FILES['avatar']['tmp_name'], $img_location)){
- //On update
- updateAvatar($img_location, $_SESSION['id']); //Updated :)
- }
- else{
- $erreurs[] = "Une erreur s'est produite durant l'upload de votre avatar. Veuillez réessayer.";
- }
- }
- //Puis enfin, on update le sexe et la newsletter, qui sont censé être présents
- updateGender($_POST['sexe'], $_SESSION['id']); //Updated :)
- updateNewsletter($newsletter, $_SESSION['id']); //Updated :)
- updateGame3($_POST['game_3'], $_SESSION['id']); //Updated :)
- updateGame2($_POST['game_2'], $_SESSION['id']); //Updated :)
- updateGame1($_POST['game_1'], $_SESSION['id']); //Updated :)
- }
- }
- $jeux = gameList();
- $info = getProfileinfo($_SESSION['id']);
- $info['description'] = stripslashes($info['description']);
- //On transforme les <br /> en \n
- $info['description'] = str_replace("<br />", "\n", $info['description']);
- include "views/updateprofile.php";
- }
- else{
- include "views/erreur_non_connecte.php";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment