Esempio n. 1
0
File: Api.php Progetto: qious/Hnust
 public function group()
 {
     $group = new \Hnust\Analyse\Group();
     $list = $group->belong($this->uid);
     $list = empty($list) ? array() : $list;
     $this->data = array();
     foreach ($list as $item) {
         $this->data[] = array_merge($item, array('member' => $group->getMember($item['gid'])));
     }
 }
Esempio n. 2
0
 public function birthday()
 {
     $this->logFileName = 'birthday';
     //生日提醒锁
     $cache = new Cache('remind_birthday');
     if ($cache->get('lock')) {
         return false;
     } else {
         $cache->set('lock', true, 86000);
     }
     $zh2num = ['零' => 0, '一' => 1, '二' => 2, '三' => 3, '四' => 4, '五' => 5, '六' => 6, '七' => 7, '八' => 8, '九' => 9];
     $lunar = new \Lunar();
     $date = $lunar->convertSolarToLunar(date('Y'), date('m'), date('d'));
     $sql = "SELECT `sid`, `name`, `phone`, `mail`, `birthday` FROM `student`\n                  WHERE (`birthday` LIKE ? OR `birthday` LIKE ?)\n                  AND `sid` IN (SELECT `uid` FROM `user`)";
     $arr = array('____' . date('md'), '____' . $date[1] . $date[2]);
     $users = Mysql::execute($sql, $arr);
     $group = new \Hnust\Analyse\Group();
     foreach ($users as $user) {
         if (is_numeric($user['birthday'])) {
             $year = (int) substr($user['birthday'], 0, 4);
         } else {
             $year = 0;
             for ($i = 0; $i < 4; $i++) {
                 $year *= 10;
                 $year += $zh2num[mb_substr($user['birthday'], $i, 1, 'utf-8')];
             }
         }
         //计算所属群组
         $groups = ['Tick网络工作室'];
         $belong = $group->belong($user['sid']);
         foreach ($belong as $item) {
             if (!in_array($item['name'], $groups)) {
                 $groups[] = $item['name'];
             }
         }
         $user['sms'] = array('name' => $user['name'], 'age' => (string) (date('Y') - $year), 'group' => implode('、', $groups), 'template' => 'SMS_7745798');
         $this->remind($user, '生日快乐', '生日快乐', '', '0001');
     }
     $this->record("=== 生日提醒执行完成 ===");
 }
Esempio n. 3
0
File: Auth.php Progetto: qious/Hnust
 public function user()
 {
     $sql = 'SELECT `u`.`uid`, `u`.`rank`, `u`.`apiToken`,
                    `s`.`name`, `s`.`class`, `s`.`major`, `s`.`college`,
                    `s`.`mail`, `s`.`phone`, `s`.`qq`
             FROM `user` `u`, `student` `s`
             WHERE `u`.`uid` = `s`.`sid` AND `u`.`uid` = ?';
     $result = Mysql::execute($sql, array($this->uid));
     $this->info = empty($result) ? array() : $result[0];
     $this->info['token'] = $this->token;
     //当前学期/周次
     $this->info['week'] = \Hnust\week();
     $this->info['term'] = Config::getConfig('current_term');
     //头像地址
     $this->info['avatar'] = Config::getConfig('local_base_url');
     if (empty($this->info['qq'])) {
         $this->info['avatar'] .= "avatar/qy/{$this->info['uid']}";
     } else {
         $this->info['avatar'] .= "avatar/qq/{$this->info['qq']}";
     }
     //用户所在群组
     $group = new \Hnust\Analyse\Group();
     $this->info['group'] = $group->belong($this->uid);
     //数组合并
     $this->info = array_merge($this->info, array('sid' => $this->sid, 'isAdmin' => $this->rank === Config::RANK_ADMIN));
     return $this->info;
 }