set_inserts(array('PRODUCTSMENU' => 'productsMenu', 'DTD' => 'strictdtd', 'MAINMENU' => 'mainMenu')); $translations = new LG_Translations_Database($page, $db, 'translations_view', 'id', 'groupid', 'languagecode', 'languagelocal', 'countrycode', 'countrytranslationid', 'text', 'EN', 'GB', 'Hostels'); $pdo = get_pdo(); $user = get_user($page, $pdo); $user->login();# force sending of the cookies here so it doesn't try to send them when it's too late (incurring a warning) require_once('nusoap/nusoap.php'); #$soapClient = new nusoap_client('http://www.HostelBookers.com/api/remote/hbcontent.cfc?wsdl'); $soapClient = new nusoap_client('http://v1.hb-api.com/api/remote/hbcontent.cfc?wsdl'); $hostelBookersKey = '109917018'; if ('HostelWorld' == $affiliate) { $hostel_handle = $db->prepare('SELECT * FROM hostels WHERE propertyNumber = '.$propertyNumber.' AND affiliate = \'HostelWorld\'')->execute(); if ($property = mysqli_fetch_array($hostel_handle)) { # Use these later $location[country] = $property[country]; $location[province] = $property[province]; $location[town] = $property[town]; $location[latitude] = $property[latitude]; $location[longitude] = $property[longitude]; # If it's in the database $property[city] = $property[town]; $hostel_images_handle = $db->prepare('SELECT * FROM hostelimages WHERE propertyNumber = '.$propertyNumber)->execute(); $i = 0; while ($image = mysqli_fetch_array($hostel_images_handle)) { $property[PropertyImages][PropertyImage][$i][imageURL] = $image[imageURL]; $property[PropertyImages][PropertyImage][$i][imageWidth] = 45; $property[PropertyImages][PropertyImage][$i][imageHeight] = 45; $property[PropertyImages][PropertyImage][$i][imageType] = 'Thumbnail'; $i++; } $hostel_facilities_handle = $db->prepare('SELECT * FROM hostelfacilities WHERE propertyNumber = '.$propertyNumber)->execute(); $i = 0; while ($facility = mysqli_fetch_array($hostel_facilities_handle)) { $property[Facilities][facility][$i++] = $facility[facility]; } } else { # Else, get it dynamically $get = file_get_contents("http://reservations.bookhostels.com/xmlapi/PropertyInformation.php?PropertyNumber=$propertyNumber&UserID=interhike"); $get = str_replace('&', '&', $get); $XMLDoc = XML_unserialize($get); $property = $XMLDoc[PropertyInformation][Property]; } } else if ('HostelBookers' == $affiliate) { $hostel_handle = $db->prepare('SELECT * FROM hostels WHERE propertyNumber = '.$propertyNumber.' AND affiliate = \'HostelBookers\'')->execute(); if ($property = mysqli_fetch_array($hostel_handle)) { # Use these later $location[country] = $property[country]; $location[province] = $property[province]; $location[town] = $property[town]; $location[latitude] = $property[latitude]; $location[longitude] = $property[longitude]; # If it's in the database $property[city] = $property[town]; $hostel_images_handle = $db->prepare('SELECT * FROM hostelimages WHERE propertyNumber = '.$propertyNumber)->execute(); $i = 0; while ($image = mysqli_fetch_array($hostel_images_handle)) { $property[PropertyImages][PropertyImage][$i][imageURL] = $image[imageURL]; $property[PropertyImages][PropertyImage][$i][imageWidth] = 45; $property[PropertyImages][PropertyImage][$i][imageHeight] = 45; $property[PropertyImages][PropertyImage][$i][imageType] = 'Thumbnail'; $i++; } $hostel_facilities_handle = $db->prepare('SELECT * FROM hostelfacilities WHERE propertyNumber = '.$propertyNumber)->execute(); $i = 0; while ($facility = mysqli_fetch_array($hostel_facilities_handle)) { $property[Facilities][facility][$i++] = $facility[facility]; } } else { # Else, get it dynamically $hostel = $soapClient->call('getPropertyDataByID', array('KEY' => $hostelBookersKey, 'LANGUAGE' => 'en', 'PROPERTY' => $propertyNumber)); # Fake the HostelWorld data format $property[propertyName] = $hostel[RESPONSE][NAME]; $property[address1] = $hostel[RESPONSE][ADDRESS][STREET1]; $property[address2] = $hostel[RESPONSE][ADDRESS][STREET2]; $property[city] = $hostel[RESPONSE][ADDRESS][CITY]; $property[country] = $hostel[RESPONSE][ADDRESS][COUNTRY]; $property[description] = $hostel[RESPONSE][LONGDESCRIPTION]; $property[directions] = $hostel[RESPONSE][DIRECTIONS]; $i = 0; foreach ($hostel[RESPONSE][FEATURES] as $feature) { $property[Facilities][facility][$i++] = $feature; } $i = 0; foreach ($hostel[RESPONSE][IMAGES] as $image) { $property[PropertyImages][PropertyImage][$i][imageURL] = $image; $property[PropertyImages][PropertyImage][$i][imageWidth] = 45; $property[PropertyImages][PropertyImage][$i][imageHeight] = 45; $property[PropertyImages][PropertyImage][$i][imageType] = 'Thumbnail'; $i++; } } } $page->set_title("Book hostel rooms at $property[propertyName], $property[city] - Interhike"); $page->set_description("Online hostel booking at $property[propertyName], $property[city]. Make your reservation online and only pay a 10% deposit."); $page->set_keywords("book hostels, $property[propertyName], $property[city], reservations, hostel booking, hostel reservations"); $canonical = '/'.textToUrlPath($location[country]).'/'.textToUrlPath($location[province]).'/'.textToUrlPath($location[town]).'/h'.$propertyNumber.'-'.$affiliate.'-'.textToUrlPath($property[propertyName]).'.html'; $page->set_head(($location[latitude] ? '' : '').' '); $page->print_header(); $townlower = textToUrlPath($location[town]); $provincelower = textToUrlPath($location[province]); $countrylower = textToUrlPath($location[country]); $encodedTown = htmlentities($location[town], ENT_NOQUOTES, 'UTF-8'); $encodedTown = str_replace("'", ''',$encodedTown); $encodedProvince = htmlentities($location[province], ENT_NOQUOTES, 'UTF-8'); $encodedProvince = str_replace("'", ''',$encodedProvince); $translatedCountry = $translations->get($location[country]); echo '

'.$translations->get('Hostels').' > '.$translatedCountry.' > '.$encodedProvince.' > '.$encodedTown.' > '.$property[propertyName].'

'.$property[propertyName].'

'; echo "

This page gives a description of your selected hostel. You can make a hostel reservation from this page by choosing your preferred room type from the pull down menu (below right) and then selecting the number of guests in your group and hitting 'Book'. If no places are available, simply click the 'Back' button on your browser to come back to this page then click it again to go back and choose a different hostel in this region.


Get Interhike Widgets for your website

$property[propertyName]

$property[address1]
$property[address2]
$property[city]
$property[country]
"; if ($startDate and $numNights) { if ('HostelWorld' == $affiliate) { $get = file_get_contents("http://reservations.bookhostels.com/xmlapi/PropertyBookingInformation.php?PropertyNumber=$propertyNumber&DateStart=$startDate&NumNights=$numNights&UserID=interhike"); $get = str_replace('&', '&', $get); $XMLDoc = XML_unserialize($get); if ('No Beds Found' == $XMLDoc[SystemMessage][UserMessage][message]) { echo '

'.$XMLDoc[SystemMessage][UserMessage][detail].'

'; } else { echo '
'; if (isset($XMLDoc[PropertyBookingInformation][Rooms][RoomType][0])) { foreach ($XMLDoc[PropertyBookingInformation][Rooms][RoomType] as $room) { if (!$room[roomTypeCode]) {continue;} # preg_match('/^(\d+)_/', $room[roomTypeCode], $matches); if (preg_match('/^(\d+):([^:]+):(\d?):/', $room[roomTypeCode], $matches)) { $beds = $matches[1]; $room_description = $matches[2]; $ensuite = $matches[3]; $options = ''; for ($i = 0; $i <= ($matches[1] <= 8 ? $matches[1] : 8); $i++) { $options .= ""; } $field_prefix = 'x'.$beds.'_'.$room_description.'_'.($ensuite ? 1 : 0); # echo ''; echo ''; } } } else { $room = $XMLDoc[PropertyBookingInformation][Rooms][RoomType]; preg_match('/^(\d+)_/', $room[roomTypeCode], $matches); $options = ''; for ($i = 0; $i <= ($matches[1] <= 8 ? $matches[1] : 8); $i++) { $options .= ""; } echo ''; } echo '
'.$translations->get('Room').''.$translations->get('NumberOfGuests').'
'.$room[roomTypeDescription].' ('.getCurrencySymbol($room[BedPrice][currency]).$room[BedPrice][price].')
'.$room[roomTypeDescription].' ('.getCurrencySymbol($room[BedPrice][currency]).$room[BedPrice][price].')
'.$room[roomTypeDescription].' ('.getCurrencySymbol($room[BedPrice][currency]).$room[BedPrice][price].')
'; } } else if ('HostelBookers' == $affiliate) { $months = array( '01' => 'January', '02' => 'February', '03' => 'March', '04' => 'April', '05' => 'May', '06' => 'June', '07' => 'July', '08' => 'August', '09' => 'September', '10' => 'October', '11' => 'November', '12' => 'December' ); $hostel_availability = $soapClient->call('getPropertyAvailability', array('KEY' => $hostelBookersKey, 'LANGUAGE' => 'en', 'PROPERTY' => $propertyNumber, 'DATE' => "$start3-$months[$start2]-$start1", 'DAYS' => $numNights)); if ('' == $hostel_availability[RESPONSE][0][ID]) { echo '

No beds found for the time period selected

'; } else { echo '
'; } # echo '
# # # # # # # #'; # echo '
# # # # # # # # # # # # #
Room:Number of Guests:
'; # foreach ($hostel_availability[RESPONSE] as $room) { # echo ''; # } # echo '
Room:Number of Guests:
'.$room[NAME].' ('.getCurrencySymbol($hostel[RESPONSE][CURRENCY][CODE]).sprintf("%.2f", $room[PRICEFROM]).')
' # .$room[NAME].' ('.getCurrencySymbol($hostel[RESPONSE][CURRENCY][CODE]).sprintf("%.2f", $room[PRICEFROM]).')
'; # echo '
# # # # # # # # # #
'; # } } } else { echo ''.$translations->get('BookThisHostel').'
'.$translations->get('ArrivalDate').'
'; } $property[description] = str_replace( array('<','>','&',"\n"), array('<','>','&','

'), $property[description]); $property[directions] = str_replace( array('<','>','&',"\n"), array('<','>','&','

'), $property[directions]); echo "

$property[description]

Directions
$property[directions]

"; #echo '
'; echo '' .($google_images ? '' : '') .($google_videos ? '' : '') .'
'; if (is_array($property[Facilities][facility])) { echo '

Facilities:
'; foreach ($property[Facilities][facility] as $facility) { $facility = str_replace( array('<','>','&'), array('<','>','&'), $facility); echo "$facility
"; } echo '

'; } #echo '
'; echo '
'; if (is_array($property[PropertyImages][PropertyImage])) { foreach ($property[PropertyImages][PropertyImage] as $image) { if ('Thumbnail' == $image[imageType]) { if (preg_match('/^(.*)\/mini_([^\/]+)$/', $image[imageURL], $matches)) { # HostelWorld Thumbnails echo "$property[propertyName] $property[city] $property[country] "; } else if (preg_match('/^(.*-\d+)s(\.[\w\d]+)$/', $image[imageURL], $matches)) { # HostelBookers Thumbnails echo "$property[propertyName] $property[city] $property[country] "; } else { echo "$property[propertyName] $property[city] $property[country] "; } } } } #TODO threading # Images #$ch = curl_init(); #$search_term = $property[propertyName].', '.$location[province]; #$propertyname = str_replace(' ', '+', $search_term); #curl_setopt($ch, CURLOPT_TIMEOUT, 1); #curl_setopt($ch, CURLOPT_URL, 'http://ajax.googleapis.com/ajax/services/search/images?v=1.0&key=ABQIAAAACTjEqVrmOX0XEyC6nNbu-hQ38ELSWRWB7zFcXBRF0cMb45N4CxRREXzt59JwOl-Cz3lnJGuBdOLhiw&q='.$propertyname); #curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); #curl_setopt($ch, CURLOPT_REFERER, 'http://www.interhike.com'.$canonical); #$google_images_api = json_decode(curl_exec($ch)); #if ($google_images_api->responseData->results) { # foreach ($google_images_api->responseData->results as $photo) { # $google_images .= ''.$property[propertyName].' at Google '; # } #} # Videos #$ch = curl_init(); #curl_setopt($ch, CURLOPT_TIMEOUT, 1); #curl_setopt($ch, CURLOPT_URL, 'http://ajax.googleapis.com/ajax/services/search/video?v=1.0&key=ABQIAAAACTjEqVrmOX0XEyC6nNbu-hQ38ELSWRWB7zFcXBRF0cMb45N4CxRREXzt59JwOl-Cz3lnJGuBdOLhiw&q='.$propertyname); #curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); #curl_setopt($ch, CURLOPT_REFERER, 'http://www.interhike.com'.$canonical); #$google_videos_api = json_decode(curl_exec($ch)); #if ($google_videos_api->responseData->results) { # foreach ($google_videos_api->responseData->results as $video) { # $video->playUrl = str_replace('autoplay=1', '', $video->playUrl); # $video->playUrl = preg_replace('/&(?!amp;)/', '&', $video->playUrl); # $google_videos .= ''.$video->titleNoFormatting.'Play button'; # } #} echo '

Alternative "'.$search_term.'" Images

'.$google_images.'
Supplied by Google (may have nothing to do with this hostel)

"'.$search_term.'" Videos

'.$google_videos.'
Supplied by Google & Youtube (may have nothing to do with this hostel)

' .get_weather($db, $location[latitude], $location[longitude]); echo '

'.$property[propertyName].' Reviews

'; $review_handle = $db->prepare('SELECT * FROM hostelreviews hr INNER JOIN advertisers a ON hr.advertiser = a.uin WHERE propertyNumber = '.$propertyNumber.' AND affiliate = \''.$affiliate.'\' AND authorised IS NOT NULL')->execute(); while ($review_pointer = mysqli_fetch_array($review_handle)) { $reviews_found = 1; $date = explode(' ', $review_pointer[added]); echo '

'.$property[propertyName].' '.($review_pointer[rating] ? ''.$review_pointer[rating].'/5 '.$review_pointer[rating].' stars' : '').'

'.$review_pointer[review].'

'.($review_pointer[nickname] ? $review_pointer[nickname] : $review_pointer[uin]).' '.$date[0].'

'; } if (!$reviews_found) { echo '

No reviews found.

'; } echo '

Submit your own review

';' #

Other '.$property[propertyName].' Reviews

'; #if ('HostelWorld' == $affiliate) { # HostelWorld don't provide reviews #} else if ('HostelBookers' == $affiliate) { # $reviews = $soapClient->call('getPropertyReviews', array('KEY' => $hostelBookersKey, 'PROPERTY' => $propertyNumber, 'TOTALREVIEWS' => 25)); #print_r($reviews); # if ($reviews[response]) { # foreach ($reviews[response][reviews][review] as $review) { # $date = explode(' ', $review[date]); # echo '
'.$review[likedBeset].'

'.$review[name].' '.$date[0].'

'; # } # } #} echo '
'.get_threads($pdo, $page, $user, $location[country], $location[province], $location[town], 0, null, 1, $propertyNumber, $affiliate).'
'; $pageType = 'hostels'; $page->print_footer(); function get_weather($db, $latitude, $longitude) { if ($latitude and $longitude) { // PDO test //$blah = new PDO('mysql:localhost:3306;dbname='.$db_name, $db_username, $db_pwd); $cache_handle = $db->prepare('SELECT weather FROM weathercache WHERE ABS(latitude - '.$latitude.') < 0.01 AND ABS(longitude - '.$longitude.') < 0.01 AND cached > DATE_SUB(NOW(), INTERVAL 1 HOUR)')->execute(); if ($cache_pointer = mysqli_fetch_array($cache_handle)) { $weather_xml = simplexml_load_string($cache_pointer[weather]); } else { //$weather_cache = file_get_contents('http://www.worldweatheronline.com/feed/weather.ashx?lat='.$latitude.'&lon='.$longitude.'&num_of_days=5&key=a1fc89d0bd184235101305'); $weather_cache = file_get_contents('http://api.openweathermap.org/data/2.5/forecast/daily?lat='.$latitude.'&lon='.$longitude.'&cnt=6&units=metric&mode=xml&appid=a181d386669df53c0094f75699ba79bb'); $weather_xml = simplexml_load_string($weather_cache); $db->prepare('DELETE FROM weathercache WHERE ABS(latitude - '.$latitude.') < 0.01 AND ABS(longitude - '.$longitude.') < 0.01')->execute(); $weather_cache = str_replace('\'', '\\\'', $weather_cache); $db->prepare('INSERT INTO weathercache (latitude, longitude, weather, cached) VALUES ('.$latitude.', '.$longitude.', \''.$weather_cache.'\', NOW())')->execute(); } //$weather = weather_cell('Current', $weather_xml[data][current_condition][weatherDesc], $weather_xml[data][current_condition][weatherIconUrl], $weather_xml[data][current_condition][temp_C], undef, $weather_xml[data][current_condition][windspeedMiles], $weather_xml[data][current_condition][winddir16Point]); for ($i = 0; $i < 6; $i++) { $date = explode('-', $weather_xml[data][weather][$i][date]); $weather .= weather_cell(date('D jS', strtotime($weather_xml->forecast->time[$i]['day'])), ucwords($weather_xml->forecast->time[$i]->symbol['name']), 'http://openweathermap.org/img/w/'.$weather_xml->forecast->time[$i]->symbol['var'].'.png', round($weather_xml->forecast->time[$i]->temperature['max']), round($weather_xml->forecast->time[$i]->temperature['min']), round($weather_xml->forecast->time[$i]->windSpeed['mps'] * 3.6).'Km/h', $weather_xml->forecast->time[$i]->windDirection['code']); } return '
'.$weather.'
'; } } function weather_cell($date, $weather_desc, $icon, $max_c, $min_c, $wind_speed, $wind_dir) { if (preg_match('/^$/', $weather_desc, $matches)) { $weather_desc = $matches[1]; } if (preg_match('/^$/', $icon, $matches)) { $icon = $matches[1]; } return '
'.$date.'
'.$weather_desc.'
'.$weather_desc.'

Temp: '.('undef' != $max_c && 'undef' != $min_c ? $min_c.'-'.$max_c.'°C' : ('undef' != $max_c ? $max_c : ('undef' != $min_c ? $min_c : 'Unknown ')).'°C').'
Wind Speed: '.$wind_speed.'
Wind Dir: '.$wind_dir.'

'; } ?>