PhpCURL: an example of simulating logon to the Zhengfang educational administration system

Source: Internet
Author: User
PhpCURL: an example of simulating logon to the Zhengfang educational administration system

  1. $ Url = ''; // logon address of the Zhengfang educational administration system
  2. $ ID = '';
  3. $ PA = '';
  4. $ Cookieid = Get_SessionId ($ url); // Obtain the session ID on the logon page.
  5. /*
  6. The is_login () function checks whether the logon is successful.
  7. */
  8. Function is_login ()
  9. {
  10. Global $ url, $ ID, $ PA, $ cookieid;
  11. Preg_match ('# value = "([^"] +) "#', curl_get ($ url), $ vi );
  12. $ P = '_ VIEWSTATE = '. urlencode ($ vi [1]). '& tbYHM = '. $ ID. '& tbPSW = '. $ PA. '& ddlSF = % D1 % A7 % C9 % FA & imgDL. x = 39 & imgDL. y = 13'; // Default Student
  13. $ Co = curl_get ($ url, $ p, 0, 0, 0, array ('cookie: asp.net _ SessionId = '. $ cookieid ));
  14. // Curl_get ('address/xsleft. aspx? Flag = grxx ', array ('cookie: ASP. NET_SessionId ='. $ cookieid); // you must access this address before obtaining basic information.
  15. Return strpos ($ co, "/xsmainfs. aspx? Xh = ". $ ID )? True: false;
  16. } // Bbs.it-home.org
  17. Function curl_get ($ url, $ add_arry_header = 0)
  18. {
  19. $ Ch = curl_init ($ url );
  20. Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ('User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) appleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16 '));
  21. If ($ add_arry_header)
  22. {
  23. Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ add_arry_header );
  24. }
  25. Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
  26. $ Get_url = curl_exec ($ ch );
  27. Curl_close ($ ch );
  28. Return $ get_url;
  29. }
  30. Function Get_SessionId ($ u) // gets the session ID of the aspx.
  31. {
  32. $ A = get_headers ($ u );
  33. $ A = str_replace (array (';', ':'), '&', $ a [6]);
  34. Parse_str ($ a, $ aa );
  35. Return $ aa ['asp _ net_sessionid'];
  36. }
  37. ?>

Note: The code is not fully available. it is only for reference and record. The logon address of the Zhengfang educational administration system is also the simplified logon box of defa4.4.aspx. the simulation should be simpler.

>>> More php simulated logon articles. topic links: php simulated logon php curl simulated logon tutorials

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.