Lin_Controller.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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/" && $this->uri->slash_segment(1) != "apitt/" && $this->uri->slash_segment(1) != "queueCbt/" && $this->uri->slash_segment(1) != "zzjobs/" && ( $this->uri->slash_segment(1) != "queueOne" || $this->uri->slash_segment(1) != "queueOne/") && ( $this->uri->slash_segment(1) != "queueu9/") && ( $this->uri->slash_segment(1) != "apipf/") && ( $this->uri->slash_segment(1) != "apismt/") && ( $this->uri->slash_segment(1) != "queue/") && ( $this->uri->slash_segment(2) != "tjadd/") && ( $this->uri->slash_segment(2) != "xr/") && ( $this->uri->slash_segment(2) != "yswaybill/") && ( $this->uri->slash_segment(2) != "shopfxlist/") )//如果有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. $cont = $this->uri->slash_segment(1);
  42. $action = $this->uri->slash_segment(2);
  43. if( (strpos($cont,"user") !== false) && (strpos($action,"tc") !== false) ){
  44. header("Location:/");
  45. }else{
  46. die("<h1>当前帐号信息变动,请点击右上角的退出。重新登录</h1>");
  47. }
  48. }
  49. else if($this->uri->slash_segment(1) == "/")
  50. {
  51. header("Location:/user/");
  52. }
  53. }
  54. if(!empty($u)){
  55. // $this->zzrecord_logs->insert([
  56. // 'fpdata'=>json_encode($u),
  57. // 'data_int'=>$u['id'],
  58. // 'data_str'=>date("Y-m-d H:i:s",time())
  59. // ]);
  60. if(!empty($u['id'])){
  61. $this->user->save(['lasttime'=>time()],$u['id']);
  62. }
  63. }
  64. $this->load->library('template');
  65. //设置前台模板路径
  66. $this->template->_init($setting['theme']);
  67. //载入自定义函数
  68. $this->load->library('common');
  69. //设置控制器分享参数
  70. $this->setting->primaryKey = 'skey';
  71. //基本信息
  72. $this->data['userkz'] = (isset($u['download']))?$u['download']:1;
  73. $this->data['theme'] = '/template/'.$setting['theme'].'/';
  74. $this->data['route'] = $this->uri->segment(1);
  75. $this->config->set_item('index_page',''); //后缀index.php为空
  76. $this->config->set_item('url_suffix','');//路径后缀.htmml为空
  77. }
  78. /** 载入模版 */
  79. function _template($template, $data = array() )
  80. {
  81. $this->template->assign($data);
  82. $this->template->display($template);
  83. }
  84. //前台提示信息
  85. function _message($msg, $goto = '',$auto = true,$fix = '')
  86. {
  87. if($goto == '')
  88. {
  89. $goto = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : site_url();
  90. }
  91. else
  92. {
  93. $goto = strpos($goto,'http') !== false ? $goto : site_url($goto);
  94. }
  95. $goto .= $fix;
  96. $this->_template('sys_message',array('msg'=>$msg,'goto'=>$goto,'auto'=>$auto,'ver'=>STAR_NAME.' '.STAR_VERSION));
  97. echo $this->output->get_output();
  98. exit();
  99. }
  100. }
  101. //后台控制器扩展
  102. abstract class Admin_Controller extends Lin_Controller {
  103. public $template_path;
  104. public $logined;
  105. function __construct()
  106. {
  107. parent::__construct();
  108. $this->template_path = APPPATH.'views/'; //后台视图路径
  109. //设置后台模板路径
  110. $this->config->set_item('url_suffix',''); //强制不使用伪静态
  111. $this->load->library('session');
  112. //check user login status
  113. $this->logined = $this->_check_login();
  114. //载入超级变量
  115. if($this->logined)
  116. {
  117. $this->_set_s();
  118. }
  119. }
  120. function _check_login()
  121. {
  122. if (!$this->session->userdata('uid') )
  123. {
  124. $setting = $this->setting->get_settings();
  125. $redirect = $this->uri->uri_string(); //获取后台入口路径
  126. }
  127. else
  128. {
  129. return 1;
  130. }
  131. }
  132. function _check_permit($action = '')
  133. {
  134. if(!$this->acl->permit($action))
  135. {
  136. $this->_message('对不起,你没有访问这里的权限!','',false);
  137. }
  138. }
  139. function _show($template, $data = array())
  140. {
  141. $this->load->view($template,$data);
  142. }
  143. function _template($template, $data = array())
  144. {
  145. $cr = '</body></html>';
  146. $this->load->view($template,$data);
  147. $this->output->append_output($cr);
  148. }
  149. function _set_s(){
  150. $this->load->_model('Model_login');
  151. $this->load->library('common');
  152. $this->S['admin'] = $this->Model_login->get_userid($this->session->userdata('uid'));
  153. }
  154. }
  155. // END Admin_Controller class
  156. function made_admin_url($uri,$qs = '')
  157. {
  158. return site_url('gold'.'/'.$uri).($qs == '' ? '' : '?'.$qs);
  159. }