function post($fromUsername) { $cookie_file = tempnam('./temp', 'cookie'); $login_url = 'xxx'; $ch = curl_init($login_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); $contents = curl_exec($ch); preg_match_all('/<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="(.+?)"/is', $contents, $arr); $VIEWSTATE = $arr[1][0]; preg_match_all('/<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="(.+?)"/is', $contents, $arr); $EVENTVALIDATION = $arr[1][0]; preg_match_all('/<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="(.+?)"/is', $contents, $arr); $VIEWSTATEGENERATOR = $arr[1][0]; curl_close($ch); require_once './sql.php'; $sql = "SELECT stu_no, stu_wd FROM students WHERE from_user = '******'"; $result = _select_data($sql); $rows = mysql_fetch_array($result); $user = $rows[stu_no]; $password = $rows[stu_wd]; $cookie_file = tempnam('./temp', 'cookie'); $url = 'xxx'; $post_fields = array("__VIEWSTATE" => $VIEWSTATE, "__EVENTVALIDATION" => $EVENTVALIDATION, "__VIEWSTATEGENERATOR" => $VIEWSTATEGENERATOR, "btnLogin" => "登录", "txtUserID" => $user, "txtUserPwd" => $password); $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); $header[] = 'xxx'; $header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0'; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_exec($ch); curl_close($ch); $url = 'xxx'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); $header[] = 'xxx'; $header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0'; $contents = curl_exec($ch); $td = get_td_array($contents); foreach ($td as $v) { if ($v[10]) { $table .= "{$v['9']}==={$v['1']}==={$v['5']}" . "\n"; } } return $table; }
function po_chengji_new($str) { preg_match('/<table cellspacing=\\"0\\" cellpadding=\\"3\\" rules=\\"rows\\" bordercolor=\\"#ADCEEF\\" border=\\"1\\" id=\\"DataGrid1\\" width=\\"100%\\">(?P<info>.+?)<\\/table>/s', $str, $results); $array = get_td_array($results['info']); array_splice($array, 0, 1); /* Array ( [0] => 学年 [1] => 学期 [2] => 课程名称 [3] => 课程类型 [4] => 任课教师 [5] => 考核方式 [6] => 总评成绩 [7] => 补考成绩 [8] => 重修成绩 [9] => 重修成绩2 [10] => 重修成绩3 [11] => 绩点 [12] => 应得学分 ) */ for ($i = 0; $i < count($array); $i++) { for ($j = 0; $j < count($array[$i]); $j++) { if ($array[$i][$j] == " ") { $array[$i][$j] = ""; } $array[$i][$j] = trim($array[$i][$j]); } } //print_r($array); //取出最后一学期的成绩 $cj = ''; $str = ''; $xn = ""; for ($i = count($array) - 1; $i >= 0; $i--) { $cj = ''; $cj = "课程名称:" . $array[$i][2] . "\n" . "课程类型:" . $array[$i][3] . "\n" . "任课教师:" . $array[$i][4] . "\n" . "总评成绩:" . $array[$i][6] . "\n"; //判断最终成绩 if (!empty($array[$i][7])) { $cj .= "补考成绩:" . $array[$i][7] . "\n"; } elseif (!empty($array[$i][8])) { $cj .= "重修成绩:" . $array[$i][8] . "\n"; } elseif (!empty($array[$i][9])) { $cj .= "重修成绩2:" . $array[$i][9] . "\n"; } elseif (!empty($array[$i][10])) { $cj .= "重修成绩3:" . $array[$i][10] . "\n"; } $cj .= "绩点:" . $array[$i][11] . "\n" . "应得学分:" . $array[$i][11] . "\n----------\n"; //学年不一样时结束循环 if ($array[$i][0] != $array[$i - 1][0]) { break; } if ($array[$i - 1][1] == '1' && $array[$i][1] != $array[$i - 1][1]) { $cj .= $array[$i - 1][0] . "学年\n第 " . $array[$i - 1][1] . " 学期\n----------\n"; } $str .= $cj; } $ret = $array[count($array) - 1][0] . "学年\n第 " . $array[count($array) - 1][1] . " 学期\n----------\n" . $str; return $ret; }
} $zkz = $_POST['number']; $xm1 = $_POST['name']; //echo urlencode($xm); $ch = curl_init('http://www.chsi.com.cn/cet/query?zkzh=' . $zkz . '&xm=' . urlencode($xm1) . ''); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); $head[] = 'Referer:http://www.chsi.com.cn/cet/'; $head[] = 'User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36'; curl_setopt($ch, CURLOPT_HTTPHEADER, $head); $str1 = curl_exec($ch); //print_r($str1); curl_close($ch); preg_match('|<table border="0" align="center" cellpadding="0" cellspacing="6" class="cetTable">(.*?)</table>|s', $str1, $table); //print_r($table); $array = get_td_array($table[0]); //print_r($array); $xm = str_replace("姓名:", "", trim($array[0][0])); $xx = str_replace("学校:", "", trim($array[1][0])); $kslb = str_replace("考试类别:", "", trim($array[2][0])); $zkzh = str_replace("准考证号:", "", trim($array[3][0])); $kssj = str_replace("考试时间:", "", trim($array[4][0])); $key = str_replace("\r\n", "", trim($array[5][0])); preg_match_all("/[0-9]+/", $key, $b); ?> <html> <head> <meta charset=UTF-8"> <title>师大小伙伴</title> <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
function getKaoshi() { if ($this->auth()) { $cookie_file = tempnam(SAE_TMP_PATH, 'cookie'); $login_url = 'http://jw.djtu.edu.cn/academic/j_acegi_security_check'; $post_fields = 'j_username='******'&j_password='******'http://jw.djtu.edu.cn/academic/student/exam/index.jsdo'; //$url='http://jw.djtu.edu.cn/academic/manager/examstu/studentQueryAllExam.do'; //$post_fields='year=32&term=1¶=0'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $header[] = "Cookie:JSESSIONID={$this->sessionid}"; curl_setopt($ch, CURLOPT_HTTPHEADER, $header); $table = curl_exec($ch); $array = get_td_array($table); $str = var_export($array, true); $exam = eval('return ' . iconv('gbk', 'utf-8', $str) . ';'); curl_close($ch); return $exam; } else { return $this->auth; } }
function get_table_array($table, $urlstr = 1, $picstr = 1, $titlestr = 1, $arraydelid = 1) { $table = preg_replace("'<table[^>]*?>'si", "", $table); $table = preg_replace("'<tr[^>]*?>'si", "", $table); $table = preg_replace("'<td[^>]*?>'si", "", $table); $table = str_replace("</table>", "{table}", $table); $table = explode('{table}', $table); array_pop($table); foreach ($table as $key => $tr) { $tablearrlist = get_td_array($tr, $urlstr, $picstr, $titlestr, $arraydelid); $newstypeid = array(typeid => $key); $table_array[] = array_merge_recursive($tablearrlist, $newstypeid); } return $table_array; }
function getGradeScore() { if (strlen($this->sno) == 10) { //本科生 if (preg_match('/^3/', $this->sno)) { $this->loginBenKe(); $url = "http://xk1.ujs.edu.cn/xsdjkscx.aspx?xh={$this->sno}&xm=&gnmkdm=N121608"; $output = _http($url, '', $this->cookieFile); $output = iconv('gb2312', 'utf-8//IGNORE', $output); $td = get_td_array($output); $grade = ''; $i = 0; foreach ($td as $v) { if ($v[2]) { if ($i == 0) { $grade .= "<thead><tr><th>{$v[2]}</th><th>{$v[4]}</th><th>{$v[5]}</th></tr></thead><tbody>"; } else { $grade .= "<tr><td>{$v[2]}</td><td>{$v[4]}</td><td>{$v[5]}</td></tr>"; } $i = 1; } } if (!$grade) { return "查不到你的等级考试成绩,可能教务系统坏了或者你改了密码,如果你改了密码请发:绑定"; } return $grade; } else { //京江学院 return "京江学院教务系统暂不支持此功能。"; } } else { //研究生 return "研究生教务系统暂不支持此功能。"; } }
function po_chengji_new($str, $xh, $name, $ch, $link) { preg_match('/<table cellspacing=\\"0\\" cellpadding=\\"3\\" rules=\\"rows\\" bordercolor=\\"#ADCEEF\\" border=\\"1\\" id=\\"DataGrid1\\" width=\\"100%\\">(?P<info>.+?)<\\/table>/s', $str, $results); $array = get_td_array($results['info']); @array_splice($array, 0, 1); /* Array ( [0] => 学年 [1] => 学期 [2] => 课程名称 [3] => 课程类型 [4] => 任课教师 [5] => 考核方式 [6] => 总评成绩 [7] => 补考成绩 [8] => 重修成绩 [9] => 重修成绩2 [10] => 重修成绩3 [11] => 绩点 [12] => 应得学分 ) */ for ($i = 0; $i < count($array); $i++) { for ($j = 0; $j < count($array[$i]); $j++) { if ($array[$i][$j] == " ") { $array[$i][$j] = ""; } $array[$i][$j] = trim($array[$i][$j]); } } //print_r($array); //取出最后一学期的成绩 $cj = ''; $str = ''; $xn = ""; for ($i = count($array) - 1; $i >= 0; $i--) { //$cj=''; $cj = "课程名称:" . $array[$i][2] . "\n" . "课程类型:" . $array[$i][3] . "\n" . "任课教师:" . $array[$i][4] . "\n" . "总评成绩:" . $array[$i][6] . "\n"; //判断最终成绩 if (!empty($array[$i][7])) { $cj .= "补考成绩:" . $array[$i][7] . "\n"; } elseif (!empty($array[$i][8])) { $cj .= "重修成绩:" . $array[$i][8] . "\n"; } elseif (!empty($array[$i][9])) { $cj .= "重修成绩2:" . $array[$i][9] . "\n"; } elseif (!empty($array[$i][10])) { $cj .= "重修成绩3:" . $array[$i][10] . "\n"; } $cj .= "绩点:" . $array[$i][11] . "\n" . "应得学分:" . $array[$i][11] . "\n----------\n"; //学年不一样时结束循环 if ($array[$i][0] != $array[$i - 1][0]) { break; } if ($array[$i - 1][1] == '1' && $array[$i][1] != $array[$i - 1][1]) { $cj .= $array[$i - 1][0] . "学年\n第 " . $array[$i - 1][1] . " 学期\n----------\n"; } $str .= $cj; } $ret = $array[count($array) - 1][0] . "学年\n第 " . $array[count($array) - 1][1] . " 学期\n----------\n" . $str; /* Conan注释 $sql_po_chengji = "REPLACE INTO `jwc_chengji` (`xh`, `name`,`chengji`, `time`) VALUES ('{$xh}','{$name}', '{$ret}', TIMESTAMP(10));"; $query_char=mysql_query("SET NAMES UTF8"); $query_po_chengji=mysql_query($sql_po_chengji,$link) or die(mysql_error());*/ return $ret; }
function getKaoshi() { if ($this->auth()) { $cookie_file = tempnam('./', 'cookie'); $login_url = 'http://jw.djtu.edu.cn/academic/j_acegi_security_check'; $post_fields = 'j_username='******'&j_password='******'http://jw.djtu.edu.cn/academic/student/exam/index.jsdo'; //$post_fields='year=32&term=1¶=0'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_POST, 1); //curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); $table = curl_exec($ch); $array = get_td_array($table); $str = var_export($array, true); $exam = eval('return ' . iconv('gbk', 'utf-8', $str) . ';'); curl_close($ch); return $exam; } else { return "您还没有绑定,请回复“绑定教务”进入绑定教务地址"; } }
public function getDelayList() { $bookurl = 'http://huiwen.ujs.edu.cn:8080/reader/book_lst.php'; $ch = curl_init($bookurl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //0显示,1不显示 curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_cookie); //使用cookie $data = curl_exec($ch); $data = html_entity_decode($data, ENT_NOQUOTES, "UTF-8"); curl_close($ch); $ret = get_td_array($data); $books = ""; $deadline = date("Y-m-d", strtotime("1 day")); foreach ($ret as $key => $tr) { $bookname = $tr[1]; $bookname = preg_replace('/[a-zA-Z]{10,}/', '', $bookname); $name = trim($bookname); $date = trim($tr[3]); if (empty($name) || empty($date)) { continue; } if ($date == $deadline) { //明天到期 if ($books) { $books .= '、《' . $name . '》'; } else { $books .= '《' . $name . '》'; } } } return $books; }
/** * 等级考试查询 */ private function getDjks() { $result = $this->Simulated($this->url . 'xsdjkscx.aspx?xh=' . $this->username . '&xm=' . $this->name . '&gnmkdm=N121606'); preg_match_all('/<table [^>]*>([\\s\\S]*?)<\\/table>/', $result, $rs); $arr = get_td_array($rs[0][0]); if (count($arr) == 1) { $shuzu = '你没有参加等级考试吧.'; } else { for ($d = 1; $d < count($arr); $d++) { $shuzu[$d][0] = '学年:' . trim($arr[$d][0]); $shuzu[$d][1] = '学期:' . $arr[$d][1]; $shuzu[$d][2] = '等级考试名称:' . $arr[$d][2]; $shuzu[$d][3] = '准考证号:' . $arr[$d][3]; $shuzu[$d][4] = '考试日期:' . $arr[$d][4]; $shuzu[$d][5] = '成绩:' . $arr[$d][5]; $shuzu[$d][6] = '听力成绩:' . $arr[$d][6]; $shuzu[$d][7] = '阅读成绩:' . $arr[$d][7]; $shuzu[$d][8] = '写作成绩:' . $arr[$d][8]; $shuzu[$d][9] = '综合成绩:' . $arr[$d][9]; } } $this->message = $shuzu; }