$zip = ""; $use_html = ""; if (isset($_REQUEST["zip"])) { $zip = $_REQUEST["zip"]; } if (isset($_REQUEST["use_html"])) { $use_html = $_REQUEST["use_html"]; } if (!is_numeric($zip)) { if($use_html == 'yes') { echo '
'; }
echo "Your entry: $zip\n";
echo "Usage: LIBRARY 12345\n\nwhere 12345 is your five-digit ZIP code.";
if($use_html == 'yes') { echo ''; }
exit();
}
$submit_url = 'https://harvester.census.gov/imls/search/library_list.asp';
$submit_vars['Zip'] = $zip;
$submit_vars['Distance'] = '50';
$submit_vars['Librarytype'] = 'CE';
$submit_vars['Librarytype'] = 'BR';
$submit_vars['ResultSetNumber'] = '1';
$submit_vars['LibTypes'] = 'CE,BR';
$submit_vars['StateSelectedIndex'] = '0';
$curl = curl_init($submit_url . '?' . http_build_query($submit_vars));
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$rawhtml = curl_exec($curl);
$pattern = "/Library_Detail.*(.*)<\/span><\/a>' . print_r($library, TRUE) . ''; echo '
' . htmlspecialchars($rawhtml) . ''; */ if (isset($library[1][0])) { $response = trim($library[1][0]) . "\n" . trim(str_replace(" ", " ", $library[2][0])) . "\n" . trim($library[3][0]); } else { $response = 'Sorry, we could not find any libraries within 50 miles of ' . $zip . '.'; } if($use_html == 'yes') { echo '
'; }
echo $response;
if($use_html == 'yes') { echo ''; }
exit();
?>