Ejemplo n.º 1
0
<?php

$uid = 1;
require_once "../config.inc.php";
if (!ob_start("ob_gzhandler")) {
    ob_start();
}
$mid = $_REQUEST['mid'];
$zoom = $_REQUEST['zoom'];
if (empty($mid)) {
    ajaxerr("insufficent parameters");
}
list($status, $msg) = make_kml($mid);
if ($status == true) {
    readfile($msg);
}
function make_kml($mid)
{
    $map = map_get_single($mid);
    if ($map === false) {
        return array(false, "no such map");
    }
    // 把地圖拿出來換成 kml
    $gpx = str_replace(".tag.png", ".gpx", $map['filename']);
    // test kml happyman add test path
    $cachefile = sprintf("/srv/www/htdocs/map/gpxtmp/test/%06d/%d/%s", $map['uid'], $map['mid'], basename(str_replace(".gpx", ".kml", $gpx)));
    if (file_exists($gpx)) {
        if (0 && file_exists($cachefile) && filemtime($cachefile) >= filemtime($gpx)) {
            return array(true, $cachefile);
        }
        @mkdir(dirname($cachefile), 0755, true);
Ejemplo n.º 2
0
    ajaxerr("insufficent parameters");
}
$da = json_decode($data, true);
$mem = new Memcached();
$mem->addServer('localhost', 11211);
$key = md5($data['address']);
switch ($op) {
    case 'get':
        // 查詢結果, 如果沒有設定 memcache, 當作加入 cache 的依據
        list($result, $msg) = geocoder($op, $da);
        if ($result == 0) {
            $mem->set($key, $data['address'], 3600);
            ajaxerr($msg);
        } else {
            ajaxok($msg);
        }
        break;
    case 'set':
        if ($mem->get($key) == $data['address']) {
            list($result, $msg) = geocoder($op, $da);
            if ($result > 0) {
                $mem->delete($key);
                ajaxok($msg);
            } else {
                ajaxerr($msg);
            }
        } else {
            ajaxerr("you can't update cache");
        }
        break;
}
Ejemplo n.º 3
0
$ret = MEMQ::enqueue("keepon", $TODO);
if ($ret === FALSE) {

error_log("add to queue fail". print_r($TODO,true));
	ajaxerr("system error");
}
*/
// gearman code
$gmclient = new GearmanClient();
$gmclient->addServer(GEARMAN_SERVER);
//把 action 加入
$workload = serialize($TODO);
// 直接用 keepon id 帶入
$job_handle = $gmclient->doBackground("keepon_worker", $workload, $id);
if ($gmclient->returnCode() != GEARMAN_SUCCESS) {
    ajaxerr("5.add to queue error");
}
// gearman code
$ret = array("time" => time(), "msg" => "accepted");
error_log("add to queue");
ajaxok($ret);
function formatreq($param)
{
    global $keepon_magic_1, $keepon_magic_2, $keepon_magic_3, $keepon_magic_4;
    $tm = $param['tm'];
    $url = $param['url'];
    $check = intval($tm[0]) * $keepon_magic_1 + intval($tm[1]) + intval($tm[2]) * $keepon_magic_2 + intval($tm[3]) + intval($tm[4]) * $keepon_magic_3 + intval($tm[5]) + $keepon_magic_4 - strlen($url);
    $param['cp'] = $check;
    return http_build_query($param);
}
Ejemplo n.º 4
0
<?php

$uid = 1;
require_once "../config.inc.php";
if (!ob_start("ob_gzhandler")) {
    ob_start();
}
$r = $_REQUEST['r'];
$x = $_REQUEST['x'];
$y = $_REQUEST['y'];
$detail = $_REQUEST['detail'];
$dup = array();
$found = 0;
if ($r > 100) {
    ajaxerr("too big range");
}
if ($r == 0) {
    ajaxok(array());
}
$data = get_waypoint($x, $y, $r, $detail);
// 整理一下 data
if ($data == false || count($data) == 0) {
    header('Access-Control-Allow-Origin: *');
    ajaxok(array());
}
if (empty($detail) || $detail == 0) {
    header('Access-Control-Allow-Origin: *');
    ajaxok($data);
} else {
    // web page
    echo "<html>";
Ejemplo n.º 5
0
$y = $_REQUEST['y'];
$detail = $_REQUEST['detail'];
$dup = array();
$found = 0;
if ($r > 100) {
    ajaxerr("too big range");
}
if ($r == 0) {
    ajaxerr("empty");
}
$data = get_waypoint($x, $y, $r, $detail);
$trk_data = get_track($x, $y, $r, $detail);
// 整理一下 data
if ($data === false || count($data) == 0 && count($trk_data) == 0) {
    header('Access-Control-Allow-Origin: *');
    ajaxerr("empty result");
}
if (empty($detail) || $detail == 0) {
    // 傳回高度
    $twDEM_path = "../db/DEM/twdtm_asterV2_30m.tif";
    $ele = get_elev($twDEM_path, $y, $x, 1);
    header('Access-Control-Allow-Origin: *');
    ajaxok(array("wpt" => $data, "trk" => $trk_data, "ele" => $ele));
} else {
    // web page
    echo "<html>";
    echo "<head><title>TWMAP waypoint detail</title><meta charset=\"UTF-8\">";
    echo "<script src='https://code.jquery.com/jquery-2.1.4.min.js'></script>";
    echo "<style>\n\t<script src='https://code.jquery.com/jquery-2.1.4.min.js'></script>\n\t/* Document level adjustments */\nhtml {\n  font-size: 17px;\n}\n@media (max-width: 900px) {\n  html,table { font-size: 15px; }\n}\n@media (max-width: 400px) {\n  html,table { font-size: 13px; }\n}\n\ntable, td, th {\n    border: 1px solid green;\n}\n\nth {\n    background-color: green;\n    color: white;\n}\n\n</style></head>";
    echo "<body><div id='wpt_info' align=center>";
    echo "<hr>以下 GPS 航跡皆為山友無私貢獻分享,請大家上山前做好準備,快樂出門,平安回家!";