Core.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Factory\Admin;
  3. use Dever;
  4. class Core
  5. {
  6. public function __construct()
  7. {
  8. $this->user = Dever::load('factory/admin/auth.check');
  9. $this->id = $this->user['factory_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);
  15. if (!in_array(2, $role)) {
  16. unset($this->user['msg_type'][1]);
  17. if (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 (strstr($uri, 'set')) {
  28. echo '您没有权限';die;
  29. }
  30. if (strstr($uri, 'user')) {
  31. echo '您没有权限';die;
  32. }
  33. $this->user['msg_type'] = implode(',', $this->user['msg_type']);
  34. }
  35. $this->info = Dever::db('factory/info')->find($this->id);
  36. if (!$this->info) {
  37. echo '工厂不存在';die;
  38. }
  39. if ($this->info['status'] != 1) {
  40. if (!strstr($uri, 'set') && !strstr($uri, 'help') && !strstr($uri, 'console')) {
  41. echo '认证中或者认证失败无法访问该功能';die;
  42. }
  43. }
  44. }
  45. }