\r\n"; mail('jim.rolt@googlemail.com', $subject, $error, $headers); } //include'memcache.php'; include'dataedit/sql.php'; $county = is_numeric($_GET['county']) && $_GET['county'] > 0 ? $_GET['county'] : 1; $town = !empty($_GET['town']) ? str_replace('-', ' ',$_GET['town']) : 'Worcester'; $qtown = mysql_real_escape_string($_GET['town']); $act = mysql_query("SELECT SQL_CACHE Activities.ID, Activities.Name, ActivityTypes.TYPE FROM Activities INNER JOIN ActivityTypes ON ActivityTypes.ID = Activities.TYPE WHERE County = $county AND Town = '$qtown' Order by TYPE, Name ")or mailjim("act", mysql_error()); $shops = mysql_query("SELECT ID, Name, TYPE FROM Shops WHERE county = $county AND Town LIKE '".preg_replace("/[-\s]/", "_", $qtown)."' AND TYPE NOT IN(1,29) ")or die('shops serror: '.mysql_error()); $ant = mysql_query("SELECT ID, Name, TYPE FROM Shops WHERE county = $county AND Town LIKE '".preg_replace("/[-\s]/", "_", $qtown)."' AND TYPE = 1 ")or mailjim("ant", mysql_error()); $sql = "SELECT EstDetails.RecordID, EstDetails.Name, EstType, EstTypeAlt, EstType2, EstType3, Town, EstDetails.description, website, EstDetails.email, CountyName, CountyNameCut, CountyDetails.CountryID, reviews.id AS Rid, Details.DPrice FROM EstDetails LEFT JOIN Details ON Details.RecordID = EstDetails.RecordID INNER JOIN CountyDetails ON (County = CountyDetails.RecordID OR County2 = CountyDetails.RecordID) LEFT JOIN reviews ON EstDetails.RecordID = reviews.est AND reviews.display = 1 AND reviews.type = 1 WHERE List = 1 AND (EstDetails.County = $county OR EstDetails.County2 = $county) AND Town LIKE '".preg_replace("/[-\s]/", "_", $qtown)."' AND (EstType IN(4,15,17,19,20) OR EstType2 IN(4,15,17,19,20) OR EstType3 IN(4,15,17,19,20) OR EstTypeAlt IN(4,15,17,19,20)) ORDER BY RAND() "; //echo $sql; $poptemp = mysql_query($sql); //$poptemp = mysql_query_cache($sql); $details = array(); $chid = array(); $count = 0; $etarray = array('Self Catering' => 4,'Holiday Park' => 15,'Camping' => 17, 'Caravan' => 19, 'Cottage' => 20); //types we want to put on the page //foreach($poptemp AS $row){ while($row = mysql_fetch_object($poptemp)){ if($count == 0){ //get county name $CountyName = $row->CountyName; $CountyNameCut = $row->CountyNameCut; $CountryID = $row->CountryID; } foreach($etarray as $key => $value){ if($row->EstType == $value || $row->EstType2 == $value || $row->EstType3 == $value || $row->EstTypeAlt == $value){ $details[$key][$row->RecordID] = array('Name'=>$row->Name, 'Town'=>$row->Town, 'description'=>$row->description, 'website'=>$row->website, 'email'=>$row->email, 'Rid'=>$row->Rid, 'DPrice'=>$row->DPrice); //add establishment to details array if(!in_array($row->RecordID, $chid)){ $count ++; $chid[] = $row->RecordID;//count each establishment once only } } } } //print_r($details); //array_multisort($etarray, SORT_DESC, SORT_STRING,$details); krsort($details); $sql = "SELECT Towns.Description, brochure, brochurelink, telcode, Towns.postcode, population, gridref, snippet, council, jobs, clientpic, piclink, Towns.latitude, Towns.longitude, Towns.weather, EstDetails.Name, history FROM Towns LEFT JOIN EstDetails ON EstDetails.RecordID = Towns.council WHERE Towns.Name LIKE '".preg_replace("/[-\s]/", "_", $qtown)."' AND Towns.County = $county"; $tdetails = mysql_query($sql)or mailjim("towndetails", "$sql\n".mysql_error()); $towndetails = mysql_fetch_object($tdetails); //$tdetails = mysql_query_cache($sql); //$towndetails = $tdetails[0]; if($count > 1 && $count < 8 && $towndetails->latitude > 0){ $hotelids = array(); foreach($details as $a => $b){ foreach($b as $c => $d){ $hotelids[] = $c; } } $hotelids = array_unique($hotelids); $exclude = implode(',',$hotelids); $sql = "SELECT EstDetails.RecordID, EstDetails.Name, Town, EstDetails.description, website, EstDetails.email, reviews.id AS Rid, EstablishmentType.TYPE, Details.DPrice, SQRT( POW( 69.1 * ( latitude - $towndetails->latitude ) , 2 ) + POW( 69.1 * ( $towndetails->longitude - longitude ) * COS( latitude / 57.3 ) , 2 ) ) AS distance FROM EstDetails INNER JOIN EstablishmentType ON EstablishmentType.ID = EstType LEFT JOIN reviews ON EstDetails.RecordID = reviews.est AND reviews.display = 1 AND reviews.type = 1 LEFT JOIN Details ON Details.RecordID = EstDetails.RecordID WHERE latitude IS NOT NULL AND EstType IN(1,2,4,5,7) AND EstDetails.RecordID NOT IN($exclude) AND List = 1 GROUP BY distance ORDER BY distance ASC LIMIT 10"; if(!$others = mysql_query($sql)){ mailjim('others', $sql.mysql_error()."\nTown: ".$_GET['town']."\nCounty: ".$_GET['county']."\nCount = $count"); } //$others = mysql_query($sql)or mailjim('others', $sql.mysql_error()); //$others = mysql_query_cache($sql); //print_r($odetails); } $sql = "SELECT COUNT(*) AS num FROM EstDetails INNER JOIN reviews ON reviews.est = EstDetails.RecordID AND reviews.display = 1 WHERE county = $county AND town LIKE '".preg_replace("/[-\s]/", "_", $qtown)."'"; $townreviews = mysql_query($sql)or mailjim("Townreviews", "$sql\n".mysql_error()); $townrev = mysql_fetch_object($townreviews); $rev= mysql_query("SELECT countyreviews.id FROM countyreviews WHERE county = $county LIMIT 1"); $townurl = rawurlencode($town); echo <<Self Catering in $town. Online booking for $town hotels, $CountyName EOT; ?>
output; include'featuredtownhotels.php'; feature($county, $qtown); include'adviva.txt'; include'burstmedia.txt';; /*if($county == 16){ ?> The London Pass
Big Bus Tours
Books
Estate Agents
Dentists
Doctors
Solicitors
Markets
Attractions
Golf Courses
Health and Fitness
Racecourses
Theatres
EOT; ?>
postcode)){ $wday = date("D"); $wdate = date("j M"); $xml = simplexml_load_string($towndetails->weather, 'SimpleXMLElement', LIBXML_NOCDATA); echo <<
Click for 5 day $town Weather
$wday
$wdate
Max {$xml->Forecast[0]->maxtemp}°C
Min {$xml->Forecast[0]->mintemp}°C
{$xml->Forecast[0]->day->windicon}
{$xml->Forecast[0]->day->windspeed_mph} mph
{$xml->Forecast[0]->day->condition}
Provided by Weather2
EOT; } //include'cotts4u/cottbox.php'; ?>
Join in
Email page to a friend
\n"; $slashtown = urlencode($town); echo<<$town
- Britain's favourite town
EOT; if($county == 16){ echo'

London Tickets

'; } if(!empty($towndetails->telcode) || !empty($towndetails->postcode) || !empty($towndetails->population) || !empty($towndetails->gridref) || !empty($towndetails->council) || $townrev->num > 0){ echo"

Information"; if(isset($towndetails->brochure) && $towndetails->brochure == 1){ if(!empty($towndetails->brochurelink)){echo" | Free Brochure";} else{echo" | Free Brochure";} } echo"

$town Map
\n". "County - $CountyName
\n"; if(!empty($towndetails->telcode)){echo"Tel code: $towndetails->telcode | code search
\n";} if(!empty($towndetails->postcode)){echo"Postcode: $towndetails->postcode | code search
\n";} if(!empty($towndetails->population)){echo"Population: $towndetails->population
\n";} if(!empty($towndetails->gridref)){echo"Grid Reference: $towndetails->gridref
\n";} if(!empty($towndetails->council)){ $pos = stripos($towndetails->Name, 'council'); $councilname = ($pos === false) ? $towndetails->Name : substr($towndetails->Name, 0, $pos); echo"Council: $councilname
\n";} if(!empty($towndetails->jobs)){echo"$town Jobs
\n";} if(!empty($towndetails->tips)){echo"$town Travel Tips
\n";} if($townrev->num > 0){echo"$town Reviews ($townrev->num)
\n";} if(mysql_num_rows($rev) > 0){echo"Visitor reports
";} if(!empty($towndetails->history)){echo"$town History
\n";} if(!empty($towndetails->Description)){echo"$town townguide
\n";} echo<<Britains Favourite Town

EOT; } ?>
1 ? 'places' : 'place'; $linkcheck = array_unique($linkcheck); $join = ''; if(empty($towndetails->snippet)){ echo"

Self Catering in $town - $count $places to stay

\n

\n"; if(!empty($towndetails->Description)){ echo"Town Guide"; $join = ' | '; } echo in_array(1, $linkcheck) || in_array(5, $linkcheck) ? " | Hotels\n" : " | Hotels\n"; if(in_array(1, $linkcheck) && in_array(2, $linkcheck)){ echo " | B & Bs\n" ; } else{ echo in_array(2, $linkcheck) ? " | B & Bs\n" : " | B & Bs\n"; } foreach($etarray as $key => $value){ if($value != 4){ echo" | $key"; } } if($county != 16){ echo"$joinToday's Best Rates\n"; } echo'

'; } else{ $join = ','; echo"

\n$towndetails->snippet.. \n"; if(!empty($towndetails->Description)){echo"Read More.

";} echo in_array(1, $linkcheck) || in_array(5, $linkcheck) ? "Hotels\n" : "Hotels\n"; if(in_array(1, $linkcheck) && in_array(2, $linkcheck)){ echo ", B & Bs\n" ; } else{ echo in_array(2, $linkcheck) ? ", B & Bs\n" : ", B & Bs\n"; } foreach($etarray as $key => $value){ if($value != 4){ echo", $key"; } } if($county != 16){ echo" or you can find Today's Best Rates or get a LATE DEAL\n"; } echo'

'; } include'hotelsummarynew.php'; foreach($details as $key =>$value){showplace($key);} if(mysql_num_rows($others) > 0){ //if(!empty($others)){ echo"

Other Places to Stay near $town

\n"; $details = array(); while($row = mysql_fetch_object($others)){ // foreach($others as $row){ $details['Hotel'][$row->RecordID] = array('Name'=>$row->Name, 'Town'=>$row->Town, 'description'=>$row->description, 'website'=>$row->website, 'email'=>$row->email, 'Rid'=>$row->Rid, 'DPrice'=>$row->DPrice, 'distance'=>sprintf("%01.2f", $row->distance)); } foreach($details as $key =>$value){showplace($key);} } include'dailyfeature.php'; ?>