Пример #1
0
function xmlPositionOutput($position)
{
    if ($position) {
        $output = xmlStart("geolocation");
        $output .= "<position source=\"GeoIP-Database\">";
        $output .= "<lat>" . $position['latitude'] . "</lat>";
        $output .= "<lon>" . $position['longitude'] . "</lon>";
        $output .= "</position>";
        $output .= "</geolocation>";
        return $output;
    } else {
        return false;
    }
}
Пример #2
0
function xmlNameOut($name, $lang, $id, $type)
{
    $output = xmlStart("names");
    $output .= "<name id=\"" . $id . "\" type=\"" . $type . "\"";
    if ($lang) {
        $output .= " lang=\"" . $lang . "\"";
    }
    if ($name) {
        $output .= ">" . $name . "</name>";
    } else {
        $output .= ">NULL</name>";
    }
    $output .= "</names>";
    return $output;
}
Пример #3
0
function xmlTimestampOut($lastupdate, $offset = 0, $lang)
{
    if ($lastupdate) {
        $difference = timeAgo(time(), $lastupdate, $offset);
        $output = xmlStart("last_update");
        $output .= "<timestamp>\n";
        $output .= "<unix>" . substr($lastupdate, 0, -1) . "</unix>\n";
        $output .= "<string>" . timestampString($lastupdate, $offset) . "</string>\n";
        $output .= "</timestamp>\n";
        $output .= "<difference>\n";
        $output .= "<unix>" . $difference . "</unix>\n";
        $output .= "<string lang=\"" . $lang . "\">" . timeAgoString($difference) . "</string>\n";
        $output .= "</difference>\n";
        $output .= "</last_update>\n";
        return $output;
    } else {
        return false;
    }
}
Пример #4
0
function xmlDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type)
{
    if ($response) {
        $output = xmlStart("details id=\"" . $id . "\" type=\"" . $type . "\"");
        $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']);
        // printing popup details
        if ($name) {
            $output .= "<name";
            if ($name[0]) {
                $output .= " lang=\"" . $name[1] . "\"";
            }
            $output .= ">" . $name[0] . "</name>\n";
        }
        // address information
        if ($response['street'] || $response['housenumber'] || $response['country'] || $response['postcode'] || $response['city']) {
            $output .= "<address>\n";
            if ($response['street']) {
                $output .= "<street>" . $response['street'] . "</street>\n";
            }
            if ($response['housenumber']) {
                $output .= "<housenumber>" . $response['housenumber'] . "</housenumber>\n";
            }
            if ($response['country']) {
                $output .= "<country>" . strtoupper($response['country']) . "</country>\n";
            }
            if ($response['postcode']) {
                $output .= "<postcode>" . $response['postcode'] . "</postcode>\n";
            }
            if ($response['city']) {
                $output .= "<city>" . $response['city'] . "</city>\n";
            }
            if ($response['suburb']) {
                $output .= "<suburb>" . $response['suburb'] . "</suburb>\n";
            }
            $output .= "</address>\n";
        }
        // contact information
        if ($phone || $fax || $mobilephone || $email) {
            $output .= "<contact>\n";
            if ($phone) {
                foreach ($phone as $phonenumber) {
                    $output .= " <phone>" . $phonenumber[1] . "</phone>";
                }
            }
            if ($fax) {
                foreach ($fax as $faxnumber) {
                    $output .= " <fax>" . $faxnumber[1] . "</fax>";
                }
            }
            if ($mobilephone) {
                foreach ($mobilephone as $mobilephonenumber) {
                    $output .= " <mobilephone>" . $mobilephonenumber[1] . "</mobilephone>";
                }
            }
            if ($email) {
                foreach ($email as $emailaddress) {
                    $output .= " <email>" . $emailaddress . "</email>";
                }
            }
            $output .= "</contact>\n";
        }
        // website and wikipedia links
        if ($website || $wikipedia[0]) {
            $output .= "<web>\n";
            foreach ($website as $webaddress) {
                if ($webaddress[0]) {
                    $output .= "<website>" . $webaddress[0] . "</website>\n";
                }
            }
            if ($wikipedia[1]) {
                $output .= "<wikipedia>" . $wikipedia[1] . "</wikipedia>\n";
            }
            $output .= "</web>\n";
        }
        // operator
        if ($response['operator']) {
            $output .= "<operator>" . $response['operator'] . "</operator>\n";
        }
        // opening hours
        if ($openinghours) {
            $output .= "<openinghours state=\"";
            if (isPoiOpen($response['openinghours'], $offset)) {
                $output .= "open";
            } else {
                if (isInHoliday($response['openinghours'], $offset)) {
                    $output .= "maybeopen";
                } else {
                    $output .= "closed";
                }
            }
            $output .= "\">" . $response['openinghours'] . "</openinghours>\n";
        }
        // service times
        if ($servicetimes) {
            $output .= "<servicetimes state=\"";
            if (isPoiOpen($response['servicetimes'], $offset)) {
                $output .= "open";
            } else {
                if (isInHoliday($response['servicetimes'], $offset)) {
                    $output .= "maybeopen";
                } else {
                    $output .= "closed";
                }
            }
            $output .= "\">" . $response['servicetimes'] . "</servicetimes>\n";
        }
        // image, only images from domains listed on a whitelist are supported
        if (imageDomainAllowed($response['image'])) {
            $url = getImageUrl($response['image']);
            $output .= "<image>";
            $output .= $url;
            $output .= "</image>\n";
        } elseif (getWikipediaImage($wikipedia[1])) {
            $image = getWikipediaImage($wikipedia[1]);
            $output .= "<image>";
            $output .= $image;
            $output .= "</image>\n";
        }
        $output .= "</details>";
        return $output;
    } else {
        return false;
    }
}
Пример #5
0
function xmlDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type)
{
    if ($response) {
        $output = xmlStart("details id=\"" . $id . "\" type=\"" . $type . "\"");
        $name = getNameDetail($langs, $nameresponse);
        $website = getWebsiteDetail(array($response['website'], $response['url'], $response['url:official'], $response['contact:website']));
        // get wikipedia link and make translation
        if ($wikipediaresponse) {
            $wikipedia = getWikipediaDetail($langs, $wikipediaresponse);
        }
        // printing popup details
        if ($name) {
            $output .= "<name";
            if ($name[0]) {
                $output .= " lang=\"" . $name[1] . "\"";
            }
            $output .= ">" . $name[0] . "</name>\n";
        }
        // website and wikipedia links
        if ($website[0] || $wikipedia[0]) {
            $output .= "<web>\n";
            if ($website[0]) {
                $output .= "<website>" . $website[0] . "</website>\n";
            }
            if ($wikipedia[1]) {
                $output .= "<wikipedia>" . $wikipedia[1] . "</wikipedia>\n";
            }
            $output .= "</web>\n";
        }
        // operator
        if ($response['operator']) {
            $output .= "<operator>" . $response['operator'] . "</operator>\n";
        }
        // timetable departures
        if ($response['departures']) {
            $output .= "<departures>" . htmlentities($response['departures']) . "</departures>\n";
        }
        // stop details
        if ($response['shelter']) {
            $output .= "<shelter>" . $response['shelter'] . "</shelter>\n";
        }
        if ($response['bench']) {
            $output .= "<bench>" . $response['bench'] . "</bench>\n";
        }
        if ($response['bin']) {
            $output .= "<bin>" . $response['bench'] . "</bin>\n";
        }
        // tactile paving
        if ($response['tactile_paving']) {
            $output .= "<tactilepaving>" . $response['tactile_paving'] . "</tactilepaving>\n";
        }
        // wheelchair
        if ($response['wheelchair']) {
            $output .= "<wheelchair>" . $response['wheelchair'] . "</wheelchair>\n";
        }
        // image, only images from domains listed on a whitelist are supported
        if (imageDomainAllowed($response['image'])) {
            $url = getImageUrl($response['image']);
            $output .= "<image>";
            $output .= $url;
            $output .= "</image>\n";
        } elseif (getWikipediaImage($wikipedia[1])) {
            $image = getWikipediaImage($wikipedia[1]);
            $output .= "<image>";
            $output .= $image;
            $output .= "</image>\n";
        }
        $output .= "</details>";
        return $output;
    } else {
        return false;
    }
}
Пример #6
0
function xmlMoreDetailsOut($response, $nameresponse, $wikipediaresponse, $langs = "en", $offset = 0, $id, $type)
{
    if ($response) {
        $output = xmlStart("moredetails id=\"" . $id . "\" type=\"" . $type . "\"");
        $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']);
        // printing popup details
        if ($name) {
            $output .= "<name";
            if ($name[0]) {
                $output .= " lang=\"" . $name[1] . "\"";
            }
            $output .= ">" . $name[0] . "</name>\n";
        }
        if ($response['description']) {
            $output .= "<description>" . $response['description'] . "</description>";
        }
        // address information
        if ($response['street'] || $response['housenumber'] || $response['country'] || $response['postcode'] || $response['city']) {
            $output .= "<address>\n";
            if ($response['street']) {
                $output .= "<street>" . $response['street'] . "</street>\n";
            }
            if ($response['housenumber']) {
                $output .= "<housenumber>" . $response['housenumber'] . "</housenumber>\n";
            }
            if ($response['country']) {
                $output .= "<country>" . strtoupper($response['country']) . "</country>\n";
            }
            if ($response['postcode']) {
                $output .= "<postcode>" . $response['postcode'] . "</postcode>\n";
            }
            if ($response['city']) {
                $output .= "<city>" . $response['city'] . "</city>\n";
            }
            if ($response['suburb']) {
                $output .= "<suburb>" . $response['suburb'] . "</suburb>\n";
            }
            $output .= "</address>\n";
        }
        // contact information
        if ($phone || $fax || $mobilephone || $email) {
            $output .= "<contact>\n";
            if ($phone) {
                foreach ($phone as $phonenumber) {
                    $output .= " <phone>" . $phonenumber[1] . "</phone>";
                }
            }
            if ($fax) {
                foreach ($fax as $faxnumber) {
                    $output .= " <fax>" . $faxnumber[1] . "</fax>";
                }
            }
            if ($mobilephone) {
                foreach ($mobilephone as $mobilephonenumber) {
                    $output .= " <mobilephone>" . $mobilephonenumber[1] . "</mobilephone>";
                }
            }
            if ($email) {
                foreach ($email as $emailaddress) {
                    $output .= "<email>" . $emailaddress . "</email>\n";
                }
            }
            $output .= "</contact>\n";
        }
        // website and wikipedia links
        if ($website) {
            $output .= "<web>\n";
            foreach ($website as $webaddress) {
                if ($webaddress[0]) {
                    $output .= "<website>" . $webaddress[0] . "</website>\n";
                }
            }
            $output .= "</web>\n";
        }
        // operator
        if ($response['operator']) {
            $output .= "<operator>" . $response['operator'] . "</operator>\n";
        }
        // opening hours
        if ($openinghours) {
            $output .= "<openinghours state=\"";
            if (isPoiOpen($response['openinghours'], $offset)) {
                $output .= "open";
            } else {
                if (isInHoliday($response['openinghours'], $offset)) {
                    $output .= "maybeopen";
                } else {
                    $output .= "closed";
                }
            }
            $output .= "\">" . $response['openinghours'] . "</openinghours>\n";
        }
        // service times
        if ($servicetimes) {
            $output .= "<servicetimes state=\"";
            if (isPoiOpen($response['servicetimes'], $offset)) {
                $output .= "open";
            } else {
                if (isInHoliday($response['servicetimes'], $offset)) {
                    $output .= "maybeopen";
                } else {
                    $output .= "closed";
                }
            }
            $output .= "\">" . $response['servicetimes'] . "</servicetimes>\n";
        }
        // 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") {
            $output .= "<fuel>\n";
            // fuel sorts
            if ($response['diesel'] == "yes") {
                $output .= "<diesel />\n";
            }
            if ($response['gtldiesel'] == "yes") {
                $output .= "<gtldiesel />\n";
            }
            if ($response['hgvdiesel'] == "yes") {
                $output .= "<hgvdiesel />\n";
            }
            if ($response['biodiesel'] == "yes") {
                $output .= "<biodiesel />\n";
            }
            if ($response['octane91'] == "yes") {
                $output .= "<octane91 />\n";
            }
            if ($response['octane95'] == "yes") {
                $output .= "<octane95 />\n";
            }
            if ($response['octane98'] == "yes") {
                $output .= "<octane98 />\n";
            }
            if ($response['octane100'] == "yes") {
                $output .= "<octane100 />\n";
            }
            if ($response['octane98l'] == "yes") {
                $output .= "<octane98l />\n";
            }
            if ($response['fuel25'] == "yes") {
                $output .= "<1:25 />\n";
            }
            if ($response['fuel50'] == "yes") {
                $output .= "<1:50 />\n";
            }
            if ($response['alcohol'] == "yes") {
                $output .= "<alcohol />\n";
            }
            if ($response['ethanol'] == "yes") {
                $output .= "<ethanol />\n";
            }
            if ($response['methanol'] == "yes") {
                $output .= "<methanol />\n";
            }
            if ($response['svo'] == "yes") {
                $output .= "<svo />\n";
            }
            if ($response['e10'] == "yes") {
                $output .= "<e10 />\n";
            }
            if ($response['e85'] == "yes") {
                $output .= "<e85 />\n";
            }
            if ($response['biogas'] == "yes") {
                $output .= "<biogas />\n";
            }
            if ($response['lpg'] == "yes") {
                $output .= "<lpg />\n";
            }
            if ($response['cng'] == "yes") {
                $output .= "<cng />\n";
            }
            if ($response['lh2'] == "yes") {
                $output .= "<lh2 />\n";
            }
            if ($response['electro'] == "yes") {
                $output .= "<electricity />\n";
            }
            if ($response['adblue'] == "yes") {
                $output .= "<adblue />\n";
            }
            // other properties of fuel station
            if ($response['carwash'] == "yes") {
                $output .= "<carwash />\n";
            }
            if ($response['carrepair'] == "yes") {
                $output .= "<carrepair />\n";
            }
            if ($response['shop'] == "kiosk" || $response['kiosk'] == "yes") {
                $output .= "<kiosk />\n";
            }
            $output .= "</fuel>\n";
        }
        // gastro
        if ($response['cuisine'] || $response['stars'] || $response['smoking'] || $response['microbrewery'] || $response['beer']) {
            $output .= "<gastronomy>\n";
            // cuisine
            if ($response['cuisine']) {
                $output .= "<cuisine>" . str_replace(";", ",", $response['cuisine']) . "</cuisine>\n";
            }
            // stars
            if ($response['stars']) {
                $output .= "<stars>" . $response['stars'] . "</stars>\n";
            }
            // smoking
            if ($response['smoking']) {
                $output .= "<smoking>" . $response['smoking'] . "</smoking>";
            }
            // beer sorts
            if ($response['beer']) {
                $output .= "<beer>" . str_replace(";", ",", $response['beer']) . "</beer>\n";
            }
            // microbrewery
            if ($response['microbrewery'] == "yes") {
                $output .= "<microbrewery />\n";
            }
            // biergarten
            if ($response['biergarten'] == "yes" || $response['beer_garden'] == "yes") {
                $output .= "<biergarten />\n";
            }
            $output .= "</gastronomy>\n";
        }
        // geographic
        if ($response['ele'] || $response['population'] || $response['iata'] || $response['icao']) {
            $output .= "<geographic>\n";
            if ($response['ele']) {
                $output .= "<ele>" . $response['ele'] . "m</ele>\n";
            }
            if ($response['population']) {
                $output .= "<population>" . $response['population'] . "</population>\n";
            }
            if ($response['iata']) {
                $output .= "<iata>" . $response['iata'] . "</iata>\n";
            }
            if ($response['icao']) {
                $output .= "<icao>" . $response['icao'] . "</icao>\n";
            }
            $output .= "</geographic>\n";
        }
        // wheelchair
        if ($response['wheelchair'] || $response['wheelchair:toilets'] || $response['wheelchair:rooms'] || $response['wheelchair:access'] || $response['wheelchair:places']) {
            $output .= "<accessibility>\n";
            if ($response['wheelchair']) {
                $output .= "<wheelchair>" . $response['wheelchair'] . "</wheelchair>\n";
            }
            if ($response['wheelchair:toilets']) {
                $output .= "<wheelchair:toilets>" . $response['wheelchair:toilets'] . "</wheelchair:toilets>\n";
            }
            if ($response['wheelchair:rooms']) {
                $output .= "<wheelchair:rooms>" . $response['wheelchair:rooms'] . "</wheelchair:rooms>\n";
            }
            if ($response['wheelchair:access']) {
                $output .= "<wheelchair:access>" . $response['wheelchair:access'] . "</wheelchair:access>\n";
            }
            if ($response['wheelchair:places']) {
                $output .= "<wheelchair:places>" . $response['wheelchair:places'] . "</wheelchair:places>\n";
            }
            $output .= "</accessibility>\n";
        }
        // fee
        if ($response['fee']) {
            $output .= "<fee>" . $response['fee'] . "</fee>\n";
        }
        // capacity
        if ($response['capacity']) {
            $output .= "<capacity>" . $response['capacity'] . "</capacity>\n";
        }
        // ref
        if ($response['ref']) {
            $output .= "<ref>" . $response['ref'] . "</ref>\n";
        }
        // internet access
        if ($response['internet_access']) {
            $output .= "<internet_access>" . $response['internet_access'] . "</internet_access>\n";
        }
        // toll
        if ($response['toll'] == "yes") {
            $output .= "<toll />\n";
        }
        // disused
        if ($response['disused'] == "yes") {
            $output .= "<disused />\n";
        }
        // wikipedia
        if ($wikipedia) {
            $output .= "<wikipedia>\n";
            $output .= "<url>" . $wikipedia[1] . "</url>\n";
            // request first lines
            $output .= "<text>" . getWikipediaBeginning($wikipedia[1]) . "</text>\n";
            $output .= "</wikipedia>\n";
        }
        // image, only images from domains listed on a whitelist are supported
        if (imageDomainAllowed($response['image'])) {
            $url = getImageUrl($response['image']);
            $output .= "<image>";
            $output .= $url;
            $output .= "</image>\n";
        } else {
            if (getWikipediaImage($wikipedia[1])) {
                $image = getWikipediaImage($wikipedia[1]);
                $output .= "<image>";
                $output .= $image;
                $output .= "</image>\n";
            }
        }
        $output .= "</moredetails>";
        return $output;
    } else {
        return false;
    }
}
Пример #7
0
/*
OpenLinkMap Copyright (C) 2010 Alexander Matheisen
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions.
See http://wiki.openstreetmap.org/wiki/OpenLinkMap for details.
*/
require_once "functions.php";
$tag = $_GET['tag'];
$format = $_GET['format'];
$callback = $_GET['callback'];
// include translation file
includeLocale($_GET['lang']);
if ($tag) {
    $parts = explode(",", $tag);
    if ($format == "xml") {
        echo xmlStart('translations lang="' . $_GET['lang'] . '"');
        // echo translated strings
        foreach ($parts as $part) {
            $part = explode("=", $part);
            $translation = translateKeyValue($part[0], $part[1]);
            if ($translation) {
                echo "<translation key=\"" . $part[0] . "\" value=\"" . $part[1] . "\">" . $translation . "</translation>\n";
            }
        }
        echo "</translations>";
    } else {
        if ($format == "json") {
            $list = array();
            foreach ($parts as $part) {
                $part = explode("=", $part);
                $translation = translateKeyValue($part[0], $part[1]);
Пример #8
0
    $langs[0] = $_GET['lang'];
}
// connnecting to database
$connection = connectToDatabase("nextobjects");
// if there is no connection
if (!$connection) {
    exit;
}
$next['busstops'] = array(_("Busstops"), getNearObjectsForId($connection, $lat, $lon, array(array("highway", "bus_stop"), array("highway", "bus_station")), 2000));
$next['stations'] = array(_("Stations"), getNearObjectsForId($connection, $lat, $lon, array(array("railway", "station"), array("railway", "halt")), 20000));
$next['tramhalts'] = array(_("Tramhalts"), getNearObjectsForId($connection, $lat, $lon, array(array("railway", "tram_stop")), 5000));
$next['parkings'] = array(_("Parkings"), getNearObjectsForId($connection, $lat, $lon, array(array("amenity", "parking")), 5000));
pg_close($connection);
if ($next) {
    if ($format == "xml") {
        echo xmlStart("nextobjects");
        foreach ($next as $data) {
            echo xmlNextobjectOut($data[1], $data[0], $lat, $lon);
        }
        echo "</nextobjects>\n";
    } else {
        if ($format == "json") {
            header("Content-Type: text/plain; charset=UTF-8");
            $list = array();
            foreach ($next as $data) {
                $list[$type] = jsonNextobjectOut($data[1], $data[0], $lat, $lon);
            }
            $jsonData = json_encode($list);
            // JSONP request?
            if (isset($callback)) {
                echo $callback . '(' . $jsonData . ')';