【发布时间】:2023-02-15 20:12:58
【问题描述】:
由于安全原因,我是 codeigniter 的新手,正在其他新服务器上迁移 codeigniter 应用程序以升级 php/mysql/apache 的版本。
- 以下是旧版本的应用程序:PHP - 5.3.5,CodeIgniter - 2.1.3,阿帕奇 - 2.4.41,MySQL - 8.0.18
- 我已经在以下版本上迁移了应用程序:PHP - 7.4.26, CodeIgniter - 2.2.6,Apache - 2.4.51,MySQL - 8.0.28
迁移后,我已成功连接数据库,并且可以通过现有用户帐户登录应用程序。
对于页面,我们正在调用布局助手而不是视图,但我无法在被调用的页面上看到布局页面内容。
家庭控制器 (home.php)
public function index() {
$this->access_control->check_login();
if ($this->access_control->group_member('Admins')) {
$data->status_message = 'Welcome to application.';
//$this->load->view('home/footer.php', $data);
load_layout('home', $data);
} else if ($this->access_control->group_member(array('HR', 'POAs', 'HR Read-only')))
$this->hr();
else if ($this->access_control->group_member(array('IT', 'IT read-only')))
$this->it();
else {
$data->error_message = 'You are not authorized to access the portal.';
load_layout('home', $data);
}
}
footer.php 文件未加载,但如果我改为加载视图,我可以看到页面内容,但结构不匹配,所以我试图只加载布局。文件路径\application\views\home\footer.php
日志文件包含以下错误:
错误 - 2022-06-07 13:14:02 --> 严重性:警告 --> 从空值 E:\wamp64\www\procurement\p2p\application\controllers\home.php 11 创建默认对象 错误 - 2022-06-07 13:14:02 --> 严重性:通知 --> 未定义属性:stdClass::$error_message E:\wamp64\www\procurement\p2p\application\helpers\layout_helper.php 24
layout_helper.php
function load_layout($view_folder, $data = NULL, $return_string = FALSE, $read_only = FALSE) {
$CI = &get_instance();
$CI->load->helper('file');
if ($data)
$layout_data = $data;
$CI->load->view('header', $data);
$layout_data->read_only = $read_only;
$layout_data->access_authorization = $CI->access_control->authorized();
// statuses
$layout_data->status_message.=$CI->session->flashdata('status');
// errors
$layout_data->error_message.=$CI->session->flashdata('error');
$layout_data->error_message.=$CI->access_control->check_error_message();
$layout_views = array('header', 'general', 'details', 'footer');
$views_folder = 'application/views/';
foreach ($layout_views as $layout_view) {
if (get_file_info($views_folder . $view_folder . '/' . $layout_view . '.php'))
$layout_data->$layout_view = $CI->load->view($view_folder . '/' . $layout_view, $data, TRUE);
}
if (isset($layout_data))
$CI->load->view('layout', $layout_data);
$CI->load->view('footer');
if ($return_string)
return $CI->output->get_output();
}
【问题讨论】:
标签: php mysql codeigniter codeigniter-2 php-7