return $out;
}
-function getPage($url,$cookie=''){
+function getPage($url,$cookie,$post){
$url = str_replace('[month]',date('F'),$url); // replace month January through December
$url = str_replace('[day]',date('j'),$url); // replace day 1 to 31
$url = str_replace('[yesterday]',date('j',strtotime('yesterday')),$url); // replace day 1 to 31
'upload_file' => '@file_to_upload.png',
'upload_text' => '@text_to_upload'
);
- curl_setopt ($curl, CURLOPT_POSTFIELDS, $postFields);
*/
+ if ($post != ''){
+ curl_setopt ($curl, CURLOPT_POSTFIELDS, $post);
+ }
$html = curl_exec ($curl);
curl_close ($curl);
return $html;
// start a session to get a cookie
$form['url'] = 'https://voterservices.elections.maryland.gov/VoterSearch';
-$form['html'] = getPage($form['url']);
+$form['html'] = getPage($form['url'],'','');
// extract the cookie from the header (see CURLOPT_HEADER)
$cookie = cut_part_out('ASP.NET_SessionId=',';',$form['html']);
// extract the form elements we will need to post with our data
-$VIEWSTATE = cut_part_out('id="__VIEWSTATE" value="','"',$form['html']);
-$VIEWSTATEGENERATOR = cut_part_out('id="__VIEWSTATEGENERATOR" value="','"',$form['html']);
-$VIEWSTATEENCRYPTED = cut_part_out('id="__VIEWSTATEENCRYPTED" value="','"',$form['html']);
-$EVENTVALIDATION = cut_part_out('id="__EVENTVALIDATION" value="','"',$form['html']);
+$post['__VIEWSTATE'] = cut_part_out('id="__VIEWSTATE" value="','"',$form['html']);
+$post['__VIEWSTATEGENERATOR'] = cut_part_out('id="__VIEWSTATEGENERATOR" value="','"',$form['html']);
+$post['__VIEWSTATEENCRYPTED'] = cut_part_out('id="__VIEWSTATEENCRYPTED" value="','"',$form['html']);
+$post['__EVENTVALIDATION'] = cut_part_out('id="__EVENTVALIDATION" value="','"',$form['html']);
// Voter Info Form Elements
-$Languages_field = '$ctl00$MainContent$listLanguages';
-$Languages = "en";
+//$post['Languages_field'] = '$ctl00$MainContent$listLanguages';
+$post['$ctl00$MainContent$listLanguages'] = "en";
if (isset($_POST['SearchFirstName'])){
- $SearchFirstName_field = 'ctl00$MainContent$txtSearchFirstName';
- $SearchFirstName = $_POST['SearchFirstName'];
+ //$post['SearchFirstName_field'] = 'ctl00$MainContent$txtSearchFirstName';
+ $post['ctl00$MainContent$txtSearchFirstName'] = $_POST['SearchFirstName'];
}else{
- $SearchFirstName = '';
+ $post['ctl00$MainContent$txtSearchFirstName'] = '';
}
if (isset($_POST['SearchLastName'])){
- $SearchLastName_field = 'ctl00$MainContent$txtSearchLastName';
- $SearchLastName = $_POST['SearchLastName'];
+ //$post['SearchLastName_field'] = 'ctl00$MainContent$txtSearchLastName';
+ $post['ctl00$MainContent$txtSearchLastName'] = $_POST['SearchLastName'];
}else{
- $SearchLastName = '';
+ $post['ctl00$MainContent$txtSearchLastName'] = '';
}
if (isset($_POST['DOBMonth'])){
- $DOBMonth_field = 'ctl00$MainContent$txtDOBMonth';
- $DOBMonth = $_POST['DOBMonth'];
+ //$post['DOBMonth_field'] = 'ctl00$MainContent$txtDOBMonth';
+ $post['ctl00$MainContent$txtDOBMonth'] = $_POST['DOBMonth'];
}else{
- $DOBMonth = '';
+ $post['ctl00$MainContent$txtDOBMonth'] = '';
}
if (isset($_POST['DOBDay'])){
- $DOBDay_field = 'ctl00$MainContent$txtDOBDay';
- $DOBDay = $_POST['DOBDay'];
+ //$post['DOBDay_field'] = 'ctl00$MainContent$txtDOBDay';
+ $post['ctl00$MainContent$txtDOBDay'] = $_POST['DOBDay'];
}else{
- $DOBDay = '';
+ $post['ctl00$MainContent$txtDOBDay'] = '';
}
if (isset($_POST['DOBYear'])){
- $DOBYear_field = 'ctl00$MainContent$txtDOBYear';
- $DOBYear = $_POST['DOBYear'];
+ //$post['DOBYear_field'] = 'ctl00$MainContent$txtDOBYear';
+ $post['ctl00$MainContent$txtDOBYear'] = $_POST['DOBYear'];
}else{
- $DOBYear = '';
+ $post['ctl00$MainContent$txtDOBYear'] = '';
}
if (isset($_POST['SearchZipCode'])){
- $SearchZipCode_field = 'ctl00$MainContent$txtSearchZipCode';
- $SearchZipCode = $_POST['SearchZipCode'];
+ //$post['SearchZipCode_field'] = 'ctl00$MainContent$txtSearchZipCode';
+ $post['ctl00$MainContent$txtSearchZipCode'] = $_POST['SearchZipCode'];
}else{
- $SearchZipCode = '';
+ $post['ctl00$MainContent$txtSearchZipCode'] = '';
}
// debug - show full response make sure we have the cookie
echo "<li>COOKIE ASP.NET_SessionId $cookie</li>";
-echo "<li>POST VIEWSTATE $VIEWSTATE</li>";
-echo "<li>POST VIEWSTATEGENERATOR $VIEWSTATEGENERATOR</li>";
-echo "<li>POST VIEWSTATEENCRYPTED $VIEWSTATEENCRYPTED</li>";
-echo "<li>POST EVENTVALIDATION $EVENTVALIDATION</li>";
-echo "<li>POST SearchFirstName $SearchFirstName</li>";
-echo "<li>POST SearchLastName $SearchLastName</li>";
-echo "<li>POST DOBMonth $DOBMonth</li>";
-echo "<li>POST DOBDay $DOBDay</li>";
-echo "<li>POST DOBYear $DOBYear</li>";
-echo "<li>POST SearchZipCode $SearchZipCode</li>";
+echo "<li>POST VIEWSTATE $post[__VIEWSTATE]</li>";
+echo "<li>POST VIEWSTATEGENERATOR $post[__VIEWSTATEGENERATOR]</li>";
+echo "<li>POST VIEWSTATEENCRYPTED $post[__VIEWSTATEENCRYPTED]</li>";
+echo "<li>POST EVENTVALIDATION $post[__EVENTVALIDATION]</li>";
+echo "<li>POST SearchFirstName $post[ctl00$MainContent$txtSearchFirstName]</li>";
+echo "<li>POST SearchLastName $post[ctl00$MainContent$txtSearchLastName]</li>";
+echo "<li>POST DOBMonth $post[ctl00$MainContent$txtDOBMonth]</li>";
+echo "<li>POST DOBDay $post[ctl00$MainContent$txtDOBDay]</li>";
+echo "<li>POST DOBYear $post[ctl00$MainContent$txtDOBYear]</li>";
+echo "<li>POST SearchZipCode $post[ctl00$MainContent$txtSearchZipCode]</li>";
echo "<hr><hr><hr><h1>Voter Form</h1>";
echo htmlspecialchars($form['html']);
-echo '<hr><hr><hr><h1>Rendered</h1>';
+echo '<hr><hr><hr>';
//echo $form['html'];
?>
<form method='POST'>
</tr>
</table>
</form>
+<?PHP
+if ($post['ctl00$MainContent$txtSearchFirstName'] != ''){
+ $result['html'] = getPage($form['url'],$cookie,$post);
+ echo "<hr><hr><hr><h1>SBE API RESULTS</h1>";
+ echo htmlspecialchars($form['html']);
+}
+?>