* obligation to do so :) * * Please read the accompanying LICENSE document for the full WTFPL * licensing text. */ if (!isset($_APP)) { die("Unauthorized."); } if (!empty($_SESSION['user_id'])) { flash_notice("You are already logged in."); redirect("/dashboard"); } if (!empty($_POST['submit'])) { if (empty($_POST['username']) || !preg_match("/^[a-zA-Z0-9-.]+\$/", $_POST['username'])) { flash_error("You did not enter a valid username. Your username can only contain a-z, A-Z, 0-9, dots, and dashes."); } elseif (User::CheckIfUsernameExists($_POST['username']) || User::CheckIfDisplayNameExists($_POST['username'])) { flash_error("The username you entered is already in use. Please pick a different username."); } if (empty($_POST['email']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { flash_error("You did not enter a valid e-mail address."); } elseif (User::CheckIfEmailExists($_POST['email'])) { flash_error("The e-mail address you entered is already in use. Did you <a href=\"/forgot-password\">forget your password</a>?"); } if (empty($_POST['password']) || strlen($_POST['password']) < 8) { flash_error("You did not enter a valid password. Your password has to be at least 8 characters."); } elseif (empty($_POST['password2']) || $_POST['password'] != $_POST['password2']) { flash_error("The passwords you entered did not match."); } if (!empty($_POST['displayname']) && User::CheckIfDisplayNameExists($_POST['displayname'])) { flash_error("The (display) name you entered is already in use. Please pick a different name. You can also just use your nickname!"); }