Ejemplo n.º 1
0
function map_add($uid, $title, $startx, $starty, $shiftx, $shifty, $px, $py, $host = "localhost", $file, $size = 0, $version = 1, $gpx = 0, $keepon_id = NULL)
{
    // 若不是 keepon 來的, 檢查是否已經有同樣參數的地圖,有的話表示是重新產生
    // 不更新 mid, 只更新 size, version, title, cdate, flag 等參數
    $row = map_exists($uid, $startx, $starty, $shiftx, $shifty, $version, $gpx);
    $db = get_conn();
    if ($row === FALSE || $keepon_id != NULL) {
        // 新地圖
        // 使用 postgresql 要改 default
        $sql = sprintf("INSERT INTO \"map\" (\"mid\",\"uid\",\"cdate\",\"host\",\"title\",\"locX\",\"locY\",\"shiftX\",\"shiftY\",\"pageX\",\"pageY\",\"filename\",\"size\",\"version\",\"gpx\",\"keepon_id\") VALUES (DEFAULT, %d, CURRENT_TIMESTAMP, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, %d, '%s') returning mid", $uid, $host, $title, $startx, $starty, $shiftx, $shifty, $px, $py, $file, $size, $version, $gpx, $keepon_id == NULL ? 'NULL' : $keepon_id);
        $rs = $db->getAll($sql);
        logsql($sql, $rs);
        if (!isset($rs[0]['mid'])) {
            //error_log("err sql: $sql");
            return FALSE;
        }
        //return $db->Insert_ID();
        return $rs[0]['mid'];
    } else {
        // 重新產生的地圖, 連檔名都要更新
        $mid = $row[0];
        $sql = sprintf("UPDATE \"map\" SET \"locX\"=%d,\"locY\"=%d,\"shiftX\"=%d,\"shiftY\"=%d,\"size\"=%d,\"flag\"=0,\"cdate\"=CURRENT_TIMESTAMP,\"title\"='%s',\"version\"=%d,\"filename\"='%s',\"gpx\"=%d WHERE \"mid\"=%d", $startx, $starty, $shiftx, $shifty, $size, $title, $version, $file, $gpx, $mid);
        $rs = $db->Execute($sql);
        logsql($sql, $rs);
        if (!$rs) {
            return FALSE;
        }
        return $mid;
    }
}
Ejemplo n.º 2
0
$db = new Ossim_db();
$conn = $db->connect();
$erase_element = GET('delete');
$erase_type = GET('delete_type');
$map = get_current_map($conn);
$type = GET('type') != '' ? GET('type') : 'host';
$name = POST('name');
ossim_valid($erase_element, OSS_SCORE, OSS_NULLABLE, OSS_ALPHA, OSS_DIGIT, ";,.", 'illegal:' . _('Erase_element'));
ossim_valid($erase_type, "map", "icon", OSS_NULLABLE, 'illegal:' . _('Erase_type'));
ossim_valid($type, OSS_ALPHA, OSS_DIGIT, OSS_SCORE, 'illegal:' . _('Type'));
ossim_valid($name, OSS_ALPHA, OSS_NULLABLE, OSS_DIGIT, OSS_SCORE, ".,%", 'illegal:' . _('Name'));
ossim_valid($map, OSS_HEX, 'illegal:' . _('Map'));
if (ossim_error()) {
    die(ossim_error());
}
if (!map_exists($map)) {
    if (!empty($map)) {
        $error_msg = _('Warning! Map no available in the system');
        echo ossim_error($error_msg, AV_WARNING);
    } else {
        $error_msg = _('There are no maps to edit');
        echo ossim_error($error_msg, AV_INFO);
    }
    exit;
}
$_SESSION['riskmap'] = $map;
// Cleanup a bit
$name = str_replace('..', '', $name);
$erase_element = str_replace('..', '', $erase_element);
$uploaded_icon = FALSE;
$allowed_formats = array(IMAGETYPE_JPEG => 1, IMAGETYPE_GIF => 1, IMAGETYPE_PNG => 1);
Ejemplo n.º 3
0
    $response['error'] = TRUE;
    $response['msg'] = ossim_get_error();
} else {
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        switch ($action) {
            case 1:
                $response = delete_map($conn, $data);
                if ($return['error'] == FALSE) {
                    unset($_SESSION['riskmap']);
                    $config = new User_config($conn);
                    $user = Session::get_session_user();
                    $default_map = $config->get($user, "riskmap", 'simple', 'main');
                    if (strcasecmp($default_map, $data) == 0) {
                        //Save new default map in the PHP Session
                        $map = get_first_map_available($conn);
                        if (map_exists($map)) {
                            $_SESSION['riskmap'] = $map;
                            set_default_map($conn, $map);
                        }
                    }
                }
                break;
            case 2:
                $response = set_default_map($conn, $data);
                //Save default map in the PHP Session
                if ($return['error'] == FALSE) {
                    $_SESSION['riskmap'] = $data;
                }
                break;
            case 3:
                $response = change_map_title($conn, $data);
Ejemplo n.º 4
0
}
$shiftx = $inp['shiftx'];
$shifty = $inp['shifty'];
$title = $inp['title'];
$startx = $inp['startx'];
$starty = $inp['starty'];
$xx = $startx * 1000;
$yy = $starty * 1000;
$ph = $inp['ph'];
// 澎湖
$gpx = $inp['gps'] > 0 ? 1 : 0;
// error_log("$stbpath, $startx, $starty, $shiftx, $shifty");
// 1. 檢查產生地圖數量是否超過上限
$user = fetch_user($_SESSION['mylogin']);
// 1. 看看本圖是否為重新產生?
if (map_exists($_SESSION['uid'], $xx, $yy, $shiftx, $shifty, $version, $gpx)) {
    $recreate_flag = 1;
} else {
    $recreate_flag = 0;
}
if (map_full($_SESSION['uid'], $user['limit'], $recreate_flag)) {
    error_out("{$recreate_flag} 已經達到數量限制" . $user['limit']);
}
$block_msg = map_blocked($out_root, $_SESSION['uid']);
if ($block_msg != null) {
    error_out($block_msg);
}
$outpath = sprintf("%s/%06d", $out_root, $_SESSION['uid']);
$outfile_prefix = sprintf("%s/%dx%d-%dx%d-v%d%s", $outpath, $startx * 1000, $starty * 1000, $shiftx, $shifty, $version, $ph == 1 ? 'p' : "");
$outimage = $outfile_prefix . ".tag.png";
$outgpx = $outfile_prefix . ".gpx";