Core.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Main\Lib;
  3. use Dever;
  4. class Core
  5. {
  6. protected $uid = -1;
  7. protected $use = array();
  8. public $data = array();
  9. public function __construct()
  10. {
  11. $this->uid = Dever::load('passport/user')->check(false);
  12. if ($this->uid <= 0) {
  13. $this->uid = 1;
  14. }
  15. if ($this->uid) {
  16. $this->user = Dever::load('passport/api')->info($this->uid);
  17. } else {
  18. $this->user = Dever::load('passport/user')->init();
  19. $this->uid = $this->user['id'];
  20. }
  21. if ($this->user) {
  22. $this->user['uid'] = $this->user['id'];
  23. }
  24. }
  25. public function checkLogin()
  26. {
  27. if (!$this->uid || $this->uid <= 0) {
  28. Dever::alert('请先登录', -2);
  29. }
  30. }
  31. public function alert($state)
  32. {
  33. if ($state) {
  34. return array('msg' => 'ok');
  35. } else {
  36. Dever::alert('操作失败');
  37. }
  38. }
  39. # 获取记录的月份列表
  40. public function month($table)
  41. {
  42. $data = Dever::db($table)->find(array('order' => array('id' => 'asc')));
  43. if ($data) {
  44. $month = date('Ym', $data['cdate']);
  45. $cur = date('Ym');
  46. if ($month == $cur) {
  47. $result[] = $month;
  48. return $result;
  49. } else {
  50. $result = array();
  51. for ($i = $month; $i < $cur; $i++) {
  52. if ($i > 12) {
  53. }
  54. $result[] = $i;
  55. }
  56. return $result;
  57. }
  58. }
  59. }
  60. }