Enregistrement

16) throw new Exception('Nickname is too long!'); if (!ctype_alnum(str_replace(array('_'), '', $nickname))) throw new Exception('Nickname contains forbidden chars!'); if (strlen($password) < 5) throw new Exception('Password is too short!'); if (strlen($password) > 20) throw new Exception('Password is too long!'); if (in_array(strtolower($password), array('qwerty', '12345'))) throw new Exception('Password is too weakness!'); if ($password != $repeat_password) throw new Exception('Passwords are not the same!'); if (!verifyCaptcha($captcha)) throw new Exception('Please check captcha!'); if (getAccountsAmount($ip) >= 2) throw new Exception('You cannot have more than two accounts!'); if (isExists($nickname)) throw new Exception('This nickname has already been registered!'); if (isPremium($nickname)) throw new Exception('You can not register premium nickname!'); register($nickname, $password, $ip); $error = 'You has been registered! Please wait 60 seconds and join again to the server!'; $_POST['sent'] = false; $_POST['nickname'] = null; $_POST['password'] = null; $_POST['repeat_password'] = null; $_POST['g-recaptcha-response'] = null; } catch(Exception $exception) { $error = $exception->getMessage(); } } ?> success; } function getAccountsAmount($ip) { $connection = mysqli_connect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT); if (mysqli_connect_errno($connection)) throw new Exception('Could not connect to the database!'); $table = MYSQL_TABLE; $column = MYSQL_COLUMN_IP; $result = mysqli_query($connection, "SELECT * FROM `$table` WHERE `$column`='$ip'"); mysqli_close($connection); return mysqli_num_rows($result); } function isExists($nickname) { $connection = mysqli_connect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT); if (mysqli_connect_errno($connection)) throw new Exception('Could not connect to the database!'); $table = MYSQL_TABLE; $column = MYSQL_COLUMN_NICKNAME; $result = mysqli_query($connection, "SELECT * FROM `$table` WHERE `$nickname`='$nickname'"); mysqli_close($connection); return mysqli_num_rows($result) > 0; } function register($nickname, $password, $ip) { $connection = mysqli_connect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT); if (mysqli_connect_errno($connection)) throw new Exception('Could not connect to the database!'); $table = MYSQL_TABLE; $index = generateIndex(); $hash = hash('sha256', $password); $language = JPREMIUM_DEFAULT_LANGUAGE; $result = mysqli_query($connection, "INSERT INTO `$table` VALUES ('$nickname', '$index', '$hash', '$language', '$ip')"); mysqli_close($connection); if ($result == false) throw new Exception('Could not register your account!'); } function generateIndex() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) ); } ?>

Hi, You can register your account!
Enough you enter nickname and password in below form and join again to the example.com!

' . $error . '

 

' : null) ?>
 



le 22/12/2019 à 13:38:52 par admin