繁体   English   中英

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); 什么回来了?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM