2 ini_set('display_errors', 1);
3 ini_set('display_startup_errors', 1);
4 error_reporting(E_ALL
);
6 function cut_part_out($start,$end,$whole){
7 $parts = explode($start,$whole);
8 $subparts = explode($end,$parts[1]);
13 function getPage($url,$cookie=''){
14 $url = str_replace('[month]',date('F'),$url); // replace month January through December
15 $url = str_replace('[day]',date('j'),$url); // replace day 1 to 31
16 $url = str_replace('[yesterday]',date('j',strtotime('yesterday')),$url); // replace day 1 to 31
17 $url = str_replace('[year]',date('Y'),$url); // replace year Examples: 1999 or 2003
19 curl_setopt ($curl, CURLOPT_URL
, $url);
20 curl_setopt ($curl, CURLOPT_USERAGENT
, sprintf("McGuire MEPS https://www.md-petition.com/ /%d.0",rand(4,50)));
21 curl_setopt ($curl, CURLOPT_RETURNTRANSFER
, 1);
22 curl_setopt ($curl, CURLOPT_HEADER
, 1);
23 curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER
, 0);
24 curl_setopt ($curl, CURLOPT_FOLLOWLOCATION
, true);
26 curl_setopt ($curl, CURLOPT_HTTPHEADER
, array("Cookie: ASP.NET_SessionId=$cookie")); // use cookies
30 'upload_file' => '@file_to_upload.png',
31 'upload_text' => '@text_to_upload'
33 curl_setopt ($curl, CURLOPT_POSTFIELDS, $postFields);
35 $html = curl_exec ($curl);
40 // start a session to get a cookie
41 $form['url'] = 'https://voterservices.elections.maryland.gov/VoterSearch';
42 $form['html'] = getPage($form['url']);
44 // extract the cookie from the header (see CURLOPT_HEADER)
45 $cookie = cut_part_out('ASP.NET_SessionId=',';',$form['html']);
46 $VIEWSTATE = cut_part_out('id="__VIEWSTATE" value="','"',$form['html']);
47 // Found Form Elements
49 //__VIEWSTATEGENERATOR
50 //__VIEWSTATEENCRYPTED
52 //ctl00$MainContent$listLanguages = en
54 // debug - show full response make sure we have the cookie
55 echo "<li>COOKIE ASP.NET_SessionId $cookie</li>";
56 echo "<li>POST VIEWSTATE $VIEWSTATE</li>";
58 echo htmlspecialchars($form['html']);
59 echo '<hr><h1>Rendered</h1>';