1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
| <?php session_start(); header('Access-Control-Allow-Origin: *'); error_reporting(E_ALL & ~E_NOTICE);
$user=$_POST['user']?$_POST['user']:$_SESSION['user']['user']; $pass=$_POST['pass']?$_POST['pass']:$_SESSION['user']['pass']; $sise_cookie=$_POST['sise_cookie']?$_POST['sise_cookie']:$_SESSION['user']['sise_cookie']; if($_POST['user']=='110'&&$_POST['pass']=='110') { include("./user.php"); exit(); } if($_GET["method"] == 'login'){ $curlpost="number=$user&pwd=$pass"; $scse_cookie=tempnam('./temp','cookie'); $scse_url="http://my.scse.com.cn/login_pro.asp"; LinkCurl($scse_url,$curlpost,$scse_cookie); $sise_login_url="http://class.sise.com.cn:7001/sise/login.jsp"; $sise_login_html=getCurlCon($sise_login_url,$scse_cookie); preg_match('/<input type=\"hidden\" name=\"(.*)\" value=\"(.*)\">/', $sise_login_html,$arr); $curlpost="username=$user&password=$pass&$arr[1]=$arr[2]"; $sise_cookie=tempnam('./temp','cookie'); $sise_login_check_url="http://class.sise.com.cn:7001/sise/login_check.jsp"; LinkCurl($sise_login_check_url,$curlpost,$sise_cookie); $res = array( "code" => 404, "msg" => "failed" ); $course_url="http://class.sise.com.cn:7001/sise/module/student_schedular/student_schedular.jsp"; $course_html=getCurlCon($course_url,$sise_cookie); preg_match_all('/<span class=\"style16\">((.*) (.*) (.*) (.*))<\/span>/', $course_html,$user_info); if(!empty($user_info[2][0])){ $_SESSION['user']= array( 'user' => $user, 'pass' => $pass, 'sise_cookie' => $sise_cookie ); $res = array( "code" => 200, "msg" => "success", 'sise_cookie' => $sise_cookie ); } print_r(json_encode($res)); } if($_GET["method"] == 'course'){ $res = array( "code" => 404, "msg" => "failed", "resData" => [] ); $course_url="http://class.sise.com.cn:7001/sise/module/student_schedular/student_schedular.jsp"; $course_html=getCurlCon($course_url,$sise_cookie); preg_match_all('/<span class=\"style16\">(.*) (.*) (.*) (.*)<\/span>/U', $course_html,$user_info); preg_match_all("/<td width=\'10%\' align=\'left\' valign=\'top\' class=\'font12\'>(.*)<\/td>/U", $course_html,$course); $res_course=array(); for($i=0;$i<8;$i++){ for($j=$i*7,$k=0;$j<$i*7+7;$j++,$k++){ if ($course[1][$j] == ' ') $course[1][$j] = ''; if($k!=5 && $k!=6) { $res_course[$i][$k] = iconv('gbk', 'utf-8', $course[1][$j]); } } } $res = array( "code" => 200, "msg" => "success", "resData" => array( "info" => array( "stuNum" => iconv('gbk', 'utf-8', mb_substr($user_info[1][0],6,null)), "name" => iconv('gbk', 'utf-8', mb_substr($user_info[2][0],6,null)), "grade" => iconv('gbk', 'utf-8', mb_substr($user_info[3][0],6,null)), "major" => iconv('gbk', 'utf-8', mb_substr($user_info[4][0],6,null)), ), "course" => $res_course ) ); print_r(json_encode($res)); } if($_GET["method"] == 'teacher'){ $name = $_GET["name"]; $data = json_decode(file_get_contents("./json/teacher.json" )); $arr = array(); $res = array(); for($i=0;$i<count($data);$i++){ if($data[$i]->name == $name){ $arr = $data[$i]; } } if(!empty($arr)){ if(mb_strlen($arr->num) ==3 ){ $arr->num = "0".$arr->num; } $res = array( "code" => 200, "msg" => "success", "resData" => $arr ); } else { $res = array( "code" => 404, "msg" => "failed", "resData" => array() ); } print_r(json_encode($res)); } if($_GET["method"] == 'attendance'){ $res = array( "code" => 404, "msg" => "failed", "resData" => [] ); $main_url="http://class.sise.com.cn:7001/sise/module/student_states/student_select_class/main.jsp"; $main_html=getCurlCon($main_url,$sise_cookie); preg_match_all('/window\.location=\'\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/(.*)\'\"/Um', $main_html,$main); $attendance_url='http://class.sise.com.cn:7001/'.$main[1][1]; $attendance_html = getCurlCon($attendance_url,$sise_cookie); preg_match_all('/<td>(.*)(\d+)<\/td>/U', $attendance_html,$count); preg_match_all('/<td align=\"center\">(.*)<\/td>/U', $attendance_html,$attendance); $res_attendance=array(); for($i=0;$i<count($attendance[1])/3;$i++){ for($j=$i*3,$k=0;$j<$i*3+3;$j++,$k++){ switch ($k) { case 0: $res_attendance[$i]["num"] = iconv('gbk', 'utf-8', $attendance[1][$j]); break; case 1: $res_attendance[$i]["name"] = iconv('gbk', 'utf-8', $attendance[1][$j]); break; case 2: preg_match_all('/\[<a href=\'(.*)\'>(.*)<\/a>\]/U', $attendance[1][$j],$count); if(empty($count[2][0])){ $res_attendance[$i]["detail"] = iconv('gbk', 'utf-8', mb_substr($attendance[1][$j],0,4)).$count[2][0]; }else{ $res_attendance[$i]["detail"] = iconv('gbk', 'utf-8', mb_substr($attendance[1][$j],0,4)).$count[2][0].'次'; } break; default: break; } } } $res = array( "code" => 200, "msg" => "success", "resData" => array( "total" => $count[2][0], "list" => $res_attendance ) ); print_r(json_encode($res)); } function LinkCurl($url,$curlpost,$cookie_file){ $curl=curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $curlpost); curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file); curl_exec($curl); curl_close($curl); } function getCurlCon($url,$cookie_file){ $curl=curl_init($url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file); $data=curl_exec($curl); curl_close($curl); return $data; } ?>
|