12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Main\Lib;
- use Dever;
- class Core
- {
- protected $uid = -1;
- protected $use = array();
- public $data = array();
- public function __construct()
- {
- $this->uid = Dever::load('passport/user')->check(false);
- if ($this->uid <= 0) {
- $this->uid = 1;
- }
- if ($this->uid) {
- $this->user = Dever::load('passport/api')->info($this->uid);
- } else {
- $this->user = Dever::load('passport/user')->init();
- $this->uid = $this->user['id'];
- }
- if ($this->user) {
- $this->user['uid'] = $this->user['id'];
- }
- }
- public function checkLogin()
- {
- if (!$this->uid || $this->uid <= 0) {
- Dever::alert('请先登录', -2);
- }
- }
- public function alert($state)
- {
- if ($state) {
- return array('msg' => 'ok');
- } else {
- Dever::alert('操作失败');
- }
- }
- # 获取记录的月份列表
- public function month($table)
- {
- $data = Dever::db($table)->find(array('order' => array('id' => 'asc')));
- if ($data) {
- $month = date('Ym', $data['cdate']);
- $cur = date('Ym');
- if ($month == $cur) {
- $result[] = $month;
- return $result;
- } else {
- $result = array();
- for ($i = $month; $i < $cur; $i++) {
- if ($i > 12) {
- }
- $result[] = $i;
- }
- return $result;
- }
- }
- }
- }
|