format($format) == $date; } /* checks if username exist and if its longer than 6 characters. */ function username($variable){ if (empty($variable)) { throw new usernameException("Verplicht!"); } else if (strlen($variable) < 6) { throw new usernameException("Moet minstens 6 karakters bevatten"); } else if (getExistingUsername() == 1) { throw new usernameException("Gebruikersnaam bestaal al"); } } /* checks if an input is longer that 8 characters. */ function longerEight($variable){ if (empty($variable)) { throw new passwordException("Verplicht!"); } else if (strlen($variable) < 8) { throw new passwordException("Moet minstens 8 karakters bevatten"); } } /* checks if an input is a valid email. */ function validateEmail($variable){ if (empty($variable)) { throw new emailException("Verplicht!"); } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) { throw new emailException("Geldige email invullen"); } else if (getExistingEmail() == 1){ throw new emailException("Email bestaal al!"); } } /* checks if an input is a valid email. */ function resetEmail($variable){ if (empty($variable)) { throw new emailException("Verplicht!"); } else if (!filter_var($variable, FILTER_VALIDATE_EMAIL)) { throw new emailException("Geldige email invullen"); } else if (getResetEmail() == 0){ throw new emailException("Email bestaat niet!"); } } /* checks if two passwords matches. */ function matchPassword(){ if ($_POST["password"] != $_POST["confirmpassword"]) { throw new confirmPasswordException("Wachtwoorden matchen niet!"); } } /* Checks if captcha is correctly filled in */ function checkCaptcha($captcha){ if(!$captcha){ throw new captchaException("Captcha needs to be filled in!"); } else { $response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=6Lc72xIUAAAAAPizuF3nUbklCPljVCVzgYespz8o&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR'])); if($response->success==false) { throw new captchaException("You are a spammer!"); } } } /* Get ip adres */ function getIp(){ if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $GLOBALS["ip"] = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $GLOBALS["ip"] = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $GLOBALS["ip"] = $_SERVER['REMOTE_ADDR']; } } /* Checks if everything is filled in correctly */ function registerCheck($status){ if ($status == false){ throw new registerException("Bepaalde velden zijn verkeerd of niet ingevuld"); } else { registerAccount(); header("location: login.php"); } } /* removes weird characters of an input. */ function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } class lettersAndSpacesException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class bdayException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class usernameException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class passwordException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class confirmPasswordException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class emailException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class captchaException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } class registerException extends Exception { public function __construct($message = "", $code = 0, Exception $previous = null) { parent::__construct($message, $code, $previous); } } ?>