Codeigniter,tank_auth代码在移动到新服务器后不起作用


Codeigniter, tank_auth code doesnt work after moving to the new server

在转移到新服务器后,我收到了很多这样的通知:

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: account/settings.php
Line Number: 28

account/settings.php视图@line 28内容为:

echo $user->description;

到处都会出现错误,我正试图从$user变量中获取信息。我想这与tank_auth有关:我正在通过控制器传递$user数据:

$data['user'] = $this->tank_auth->user();
[..]
$this->load->view('account/settings', $data);

我登录了。

我的目录路径与早期服务器上的路径完全相同

问题出在哪里?

这可能是因为服务器哈希设置为不可移植。。

application/config/tank_auth.php中的第13-23行

/*
|--------------------------------------------------------------------------
| Security settings
|
| The library uses PasswordHash library for operating with hashed passwords.
| 'phpass_hash_portable' = Can passwords be dumped and exported to another server. If set to FALSE then you won't be able to use this database on another server.
| 'phpass_hash_strength' = Password hash strength.
|--------------------------------------------------------------------------
*/
## Set this to TRUE
$config['phpass_hash_portable'] = FALSE;
$config['phpass_hash_strength'] = 8;

application/libraries/phpass-0.1/PasswordHash.php的203-235行

为了防止你好奇这个配置在哪里发挥作用,它在blowfish哈希创建中:

function HashPassword($password)
{
    $random = '';
    if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
        $random = $this->get_random_bytes(16);
        $hash =
            crypt($password, $this->gensalt_blowfish($random));
        if (strlen($hash) == 60)
            return $hash;
    }
    if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
        if (strlen($random) < 3)
            $random = $this->get_random_bytes(3);
        $hash =
            crypt($password, $this->gensalt_extended($random));
        if (strlen($hash) == 20)
            return $hash;
    }
    if (strlen($random) < 6)
        $random = $this->get_random_bytes(6);
    $hash =
        $this->crypt_private($password,
        $this->gensalt_private($random));
    if (strlen($hash) == 34)
        return $hash;
    # Returning '*' on error is safe here, but would _not_ be safe
    # in a crypt(3)-like function used _both_ for generating new
    # hashes and for validating passwords against existing hashes.
    return '*';
}

如果这不能解决问题

试试print_r($user);什么回来了?