Пример #1
0
function update_for_user($user_id)
{
    $sql = "SELECT `user_id`,`password` FROM `users` WHERE `user_id`='" . $user_id . "' ";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    if ($row) {
        $oldpw = $row['password'];
        if (!isOldPW($oldpw)) {
            return False;
        }
        $newpw = pwGen($row['password'], True);
        $sql = "UPDATE `users` set `password`='{$newpw}' where `user_id`='{$user_id}' LIMIT 1";
        mysql_query($sql);
        return True;
    }
    return False;
}
Пример #2
0
function pwCheck($password, $saved)
{
    if (isOldPW($saved)) {
        $mpw = md5($password);
        if ($mpw == $saved) {
            return True;
        } else {
            return False;
        }
    }
    $svd = base64_decode($saved);
    $salt = substr($svd, 20);
    $hash = base64_encode(sha1(md5($password) . $salt, true) . $salt);
    if (strcmp($hash, $saved) == 0) {
        return True;
    } else {
        return False;
    }
}