1

您好,我有一个投票系统,其中包含许多使用会话的步骤。

当我们点击会话 ID '2' 时,我执行以下操作:

    if ($_SESSION['vote_id'] == 1)
    {
        $_SESSION['vote_id'] = 2;
        $vote->generate_Auth($_SERVER['REMOTE_ADDR']);

        try
        {
            $_SESSION['auth'] = $vote->getAuth($_SERVER['REMOTE_ADDR']);
        }
        catch (exception $e)
        {
            echo $e->getMessage();
        }
    }

这些是我在此操作中使用的功能:

生成身份验证:

    public function generate_Auth($ip)
    {
        $this->gen_auth = self::pre_auth(substr(hash('SHA512', $ip), 0, 6));
        $this->auth = substr(hash('SHA512', $this->gen_auth), 0, 6);
        $this->quickfind = substr(str_shuffle(self::generate_quick_find_code()), 0, 21);

        $this->generated_auth = $this->auth;
        $this->generated_quickfind = $this->quickfind;

        $this->insert = $this->pdo->prepare
        ("
            INSERT INTO auths
            (auth_code, sites_voted, voter_ip, date, time, quickfind_code)
            VALUES
            (:code, :sites, :ip, CURDATE(), CURTIME(), :find)
        ");

        $this->insert->execute(array
        (
            ":code" => $this->generated_auth,
            ":sites" => '1',
            "ip" => $ip,
            "find" => $this->generated_quickfind
        ));
    }

获取授权:

    public function getAuth($ip)
    {
        $this->get = $this->pdo->prepare("SELECT * FROM auths WHERE voter_ip = :ip LIMIT 1");
        $this->get->execute(array( ":ip" => $ip));

        if ($this->get->rowCount())
        {
            return $this->get;
        }
        else
        {
            throw new exception ("An error has occurred!");
        }
    }

pre_auth 静态:

    public static function pre_auth($salt)
    {
        $auth = substr(hash('SHA512', $salt), 0, 6);
        return $auth;
    }

行动时,它给了我这个错误:

致命错误:在第 0 行的 Unknown 中抛出没有堆栈帧的异常

我以前从未经历过这个错误,我读过这个但没有得到太多。

谁能解释一下?出了什么问题?

4

0 回答 0