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'); ?> ////////////////////////////////////////////// // town.php // Author: Derek Myska // // -- description -- // town info page for all non-grandfathered // towns ////////////////////////////////////////////// include_once("/mnt/cluster/www6/readysetgov/includes/common.php"); include_once('include/config.php'); include_once('include/lib.php'); clean_params(); // global vars $town = $_REQUEST['t']; $info = array(); // clear drop select if not in a necessary town if (preg_match('/bmv|wic|park|career|court|dhhs/i', $town)) { $_REQUEST['drop_select'] = ''; } ////////////////////////////////////////////// // validate ////////////////////////////////////////////// $query = @mysql_query( "SELECT town_id FROM towns WHERE town_name LIKE '$town'" ) or die(ERROR_MESSAGE); $row = mysql_fetch_assoc($query); if (!preg_match('/^\d+$/', $row['town_id'])) { header("Location: index.html"); } else { $townName = $town; $town = $row['town_id']; } if ($GRANDFATHERED[$town] == 1) { header("Location: town2.php?t=$townName"); } ////////////////////////////////////////////// // get town contact information ////////////////////////////////////////////// $query = @mysql_query( "SELECT town_name, town_id FROM towns WHERE towns.town_id='$town'" ) or die(ERROR_MESSAGE); $row = mysql_fetch_assoc($query); $info['town_info']['town_name'] = $row['town_name']; $info['town_info']['town_id'] = $row['town_id']; ////////////////////////////////////////////// // get town facts ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM pages, published_page_values, towns WHERE towns.town_id='$town' AND pages.page_town_id=towns.town_id AND published_page_values.page_value_page_id=pages.page_id AND published_page_values.page_value_template_modules_id='4' AND published_page_values.page_value_module_option_id IN ( '9', '10', '11', '12', '13', '14', '15', '16', '17', '18' ) ORDER BY published_page_values.page_value_module_option_id" ) or die(ERROR_MESSAGE); while ($row = mysql_fetch_assoc($query)) { $info['town_facts']['option_' . $row['page_value_module_option_id']] = $row['page_value_data']; } foreach ($info['town_facts'] as $key => $value) { if (preg_match('/.+\"VALUE\"\;s\:\d*\:\".+\"\;\}$/', $info['town_facts'][$key])) { $info['town_facts'][$key] = preg_replace('/.+\"VALUE\"\;s\:\d*\:\"(.+)\"\;\}$/', '$1', $value); } else { $info['town_facts'][$key] = "N/A"; } } $countyLink = strtolower($info['town_facts']['option_9']); $senate = explode(",", $info['town_facts']['option_11']); $house = explode(",", $info['town_facts']['option_12']); $senateAll = array(); foreach ($senate as $key => $value) { array_push($senateAll, $value); } $houseAll = array(); foreach ($house as $key => $value) { array_push($houseAll, $value); } ////////////////////////////////////////////// // get town contact information ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM pages, published_page_values, towns WHERE towns.town_id='$town' AND pages.page_town_id=towns.town_id AND published_page_values.page_value_page_id=pages.page_id AND published_page_values.page_value_template_modules_id='5' AND published_page_values.page_value_module_option_id IN ( '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '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']; } foreach ($info['contact_info'] as $key => $value) { $info['contact_info'][$key] = preg_replace('/.+\"VALUE\"\;s\:\d*\:\"(.+)\"\;\}$/', '$1', $value); } // 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"; } // check the official web site link if ($info['contact_info']['option_26']) { if (!preg_match('/^http\:\/\//i', $info['contact_info']['option_26'])) { $info['contact_info']['option_26'] = "http://".$info['contact_info']['option_26']; } $info['contact_info']['option_26'] = "
Website: Official Website
"; } // build map it link $mapit = "https://www.maine.gov/local/town.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=Town of $townName&"; $mapit .= "t=".$townName; ////////////////////////////////////////////// // get the county online services ////////////////////////////////////////////// $query = @mysql_query( "SELECT * FROM pages, published_page_values, towns WHERE towns.town_id='$town' AND pages.page_town_id=towns.town_id AND published_page_values.page_value_page_id=pages.page_id AND page_value_template_modules_id='6' 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['town_services']['option_' . $row['page_value_module_option_id']] = $row['page_value_data']; } foreach ($info['town_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 = ''; print ""; if (!preg_match('/^\s*$/', $values)) { print ""; $query = @mysql_query( "SELECT * FROM online_services WHERE online_service_id IN($values)" ) or die(ERROR_MESSAGE); $i = 0; $info['town_services'] = array(); while ($row = mysql_fetch_assoc($query)) { $links .= "" . $row['online_service_name'] . "
"; $info['town_services'][$i]['service'] = $row['online_service_name']; $info['town_services'][$i]['url'] = $row['online_service_url']; $i++; } } $links .= ""; ?>