Exemplo n.º 1
0
if (empty($id) || empty($tm) || empty($url) || empty($cp) || empty($title)) {
    ajaxerr("1:not enough parameters");
}
// 這是地圖產生器跟 keepon 間的祕密, 這段就免看了
$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(urldecode($url));
if ($cp != $check) {
    error_log("checksum error");
    ajaxerr("2:checksum error");
}
$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);
Exemplo n.º 2
0
require_once "config.inc.php";
// 2. check _POST
$_inp = $_POST;
if (!isset($_inp['mid'])) {
    error_out(print_r($_POST, true) . " requires mid");
}
// 3. 檢查 user 是否能刪除此檔
$map = map_get_single($_inp['mid']);
if ($map == null) {
    error_out("no such map" . $_inp['mid']);
}
if ($map['uid'] != $_SESSION['uid']) {
    error_out("you are not the owner");
}
// 3.1 正在搬移資料結構, 或重新整理
$block_msg = map_blocked($out_root, $_SESSION['uid']);
if ($block_msg != null) {
    error_out($block_msg);
}
// 4. 真的刪除/回收
if ($_inp['op'] && $_inp['op'] == 'recycle') {
    $ok = map_expire($_inp['mid']);
} else {
    $ok = map_del($_inp['mid']);
}
if ($ok === FALSE) {
    error_out("delete/expire fail");
}
sleep(1);
$mid = $_inp['mid'];
ok_out("{$mid} deleted", $mid);