function keepon_MapDelete($id) { $kurl = "http://www.keepon.com.tw/api/MapGenerator/MapDelete"; $params = array('Identity' => $id); $result = request_curl($kurl, "POSTJSON", $params); error_log("request {$kurl} with params" . print_r($params, true) . "get {$result}"); kcli_msglog("request {$kurl} with params" . print_r($params, true) . "get {$result}"); return array(true, $result); }
$uid = 1; if ($url == 'delete') { $result = keepon_map_exists($uid, $id); if ($result === false) { ajaxerr("5:map not exists"); } if (map_del($result['mid'])) { ajaxok("刪除完成"); } else { ajaxerr("6:map delete fail,please report"); } } // 1. 先抓取 gpx 檔案 $tmp_gpx = tempnam("/tmp", "GPX") . ".gpx"; try { $data = request_curl($url); $TODO = $_REQUEST; $TODO['gpx'] = $tmp_gpx; $url_parts = parse_url($url); if (preg_match("/gdb\$/i", $url_parts['path'])) { $tmp_gdb = tempnam("/tmp", "GDB") . ".gdb"; file_put_contents($tmp_gdb, $data); $cmd = sprintf("/usr/bin/gpsbabel -i gdb -o gpx -f %s -F %s", $tmp_gdb, $tmp_gpx); exec($cmd, $out, $ret); if ($ret != 0) { @unlink($tmp_gdb); ajaxerr("4:unsupported format?[gdb fail to convert to gpx]"); } } else { file_put_contents($tmp_gpx, $data); }