function create_rows($maps, $startsn = 0) { global $TWMAP3URL; for ($i = 0; $i < count($maps); $i++) { if ($maps[$i]['gpx'] == 1) { // 產生瀏覽連結 $gpx = sprintf("<span id='icon_mapshow' onclick=\"map_action('mapshow','%s?goto=%d,%d&show_kml_layer=1')\"></span>", $TWMAP3URL, $maps[$i]['locX'] + $maps[$i]['shiftX'] * 500, $maps[$i]['locY'] - $maps[$i]['shiftY'] * 500); } else { $gpx = ""; } $rows[$i]['sn'] = $i + 1 + $startsn; $rows[$i]['date'] = preg_replace("#\\.\\d+\$#", "", $maps[$i]['cdate']); $rows[$i]['title'] = sprintf("%s <span id='icon_save_link' onclick='map_action(\"view\",%d);'>%s</span>", $gpx, $maps[$i]['mid'], $maps[$i]['title']); $rows[$i]['x'] = $maps[$i]['locX']; $rows[$i]['y'] = $maps[$i]['locY']; $rows[$i]['grid'] = sprintf("%dx%d", $maps[$i]['shiftX'], $maps[$i]['shiftY']); $rows[$i]['pages'] = $maps[$i]['pageX'] * $maps[$i]['pageY']; if (map_file_exists($maps[$i]['filename'], 'pdf')) { $rows[$i]['pagetype'] = '<img src="imgs/pdf_icon.png" width="32px" alt="PDF" />'; } else { $rows[$i]['pagetype'] = determine_type($maps[$i]['shiftX'], $maps[$i]['shiftY'], 1) == 'A4R' ? '<img src="imgs/a4r.png" width="20px" alt="橫印" title="A4橫" />' : ""; } $rows[$i]['version'] = $maps[$i]['version']; $rows[$i]['size'] = humanreadable($maps[$i]['size']); $button_class = 'class="fg-button ui-state-default ui-corner-all"'; $op = array(); $op[] = sprintf("<span id='icon_delete' title='永久刪除'\n\t\t\tonclick=\"map_action('del',%d)\"></span>", $maps[$i]['mid']); // 如果地圖已經過期 if ($maps[$i]['flag'] == 1) { // 看看是不是澎湖 if (strstr($maps[$i]['filename'], 'v3p')) { $ph = 1; } else { $ph = 0; } if ($maps[$i]['gpx'] == 1) { $param = sprintf("mid=%s&title=%s&filename=%s", $maps[$i]['mid'], $maps[$i]['title'], $maps[$i]['filename']); $op[] = sprintf("<span id='icon_recreate' title=\"mid=%d 重新產生\" \n\t\t\t\t\tonclick=\"map_action('recreate_gpx','%s')\"></span>", $maps[$i]['mid'], $param); } else { $param = sprintf("x=%d&y=%d&shiftx=%d&shifty=%d&title=%s&version=%d&ph=%d", $maps[$i]['locX'] / 1000, $maps[$i]['locY'] / 1000, $maps[$i]['shiftX'], $maps[$i]['shiftY'], $maps[$i]['title'], $maps[$i]['version'], $ph); $op[] = sprintf("<span id='icon_recreate' title=\"mid=%d 重新產生\" \n\t\t\t\t\tonclick=\"map_action('recreate','%s')\"></span>", $maps[$i]['mid'], $param); } } else { $op[] = sprintf("<span id='icon_recycle' onclick=\"map_action('expire',%d)\" title=\"清理空間\"></span>", $maps[$i]['mid']); $op[] = sprintf("<span id='icon_save' onclick=\"map_action('view',%d)\" title=\"mid=%d%s 檢視下載\"></span>", $maps[$i]['mid'], $maps[$i]['mid'], $maps[$i]['keepon_id'] ? ",keepon=" . $maps[$i]['keepon_id'] : ""); $op[] = sprintf("<span id='icon_browse' onclick=\"map_action('link',%d)\" title='外部連結'></span>\n", $maps[$i]['mid']); } $rows[$i]['op'] = implode("\n", $op); $td[$i] = array($rows[$i]['sn'], $rows[$i]['date'], $rows[$i]['title'], $rows[$i]['x'], $rows[$i]['y'], $rows[$i]['grid'], sprintf("%s %s", $rows[$i]['pages'], $rows[$i]['pagetype']), $rows[$i]['version'], $rows[$i]['size'], $rows[$i]['op']); } return $td; }
public function init() { $type = determine_type(); $query1 = array( "request" => "getselection", "type" => "query", "layer" => $type["type"], "idfield" => $type["field"], "query" => $type["field"] ." in ('" . select_value() . "')" ); $url = WMS_URL . '?' . http_build_query($query1); $error_reporting = intval(ini_get('error_reporting')); error_reporting($error_reporting & ~E_WARNING); $xml = file_get_contents($url); error_reporting($error_reporting); if($xml == "") { // if failed to grab xml feed, then run the generic error handler throw new DataServerException("$url is experiencing problems"); } $xml_obj = new DOMDocument(); $xml_obj->loadXML($xml); $extent = $xml_obj->firstChild->firstChild; if(!$extent) { //IMS server does not seem to be able to find anything return; } $bbox = array(); foreach(array('minx','miny','maxx','maxy') as $key) { $bbox[$key] = (int) $extent->getAttribute($key); } self::$server_BBox = $bbox; }
if ($ret === FALSE) { cli_error_out("無法建立 {$outpath}"); } } $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"; $outimage_orig = $outfile_prefix . ".orig.tag.png"; $outimage_gray = $outfile_prefix . ".gray.png"; $outtext = $outfile_prefix . ".txt"; $outsvg = $outfile_prefix . ".svg"; $outsvg_big = $outfile_prefix . ".svg2"; $merged_gpx = $outfile_prefix . ".gpx2"; $outpdf = $outfile_prefix . ".pdf"; $stage = 1; // 決定哪一種輸出省紙 $type = determine_type($shiftx, $shifty); // add version 3 if ($version == 1) { if ($ph == 1) { cli_error_out("無澎湖圖資"); } $g = new STB($stbpath, $startx, $starty, $shiftx, $shifty); } else { $g = new STB2($tilepath, $startx, $starty, $shiftx, $shifty, $ph); } if (!empty($log_channel)) { $g->setLog($log_channel); cli_msglog("setup log channel " . md5($log_channel)); cli_msglog("ps%0"); } if (!empty($g->err)) {
public function run($job, &$log) { global $out_root, $site_url; $workload = $job->workload(); $todo = unserialize($workload); $uid = 1; $limit = 20000; $puid = WWWRUN_UID; $cmd_make = realpath(__DIR__ . "/../cmd_make2.php"); kcli_msglog($todo); $version = 3; $trk_label = 0; $wpt_label = 2; $shiftx = $todo['shiftx']; $shifty = $todo['shifty']; $startx = $todo['startx']; $starty = $todo['starty']; $xx = $startx * 1000; $yy = $starty * 1000; $ph = $todo['ph']; $gpxfile = $todo['gpx']; $keepon_id = $todo['id']; $title = trim($todo['title']); echo "Doing id={$keepon_id} title={$title}\n"; // 1. 檢查是否已經處理過 keepon_id $map = keepon_map_exists($uid, $keepon_id); if ($map !== false) { if (!isset($map['mid']) || $map['mid'] == 0) { kcli_msglog("keepon_id: {$keepon_id} uid: {$uid} exists but return " . print_r($map)); exit(0); } $ret_url = sprintf("http://map.happyman.idv.tw/twmap/show.php?mid=%d&info=%dx%d-%dx%d", $map['mid'], $map['locX'], $map['locY'], $map['shiftX'], $map['shiftY']); kok_out($keepon_id, "已經產生過", $ret_url, $map['cdate']); $log[] = "{$keepon_id} 已經產生過"; return; } $block_msg = map_blocked($out_root, $uid); if ($block_msg != null) { kerror_out($keepon_id, $block_msg); $log[] = "{$keepon_id} 無法 block"; return; } $outpath = sprintf("%s/%06d", $out_root, $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"; $svg_params = ""; // 終於可以把 gpx 存起來 // if ($inp['gps'] == 1 ) { @mkdir($outpath, 0755, true); if (!copy($gpxfile, $outgpx)) { @unlink($gpxfile); kerror_out($keepon_id, "{$outgpx} 存入上傳檔案失敗"); $log[] = "{$keepon_id} {$gpxfile} {$outgpx} 存入失敗"; return; } @unlink($gpxfile); $svg_params = sprintf("-g %s:%d:%d", $outgpx, $trk_label, $wpt_label); $cmd = sprintf("php %s -r %d:%d:%d:%d -O %s -v %d -t '%s' -i %s -p %d %s", $cmd_make, $startx, $starty, $shiftx, $shifty, $outpath, $version, addslashes($title), "localhost", $ph, $svg_params); kcli_msglog($cmd); $output = array(); exec($cmd, $output, $ret); if ($ret != 0) { kerror_out($keepon_id, implode("\n", $output)); $log[] = "{$keepon_id} 產生錯誤" . implode("\n", $output); return; } // 限制數量 if (map_full($uid, $limit, 0)) { $files = map_files($outimage); foreach ($files as $f) { @unlink($f); } kerror_out($keepon_id, "已經達到數量限制" . $limit); $log[] = "{$keepon_id} 已達數量限制"; return; } $type = determine_type($shiftx, $shifty); $outx = ceil($shiftx / $tiles[$type]['x']); $outy = ceil($shifty / $tiles[$type]['y']); if (file_exists(str_replace(".tag.png", ".gpx", $outimage))) { $gpx = 1; } // 檢查是否重新連線 //require("lib/db.inc.php"); $mid = map_add($uid, $title, $xx, $yy, $shiftx, $shifty, $outx, $outy, "localhost", $outimage, map_size($outimage), $version, 1, $keepon_id); if ($mid === false) { // 防止錯誤發生需要重跑 kcli_msglog(implode("|", array($title, $xx, $yy, $shiftx, $shifty, $keepon_id))); kerror_out($keepon_id, "新增錯誤"); $log[] = "{$keepon_id} 新增錯誤"; return; } // 最後搬移到正確目錄 map_migrate($out_root, $uid, $mid); $okmsg = kcli_msglog("done"); $ret_url = sprintf("%s%s/show.php?mid=%d&info=%dx%d-%dx%d", $site_url, $site_html_root, $mid, $xx, $yy, $shiftx, $shifty); kok_out($keepon_id, "done", $ret_url); $log[] = "{$keepon_id} 產生完畢"; }
function get_info($f) { global $descr; if(!isset($_REQUEST['type'])) $_REQUEST['type'] = determine_type($f); if(isset($_REQUEST['file'])) $f = clean($_REQUEST['file'], true); if($f == lang('My computer')) { $_RESULT = array( 'name' => 'details', 'filename' => htmlspecialchars($f), 'dir' => false, 'type' => lang('System folder'), ); }else if(in_array($_REQUEST['type'],array(tDIR,tFILE))) { if(!@lstat($f)) return null; $ext=pathinfo($f); @$ext=strtolower($ext['extension']); $imgext = array('jpeg','jpe','gif','png','jpg'); if(preg_match('/Darwin/is', PHP_OS)) $imgext = array_merge($imgext, explode(' ','pdf doc docx ppt pptx xls xlsx tiff tif bmp mov avi mpg mp4 tga psd svg eps key pages html')); $img=in_array($ext,$imgext); //echo $f; $real_link = $link_raw = @is_link($f) && function_exists('readlink') ? readlink($f) : false; if($link_raw !== false && $link_raw[0] != '/') // not absolute link { $link_raw = abs_path( dirname($f).'/'.$link_raw ); } $_RESULT=array( 'name' => 'details', 'filename' => htmlspecialchars(basename($f)), 'filename_encoded' => rawurlencode($f), 'fullpath' => $f, 'link' => $link_raw !== false ? htmlspecialchars($real_link) : false, 'link_raw' => $link_raw, 'md5(filename)' => md5($f), 'dir' => d_is_dir($f), 'type' => (d_is_dir($f) ? false : get_type($f)), 'changed' => ((@$t=filemtime($f)) ? date('d F Y, H:i',$t) : false), 'size' => ( (d_is_dir($f) && !SHOW_DIRSIZE) ? (/*no subdirectories*/!empty($GLOBALS['files']) && sizeof($GLOBALS['dirs'])==0 && !empty($GLOBALS['sz']) ? show_size(true,true,$GLOBALS['sz']) : false) : show_size($f)), 'size_bytes' => d_filesize($f), 'thumb' => ($img ? '<div style="padding-bottom: 10px;" align="center"><img src="system/preview.php?file='.rawurlencode($f).'&size=small" align="center"></div>' : false), 'id3' => (($img && d_filesize($f) < 15*1024*1024 && @$sz=getimagesize($f)) ? 'Dimensions: '.$sz[0].'x'.$sz[1] : ''), 'owner' => get_owner($f), 'group' => get_group($f), 'rights' => d_get_rights($f, false), ); }else if($_REQUEST['type']==tDRIVE) { $_RESULT=array( 'name' => 'details', 'filename' => !empty($_REQUEST['name']) ? $_REQUEST['name'] : $_SESSION['DIR'], 'type' => $descr[$_REQUEST['icon']], 'dir' => false, ); if(!empty($_REQUEST['fs'])) $_RESULT['fs'] = $_REQUEST['fs']; if($s = disk_free_space($f)) $_RESULT['free']=show_size(true,true,$s); if($s = disk_total_space($f)) $_RESULT['total']=show_size(true,true,$s); } return $_RESULT; }