-
- $url = '';//Login address of Zhengfang Academic Affairs System
- $ID = '';
- $PA = '';
- $cookieid = Get_SessionId($url);//Get The session ID of the login page
- /*
- is_login() function to determine whether the login is successful
- */
- function is_login()
- {
- global $url,$ID,$PA,$cookieid;
- preg_match('#value="( [^"]+)"#', curl_get($url), $vi);
- $p = '__VIEWSTATE=' . urlencode($vi[1]) . '&tbYHM=' . $ID . '&tbPSW=' . $PA . '&ddlSF=%D1%A7%C9%FA&imgDL.x=39&imgDL.y=13'; //Default student
- $co = curl_get($url, $p, 0, 0, 0, array(' Cookie: asp.net_SessionId=' . $cookieid));
- //curl_get('Address/xsleft.aspx?flag=grxx', array('Cookie: ASP.NET_SessionId=' . $cookieid)); //Get basic Information must be accessed before this address
- return strpos($co, "/xsmainfs.aspx?xh=" . $ID)? true : false ;
- } // bbs.it-home.org
- function curl_get($url, $ add_arry_header = 0)
- {
- $ch = curl_init($url);
- 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'));
- if ($add_arry_header)
- {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $add_arry_header);
- }
- curl_setopt($ ch, CURLOPT_RETURNTRANSFER, true);
- $get_url = curl_exec($ch);
- curl_close($ch);
- return $get_url;
- }
- function Get_SessionId($u) // Get the session ID of aspx
- {
- $a = get_headers($u);
- $a = str_replace(array(';', ':'), '&', $a[6]);
- parse_str($a, $aa);
- return $aa[ 'ASP_NET_SessionId'] ;
- }
- ?>
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
|