CommonController.class.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. use Think\Controller;
  16. class CommonController extends Controller{
  17. /* 初始化,权限控制,菜单显示 */
  18. protected function _initialize(){
  19. // 获取当前用户ID
  20. define('SELLERUID',is_seller_login());
  21. //string(6) "Supply" string(5) "index"
  22. if( CONTROLLER_NAME == 'Supply' && (ACTION_NAME == 'login' || ACTION_NAME == 'login_do') )
  23. {
  24. }else{
  25. if(!SELLERUID){// 还没登录 跳转到登录页面
  26. if(is_agent_login())
  27. {
  28. define('ROLE','agenter');
  29. }else{
  30. //cookie('last_login_page', $rmid);
  31. $last_login_page = cookie('last_login_page');
  32. $this->redirect('Public/login');
  33. }
  34. }
  35. }
  36. /* 读取数据库中的配置 */
  37. $config = S('DB_CONFIG_DATA');
  38. if(!$config){
  39. $config = api('Config/lists');
  40. S('DB_CONFIG_DATA',$config);
  41. }
  42. C($config); //添加配置
  43. $blog_seller_order_ids = M('blog_seller_order')->field('blog_id')->where( array('seller_id' =>SELLERUID) )->select();
  44. $blog_ids_arr = array();
  45. foreach($blog_seller_order_ids as $val)
  46. {
  47. array_push($blog_ids_arr, $val['blog_id']);
  48. }
  49. if(!empty($blog_ids_arr))
  50. {
  51. $blog_ids_str = '';
  52. $map = array();
  53. $map['status'] = 1;
  54. $map['type'] = 'seller';
  55. $map['seller_id'] = SELLERUID;
  56. $map['blog_id']= array('not in',$blog_ids_arr );
  57. $blog_not_count = M('blog')->where( $map )->count();
  58. $blog_not_list = M('blog')->field('blog_id,title')->where( $map )->limit(10)->select();
  59. } else{
  60. $blog_ids_str = '';
  61. $map = array();
  62. $map['type'] = 'seller';
  63. $map['status'] = 1;
  64. $blog_not_count = M('blog')->where( $map )->count();
  65. $blog_not_list = M('blog')->field('blog_id,title')->where( $map )->limit(10)->select();
  66. }
  67. //http://mall.shiziyu888.com/dan/seller.php?s=/Member/info/id/1668
  68. //strpos("You love php, I love php too!","php");
  69. $unsave_action_arr = array();
  70. $unsave_action_arr[] = 'Member/info/id';
  71. $can_save = true;
  72. foreach($unsave_action_arr as $val)
  73. {
  74. if( strpos($_SERVER['HTTP_REFERER'],$val) )
  75. {
  76. $can_save = false;
  77. }
  78. }
  79. if($can_save)
  80. {
  81. cookie('http_refer',$_SERVER['HTTP_REFERER']);
  82. }
  83. $this->blog_not_count = $blog_not_count;
  84. $this->blog_not_list = $blog_not_list;
  85. $this->system_hide_wepro = false;
  86. $this->system_hide_dan = true;
  87. // 权限过滤
  88. // $this->filterAccess();
  89. $this->check_supply_access();
  90. }
  91. protected function check_supply_access()
  92. {
  93. if( defined('ROLE') && ROLE == 'agenter' )
  94. {
  95. $access_controller_action = array();
  96. $access_controller_action[] = 'index_index';
  97. $access_controller_action[] = 'index_analys';
  98. $access_controller_action[] = 'index_order_count';
  99. $access_controller_action[] = 'goods_index';
  100. $access_controller_action[] = 'goods_settime';
  101. $access_controller_action[] = 'order_index';
  102. $access_controller_action[] = 'order_ordersendall';
  103. $access_controller_action[] = 'order_orderaftersales';
  104. $access_controller_action[] = 'order_printconfig';
  105. $access_controller_action[] = 'supply_floworder';
  106. $access_controller_action[] = 'supply_tixianlist';
  107. $access_controller_action[] = 'goods_addgoods';
  108. $access_controller_action[] = 'index_order';
  109. $access_controller_action[] = 'order_oprefund';
  110. $access_controller_action[] = 'goods_labelquery';
  111. $access_controller_action[] = 'goods_edit';
  112. $access_controller_action[] = 'goods_change';
  113. $access_controller_action[] = 'goods_tpl';
  114. $access_controller_action[] = 'goods_mult_tpl';
  115. $access_controller_action[] = 'goods_settop';
  116. $access_controller_action[] = 'goods_ajax_batchcates';
  117. $access_controller_action[] = 'goods_copy';
  118. $access_controller_action[] = 'communityhead_query_head';
  119. $access_controller_action[] = 'goods_ajax_batchcates_headgroup';
  120. $access_controller_action[] = 'goods_ajax_batchtime';
  121. $access_controller_action[] = 'goods_ajax_batchheads';
  122. $access_controller_action[] = 'delivery_onekey_tosendallorder';
  123. $access_controller_action[] = 'order_do_order_quene';
  124. $access_controller_action[] = 'order_export_form';
  125. $access_controller_action[] = 'order_detail';
  126. $access_controller_action[] = 'order_opchangeaddress';
  127. $access_controller_action[] = 'order_order_print_dan';
  128. $access_controller_action[] = 'order_all_opprint';
  129. $access_controller_action[] = 'order_batchsend_import';
  130. $access_controller_action[] = 'order_check_order_data';
  131. $access_controller_action[] = 'order_commentstate';
  132. $access_controller_action[] = 'order_deletecomment';
  133. $access_controller_action[] = 'order_do_opprint_quene';
  134. $access_controller_action[] = 'order_do_order_quene';
  135. $access_controller_action[] = 'order_export_form';
  136. $access_controller_action[] = 'order_history';
  137. $access_controller_action[] = 'order_opchangeaddress';
  138. $access_controller_action[] = 'order_opchangeexpress';
  139. $access_controller_action[] = 'order_opclose';
  140. $access_controller_action[] = 'order_opfinish';
  141. $access_controller_action[] = 'order_oppay';
  142. $access_controller_action[] = 'order_opprint';
  143. $access_controller_action[] = 'order_opreceive';
  144. $access_controller_action[] = 'order_oprefund';
  145. $access_controller_action[] = 'order_oprefund_do';
  146. $access_controller_action[] = 'order_oprefund_doform';
  147. $access_controller_action[] = 'order_oprefund_goods_do';
  148. $access_controller_action[] = 'order_oprefund_submit';
  149. $access_controller_action[] = 'order_opremarksaler';
  150. $access_controller_action[] = 'order_opsend';
  151. $access_controller_action[] = 'order_opsend_tuanz';
  152. $access_controller_action[] = 'order_opsend_tuanz_over';
  153. $access_controller_action[] = 'order_opsendcancel';
  154. $access_controller_action[] = 'order_order_print_dan';
  155. $access_controller_action[] = 'order_orderaftersales';
  156. $access_controller_action[] = 'order_ordercomment';
  157. $access_controller_action[] = 'order_ordercomment_config';
  158. $access_controller_action[] = 'order_ordersendall';
  159. $access_controller_action[] = 'order_print_order';
  160. $access_controller_action[] = 'order_refund_mult';
  161. $access_controller_action[] = 'order_refund_mult_do';
  162. $access_controller_action[] = 'order_refunddone';
  163. $access_controller_action[] = 'order_sendexpress';
  164. $access_controller_action[] = 'order_sendexpress_excel_done';
  165. $access_controller_action[] = 'order_show_order';
  166. $access_controller_action[] = 'order_show_refund';
  167. $access_controller_action[] = 'order_check_delivery_config';
  168. $access_controller_action[] = 'order_thirth_delivery_order';
  169. $access_controller_action[] = 'order_third_delivery_log_list';
  170. $access_controller_action[] = 'order_third_cancel_reason';
  171. $access_controller_action[] = 'order_thirth_cancel_delivery_order';
  172. $access_controller_action[] = 'order_thirth_renew_delivery_order';
  173. $access_controller_action[] = 'supply_apply_money';
  174. $access_controller_action[] = 'supply_login';
  175. $access_controller_action[] = 'supply_login_do';
  176. $access_controller_action[] = 'statistics_load_echat_month_head_sales';
  177. $access_controller_action[] = 'statistics_load_echat_month_goods_sales';
  178. $access_controller_action[] = 'statistics_index_data';
  179. $access_controller_action[] = 'statistics_order_buy_data';
  180. $access_controller_action[] = 'statistics_load_goods_paihang';
  181. $access_controller_action[] = 'statistics_load_goods_chart';
  182. $access_controller_action[] = 'statistics_load_echat_member_incr';
  183. $access_controller_action[] = 'statistics_load_echat_head_incr';
  184. $access_controller_action[] = 'supply_modifypassword';
  185. $access_controller_action[] = 'goods_delete';
  186. $access_controller_action[] = 'express_localtownconfig';
  187. $access_controller_action[] = 'order_opsend_localtown';
  188. $access_controller_action[] = 'orderdistribution_choosemember';
  189. $access_controller_action[] = 'orderdistribution_sub_orderchoose_distribution';
  190. $access_controller_action[] = 'orderdistribution_index';
  191. $access_controller_action[] = 'orderdistribution_adddistribution';
  192. $access_controller_action[] = 'orderdistribution_deletedistribution';
  193. $access_controller_action[] = 'orderdistribution_change';
  194. $access_controller_action[] = 'orderdistribution_distribution_list';
  195. $access_controller_action[] = 'orderdistribution_distributionconfig';
  196. $access_controller_action[] = 'orderdistribution_withdrawallist';
  197. $access_controller_action[] = 'orderdistribution_withdrawalconfig';
  198. $access_controller_action[] = 'orderdistribution_agent_check_apply';
  199. $access_controller_action[] = 'user_zhenquery';
  200. $access_controller_action[] = 'salesroom_index';
  201. $access_controller_action[] = 'salesroom_add';
  202. $access_controller_action[] = 'salesroom_delete';
  203. $access_controller_action[] = 'salesroom_query';
  204. $access_controller_action[] = 'salesroom_member_index';
  205. $access_controller_action[] = 'salesroom_member_add';
  206. $access_controller_action[] = 'salesroom_member_delete';
  207. $access_controller_action[] = 'salesroom_member_query';
  208. $access_controller_action[] = 'salesroom_order_index';
  209. $access_controller_action[] = 'salesroom_order_member_orders';
  210. $access_controller_action[] = 'salesroom_order_member_orders';
  211. $access_controller_action[] = 'order_order_hexiao';
  212. $access_controller_action[] = 'order_hexiao_times';
  213. $access_controller_action[] = 'order_hexiao_goods';
  214. $access_controller_action[] = 'order_view_hexiao_history';
  215. $access_controller_action[] = 'order_hexiao_goods_assign_salesroom';
  216. $access_controller_action[] = 'salesroom_change';
  217. $c_controller = strtolower(CONTROLLER_NAME);
  218. $c_action = strtolower(ACTION_NAME);
  219. $cur_key = $c_controller.'_'.$c_action;
  220. if( !in_array($cur_key, $access_controller_action) )
  221. {
  222. die('您无此操作权限');
  223. }
  224. }
  225. }
  226. /**
  227. * 权限过滤
  228. * @return
  229. */
  230. protected function filterAccess() {
  231. if (!C('USER_AUTH_ON')) {
  232. return ;
  233. }
  234. //Admin
  235. //var_dump( \Org\Util\Rbac::AccessDecision(C('GROUP_AUTH_NAME')) );die();
  236. if (\Org\Util\Rbac::AccessDecision(C('GROUP_AUTH_NAME'))) {
  237. return ;
  238. }
  239. if (!$_SESSION [C('USER_AUTH_KEY')]) {
  240. // 登录认证号不存在
  241. return $this->redirect(C('USER_AUTH_GATEWAY'));
  242. }
  243. if ('Index' === CONTROLLER_NAME && 'index' === ACTION_NAME) {
  244. // 首页无法进入,则登出帐号
  245. D('Admin', 'Service')->logout();
  246. }
  247. return $this->error('您没有权限执行该操作!');
  248. }
  249. /* 空操作,用于输出404页面 */
  250. public function _empty(){
  251. // $this->display('Public:404');die();
  252. die('空操作');
  253. }
  254. /**
  255. *跳转控制
  256. */
  257. public function osc_alert($status){
  258. if($status['status']=='back'){
  259. $this->error($status['message']);
  260. die;
  261. }elseif($status['status']=='success'){
  262. $this->success($status['message'],$status['jump']);
  263. die;
  264. }elseif($status['status']=='fail'){
  265. $this->error($status['message'],$status['jump']);
  266. die;
  267. }
  268. }
  269. }
  270. ?>