获得致命错误:调用未定义的方法

时间:2014-11-18 12:56:36

标签: php error-handling fatal-error

我正在使用CMS脚本。当我尝试登录管理面板时,我收到错误:

  

致命错误:在第105行的C:\ xampp \ htdocs \ app \ controllers \ administrator \ auth.php中调用未定义的方法Users_model :: get_user_function()

第105行auth.php:

$query = $this->Users_model->get_user_function($login);  

从auth.php登录公共函数(导致105行的错误):

public function login()
{
$val = $this->form_validation;
if ($this->input->post()) {
    $val->set_rules("usernameli", "Username", "trim|required|xss_clean");
    $val->set_rules("passwordli", "Password", "trim|required|xss_clean");
    $val->set_rules("remember", "Remember me", "integer");
    if ($this->form_validation->run()) {
        if ($this->config->item("DX_login_using_username") && $this->config->item("DX_login_using_email")) {
            $get_user_function = "get_login";
        } else {
            if ($this->config->item("DX_login_using_email")) {
                $get_user_function = "get_user_by_email";
            } else {
                $get_user_function = "get_user_by_username";
            }
        }
        $query = $this->Users_model->get_user_function($login);
        if ($query && $query->num_rows() == 1) {
            $row = $val;
            if ($row->banned > 0) {
                $this->session->set_flashdata("flash_message", $this->Common_model->admin_flash_message("error", "Login failed! you are banned"));
                redirect_admin("login", "refresh");
            } else {
                $password    = $this->dx_auth->_encode($password);
                $stored_hash = $row->password;
                if (crypt($password, $stored_hash) === $stored_hash) {
                    $this->dx_auth->_set_session($row, "ALLOW");
                    if ($row->newpass) {
                        $this->users->clear_newpass($row->id);
                    }
                    if ($remember) {
                        $this->dx_auth->_create_autologin($row->id);
                    }
                    $this->dx_auth->_set_last_ip_and_last_login($row->id);
                    $this->dx_auth->_clear_login_attempts();
                    $this->dx_auth_event->user_logged_in($row->id);
                    $this->session->set_flashdata("flash_message", $this->Common_model->admin_flash_message("success", "Logged in successfully."));
                    redirect_admin("", "refresh");
                } else {
                    $this->session->set_flashdata("flash_message", $this->Common_model->admin_flash_message("error", "Login failed! Incorrect username or password"));
                    redirect_admin("login", "refresh");
                }
            }
        } else {
            $this->session->set_flashdata("flash_message", $this->Common_model->admin_flash_message("error", "Login failed! Incorrect username or password"));
            redirect_admin("login", "refresh");
        }
    }
}
$data['message_element'] = "administrator/view_login";
$data['auth_message']    = "You are already logged in.";
$this->load->view("administrator/admin_template", $data);
}

一块users_model.php:

/*function get_user_by_username($username)
{
    $this->db->where('username', $username);
    return $this->db->get($this->_table);
}*/
function get_user_by_username($username)
{
    $this->db->where('username', $username);
    return $this->db->get($this->_table);
}
function get_user_by_email($email)
{
    $this->db->where('email', $email);
    return $this->db->get($this->_table);
}

function get_login($login)
{
    $this->db->where('username', $login);
    $this->db->or_where('email', $login);
    return $this->db->get($this->_table);
}

function check_ban($user_id)
{
    $this->db->select('1', FALSE);
    $this->db->where('id', $user_id);
    $this->db->where('banned', '1');
    return $this->db->get($this->_table);
}

function check_username($username)
{
    $this->db->select('1', FALSE);
    $this->db->where('LOWER(username)=', strtolower($username));
    return $this->db->get($this->_table);
}

1 个答案:

答案 0 :(得分:0)

您执行函数get_user_function而不是使用变量$get_user_function

变化:

$query = $this->Users_model->get_user_function($login);

分为:

$query = $this->Users_model->$get_user_function($login);