storeFormValues($_POST); $user->insert(); $_SESSION['message'] = [ 'type' => 'success', 'text' => 'Your account has been created.' ]; header('Location: '.get_permalink('login')); return; } } } function check_errors(){ global $errors; $val = 0; $_POST['username'] = strtolower($_POST['username']); $username = preg_replace('~[^A-Za-z0-9_.-]~','', $_POST['username']); $password = str_replace(' ','',$_POST['password']); if(!verify_csrf_token()){ $errors[] = _t('CSRF invalid!'); $val = 1; } if(User::getByUsername($_POST['username'])){ $errors[] = _t('User %a already exist!', $_POST['username']); $val = 1; } if($username != $_POST['username']){ $errors[] = _t('Username contains illegal characters!'); $val = 1; } if($_POST['email']){ if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors[] = _t('Email not valid!'); $val = 1; } else { if(User::getByEmail($_POST['email'])){ $errors[] = _t('Email %a already exist!', $_POST['email']); $val = 1; } } } if ($password != $_POST['password']) { $errors[] = _t('Password must not contain any space!'); $val = 1; } else { if($password != $_POST['confirm_password']){ $errors[] = _t('Password not match!'); $val = 1; } } if(!$val){ if(file_exists(ABSPATH.'includes/banned-username.json')){ $usernames = json_decode(file_get_contents(ABSPATH.'includes/banned-username.json'), true); foreach ($usernames as $name) { if($username === $name){ $errors[] = _t('Username %a is not available!', $_POST['username']); return 1; } } } if(file_exists(ABSPATH.'includes/banned-words.json')){ $words = json_decode(file_get_contents(ABSPATH.'includes/banned-words.json'), true); foreach ($words as $word) { if(strpos('-'.$username, $word)){ $errors[] = _t('Username contains banned word!'); return 1; } } } } if(isset($_POST['captcha'])){ if(isset($_SESSION['captcha'])){ if(strtolower($_POST['captcha']) != $_SESSION['captcha']){ $errors[] = _t('The captcha code does not match!'); return 1; } } } return $val; } ?> <?php _e('Register') ?> | <?php echo SITE_TITLE ?> '; } elseif(file_exists( ABSPATH . TEMPLATE_PATH . '/style/style.css')){ echo ''; } if(file_exists( ABSPATH . TEMPLATE_PATH . '/css/custom.css')){ echo ''; } elseif(file_exists( ABSPATH . TEMPLATE_PATH . '/style/custom.css')){ echo ''; } ?>
0){ foreach ($errors as $msg) { show_alert($msg, 'warning'); } } ?>
>