public function login() { //获取教务网密码 $inputPasswd = $this->passwd; $passwdClass = new Passwd($this->sid); if (empty($this->passwd)) { $this->passwd = $passwdClass->cwc(); } $result = parent::login(); //保存密码 if ($result && !empty($inputPasswd)) { $passwdClass->cwc($inputPasswd); } return $result; }
public function login() { if ($this->logined) { return true; } //随机登陆 $passwdClass = new Passwd($this->sid); $students = $passwdClass->randJwc(); foreach ($students as $student) { $this->sid = $student['sid']; $this->passwd = $student['jwc']; try { return parent::login(); } catch (\Exception $e) { if (Config::RETURN_NEED_PASSWORD === $e->getCode()) { continue; } throw new \Exception($e->getMessage(), $e->getCode()); } } }
public function getList($term = null) { if (empty($term)) { $term = $this->term; } //随机登陆 $passwdClass = new Passwd($this->sid); $students = $passwdClass->randJwc(); foreach ($students as $student) { $this->sid = $student['sid']; $this->passwd = $student['jwc']; try { parent::login(); } catch (\Exception $e) { if (Config::RETURN_NEED_PASSWORD === $e->getCode()) { continue; } throw new \Exception($e->getMessage(), $e->getCode()); } } //获取列表 $list = parent::getList($term); //更新数据库 $sql = 'INSERT INTO `elective_list`( `school`, `course`, `college`, `credit`, `total`, `remain`, `teacher`, `week`, `time`, `place`, `url`, `term` ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `credit` = ?, `total` = ?, `remain` = ?, `week` = ?, `time` = ?, `place` = ?'; $sqlArr = array(); foreach ($list as $item) { $sqlArr[] = array($item['school'], $item['course'], $item['college'], $item['credit'], $item['total'], $item['remain'], $item['teacher'], $item['week'], $item['time'], $item['place'], $item['url'], $item['term'], $item['credit'], $item['total'], $item['remain'], $item['week'], $item['time'], $item['place']); } Mysql::executeMultiple($sql, $sqlArr); return $list; }