Lin_Controller.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /** STAR 核心控制类扩展 */
  3. define('IN_STAR',TRUE);
  4. define('STAR_NAME','STAR');
  5. define('STAR_VERSION','V1.0.00');
  6. define('STAR_BUILDTIME','201801011');
  7. // ------------------------------------------------------------------------
  8. class Lin_Controller extends CI_Controller {
  9. public $setting;
  10. public $S;
  11. //初始化扩展控制类
  12. function __construct()
  13. {
  14. parent::__construct();
  15. //载入配置
  16. $this->load->library('session');
  17. $this->load->_model('Model_setting','setting');
  18. $this->load->_model('Model_user','user');
  19. $this->load->_model("Model_zzrecord_logs",'zzrecord_logs');
  20. $this->load->helper('url');
  21. }
  22. }
  23. // END Lin_Controller class
  24. //前台页面控制器
  25. abstract class Start_Controller extends Lin_Controller {
  26. public $data;
  27. function __construct()
  28. {
  29. parent::__construct();
  30. $setting = $this->setting->get_settings();
  31. 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
  32. {
  33. $this->session->sess_destroy();
  34. header("Location:/");
  35. }
  36. if(isset($_SESSION['api']))
  37. {
  38. $u = $this->user->get_api($_SESSION['api']);
  39. if(!$u && $this->uri->slash_segment(1) != "/")
  40. {
  41. $this->session->sess_destroy();
  42. header("Location:/");
  43. }
  44. else if($this->uri->slash_segment(1) == "/")
  45. {
  46. header("Location:/user/");
  47. }
  48. }
  49. if(!empty($u)){
  50. // $this->zzrecord_logs->insert([
  51. // 'fpdata'=>json_encode($u),
  52. // 'data_int'=>$u['id'],
  53. // 'data_str'=>date("Y-m-d H:i:s",time())
  54. // ]);
  55. if(!empty($u['id'])){
  56. $this->user->save(['lasttime'=>time()],$u['id']);
  57. }
  58. }
  59. $this->load->library('template');
  60. //设置前台模板路径
  61. $this->template->_init($setting['theme']);
  62. //载入自定义函数
  63. $this->load->library('common');
  64. //设置控制器分享参数
  65. $this->setting->primaryKey = 'skey';
  66. //基本信息
  67. $this->data['userkz'] = (isset($u['download']))?$u['download']:1;
  68. $this->data['theme'] = '/template/'.$setting['theme'].'/';
  69. $this->data['route'] = $this->uri->segment(1);
  70. $this->config->set_item('index_page',''); //后缀index.php为空
  71. $this->config->set_item('url_suffix','');//路径后缀.htmml为空
  72. }
  73. /** 载入模版 */
  74. function _template($template, $data = array() )
  75. {
  76. $this->template->assign($data);
  77. $this->template->display($template);
  78. }
  79. //前台提示信息
  80. function _message($msg, $goto = '',$auto = true,$fix = '')
  81. {
  82. if($goto == '')
  83. {
  84. $goto = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : site_url();
  85. }
  86. else
  87. {
  88. $goto = strpos($goto,'http') !== false ? $goto : site_url($goto);
  89. }
  90. $goto .= $fix;
  91. $this->_template('sys_message',array('msg'=>$msg,'goto'=>$goto,'auto'=>$auto,'ver'=>STAR_NAME.' '.STAR_VERSION));
  92. echo $this->output->get_output();
  93. exit();
  94. }
  95. }
  96. //后台控制器扩展
  97. abstract class Admin_Controller extends Lin_Controller {
  98. public $template_path;
  99. public $logined;
  100. function __construct()
  101. {
  102. parent::__construct();
  103. $this->template_path = APPPATH.'views/'; //后台视图路径
  104. //设置后台模板路径
  105. $this->config->set_item('url_suffix',''); //强制不使用伪静态
  106. $this->load->library('session');
  107. //check user login status
  108. $this->logined = $this->_check_login();
  109. //载入超级变量
  110. if($this->logined)
  111. {
  112. $this->_set_s();
  113. }
  114. }
  115. function _check_login()
  116. {
  117. if (!$this->session->userdata('uid') )
  118. {
  119. $setting = $this->setting->get_settings();
  120. $redirect = $this->uri->uri_string(); //获取后台入口路径
  121. }
  122. else
  123. {
  124. return 1;
  125. }
  126. }
  127. function _check_permit($action = '')
  128. {
  129. if(!$this->acl->permit($action))
  130. {
  131. $this->_message('对不起,你没有访问这里的权限!','',false);
  132. }
  133. }
  134. function _show($template, $data = array())
  135. {
  136. $this->load->view($template,$data);
  137. }
  138. function _template($template, $data = array())
  139. {
  140. $cr = '</body></html>';
  141. $this->load->view($template,$data);
  142. $this->output->append_output($cr);
  143. }
  144. function _set_s(){
  145. $this->load->_model('Model_login');
  146. $this->load->library('common');
  147. $this->S['admin'] = $this->Model_login->get_userid($this->session->userdata('uid'));
  148. }
  149. }
  150. // END Admin_Controller class
  151. function made_admin_url($uri,$qs = '')
  152. {
  153. return site_url('gold'.'/'.$uri).($qs == '' ? '' : '?'.$qs);
  154. }