Core.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace store\Admin;
  3. use Dever;
  4. class Core
  5. {
  6. public function __construct()
  7. {
  8. $this->user = Dever::load('store/admin/auth.check');
  9. $this->id = $this->user['store_id'];
  10. $role = explode(',', $this->user['role_id']);
  11. $uri = Dever::uri();
  12. $this->user['msg_type'] = false;
  13. if (!in_array(1, $role)) {
  14. $this->user['msg_type'] = array(1,2,6,7);
  15. if (!in_array(2, $role)) {
  16. unset($this->user['msg_type'][1]);
  17. if ($uri == 'order' || strstr($uri, 'admin/order') || strstr($uri, 'order_')) {
  18. echo '您没有权限';die;
  19. }
  20. }
  21. if (!in_array(4, $role)) {
  22. unset($this->user['msg_type'][2]);
  23. if (strstr($uri, 'stat')) {
  24. echo '您没有权限';die;
  25. }
  26. }
  27. if (!in_array(3, $role)) {
  28. unset($this->user['msg_type'][3]);
  29. if (strstr($uri, 'factory_order') || strstr($uri, 'goods') || strstr($uri, 'out')) {
  30. echo '您没有权限';die;
  31. }
  32. }
  33. if (strstr($uri, 'set')) {
  34. echo '您没有权限';die;
  35. }
  36. if (strstr($uri, 'user')) {
  37. echo '您没有权限';die;
  38. }
  39. $this->user['msg_type'] = implode(',', $this->user['msg_type']);
  40. }
  41. $this->info = Dever::db('store/info')->find($this->id);
  42. if (!$this->info) {
  43. echo '仓库不存在';die;
  44. }
  45. if ($this->info['status'] != 1) {
  46. if (!strstr($uri, 'set') && !strstr($uri, 'help') && !strstr($uri, 'console')) {
  47. echo '认证中或者认证失败无法访问该功能';die;
  48. }
  49. }
  50. }
  51. }