College English 46 Grade query system core code

Source: Internet
Author: User
Tags explode query strlen trim ticket
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
    1. function query ($examid, $examtype) {
    2. $examid = Trim ($examid);
    3. $examtype = Trim ($examtype);
    4. if (!is_numeric ($examid)) {
    5. Return ' Admission number must be number ';
    6. }
    7. if (strlen ($examid)!= 15) {
    8. Return ' ticket number is not correct ';
    9. }
    10. if ($examtype = = ' 1 ') {
    11. if ((Substr ($examid, 6, 4)!= ' 0521 ') &&
    12. (Substr ($examid, 6, 4)!= ' 1052 ')) {
    13. Return ' admission number is not in conformity with the test type ';
    14. }
    15. }
    16. if ($examtype = = ' 2 ') {
    17. if ((Substr ($examid, 6, 4)!= ' 0512 ') &&
    18. (Substr ($examid, 6, 4)!= ' 0522 ') &&
    19. (Substr ($examid, 6, 4)!= ' 2052 ')) {
    20. Return ' admission number is not in conformity with the test type ';
    21. }
    22. }
    23. $examid 1 = substr ($examid, 0, 6). $examtype. ' 052 '. SUBSTR ($examid, 10, 5);
    24. $request = "examtype= $examtype &examid= $examid &image.x=23&image.y=32";
    25. $content _len = strlen ($request);
    26. $handle = @fsockopen (' cet.etang.com ', $errno, $ERRSTR, 10);
    27. $buf = ';
    28. $id = Base_convert (Mt_rand (). Mt_rand (), 10, 36);
    29. if ($handle) {
    30. $http _request =
    31. "Post/dog/cet http/1.0\r\n".
    32. "Accept: */*\r\n".
    33. "Referer:http://cet.etang.com/cet_girldemand_$id.htm\r\n".
    34. "User-agent:mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Alexa Toolbar) \ r \ n ".
    35. "Host:cet.etang.com\r\n".
    36. "Content-type:application/x-www-form-urlencoded\r\n".
    37. "Content-length: $content _len\r\n".
    38. "Cache-control:no-cache\r\n".
    39. "COOKIE:ZI=A; Examid1= $examid; Examtype1= $examtype; Sex=girl; examid= $examid 1; Examtype= $examtype \ r \ n ".
    40. "\ r \ n".
    41. $request;
    42. Fputs ($handle, $http _request, strlen ($http _request));
    43. while (!feof ($handle)) {
    44. $buf. = Fgets ($handle, 128);
    45. }
    46. Fclose ($handle);
    47. }
    48. else {
    49. Return "Query server temporarily unable to connect";
    50. }
    51. $buf = Explode ("\ r \ n", $buf);
    52. $buf = $buf [11];
    53. $score = "";
    54. if (substr ($buf, 0,) = = ' set-cookie:score= ') {
    55. $score = substr ($buf, Strpos ($buf, '; ')-18);
    56. }
    57. if (($score!= ') and ($score!= ' error ')) {
    58. $score = Explode (', ', $score);
    59. }
    60. else {
    61. Return ' The ticket number that you inquire does not exist ';
    62. }
    63. return $score;
    64. }


  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.