function jsonDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type, $callback) { if ($response) { $name = getNameDetail($langs, $nameresponse); $phone = getPhoneFaxDetail(array($response['phone1'], $response['phone2'], $response['phone3'])); $fax = getPhoneFaxDetail(array($response['fax1'], $response['fax2'], $response['fax3'])); $mobilephone = getPhoneFaxDetail(array($element['mobilephone1'], $element['mobilephone2'])); $website = getWebsiteDetail(array($response['website1'], $response['website2'], $response['website3'], $response['website4'])); $email = getMailDetail(array($response['email1'], $response['email2'], $response['email3'])); // get wikipedia link and make translation if ($wikipediaresponse) { $wikipedia = getWikipediaDetail($langs, $wikipediaresponse); } $openinghours = getOpeninghoursDetail($response['openinghours']); $servicetimes = getOpeninghoursDetail($response['servicetimes']); $data = array('id' => (int) $id, 'type' => $type); // name if ($name) { if ($name[0]) { $data['name'] = array('lang' => $name[1], 'name' => $name[0]); } else { $data['name'] = $name[0]; } } // address information if ($response['street']) { $data['street'] = $response['street']; } if ($response['housenumber']) { $data['housenumber'] = $response['housenumber']; } if ($response['country']) { $data['country'] = strtoupper($response['country']); } if ($response['postcode']) { $data['postcode'] = $response['postcode']; } if ($response['city']) { $data['city'] = $response['city']; } if ($response['suburb']) { $data['suburb'] = $response['suburb']; } // contact information if ($phone) { $tmp = array(); foreach ($phone as $phonenumber) { array_push($tmp, $phonenumber[1]); } $data['phone'] = $tmp; } if ($fax) { $tmp = array(); foreach ($fax as $faxnumber) { array_push($tmp, $faxnumber[1]); } $data['fax'] = $tmp; } if ($mobilephone) { $tmp = array(); foreach ($mobilephone as $mobilephonenumber) { array_push($tmp, $mobilephonenumber[1]); } $data['mobilephone'] = $tmp; } if ($email) { $data['email'] = $email; } // website and wikipedia links if ($website) { $tmp = array(); foreach ($website as $webaddress) { array_push($tmp, $webaddress[0]); } $data['website'] = $tmp; } if ($wikipedia[1]) { $data['wikipedia'] = $wikipedia[1]; } // operator if ($response['operator']) { $data['operator'] = $response['operator']; } // opening hours if ($openinghours) { if (isPoiOpen($response['openinghours'], $offset)) { $state .= "open"; } else { if (isInHoliday($response['openinghours'], $offset)) { $state .= "maybeopen"; } else { $state .= "closed"; } } $data['openinghours'] = array('state' => $state, 'openinghours' => $response['openinghours']); } // service times if ($servicetimes) { if (isPoiOpen($response['servicetimes'], $offset)) { $state .= "open"; } else { if (isInHoliday($response['servicetimes'], $offset)) { $state .= "maybeopen"; } else { $state .= "closed"; } } $data['servicetimes'] = array('state' => $state, 'servicetimes' => $response['servicetimes']); } // image, only images from domains listed on a whitelist are supported if (imageDomainAllowed($response['image'])) { $data['image'] = getImageUrl($response['image']); } else { if (getWikipediaImage($wikipedia[1])) { $data['image'] = getWikipediaImage($wikipedia[1]); } } $jsonData = json_encode($data); // JSONP request? if (isset($callback)) { return $callback . '(' . $jsonData . ')'; } else { return $jsonData; } } else { return false; } }
function jsonMoreDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type, $callback) { if ($response) { $name = getNameDetail($langs, $nameresponse); $phone = getPhoneFaxDetail(array($response['phone1'], $response['phone2'], $response['phone3'])); $fax = getPhoneFaxDetail(array($response['fax1'], $response['fax2'], $response['fax3'])); $mobilephone = getPhoneFaxDetail(array($response['mobilephone1'], $response['mobilephone2'])); $website = getWebsiteDetail(array($response['website1'], $response['website2'], $response['website3'], $response['website4'])); $email = getMailDetail(array($response['email1'], $response['email2'], $response['email3'])); // get wikipedia link and make translation if ($wikipediaresponse) { $wikipedia = getWikipediaDetail($langs, $wikipediaresponse); } $openinghours = getOpeninghoursDetail($response['openinghours']); $servicetimes = getOpeninghoursDetail($response['servicetimes']); $data = array('id' => (int) $id, 'type' => $type); // name if ($name) { if ($name[0]) { $data['name'] = array('lang' => $name[1], 'name' => $name[0]); } else { $data['name'] = $name[0]; } } if ($response['description']) { $data['description'] = $response['description']; } // address information if ($response['street']) { $data['street'] = $response['street']; } if ($response['housenumber']) { $data['housenumber'] = $response['housenumber']; } if ($response['country']) { $data['country'] = strtoupper($response['country']); } if ($response['postcode']) { $data['postcode'] = $response['postcode']; } if ($response['city']) { $data['city'] = $response['city']; } if ($response['suburb']) { $data['suburb'] = $response['suburb']; } // contact information if ($phone) { $tmp = array(); foreach ($phone as $phonenumber) { array_push($tmp, $phonenumber[1]); } $data['phone'] = $tmp; } if ($fax) { $tmp = array(); foreach ($fax as $faxnumber) { array_push($tmp, $faxnumber[1]); } $data['fax'] = $tmp; } if ($mobilephone) { $tmp = array(); foreach ($mobilephone as $mobilephonenumber) { array_push($tmp, $mobilephonenumber[1]); } $data['mobilephone'] = $tmp; } if ($email) { $data['email'] = $email; } // website link if ($website) { $tmp = array(); foreach ($website as $webaddress) { array_push($tmp, $webaddress[0]); } $data['website'] = $tmp; } // operator if ($response['operator']) { $data['operator'] = $response['operator']; } // opening hours if ($openinghours) { if (isPoiOpen($response['openinghours'], $offset)) { $state .= "open"; } else { if (isInHoliday($response['openinghours'], $offset)) { $state .= "maybeopen"; } else { $state .= "closed"; } } $data['openinghours'] = array('state' => $state, 'openinghours' => $response['openinghours']); } // service times if ($servicetimes) { if (isPoiOpen($response['servicetimes'], $offset)) { $state .= "open"; } else { if (isInHoliday($response['servicetimes'], $offset)) { $state .= "maybeopen"; } else { $state .= "closed"; } } $data['servicetimes'] = array('state' => $state, 'servicetimes' => $response['servicetimes']); } // fuel details if ($response['carwash'] || $response['carrepair'] || $response['kiosk'] || $response['diesel'] == "yes" || $response['gtldiesel'] == "yes" || $response['hgvdiesel'] == "yes" || $response['biodiesel'] == "yes" || $response['octane91'] == "yes" || $response['octane95'] == "yes" || $response['octane98'] == "yes" || $response['octane100'] == "yes" || $response['octane98l'] == "yes" || $response['fuel25'] == "yes" || $response['fuel50'] == "yes" || $response['alcohol'] == "yes" || $response['ethanol'] == "yes" || $response['methanol'] == "yes" || $response['svo'] == "yes" || $response['e85'] == "yes" || $response['biogas'] == "yes" || $response['lpg'] == "yes" || $response['cng'] == "yes" || $response['lh2'] == "yes" || $response['electro'] == "yes" || $response['adblue'] == "yes") { $data['fuel'] = array(); // fuel sorts if ($response['diesel'] == "yes") { array_push($data['fuel'], "diesel"); } if ($response['gtldiesel'] == "yes") { array_push($data['fuel'], "gtldiesel"); } if ($response['hgvdiesel'] == "yes") { array_push($data['fuel'], "hgvdiesel"); } if ($response['biodiesel'] == "yes") { array_push($data['fuel'], "biodiesel"); } if ($response['octane91'] == "yes") { array_push($data['fuel'], "octane91"); } if ($response['octane95'] == "yes") { array_push($data['fuel'], "octane95"); } if ($response['octane98'] == "yes") { array_push($data['fuel'], "octane98"); } if ($response['octane100'] == "yes") { array_push($data['fuel'], "octane100"); } if ($response['octane98l'] == "yes") { array_push($data['fuel'], "octane98l"); } if ($response['fuel25'] == "yes") { array_push($data['fuel'], "1:25"); } if ($response['fuel50'] == "yes") { array_push($data['fuel'], "1:50"); } if ($response['alcohol'] == "yes") { array_push($data['fuel'], "alcohol"); } if ($response['ethanol'] == "yes") { array_push($data['fuel'], "ethanol"); } if ($response['methanol'] == "yes") { array_push($data['fuel'], "methanol"); } if ($response['svo'] == "yes") { array_push($data['fuel'], "svo"); } if ($response['e10'] == "yes") { array_push($data['fuel'], "e10"); } if ($response['e85'] == "yes") { array_push($data['fuel'], "e85"); } if ($response['biogas'] == "yes") { array_push($data['fuel'], "biogas"); } if ($response['lpg'] == "yes") { array_push($data['fuel'], "lpg"); } if ($response['cng'] == "yes") { array_push($data['fuel'], "cng"); } if ($response['lh2'] == "yes") { array_push($data['fuel'], "lh2"); } if ($response['electro'] == "yes") { array_push($data['fuel'], "electricity"); } if ($response['adblue'] == "yes") { array_push($data['fuel'], "adblue"); } // other properties of fuel station if ($response['carwash'] == "yes") { array_push($data['fuel'], "carwash"); } if ($response['carrepair'] == "yes") { array_push($data['fuel'], "carrepair"); } if ($response['shop'] == "kiosk" || $response['kiosk'] == "yes") { array_push($data['fuel'], "kiosk"); } } // gastro if ($response['cuisine'] || $response['stars'] || $response['smoking'] || $response['microbrewery'] || $response['beer']) { // cuisine if ($response['cuisine']) { $data['cuisine'] = explode(";", $response['cuisine']); } // stars if ($response['stars']) { $data['stars'] = $response['stars']; } // smoking if ($response['smoking']) { $data['smoking'] = $response['smoking']; } // beer sorts if ($response['beer']) { $data['beer'] = str_replace(";", ",", $response['beer']); } // microbrewery if ($response['microbrewery'] == "yes") { $data['microbrewery'] = "yes"; } // biergarten if ($response['biergarten'] == "yes" || $response['beer_garden'] == "yes") { $data['biergarten'] = "yes"; } } // geographic if ($response['ele'] || $response['population'] || $response['iata'] || $response['icao']) { if ($response['ele']) { $data['ele'] = $response['ele']; } if ($response['population']) { $data['population'] = $response['population']; } if ($response['iata']) { $data['iata'] = $response['iata']; } if ($response['icao']) { $data['icao'] = $response['icao']; } } // wheelchair if ($response['wheelchair'] || $response['wheelchair:toilets'] || $response['wheelchair:rooms'] || $response['wheelchair:access'] || $response['wheelchair:places']) { if ($response['wheelchair']) { $data['wheelchair'] = $response['wheelchair']; } if ($response['wheelchair:toilets']) { $data['wheelchair:toilets'] = $response['wheelchair:toilets']; } if ($response['wheelchair:rooms']) { $data['wheelchair:rooms'] = $response['wheelchair:rooms']; } if ($response['wheelchair:access']) { $data['wheelchair:access'] = $response['wheelchair:access']; } if ($response['wheelchair:places']) { $data['wheelchair:places'] = $response['wheelchair:places']; } } // fee if ($response['fee']) { $data['fee'] = $response['fee']; } // capacity if ($response['capacity']) { $data['capacity'] = $response['capacity']; } // ref if ($response['ref']) { $data['ref'] = $response['ref']; } // internet access if ($response['internet_access']) { $data['internet_access'] = $response['internet_access']; } // toll if ($response['toll'] == "yes") { $data['toll'] = "yes"; } // disused if ($response['disused'] == "yes") { $data['disused'] = "yes"; } // wikipedia if ($wikipedia) { $data['wikipedia'] = array('url' => $wikipedia[1], 'text' => getWikipediaBeginning($wikipedia[1])); } // image, only images from domains listed on a whitelist are supported if (imageDomainAllowed($response['image'])) { $data['image'] = getImageUrl($response['image']); } else { if (getWikipediaImage($wikipedia[1])) { $data['image'] = getWikipediaImage($wikipedia[1]); } } $jsonData = json_encode($data); // JSONP request? if (isset($callback)) { return $callback . '(' . $jsonData . ')'; } else { return $jsonData; } } else { return false; } }
function jsonDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type, $callback) { if ($response) { $name = getNameDetail($langs, $nameresponse); $website = getWebsiteDetail(array($response['website1'], $response['website2'], $response['website3'], $response['website4'])); // get wikipedia link and make translation if ($wikipediaresponse) { $wikipedia = getWikipediaDetail($langs, $wikipediaresponse); } $data = array('id' => (int) $id, 'type' => $type); // name if ($name) { if ($name[0]) { $data['name'] = array('lang' => $name[1], 'name' => $name[0]); } else { $data['name'] = $name[0]; } } // website and wikipedia links if ($website[0]) { $data['website'] = $website[0]; } if ($wikipedia[1]) { $data['wikipedia'] = $wikipedia[1]; } // operator if ($response['operator']) { $data['operator'] = $response['operator']; } // timetable departures if ($response['departures']) { $data['departures'] = $response['departures']; } // stop details if ($response['shelter']) { $data['shelter'] = $response['shelter']; } if ($response['bench']) { $data['bench'] = $response['bench']; } if ($response['bin']) { $data['bin'] = $response['bin']; } // tactile paving if ($response['tactile_paving']) { $data['tactile_paving'] = $response['tactile_paving']; } // wheelchair if ($response['wheelchair']) { $data['wheelchair'] = $response['wheelchair']; } // image, only images from domains listed on a whitelist are supported if (imageDomainAllowed($response['image'])) { $data['image'] = getImageUrl($response['image']); } else { if (getWikipediaImage($wikipedia[1])) { $data['image'] = getWikipediaImage($wikipedia[1]); } } $jsonData = json_encode($data); // JSONP request? if (isset($callback)) { return $callback . '(' . $jsonData . ')'; } else { return $jsonData; } } else { return false; } }
if (isset($lang)) { $langs = array($lang); } else { $langs = getLangs(); } // connnecting to database $connection = connectToDatabase($db); // if there is no connection if (!$connection) { exit; } // request $request = "SELECT\n\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\tFROM (\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t) AS foo\n\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';"; $response = requestDetails($request, $connection, $type); pg_close($connection); $name = getNameDetail($langs, $response); if ($format == "xml") { echo xmlNameOut($name[0], $name[1], $id, $type); } else { if ($format == "json") { echo jsonNameOut($name[0], $name[1], $id, $type, $callback); } else { echo textNameOut($name[0], $id, $type); } } // output of name data in plain text format function textNameOut($name, $id, $type) { global $db; // setting header header("Content-Type: text/html; charset=UTF-8");