PhpCURL: an example of simulating logon to the Zhengfang educational administration system
- $ Url = ''; // logon address of the Zhengfang educational administration system
- $ ID = '';
- $ PA = '';
- $ Cookieid = Get_SessionId ($ url); // Obtain the session ID on the logon page.
- /*
- The is_login () function checks whether the logon 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); // you must access this address before obtaining basic information.
- 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) // gets the session ID of the aspx.
- {
- $ A = get_headers ($ u );
- $ A = str_replace (array (';', ':'), '&', $ a [6]);
- Parse_str ($ a, $ aa );
- Return $ aa ['asp _ net_sessionid'];
- }
- ?>
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 |