0) { array_push($errors, "The town selected does not exist."); } else { $name = get_town_name($town); $townLink = "Town of ".ucwords($name).""; $leftNav = build_left_nav($town, $townName, $page); if (!preg_match('/^\d+$/', $page)) { array_push($errors, "The page you selected to view does not exist."); } else { $query = @mysql_query( "SELECT COUNT(*) as total FROM pages WHERE page_town_id='$town' AND page_id='".$page."'" ); $row = mysql_fetch_assoc($query); if (!$row['total'] > 0) { array_push($errors, "This section is not available for the selected town."); } if (!preg_match('/^\s*$/', $_REQUEST['nid']) and !preg_match('/^\d+$/', $_REQUEST['nid'])) { array_push($errors, "The headline you selected does not exist."); } else { $query = @mysql_query( "SELECT COUNT(*) as total FROM news WHERE news_town_id='$town' AND news_id='".$_REQUEST['nid']."'" ); if (!$row['total'] > 0) { array_push($errors, "This headline is not available for the selected town."); } } if (!preg_match('/^\s*$/', $_REQUEST['mid']) and !preg_match('/^\d+$/', $_REQUEST['mid'])) { array_push($errors, "The meeting you selected does not exist."); } else { $query = @mysql_query( "SELECT COUNT(*) as total FROM town_meeting WHERE town_meeting_town_id='$town' AND town_meeting_id='".$_REQUEST['mid']."'" ); if (!$row['total'] > 0) { array_push($errors, "This meeting is not available for the selected town."); } } } } } if (count($errors) > 0) { return false; } else { return true; } } ////////////////////////////////////////////// // if there are errors, handle them ////////////////////////////////////////////// function error() { global $errors, $errorMessage; foreach ($errors as $key => $value) { $errorMessage .= $value . "
"; } } ////////////////////////////////////////////// // everything worked ////////////////////////////////////////////// function build_page() { global $town, $page, $pageTitle, $dbh; $query = @mysql_query( "SELECT page_title FROM pages WHERE page_town_id='$town' AND page_id='".$page."'" ); $row = mysql_fetch_assoc($query); $pageTitle = $row['page_title']; } ////////////////////////////////////////////// // comment form ////////////////////////////////////////////// function get_comment_form() { global $page, $dbh; $query = @mysql_query( "SELECT page_value_module_option_id, page_value_data FROM published_page_values WHERE page_value_page_id='$page'" ); $info = array(); while ($row = mysql_fetch_assoc($query)) { $info[$row['page_value_module_option_id']] = $row['page_value_data']; } $form = "

".$info['46']."

Comments:

Contact Information

Name:

Street:

City/Town:

State:

Zip:

Email:

Phone:

Preferred Contact Method:

"; return $form; } ////////////////////////////////////////////// // facilities ////////////////////////////////////////////// function get_values($template, $option) { global $page, $dbh; if ($template) { $queryAdd = "AND page_value_template_modules_id='$template'"; } $query = @mysql_query( "SELECT page_value_data FROM published_page_values WHERE page_value_page_id='$page' $queryAdd AND page_value_module_option_id='$option'" ); if (mysql_num_rows($query) <= 0) { $query = @mysql_query( "SELECT page_value_data FROM published_page_values WHERE page_value_page_id='$page' AND page_value_module_option_id='47'" ); } $row = mysql_fetch_assoc($query); if (preg_match('/^\s*$/', $row['page_value_data'])) { $row['page_value_data'] = "No information available"; } // make sure links are actually links return preg_replace('/(http:\/\/[\w\/\.\-\?\&\=]+)/', "$1", $row['page_value_data']); } ////////////////////////////////////////////// // get news items ////////////////////////////////////////////// function get_news() { global $page, $town; if (preg_match('/^\d+$/', $_REQUEST['nid'])) { $headlines = "

Back to News

"; $query = @mysql_query( "SELECT *, DATE_FORMAT(news_event_date, '%M %D, %Y') as display_date FROM news WHERE news_id='".$_REQUEST['nid']."'" ); $row = mysql_fetch_assoc($query); $headlines .= "

" . $row['display_date'] . "

"; $headlines .= "

" . $row['news_body'] . "

"; } else { if ($_REQUEST['archive'] == 1) { $query = @mysql_query( "SELECT *, DATE_FORMAT(news_event_date, '%M %D, %Y') as display_date FROM news WHERE news_town_id='$town' AND news_end_date != '0' AND DATE_ADD(news_start_date, INTERVAL news_end_date DAY) <= NOW() ORDER BY news_event_date DESC" ); } else { $query = @mysql_query( "SELECT *, DATE_FORMAT(news_event_date, '%M %D, %Y') as display_date FROM news WHERE news_town_id='$town' AND (( news_end_date = '0' ) OR ( DATE_ADD(news_start_date, INTERVAL news_end_date DAY) >= NOW() )) ORDER BY news_event_date DESC" ); } while ($row = mysql_fetch_assoc($query)) { $headlines .= "

".$row['display_date']." - ".$row['news_headline']."

"; } if (!preg_match('/^\s*$/', $headlines)) { $headlines .= "
"; if ($_REQUEST['archive'] == 1) { $headlines .= "

Back to News

"; } else { $headlines .= "

View Archived News

"; } } else { $headlines = "We're sorry, but there are currently no headlines."; } } return $headlines; } ////////////////////////////////////////////// // get news items ////////////////////////////////////////////// function get_meetings() { global $page, $town; $minutes = ''; if (preg_match('/^\d+$/', $_REQUEST['mid'])) { $query = @mysql_query( "SELECT *, DATE_FORMAT(town_meeting_date, '%b %D, %Y') as display_date FROM town_meeting WHERE town_meeting_id='".$_REQUEST['mid']."'" ); $row = mysql_fetch_assoc($query); $minutes .= "

Back to Meetings & Minutes

"; $minutes .= "

Date: ".$row['display_date']."

"; $minutes .= "

Time: ".$row['town_meeting_starttime']." - ".$row['town_meeting_endtime']."

"; $minutes .= "

Location: ".$row['town_meeting_location']."

"; $minutes .= "

Agenda/Description:

"; $minutes .= "

".$row['town_meeting_description']."

"; } else { // get town folder $query = @mysql_query( "SELECT town_folder FROM towns WHERE town_id='$town'" ); $thisTown = mysql_fetch_assoc($query); // get county folder $query = @mysql_query( "SELECT town_county_id FROM towns WHERE town_id='$town'" ); $cid = mysql_fetch_assoc($query); $query = @mysql_query( "SELECT county_folder FROM counties WHERE county_id='".$cid['town_county_id']."'" ); $thisCounty = mysql_fetch_assoc($query); // get minutes $query = @mysql_query( "SELECT COUNT(*) as total FROM town_meeting WHERE town_meeting_town_id='$town'" ); $row = mysql_fetch_assoc($query); if ($row['total'] > 0) { // upcoming meetings $query = @mysql_query( "SELECT *, DATE_FORMAT(town_meeting_date, '%b %D, %Y') as display_date FROM town_meeting WHERE town_meeting_town_id='$town' AND town_meeting_date > NOW() ORDER BY town_meeting_date DESC" ); if (mysql_num_rows($query) > 0) { $minutes .= "

Upcoming Meetings & Minutes

"; while ($row = mysql_fetch_assoc($query)) { if ($row['town_meeting_description_document_id'] != 0) { $docid = $row['town_meeting_description_document_id']; } else { $docid = false; } if ($row['town_meeting_minutes_document_id'] != 0) { $docid2 = $row['town_meeting_minutes_document_id']; } else { $docid2 = false; } $docLink = $row['town_meeting_name'] . "  "; if ($docid) { $query2 = @mysql_query( "SELECT document_location FROM documents WHERE document_id='".$docid."'" ); $link = mysql_fetch_assoc($query2); $docLink .= "(Agenda)  "; } if ($docid2) { $query3 = @mysql_query( "SELECT document_location FROM documents WHERE document_id='".$docid2."'" ); $link = mysql_fetch_assoc($query3); $docLink .= "(Minutes)  "; } $minutes .= "

".$row['display_date']." - $docLink

"; } } // past meetings $query = @mysql_query( "SELECT *, YEAR(town_meeting_date) as meeting_year, DATE_FORMAT(town_meeting_date, '%b %D, %Y') as display_date FROM town_meeting WHERE town_meeting_town_id='$town' AND town_meeting_date <= NOW() ORDER BY town_meeting_date DESC" ); if (mysql_num_rows($query) > 0) { $meetings = array(); $minutes .= "

Past Meetings & Minutes

"; while ($row = mysql_fetch_assoc($query)) { if ($row['town_meeting_description_document_id'] != 0) { $docid = $row['town_meeting_description_document_id']; } else { $docid = false; } if ($row['town_meeting_minutes_document_id'] != 0) { $docid2 = $row['town_meeting_minutes_document_id']; } else { $docid2 = false; } $docLink = $row['town_meeting_name'] . "  "; if ($docid) { $query2 = @mysql_query( "SELECT document_location FROM documents WHERE document_id='".$docid."'" ); $link = mysql_fetch_assoc($query2); $docLink .= "(Agenda)  "; } if ($docid2) { $query3 = @mysql_query( "SELECT document_location FROM documents WHERE document_id='".$docid2."'" ); $link = mysql_fetch_assoc($query3); $docLink .= "(Minutes)  "; } if (!is_array($meetings[$row['meeting_year']])) { $meetings[$row['meeting_year']] = array(); } array_push($meetings[$row['meeting_year']], "

".$row['display_date']." - $docLink

"); } foreach ($meetings as $key => $value) { $minutes .= "

$key

"; foreach ($meetings[$key] as $k => $v) { $minutes .= $v; } } } } else { $minutes = "

Currently no meetings/minutes available

"; } } return $minutes; } ////////////////////////////////////////////// // upcoming events ////////////////////////////////////////////// function get_calendar() { global $town, $page; $calendar = ''; $query = @mysql_query( "SELECT *, DATE_FORMAT(town_meeting_date, '%b %D, %Y') as display_date FROM town_meeting WHERE town_meeting_town_id='$town' AND town_meeting_date > NOW() ORDER BY town_meeting_date DESC" ); $row = mysql_fetch_assoc($query); if (mysql_num_rows($query) > 0) { $calendar .= "

".$row['display_date']." - ".$row['town_meeting_name']."

"; } else { $calendar .= "

No events currently scheduled

"; } return $calendar; } ////////////////////////////////////////////// // get related documents ////////////////////////////////////////////// function get_documents() { global $page, $town; $query = @mysql_query( "SELECT page_value_data FROM published_page_values WHERE page_value_page_id='$page' AND page_value_module_option_id='53'" ); $row = mysql_fetch_assoc($query); preg_match_all('/\{\w+\:\d+\:\"\w+\"\;\w+\:\d+\:\"(\d+)\"\;/', $row['page_value_data'], $matches); $count = 1; foreach ($matches[1] as $key => $value) { $queryAdd .= "'$value'"; if ($count < count($matches[1])) { $queryAdd .= ","; } $count++; } // get town folder $query = @mysql_query( "SELECT town_folder FROM towns WHERE town_id='$town'" ); $thisTown = mysql_fetch_assoc($query); // get county folder $query = @mysql_query( "SELECT town_county_id FROM towns WHERE town_id='$town'" ); $cid = mysql_fetch_assoc($query); $query = @mysql_query( "SELECT county_folder FROM counties WHERE county_id='".$cid['town_county_id']."'" ); $thisCounty = mysql_fetch_assoc($query); $query = @mysql_query( "SELECT document_location, document_type, document_name, document_size, document_description FROM documents WHERE document_id IN ($queryAdd)" ); $output = ""; if (mysql_num_rows($query)) { $output .= "

Related Documents:

"; while ($row = mysql_fetch_assoc($query)) { $output .= "".$row['document_name']." (".strtoupper($row['document_type']).") ".$row['document_size']."k
"; } $output .= "

"; } return $output; } ////////////////////////////////////////////// // if the page has an image, display it ////////////////////////////////////////////// function get_page_image() { global $page, $town; // get image alignment $query = @mysql_query( "SELECT page_value_data FROM published_page_values WHERE page_value_page_id='$page' AND page_value_module_option_id='52'" ); $row = mysql_fetch_assoc($query); $align = $row['page_value_data']; // get image ID $query = @mysql_query( "SELECT page_value_data FROM published_page_values WHERE page_value_page_id='$page' AND page_value_module_option_id='51'" ); $row = mysql_fetch_assoc($query); $query = @mysql_query( "SELECT photo_image, photo_caption FROM photos WHERE photo_id='".$row['page_value_data']."'" ); $row = mysql_fetch_assoc($query); // get town folder $query = @mysql_query( "SELECT town_folder FROM towns WHERE town_id='$town'" ); $thisTown = mysql_fetch_assoc($query); // get county folder $query = @mysql_query( "SELECT town_county_id FROM towns WHERE town_id='$town'" ); $cid = mysql_fetch_assoc($query); $query = @mysql_query( "SELECT county_folder FROM counties WHERE county_id='".$cid['town_county_id']."'" ); $thisCounty = mysql_fetch_assoc($query); $output = ''; if (count($row) > 0) { $image = "photos/".$thisCounty['county_folder']."/".$thisTown['town_folder']."/photos/200_".$row['photo_image']; if (file_exists($image)) { $output .= ""; } } return $output; } ?> Maine.gov: Local
Home > Local >

0) { print "Error"; } else { print $pageTitle; } ?>

0) { print $errorMessage; } else { print get_page_image(); if (preg_match('/comment form/i', $pageTitle)) { print get_comment_form(); } elseif (preg_match('/meetings/i', $pageTitle)) { print get_meetings(); $documents = false; } elseif (preg_match('/town calendar/i', $pageTitle)) { if (preg_match('/^\d+$/', $_REQUEST['mid'])) { print get_meetings(); $documents = false; } else { print get_calendar(); } } elseif (preg_match('/ordinances/i', $pageTitle)) { print get_values('', '50'); } elseif (preg_match('/town news/i', $pageTitle)) { print get_news(); } elseif (preg_match('/history/i', $pageTitle)) { print get_values('26', '47'); } elseif (preg_match('/most requested services/i', $pageTitle)) { print get_values('', '50'); print get_documents(); } elseif (preg_match('/facilities/i', $pageTitle)) { print get_values('20', '47'); } elseif (preg_match('/departments/i', $pageTitle)) { print get_values('22', '47'); } else { print get_values('', '50'); } if ($documents) { print get_documents(); } } ?>