CommonController.class.php 11 KB

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