Home > Backend Development > PHP Tutorial > Example of php CURL simulated login to Zhengfang Academic Affairs System

Example of php CURL simulated login to Zhengfang Academic Affairs System

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-25 08:53:00
Original
1153 people have browsed it
  1. $url = '';//Login address of Zhengfang Academic Affairs System
  2. $ID = '';
  3. $PA = '';
  4. $cookieid = Get_SessionId($url);//Get The session ID of the login page
  5. /*
  6. is_login() function to determine whether the login 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)); //Get basic Information must be accessed before this address
  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) // Get the session ID of 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. ?>
Copy code

Instructions: The code is not fully available, just for reference and recording. The login address of Zhengfang Academic Affairs System also has a simplified login box of default4.aspx, and the simulation should be simpler.

>>> More php simulated login articles, topic links: php simulated login php curl simulated login tutorials



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template