Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author Inconnu
- * @copyright 2011
- */
- $compte = Array(
- 'host' => "127.0.0.1",//Host de votre compte mysql
- 'user' => "mangos", //Nom de votre compte mysql
- 'pass' => "mangos", //Pass de votre compte mysql
- 'db' => "realmd" //DB du site
- );
- mysql_connect($compte['host'], $compte['user'], $compte['pass']) or die(mysql_error());
- mysql_select_db($compte['db']) or die(mysql_error());
- define('USER_LENGHT', 3); // Taille minimum du nom de compte
- define('PASSWORD_LENGHT', 3); // Taille minimum du mot de passe
- class Inscription
- {
- private $inscriptionID;
- private $username;
- private $password;
- private $passwordRepeat;
- private $cryptedPassword;
- private $email;
- private $inscriptionDate;
- private $extension;
- private $errorMsg;
- private $error;
- private $injection;
- private function construct()
- {
- $this->inscriptionDate = date('Y-m-d H:i:s');
- $this->error = false;
- $this->errorMsg = '';
- $this->injection = false;
- $this->cryptedPassword = '';
- }
- private function verifyUsername()
- {
- if(strlen($this->username) <= USER_LENGHT)
- {
- $this->error = true;
- $this->errorMsg .= ' - Le nom d\'utilisateur choisi est trop court.<br />';
- }
- $sqlUsername = mysql_query('SELECT COUNT(*) AS nombre FROM account WHERE username=\'' . $this->username.'\'') or die('Comparaison des noms d\'utilisateur : '.mysql_error());
- $datasUsername = mysql_fetch_assoc($sqlUsername);
- if($datasUsername['nombre'] == 1)
- {
- $this->error = true;
- $this->errorMsg .= ' - Ce nom d\'utilisateur est déjà pris.<br />';
- }
- $this->sqlDetect($this->username);
- }
- private function verifyPassword()
- {
- if(strlen($this->password) <= PASSWORD_LENGHT)
- {
- $this->error = true;
- $this->errorMsg .= ' - Le mot de passe choisi est trop court.<br />';
- }
- if (isset($_POST['conditions']) == null)
- {
- $this->error = true;
- $this->errorMsg .= ' - Les Conditions Générales d\'Utilisation ne sont pas acceptées.<br />';
- }
- if($this->password !== $this->passwordRepeat)
- {
- $this->error = true;
- $this->errorMsg .= ' - Les mots de passe ne sont pas identiques.<br />';
- }
- $this->sqlDetect($this->password);
- }
- private function verifyEmail()
- {
- if(!preg_match('#^[a-z0-9.-_]+@[a-z0-9.-_]{2,}\.[a-z]{2,4}$#', $this->email))
- {
- $this->error = true;
- $this->errorMsg .= ' - L\'email n\'est pas correct.<br />';
- }
- $sqlEmail = mysql_query('SELECT COUNT(*) AS nombre FROM account WHERE email=\''.$this->email.'\'') or die('Comparaison des emails : '.mysql_error());;
- $datasEmail = mysql_fetch_assoc($sqlEmail);
- if($datasEmail['nombre'] != 0)
- {
- $this->error = true;
- $this->errorMsg .= ' - L\'email est déjà utilisé.<br />';
- }
- $this->sqlDetect($this->email);
- }
- public function verifyAll()
- {
- $this->verifyUsername();
- $this->verifyEmail();
- $this->verifyPassword();
- if(!$this->error)
- {
- $this->cryptedPassword = sha1(strtoupper($this->username).':'.strtoupper($this->password));
- mysql_query('INSERT INTO account(username,
- sha_pass_hash,
- email,
- joindate,
- last_ip,
- expansion)
- VALUES(\''.$this->username.'\',
- \''.$this->cryptedPassword.'\',
- \''.$this->email.'\',
- \''.$this->inscriptionDate.'\',
- \''.$_SERVER['REMOTE_ADDR'].'\',
- \''.$this->extension.'\')') or die('Enregistrement du compte : '.mysql_error());
- echo '<p class="info"><br /><br /><br />Votre enregistrement à été effectué avec succès !<br /><a href="inscription.php">Retour à l\'accueil</a></p>';
- }
- else
- {
- if($this->injection)
- {
- echo '<p class="info"><br /><br />On ne fait pas ça !</p>';
- }
- else
- {
- echo '<p class="info">Des erreurs ont été trouvée durant l\'enregistrement :<br /><br />',$this->errorMsg,'<br /><a href="inscription.php">Réessayer</a></p>';
- }
- }
- }
- private function sqlDetect($string)
- {
- if (preg_match('#INSERT|SELECT|UNION|FROM|WHERE|DELETE#', $string))
- {
- $this->error = true;
- $this->errorMsg .= ' - Injection sql detéctée !<br />';
- $this->injection = true;
- }
- }
- public function setUsername($username)
- {
- $this->username = mysql_real_escape_string($username);
- }
- public function setPassword($password)
- {
- $this->password = mysql_real_escape_string($password);
- }
- public function setPasswordRepeat($password)
- {
- $this->passwordRepeat = mysql_real_escape_string($password);
- }
- public function setEmail($email)
- {
- $this->email = mysql_real_escape_string($email);
- }
- public function setExtension($extension)
- {
- $this->extension = $extension;
- }
- }
- /* Connexion à la base de données */
- mysql_connect($compte['host'], $compte['user'], $compte['pass']) or die(mysql_error());
- mysql_select_db($compte['db']) or die(mysql_error());
- if(isset($_POST['ok']))
- {
- $joueur = new Inscription();
- $joueur->setUsername($_POST['username']);
- $joueur->setPassword($_POST['password']);
- $joueur->setPasswordRepeat($_POST['passwordRepeat']);
- $joueur->setEmail($_POST['email']);
- $joueur->setExtension($_POST['extension']);
- $joueur->verifyAll();
- }
- else
- {
- echo '
- <form action="" method="post">
- <table width="430" border="0" cellspacing="0" cellpadding="2" align="center">
- <tr>
- <p style="text-align: left;">Pour vous inscrire et nous rejoindre sur notre serveur de jeu, il vous suffit simplement de remplir les champs ci-dessous !<br /> Les identifiants que vous choisirez lors de votre inscription seront ceux que vous utiliserez pour vous connecter à notre serveur une fois votre jeu lancé !</p>
- </tr>
- <br><br><br>
- <tr>
- <td colspan="2"><div id="erreurTxt" style="color:#F00;font-size:10px"></div></td>
- </tr>
- <tr>
- <td width="200" align="right" valign="top" class="TextSmall">Nom de compte :</td>
- <td><input name="username" type="text" size="25" maxlength="60" id="txtNomCompte" value="" autocomplete="off" />
- </td>
- </tr>
- <tr>
- <td align="right" class="TextSmall">Adresse e-mail :</td>
- <td><input name="email" type="text" size="25" maxlength="60" id="txtEmail" value="" autocomplete="off" /></td>
- </tr>
- <tr>
- <td align="right" class="TextSmall">Mot de passe :</td>
- <td><input name="password" type="password" size="25" maxlength="60" id="txtPass" value="" autocomplete="off" /></td>
- </tr>
- <tr>
- <td align="right" class="TextSmall">Validation du mot de passe :</td>
- <td><input name="passwordRepeat" type="password" size="25" maxlength="60" id="txtValPass" value="" autocomplete="off"/></td>
- </tr>
- <tr>
- <td align="right" class="TextSmall">Type de jeu</td>
- <td>
- <select name="extension" id="selTypeJeu" class="TextXSmall">
- <option value="2">World of Warcraft Classique</option>
- <option value="1">World of Warcraft - The Burning Crusade</option>
- <option value="0">World of Warcraft - Wrath of the lich King</option>
- </select>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="right">
- <input type="submit" name="ok" id="Submit" value="Valider" /></td>
- </tr>
- </table>
- <center><br>
- Veuillez prendre note du règlement avant tout.<br>
- <input type="checkbox" name="conditions"><a href="#" target="_blank"><font color="#A05050"><u>Conditions générales d\'utilisation du serveur</u></font></a> lues et acceptées.<br><br>
- <font color="#A05050">Une fois votre inscription faite et donc cette case cochée, vous êtes tenus de respecter ces règles.</font></center>
- </form>
- <br><br><br><br>
- <center><b><u><big>Attention:</u></big></b> Vous devez impérativement posséder une adresse e-mail valide sinon vous ne pourrez pas effectuer de modifications sur votre compte (Changement de mot de passe, mot de passe perdu, ...).</center>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement