Query system
A few days ago did a college English 46 grade query system, a PHPRPC version , a WAP version . Their core code is the same. Here is the core code for getting college English 46 grades from Etang.cet:
Download:cetquery.php
- function query ($examid, $examtype) {
- $examid = Trim ($examid);
- $examtype = Trim ($examtype);
- if (!is_numeric ($examid)) {
- Return ' Admission number must be number ';
- }
- if (strlen ($examid)!= 15) {
- Return ' ticket number is not correct ';
- }
- if ($examtype = = ' 1 ') {
- if ((Substr ($examid, 6, 4)!= ' 0521 ') &&
- (Substr ($examid, 6, 4)!= ' 1052 ')) {
- Return ' admission number is not in conformity with the test type ';
- }
- }
- if ($examtype = = ' 2 ') {
- if ((Substr ($examid, 6, 4)!= ' 0512 ') &&
- (Substr ($examid, 6, 4)!= ' 0522 ') &&
- (Substr ($examid, 6, 4)!= ' 2052 ')) {
- Return ' admission number is not in conformity with the test type ';
- }
- }
- $examid 1 = substr ($examid, 0, 6). $examtype. ' 052 '. SUBSTR ($examid, 10, 5);
- $request = "examtype= $examtype &examid= $examid &image.x=23&image.y=32";
- $content _len = strlen ($request);
- $handle = @fsockopen (' cet.etang.com ', $errno, $ERRSTR, 10);
- $buf = ';
- $id = Base_convert (Mt_rand (). Mt_rand (), 10, 36);
- if ($handle) {
- $http _request =
- "Post/dog/cet http/1.0\r\n".
- "Accept: */*\r\n".
- "Referer:http://cet.etang.com/cet_girldemand_$id.htm\r\n".
- "User-agent:mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar) \ r \ n ".
- "Host:cet.etang.com\r\n".
- "Content-type:application/x-www-form-urlencoded\r\n".
- "Content-length: $content _len\r\n".
- "Cache-control:no-cache\r\n".
- "COOKIE:ZI=A; Examid1= $examid; Examtype1= $examtype; Sex=girl; examid= $examid 1; Examtype= $examtype \ r \ n ".
- "\ r \ n".
- $request;
- Fputs ($handle, $http _request, strlen ($http _request));
- while (!feof ($handle)) {
- $buf. = Fgets ($handle, 128);
- }
- Fclose ($handle);
- }
- else {
- Return "Query server temporarily unable to connect";
- }
- $buf = Explode ("\ r \ n", $buf);
- $buf = $buf [11];
- $score = "";
- if (substr ($buf, 0,) = = ' set-cookie:score= ') {
- $score = substr ($buf, Strpos ($buf, '; ')-18);
- }
- if (($score!= ') and ($score!= ' error ')) {
- $score = Explode (', ', $score);
- }
- else {
- Return ' The ticket number that you inquire does not exist ';
- }
- return $score;
- }