Esempio n. 1
0
 public function room()
 {
     $session = \Hnust\input('session');
     $classroom = \Hnust\input('classroom');
     if (empty($session) || empty($classroom)) {
         $this->msg = '参数有误';
         $this->code = Config::RETURN_ERROR;
     } elseif (!in_array($session, array(1, 2, 3, 4, 5))) {
         $this->msg = '上课时间有误,注意:一天只有1-5节课';
         $this->code = Config::RETURN_ERROR;
     } else {
         $week = \Hnust\week();
         $day = date('w') ? date('w') : 7;
         $schedule = new \Hnust\Analyse\Schedule('1301010101');
         $this->data = $schedule->getCourse($week, $day, $session, $classroom);
     }
 }
Esempio n. 2
0
 public function schedule()
 {
     $type = \Hnust\input('type');
     $week = \Hnust\input('week');
     $term = \Hnust\input('term');
     $week = strlen($week) ? $week : \Hnust\week();
     $term = strlen($term) ? $term : Config::getConfig('current_term');
     $isDownload = \Hnust\input('download/b', false);
     $schedule = new \Hnust\Analyse\Schedule($this->sid);
     if ($isDownload) {
         $schedule->getExcel($this->uid, $this->sid, $term);
     } else {
         $this->data = $schedule->getSchdule($this->sid, $term, $type, $week);
         $this->info = array('sid' => $this->sid, 'week' => $week, 'term' => $term, 'terms' => $this->getTerms(), 'remarks' => $this->data['remarks']);
         $this->msg = $schedule->error;
         unset($this->data['remarks']);
     }
 }
Esempio n. 3
0
 public function schedule()
 {
     $term = Config::getConfig('current_term');
     $schedule = new \Hnust\Analyse\Schedule($this->sid);
     $data = $schedule->getSchdule($this->sid, $term, 1);
     //获取周次与星期
     $week = \Hnust\week();
     $day = date('w');
     $isToday = true;
     if (date('H') >= 21) {
         $isToday = false;
         $day = ($day + 1) % 7;
     }
     $day = $day ? $day : 7;
     //获取当天课表
     $data = $data[$week][$day];
     $session = array('', '一、二', '三、四', '五、六', '七、八', '九、十');
     $content = '';
     for ($i = 1; $i <= 5; $i++) {
         if (empty($data[$i])) {
             continue;
         }
         $content .= "第{$session[$i]}节:\n课程:{$data[$i]['course']}\n教室:{$data[$i]['classroom']}\n\n";
     }
     //回复
     if ($content) {
         $content = ($isToday ? '今' : '明') . "日课表如下:\n\n" . $content;
         if ($schedule->error) {
             $content .= $schedule->error;
         }
         $this->data = trim($content);
     } else {
         $this->data = ($isToday ? '今' : '明') . '日无课,但不要太放松哦';
     }
 }
Esempio n. 4
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;
 }