Beispiel #1
0
$result = mysqli_query($global_mysqli_link, "SELECT propertyvalue FROM properties WHERE propertyname='trackversion'") or die_nice("Can't retrieve the tracks version from database: " . mysqli_error($global_mysqli_link));
if ($row = mysqli_fetch_row($result)) {
    $trackversion = $row[0];
} else {
    $trackversion = "UNKNOWN";
}
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
    print "Forbidden! Access only from localhost!\n";
    exit(0);
}
print "# gettracks.php result, trackversion={$trackversion}\n";
if ($maxdistance != 0) {
    print "# will extract node pairs longer than {$maxdistance} km.\n";
}
print "# Format: <trackId>\t<penalty>\t<num-of-points>\t<lat1 lon1 lat2 lon2>\t<loop>\t<transferNodes>\n";
$result = mysqli_query($global_mysqli_link, "SELECT trackTypeId, trackId, AsText(geodata), pathloop, penalty, transferNodes FROM tracks WHERE geodata IS NOT NULL ORDER BY trackId") or die_nice("Can't retrieve the track infromation from database: " . mysqli_error($global_mysqli_link));
while ($row = mysqli_fetch_row($result)) {
    if (!file_exists('../../public_html/images/means/' . $row[0] . '/' . $row[1] . $means_image_extension)) {
        print "# WARNING: couldn't find image file for this route: " . $row[0] . '.' . $row[1] . "\n";
    }
    // Setup track info
    $tracks = lineStringToLatLngArray($row[2]);
    $tracksize = sizeof($tracks);
    $transitnodes = $row[5] == '' ? array('0-' . ($tracksize - 1)) : split(',', $row[5]);
    $transitnodes_count = count($transitnodes);
    for ($i = 0; $i < $transitnodes_count; $i++) {
        $transitnodes[$i] = rangestr_to_array($transitnodes[$i]);
    }
    $trackstring = '';
    $inserted_nodes = 0;
    $transfernodes_offset = array();
Beispiel #2
0
/**
 * method for check if the api keys is in database.
 * @param string $apikey provided by user to be checked.
 */
function check_apikey($apikey)
{
    //check message with global_hush_hush
    global $global_hush_hush, $global_mysqli_link;
    $global_hush_hush = false;
    //check apikey: is this api key exist in database?
    $apisqlquerry = mysqli_query($global_mysqli_link, "SELECT apikeys.verifier, apikeys.ipFilter FROM apikeys WHERE\n\t\t\tapikeys.verifier = '{$apikey}'") or die_nice("failed to execute query on Apikey check.");
    // if it exist, it must be found 1 row (because apiKeyOrDomain are unique)
    if ($querry = mysqli_fetch_array($apisqlquerry)) {
        // check for ip filter
        if ($_SERVER['REMOTE_ADDR'] != $querry['ipFilter'] && $querry['ipFilter'] != NULL) {
            die_nice("IP address is not accepted for this API key.");
        }
    } else {
        die_nice("API key is not recognized: {$apikey}.");
    }
}
Beispiel #3
0
<?php

// Convert tracks from database into text file to be read by the mjnserve
require_once '../../etc/utils.php';
require_once '../../etc/constants.php';
header('Content-Type: text/plain');
header('Cache-control: no-cache');
header('Pragma: no-cache');
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
    print "Forbidden! Access only from localhost!\n";
    exit(0);
}
init_mysql();
$result = mysqli_query($global_mysqli_link, "SELECT propertyvalue FROM properties WHERE propertyname='placesversion'") or die_nice("Can't retrieve the places version from database: " . mysqli_error($global_mysqli_link));
if ($row = mysqli_fetch_row($result)) {
    $placesversion = $row[0];
} else {
    $placesversion = "UNKNOWN";
}
print "# getplaces.php result, placesversion={$placesversion}\n";
print "# Format: <orderId>\t<lat>\t<lon>\n";
$result = mysqli_query($global_mysqli_link, "SELECT orderId, AsText(location) FROM adorder WHERE location IS NOT NULL ORDER BY orderId") or die_nice("Can't retrieve the places infromation from database: " . mysqli_error($global_mysqli_link));
while ($row = mysqli_fetch_row($result)) {
    $latlng = preg_replace('/POINT\\(-?(\\d+(\\.\\d+)?) (-?\\d+(\\.\\d+)?)\\)/', "\$3\t\$1", $row[1]);
    print $row[0] . "\t{$latlng}\n";
}
deinit_mysql();
Beispiel #4
0
/**
 * 
 * Simply checks the input parameter, when false do default action
 * to return "user does not have privilege"
 * @param boolean $privilege if false will return error
 */
function check_privilege($privilege)
{
    if (!$privilege) {
        die_nice("User doesn't have enough privilege to perform the action.", true);
    }
}