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; }
echo "Please run as root\n"; exit; } $opt = getopt("t:r"); if (!isset($opt['t'])) { echo "Usage: {$argv['0']} -t 180 -d\n"; echo " -r: real run, default is dry run\n"; echo " -t days: expire maps xx days ago\n"; exit(0); } $tt = $opt['t']; $realdo = 0; if (isset($opt['r'])) { $realdo = 1; } echo $realdo == 1 ? "Do " : "Test (without -r)"; echo "expire maps start: " . date('Y-m-d H:i:s') . "\n"; list($file_expired, $size_freed) = do_expire($tt, $realdo); echo "Expire from " . date('Y-m-d H:i', time() - $tt * 86400) . "\n"; echo "File expired: {$file_expired}\n"; echo "Size Freed: " . humanreadable($size_freed) . "\n"; echo "Total Size: " . humanreadable(map_totalsize()) . "\n"; /* $a =map_expire($mid); if ($a === false) { echo "failed\n"; } else { echo "done\n"; } */
<?php if (!$_SESSION) { session_start(); } if (empty($_SESSION['loggedin'])) { header("Location: login.php"); exit(0); } require_once "config.inc.php"; $smarty->assign("twmap_gen_version", $twmap_gen_version); list($total_maps, $total_size, $all_users, $active_users, $created) = stats(); $smarty->assign("size", humanreadable($total_size)); $smarty->assign("all_users", $all_users); $smarty->assign("created", $created); $smarty->assign("total_maps", $total_maps); $smarty->assign("active_users", $active_users); $smarty->assign("avg_maps", floor($total_maps / $active_users)); $smarty->display("about.html");