gpt4 book ai didi

php - 出现 fatal error : Call to undefined method

转载 作者:行者123 更新时间:2023-12-03 09:14:51 26 4
gpt4 key购买 nike

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

Fatal error: Call to undefined method Users_model::get_user_function() in C:\xampp\htdocs\app\controllers\administrator\auth.php on line 105



第 105 行 auth.php:
$query = $this->Users_model->get_user_function($login);  

来自 auth.php 的公共(public)函数登录(导致 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);
}

最佳答案

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

改变:
$query = $this->Users_model->get_user_function($login);
进入:
$query = $this->Users_model->$get_user_function($login);

关于php - 出现 fatal error : Call to undefined method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26994915/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com