d93c0f769c9c2ef4df9bf2fe8c9aac9db908d232
3 ini_set('display_errors', 1);
4 ini_set('display_startup_errors', 1);
5 error_reporting(E_ALL);
7 include_once('/var/www/secure.php'); //outside webserver
10 function cut_part_out($start,$end,$whole){
11 $parts = explode($start,$whole);
12 $subparts = explode($end,$parts[1]);
17 function MVgetPage($url,$cookie,$post){
18 $url = str_replace('[month]',date('F'),$url); // replace month January through December
19 $url = str_replace('[day]',date('j'),$url); // replace day 1 to 31
20 $url = str_replace('[yesterday]',date('j',strtotime('yesterday')),$url); // replace day 1 to 31
21 $url = str_replace('[year]',date('Y'),$url); // replace year Examples: 1999 or 2003
23 curl_setopt ($curl, CURLOPT_URL
, $url);
24 curl_setopt ($curl, CURLOPT_USERAGENT
, sprintf("McGuire MEPS https://www.md-petition.com/ /%d.0",rand(4,50)));
25 curl_setopt ($curl, CURLOPT_RETURNTRANSFER
, 1);
26 curl_setopt ($curl, CURLOPT_HEADER
, 1);
27 curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER
, 0);
28 curl_setopt ($curl, CURLOPT_FOLLOWLOCATION
, true);
30 curl_setopt ($curl, CURLOPT_HTTPHEADER
, array("Cookie: ASP.NET_SessionId=$cookie")); // use cookies
34 'upload_file' => '@file_to_upload.png',
35 'upload_text' => '@text_to_upload'
39 curl_setopt ($curl, CURLOPT_POSTFIELDS
, $post);
41 $html = curl_exec ($curl);
46 function md_voter_lookup($SearchFirstName,$SearchLastName,$DOBMonth,$DOBDay,$DOBYear,$SearchZipCode,$SearchHouseNumber,$SearchMiddleInitial){
48 $post['ctl00$MainContent$btnSearch'] = "Search";
49 $post['btnSearch'] = "Search";
50 $post['ctl00$MainContent$listLanguages'] = "en";
51 $post['listLanguages'] = "en";
52 $post['ctl00$MainContent$txtSearchFirstName'] = $SearchFirstName;
53 $post['txtSearchFirstName'] = $SearchFirstName;
54 $post['ctl00$MainContent$txtSearchLastName'] = $SearchLastName;
55 $post['txtSearchLastName'] = $SearchLastName;
56 $post['ctl00$MainContent$txtDOBMonth'] = $DOBMonth;
57 $post['txtDOBMonth'] = $DOBMonth;
58 $post['ctl00$MainContent$txtDOBDay'] = $DOBDay;
59 $post['txtDOBDay'] = $DOBDay;
60 $post['ctl00$MainContent$txtDOBYear'] = $DOBYear;
61 $post['txtDOBYear'] = $DOBYear;
62 $post['ctl00$MainContent$txtSearchZipCode'] = $SearchZipCode;
63 $post['txtSearchZipCode'] = $SearchZipCode;
64 $post['ctl00$MainContent$txtSearchHouseNumber'] = $SearchHouseNumber;
65 $post['txtSearchHouseNumber'] = $SearchHouseNumber;
66 $post['ctl00$MainContent$txtSearchMiddleInitial'] = $SearchMiddleInitial;
67 $post['txtSearchMiddleInitial'] = $SearchMiddleInitial;
68 // start a session to get a cookie
69 $form['url'] = 'https://voterservices.elections.maryland.gov/VoterSearch';
70 $form['html'] = MVgetPage($form['url'],'','');
71 // extract the cookie from the header (see CURLOPT_HEADER)
72 $cookie = cut_part_out('ASP.NET_SessionId=',';',$form['html']);
73 // extract the form elements we will need to post with our data
74 $post['__VIEWSTATE'] = cut_part_out('id="__VIEWSTATE" value="','"',$form['html']);
75 $post['__VIEWSTATEGENERATOR'] = cut_part_out('id="__VIEWSTATEGENERATOR" value="','"',$form['html']);
76 $post['__VIEWSTATEENCRYPTED'] = cut_part_out('id="__VIEWSTATEENCRYPTED" value="','"',$form['html']);
77 $post['__EVENTVALIDATION'] = cut_part_out('id="__EVENTVALIDATION" value="','"',$form['html']);
78 $result['html'] = MVgetPage($form['url'],$cookie,$post);
79 //echo "<h1>STEP 2: SBE RESULTS</h1>";
80 $return['debug'] = htmlspecialchars($result['html']);
81 $return['html'] = $result['html'];
82 $html = $petition->real_escape_string($result['html']);
83 $petition->query("INSERT INTO `RemoteVoterList` (`date_validated`, `txtSearchFirstName`, `txtSearchLastName`, `txtDOBMonth`, `txtDOBDay`, `txtDOBYear`, `txtSearchZipCode`, `txtSearchHouseNumber`, `txtSearchMiddleInitial`, `sbe_response`)
84 VALUES (now(), '$SearchFirstName', '$SearchLastName', '$DOBMonth', '$DOBDay', '$DOBYear', '$SearchZipCode', '$SearchHouseNumber', '$SearchMiddleInitial', '$html')");
88 if (isset($_POST['SearchFirstName'])){
89 $voter = md_voter_lookup($_POST['SearchFirstName'],$_POST['SearchLastName'],$_POST['DOBMonth'],$_POST['DOBDay'],$_POST['DOBYear'],$_POST['SearchZipCode'],$_POST['SearchHouseNumber'],$_POST['SearchMiddleInitial']);
96 <td>SearchFirstName</td><td><input name='SearchFirstName'></td>
99 <td>SearchLastName</td><td><input name='SearchLastName'></td>
102 <td>DOBMonth</td><td><input name='DOBMonth'></td>
105 <td>DOBDay</td><td><input name='DOBDay'></td>
108 <td>DOBYear</td><td><input name='DOBYear'></td>
111 <td>SearchZipCode</td><td><input name='SearchZipCode'></td>
114 <td>SearchHouseNumber*</td><td><input name='SearchHouseNumber'></td>
117 <td>SearchMiddleInitial*</td><td><input name='SearchMiddleInitial'></td>
120 <td>*Optional</td><td><input type='submit'></td>