load->library('session'); $this->load->_model('Model_setting','setting'); $this->load->_model('Model_user','user'); $this->load->_model("Model_zzrecord_logs",'zzrecord_logs'); $this->load->helper('url'); } } // END Lin_Controller class //前台页面控制器 abstract class Start_Controller extends Lin_Controller { public $data; function __construct() { parent::__construct(); $setting = $this->setting->get_settings(); if(!isset($_SESSION['api']) && $this->uri->slash_segment(1) != "/" && $this->uri->slash_segment(1) != "phone/" && $this->uri->slash_segment(1) != "apt/" && $this->uri->slash_segment(1) != "outbound/" && $this->uri->slash_segment(2) != "isorder/" && $this->uri->slash_segment(2) != "waybill/" && $this->uri->slash_segment(2) != "apple/" && $this->uri->slash_segment(2) != "query/" && $this->uri->slash_segment(2) != "fhd/" && $this->uri->slash_segment(2) != "kc/" && $this->uri->slash_segment(2) != "syns/" && $this->uri->slash_segment(1) != "api/" && $this->uri->slash_segment(2) != "khjz/" && $this->uri->slash_segment(2) != "khjzfs/" && $this->uri->slash_segment(2) != "webhook/" && $this->uri->slash_segment(2) != "ttwebhook/" && $this->uri->slash_segment(2) != "sq/" && $this->uri->slash_segment(2) != "kcpd/"&& $this->uri->slash_segment(1) != "errorlog/" && $this->uri->slash_segment(1) != "apiexpress/" && $this->uri->slash_segment(1) != "apiexpressv1/")//如果有api { $this->session->sess_destroy(); header("Location:/"); } if(isset($_SESSION['api'])) { $u = $this->user->get_api($_SESSION['api']); if(!$u && $this->uri->slash_segment(1) != "/") { $this->session->sess_destroy(); header("Location:/"); } else if($this->uri->slash_segment(1) == "/") { header("Location:/user/"); } } if(!empty($u)){ $this->zzrecord_logs->insert([ 'fpdata'=>json_encode($u), 'data_int'=>$u['id'], 'data_str'=>date("Y-m-d H:i:s",time()) ]); if(!empty($u['id'])){ $this->user->save(['lasttime'=>time()],$u['id']); } } $this->load->library('template'); //设置前台模板路径 $this->template->_init($setting['theme']); //载入自定义函数 $this->load->library('common'); //设置控制器分享参数 $this->setting->primaryKey = 'skey'; //基本信息 $this->data['userkz'] = (isset($u['download']))?$u['download']:1; $this->data['theme'] = '/template/'.$setting['theme'].'/'; $this->data['route'] = $this->uri->segment(1); $this->config->set_item('index_page',''); //后缀index.php为空 $this->config->set_item('url_suffix','');//路径后缀.htmml为空 } /** 载入模版 */ function _template($template, $data = array() ) { $this->template->assign($data); $this->template->display($template); } //前台提示信息 function _message($msg, $goto = '',$auto = true,$fix = '') { if($goto == '') { $goto = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : site_url(); } else { $goto = strpos($goto,'http') !== false ? $goto : site_url($goto); } $goto .= $fix; $this->_template('sys_message',array('msg'=>$msg,'goto'=>$goto,'auto'=>$auto,'ver'=>STAR_NAME.' '.STAR_VERSION)); echo $this->output->get_output(); exit(); } } //后台控制器扩展 abstract class Admin_Controller extends Lin_Controller { public $template_path; public $logined; function __construct() { parent::__construct(); $this->template_path = APPPATH.'views/'; //后台视图路径 //设置后台模板路径 $this->config->set_item('url_suffix',''); //强制不使用伪静态 $this->load->library('session'); //check user login status $this->logined = $this->_check_login(); //载入超级变量 if($this->logined) { $this->_set_s(); } } function _check_login() { if (!$this->session->userdata('uid') ) { $setting = $this->setting->get_settings(); $redirect = $this->uri->uri_string(); //获取后台入口路径 } else { return 1; } } function _check_permit($action = '') { if(!$this->acl->permit($action)) { $this->_message('对不起,你没有访问这里的权限!','',false); } } function _show($template, $data = array()) { $this->load->view($template,$data); } function _template($template, $data = array()) { $cr = ''; $this->load->view($template,$data); $this->output->append_output($cr); } function _set_s(){ $this->load->_model('Model_login'); $this->load->library('common'); $this->S['admin'] = $this->Model_login->get_userid($this->session->userdata('uid')); } } // END Admin_Controller class function made_admin_url($uri,$qs = '') { return site_url('gold'.'/'.$uri).($qs == '' ? '' : '?'.$qs); }