header('Content-type: text/html'); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header('X-Content-Type-Options: nosniff'); ?> ////////////////////////////////////////////// // county.php // Author: Derek Myska // // -- description -- // county info page ////////////////////////////////////////////// include_once("/mnt/cluster/www6/readysetgov/includes/common.php"); include_once('include/config.php'); include_once('include/lib.php'); clean_params(); // global vars $county = $_REQUEST['c']; $info = array(); ////////////////////////////////////////////// // validate ////////////////////////////////////////////// $query = @mysql_query( "SELECT COUNT(*) as total FROM counties WHERE counties.county_name='$county'" ) or die(ERROR_MESSAGE); $row = mysql_fetch_assoc($query); if($row['total'] == 0) { header("Location: index.html"); } ////////////////////////////////////////////// // get county contact information ////////////////////////////////////////////// $query = @mysql_query( "SELECT county_name, county_id FROM counties WHERE counties.county_name='$county'" ) or die(ERROR_MESSAGE); $row = mysql_fetch_assoc($query); $info['county_info']['county_name'] = $row['county_name']; $info['county_info']['county_id'] = $row['county_id']; ////////////////////////////////////////////// // get county facts ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM pages, published_page_values, counties WHERE counties.county_name='$county' AND pages.page_county_id=counties.county_id AND published_page_values.page_value_page_id=pages.page_id AND published_page_values.page_value_template_modules_id='12' AND published_page_values.page_value_module_option_id IN('19', '20', '21', '22', '23', '24', '25', '26', '27', '30') ORDER BY published_page_values.page_value_module_option_id" ) or die(ERROR_MESSAGE); while ($row = mysql_fetch_assoc($query)) { $info['contact_info']['option_' . $row['page_value_module_option_id']] = $row['page_value_data']; } // reformat the phone/fax numbers $info['contact_info']['option_24'] = preg_replace('/(\d{3})(\d{3})(\d{4})/', '($1) $2-$3', $info['contact_info']['option_24']); $info['contact_info']['option_25'] = preg_replace('/(\d{3})(\d{3})(\d{4})/', '($1) $2-$3', $info['contact_info']['option_25']); // set to N/A if its....well...N/A if (preg_match('/^\s*$/', $info['contact_info']['option_24'])) { $info['contact_info']['option_24'] = "N/A"; } if (preg_match('/^\s*$/', $info['contact_info']['option_25'])) { $info['contact_info']['option_25'] = "N/A"; } // address for initial mapping $address = $info['contact_info']['option_20'] . $info['contact_info']['option_21'] . ", " . $info['contact_info']['option_22'] . $info['contact_info']['option_23']; // build map it link $mapit = "https://www1.maine.gov/local/county.php?show=queryParam&"; $mapit .= "address=".$info['contact_info']['option_20']."&"; $mapit .= "city=".$info['contact_info']['option_21']."&"; $mapit .= "state=ME&"; $mapit .= "zip=".$info['contact_info']['option_23']."&"; //$mapit .= "name=County of $county&"; $mapit .= "c=$county"; ////////////////////////////////////////////// // get towns in this county ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM towns WHERE town_county_id='" . $info['county_info']['county_id'] . "' ORDER BY town_name" ) or die(ERROR_MESSAGE); $towns['ABCD'] = array(); $towns['EFGH'] = array(); $towns['IJKL'] = array(); $towns['MNOP'] = array(); $towns['QRST'] = array(); $towns['UVW'] = array(); $towns['XYZ'] = array(); while ($row = mysql_fetch_assoc($query)) { $letter = substr($row['town_name'], 0, 1); $town = "" . $row['town_name'] . ""; if (preg_match('/A|B|C|D/', $letter)) { array_push($towns['ABCD'], $town); } elseif (preg_match('/E|F|G|H/', $letter)) { array_push($towns['EFGH'], $town); } elseif (preg_match('/I|J|K|L/', $letter)) { array_push($towns['IJKL'], $town); } elseif (preg_match('/M|N|O|P/', $letter)) { array_push($towns['MNOP'], $town); } elseif (preg_match('/Q|R|S|T/', $letter)) { array_push($towns['QRST'], $town); } elseif (preg_match('/U|V|W/', $letter)) { array_push($towns['UVW'], $town); } elseif (preg_match('/X|Y|Z/', $letter)) { array_push($towns['XYZ'], $town); } } ////////////////////////////////////////////// // get the county facts ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM pages, published_page_values, counties WHERE counties.county_name='$county' AND pages.page_county_id=counties.county_id AND published_page_values.page_value_page_id=pages.page_id AND page_value_template_modules_id='11' AND published_page_values.page_value_module_option_id IN('34','35','36','37') ORDER BY published_page_values.page_value_module_option_id" ) or die(ERROR_MESSAGE); while ($row = mysql_fetch_assoc($query)) { $info['county_facts']['option_' . $row['page_value_module_option_id']] = $row['page_value_data']; } foreach ($info['county_facts'] as $key => $value) { $info['county_facts'][$key] = preg_replace('/.+\"VALUE\"\;s\:\d*\:\"(.+)\"\;\}$/', '$1', $value); } ////////////////////////////////////////////// // get the county online services ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM pages, published_page_values, counties WHERE counties.county_name='$county' AND pages.page_county_id=counties.county_id AND published_page_values.page_value_page_id=pages.page_id AND page_value_template_modules_id='13' AND published_page_values.page_value_module_option_id='29' ORDER BY published_page_values.page_value_module_option_id" ) or die(ERROR_MESSAGE); while ($row = mysql_fetch_assoc($query)) { $info['county_services']['option_' . $row['page_value_module_option_id']] = $row['page_value_data']; } foreach ($info['county_services'] as $key => $value) { preg_match_all('/\"(\d+)\"/', $value, $out); } $services = join(",", $out); foreach ($out[1] as $key => $value) { $values .= "'$value',"; } $values = preg_replace('/,$/', '', $values); $links = ''; if (!preg_match('/^\s*$/', $values)) { $query = @mysql_query( "SELECT * FROM online_services WHERE online_service_id IN($values)" ) or die(ERROR_MESSAGE); $i = 0; $info['county_services'] = array(); while ($row = mysql_fetch_assoc($query)) { $links .= "
" . $row['online_service_name'] . "
"; $info['county_services'][$i]['service'] = $row['online_service_name']; $info['county_services'][$i]['url'] = $row['online_service_url']; $i++; } } $links .= ""; ?>