本文整理汇总了PHP中Validator::validatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::validatePassword方法的具体用法?PHP Validator::validatePassword怎么用?PHP Validator::validatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::validatePassword方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPassword
public function setPassword($string)
{
$validator = new Validator();
if ($validator->validatePassword($string) == false) {
} else {
$this->password = hash('sha256', $string);
}
}
示例2: userIsValid
public static function userIsValid($user)
{
$validArray = array();
$valid['ue'] = Validator::validateUe($user->ue());
$valid['name'] = Validator::validateName($user->name());
$valid['email'] = Validator::validateEMail($user->email());
$valid['tel'] = Validator::validateTel($user->tel());
$valid['password'] = Validator::validatePassword($user->password());
return !in_array(false, $validArray);
}
示例3: actionLogin
function actionLogin($params = '')
{
if (!empty($params['email']) && !empty($params['password'])) {
if ($this->objAuthentication->login($params['email'], $params['password'])) {
//no errors, continue to home
/*$objDispatcher = new Dispatcher;
$objDispatcher->setController('Forum');
$objDispatcher->setAction('Index');
$objDispatcher->setParams($params);
$objDispatcher->dispatch();*/
$this->actionIndex($params);
} else {
$this->view->assign('errorMsg', 'Unable to login, try again.');
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
}
} else {
if (!empty($params['createAccount']) && $params['createAccount'] == 1) {
$errorMessages = array();
$objValidator = new Validator();
$objValidator->reset();
$objValidator->validateEmail($params['create_email']);
$objValidator->validatePassword($params['create_password']);
$objValidator->passwordsMatch($params['create_password'], $params['create_password2']);
$objValidator->validateName($params['create_displayName']);
if ($objValidator->hasError || empty($params['create_terms'])) {
$error = $objValidator->getError();
if (empty($params['create_terms'])) {
$error[] = 'You must agree to the Terms of Use to make an account';
}
$this->view->assign('errorMessages', $error);
$this->view->assign('created', false);
} else {
$userData = array();
$userData['email'] = $params['create_email'];
$userData['password'] = $params['create_password'];
$userData['displayName'] = $params['create_displayName'];
$userModel = new UserModel();
$created = $userModel->createUser($userData);
if (!empty($created)) {
$this->view->assign('created', true);
$objEmail = new Emailer();
$objEmail->setFrom(CONTACT_EMAIL);
$objEmail->setSubject('Retail Roar Community account created');
$objEmail->addTO($userData['email']);
$objEmail->setBody($this->view->fetch('emails/communitysignup.tpl'), true);
$sent = $objEmail->sendMail();
} else {
$this->view->assign('created', false);
$this->view->assign('errorMessages', $userModel->errorMsg);
}
$this->view->assign('submitted', true);
}
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
} else {
if ($this->objAuthentication->loggedIn()) {
$this->view->assign('content', 'Already logged in.');
$this->finish();
} else {
$this->view->assign('content', $this->view->fetch('tpl/community/login.tpl'));
$this->finish();
}
}
}
}
示例4: Securimage
$img = new Securimage();
if ($img->check($captcha) == false) {
$res['message'] = '验证码错误!';
$res['action'] = 'reset';
} else {
$reset_pwd = $_SESSION['reset_pwd'];
if ($reset_pwd['b_confirm'] == false) {
$res['message'] = '您还未经过邮件验证,收取邮件或重发邮件!';
$res['action'] = 'resend';
} else {
$db = new MySQL($log);
if ($mysqli = $db->openDB()) {
$user = new User($mysqli, $log);
if ($user->getUserByName($username)) {
if ($user->id === $reset_pwd['id']) {
if ($password_1 == $password_2 && Validator::validatePassword($password_1)) {
$user->password = hash("sha256", $password_1);
if ($user->updateUser($user->id)) {
session_unset();
session_destroy();
$res['result'] = true;
$res['message'] = '密码已修改成功!';
$res['action'] = 'login';
} else {
$res['message'] = '密码修改失败!';
$res['action'] = 'reset';
}
} else {
$res['message'] = '密码格式错误!';
$res['action'] = 'reset';
}
示例5: error_reporting
require_once "../Path.php";
require_once "../sess.php";
require_once PHP_BASE_DIR . "/db/MySQL.php";
require_once PHP_BASE_DIR . "/util/Validator.php";
require_once PHP_BASE_DIR . "/entity/User.php";
error_reporting(E_ALL ^ E_NOTICE);
header("Content-Type: application/json; charset=UTF-8");
$username = $_POST["username"];
$password = $_POST["password"];
$captcha = $_POST["captcha"];
$username = $username ? $username : "";
$password = $password ? $password : "";
$captcha = $captcha ? $captcha : "";
$res = array("result" => false, "reason" => "");
//string format validate
if (!(Validator::validateUserName($username) && Validator::validatePassword($password) && Validator::validateCaptcha($captcha))) {
$res["reason"] = "输入不合法!";
die(json_encode($res));
}
//Captcha Validate
require_once PHP_BASE_DIR . "/securimage/securimage.php";
$img = new Securimage();
if ($img->check($captcha) == false) {
$res['reason'] = '验证码错误!';
die(json_encode($res));
}
$db = new MySQL($log);
$mysqli = $db->openDB();
//Validate Password
if ($mysqli != null) {
$user = new User($mysqli, $log);
示例6: die
die(json_encode($res));
}
//验证邮箱是否重复
if ($user->getUserByMailExId($email, $_SESSION['user_info']['id'])) {
$res['reason'] = '邮箱已被使用!';
$db->closeDB();
die(json_encode($res));
}
$user->getUserByID($_SESSION['user_info']['id']);
//选择修改密码
if ($chpwd[0] == "true") {
if (hash("sha256", $password_0) == $user->password) {
if ($password_1 !== $password_0) {
if ($password_1 == $password_2) {
//string format validate
if (Validator::validateUserName($username) && Validator::validatePassword($password_1) && Validator::validateEmail($email)) {
$user->username = $username;
$user->password = hash("sha256", $password_1);
$user->email = $email;
if ($user->updateUser($id)) {
$_SESSION['user_info']['username'] = $username;
$_SESSION['user_info']['email'] = $email;
$res["result"] = true;
$res["reason"] = "用户信息更新成功!";
} else {
$res["reason"] = "用户信息更新失败!";
}
} else {
$res["reason"] = "输入不合法!";
}
} else {
示例7: Validator
* Created by PhpStorm.
* User: Rimas
* Date: 1/27/2016
* Time: 12:03 AM
*/
require 'config.php';
require 'autoload.php';
if (!empty($_POST)) {
$validator = new Validator();
if ($validator->validateName($_POST['name']) == false) {
echo 'Please enter name';
}
if ($validator->validateName($_POST['email']) == false) {
echo 'Please enter email';
}
if ($validator->validatePassword($_POST['password']) == false) {
echo 'Please enter password';
}
if ($validator->validateName($_POST['name']) && $validator->validateName($_POST['email']) && $validator->validatePassword($_POST['password'])) {
$user1 = new User();
$user1->setName($_POST['name']);
$user1->setEmail($_POST['email']);
$user1->setPassword($_POST['password']);
$user1->setMessage($_POST['message']);
$database = new Database();
if ($database->Connect($servername, $dbname, $username, $password)) {
$database->setTable('users');
if (!$database->userExists($_POST['name'])) {
$database->AddData($user1->getName(), $user1->getEmail(), $user1->getPassword(), $user1->getMessage());
session_start();
$_SESSION['username'] = $_POST['name'];
示例8: actionChangePassword
function actionChangePassword($params = '')
{
$this->objAuthentication->requiresAccount();
$errorMsg = false;
$changedpassword = false;
if (!empty($params['changepassword'])) {
$objUser = new UserModel();
if (!empty($params['orignal_pw']) && !empty($params['password']) && !empty($params['password2'])) {
// verify old password
$passwordMatch = $objUser->testPassword($this->objAuthentication->user_id, $params['orignal_pw']);
if ($passwordMatch) {
$objValidation = new Validator();
$objValidation->validatePassword($params['password']);
$objValidation->passwordsMatch($params['password'], $params['password2']);
if ($objValidation->hasError) {
$errorMsg = $objValidation->getError();
if (is_array($errorMsg)) {
$errorMsg = implode(', ', $errorMsg);
}
} else {
$saveData = array();
$saveData['id'] = $this->objAuthentication->user_id;
$saveData['password'] = $this->objAuthentication->encryptPassword($params['password']);
$changedpassword = $objUser->save($saveData, 'users');
if ($changedpassword) {
$objEmailer = new EmailSender();
$objEmailer->sendUserChangePassword($this->objAuthentication->user_id);
} else {
$errorMsg = 'Unable to change password.';
}
}
} else {
$errorMsg = 'Current password incorrect.';
}
} else {
$errorMsg = 'Current password and new password are required.';
}
}
$objLayout = new LayoutModel();
$objTemplate = new TemplatesModel();
$layoutInfo = $objLayout->loadLayout();
$template = $objTemplate->loadTemplateFromKeyname('user-changepassword');
$this->view->assign('errorMsg', $errorMsg);
$this->view->assign('changedpassword', $changedpassword);
$this->view->assign('content', $this->view->fetch('fromstring:' . $template['content']));
$this->view->assign('sidebar_left', $this->view->fetch('fromstring:' . $template['left_sidebar']));
$this->view->assign('sidebar_right', $this->view->fetch('fromstring:' . $template['right_sidebar']));
$this->view->assign('layout', $this->view->fetch('fromstring:' . $layoutInfo['code']));
$this->finish();
}
示例9: htmlspecialchars
$password_2 = $_POST["password_2"];
$invitation_code = $_POST["invitation_code"];
$captcha = $_POST["captcha"];
$username = $username ? htmlspecialchars($username, ENT_QUOTES) : "";
$email = $email ? htmlspecialchars($email, ENT_QUOTES) : "";
$password_1 = $password_1 ? $password_1 : "";
$password_2 = $password_2 ? $password_2 : "";
$invitation_code = $invitation_code ? $invitation_code : "";
$captcha = $captcha ? $captcha : "";
$res = array("result" => false, "reason" => "");
if ($password_1 != $password_2) {
$res["reason"] = "两次密码输入不同!";
die(json_encode($res));
}
//string format validate
if (!(Validator::validateUserName($username) && Validator::validateEmail($email) && Validator::validatePassword($password_1) && Validator::validateCaptcha($captcha))) {
$res["reason"] = "输入不合法!";
die(json_encode($res));
}
//Captcha Validate
require_once PHP_BASE_DIR . "/securimage/securimage.php";
$img = new Securimage();
if ($img->check($captcha) == false) {
$res['reason'] = '验证码错误!';
die(json_encode($res));
}
$db = new MySQL($log);
if ($mysqli = $db->openDB()) {
$user = new User($mysqli, $log);
$invitation = new Invitation($mysqli, $log);
if ($user->getUserByName($username)) {