Controller inside: ElseIf (! $model->validatepassword ($data->password))
Copy the Code code as follows:
Class Xbasemodel extends Cactiverecord
{
/**
* User Password detection
*
* @return Boolean
*/
Public Function ValidatePassword ($password)
{
return $this->hashpassword ($this->password) = = = $password;
}
/**
* Password is encrypted
* @return String Password
*/
Public Function Hashpassword ($password)
{
return MD5 ($PASSWORD);
}
}
Or:
if ($user && $user->password = = $user->hashpassword ($this->password, $user->salt)) {
Copy the Code code as follows:
Public Function ValidatePassword ($password) {
return $this->hashpassword ($password, $this->salt) = = = $this->password;
}
Public Function Hashpassword ($password, $salt) {
return MD5 (MD5 ($PASSWORD). $salt);
}
Public Function Generatesalt () {
$str = ' 1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
$len = strlen ($str)-1;
$string = ";
for ($i = 0; $i < 6; $i + +) {
$string. = $str [Mt_rand (0, $len)];
}
return $string;
}
Or:
Copy the Code code as follows:
Public Function ValidatePassword ($password) {
return $this->hashpassword ($password, $this->salt) = = = $this->password;
}
Public Function Hashpassword ($password, $salt)
{
return MD5 ($salt. $password);
}
protected function Generatesalt ()
{
Return Uniqid (", true);
}
Note: If you have a salt, the database field must have a salt.
http://www.bkjia.com/PHPjc/824853.html www.bkjia.com true http://www.bkjia.com/PHPjc/824853.html techarticle controller inside: ElseIf (! $model-validatepassword ($data-password)) Copy the Code code as follows:? PHP class Xbasemodel extends Cactiverecord {/** * Detect User Password * * @return Boo ...