Пример #1
0
    header("Date: " . $now);
    header("Expires: " . $now);
    header("Cache-Control: private, max-age=0");
    header("X-Content-Type-Options: nosniff");
    header("X-XSS-Protection: 0");
    header("Content-Length: 20");
    header("Server: GFE/2.0");
}
function geolog($message)
{
    global $debug, $ip;
    if (!$debug) {
        return;
    }
    $f = fopen("geolog.log", "a");
    fputs($f, date(DATE_W3C) . " (" . $ip . "): " . $message . "\n");
    fclose($f);
}
// This is a GET, which we use to preset parameters to return when the next POST is called (this is so not REST...)
@unlink($geostatefilename);
geolog("SETUP: " . $_SERVER['QUERY_STRING']);
$state_file = fopen($geostatefilename, 'w');
$paramsStart = strpos($_SERVER['QUERY_STRING'], "?");
$params = substr($_SERVER['QUERY_STRING'], $paramsStart);
fputs($state_file, urldecode($params));
fclose($state_file);
sendheaders();
$output = "// hello, " . $ip;
printf($output);
geolog("sent response: " . $output);
Пример #2
0
        }
    }
    //parse post data
    if ($post_data && $post_data != '') {
        $request = json_decode($post_data, TRUE);
        if (!$request) {
            geolog("Bad JSON data sent in POST -> server error 400");
            sendheaders();
            header($_SERVER["SERVER_PROTOCOL"] . " 400 Bad Request");
            header("Status: 400");
            echo "Bad request";
            exit;
        }
    }
}
geolog("response: " . $output);
sendheaders();
print $output;
// examples (from http://code.google.com/p/gears/wiki/GeolocationAPI)
//
//{
//  "location": {
//    "latitude": 51.0,
//    "longitude": -0.1,
//    "altitude": 30.1,
//    "accuracy": 1200.1,
//    "altitude_accuracy": 10.1,
//    "address": {
//      "street_number": "100",
//      "street": "Amphibian Walkway",
//      "postal_code": "94043",