require_once dirname(__FILE__) . "/../include/classes/statistics.class.php"; $mapId = (int) $_GET['mapid']; $stats = new Statistics(); $map = getMapById($mapId); $cacheDirectory = dirname(__FILE__) . "/../cache"; $cacheFile = $cacheDirectory . "/" . md5($mapId) . ".cache"; if (file_exists($cacheFile)) { // Show file from cache $stats->addMapView($_SERVER['REMOTE_ADDR'], $mapId, $map['name'], $map['users_id']); echo file_get_contents($cacheFile); exit; } $user = getUserInfo(); if ($map) { if ($map['password'] == "" || $_POST['password'] == $map['password'] || $user && $user['id'] == $map['users_id']) { $shapes = getShapesByMapId($mapId); $content = processMapFile($map, $shapes, dirname(__FILE__) . "/map/view.tpl"); if ($map['password'] == "") { file_put_contents($cacheFile, $content); } $stats->addMapView($_SERVER['REMOTE_ADDR'], $mapId, $map['name'], $map['users_id']); echo $content; exit; } } else { die("Map Not Found!"); } ?> <!DOCTYPE html> <html lang="en">
function getPureJSON($mapId) { $map = getMapById((int) $mapId); $shapes = getShapesByMapId($mapId); $geoJSON = array("type" => "FeatureCollection", "features" => array()); if (is_array($shapes) && count($shapes) > 0) { $i = 0; foreach ($shapes as $shape) { $propertiesList = array(); $properties = json_decode($shape['properties']); foreach ($properties as $property) { $propertiesList[$property->name] = $property->value; } $geoJSON['features'][$i] = array("type" => "Feature", "properties" => $propertiesList, "geometry" => array("type" => $shape['type'], "coordinates" => json_decode($shape['coordinates']))); $i++; } } return json_encode($geoJSON); }
<?php require_once dirname(__FILE__) . "/../include/master.inc.php"; if (!isLogin()) { redirect("login.php"); } $user = getUserInfo(); if (isset($_GET['action']) && $_GET['action'] == 'delete') { deleteMarker((int) $_GET['marker_id'], (int) $_GET['id'], $user['id']); redirect("map-edit.php?id=" . (int) $_GET['id']); } $map = getMapById((int) $_GET['id'], (int) $user['id']); if (!$map) { redirect("map.php"); } $shapes = getShapesByMapId((int) $map['id']); $create_update = "Update"; if ($_GET['action'] == 'create') { $PAGE = "MAP_CREATE"; $create_update = "Create"; } else { $PAGE = "MAP_VIEW"; } $layers = getLayersByUserId($user['id']); $groups = getGroupsByUserId($user['id']); if (isAdmin($user)) { $projects = getProjectsByUserId($user['id']); } else { $projects = getMyProjects($user['id']); } ?>
foreach ($maps as $map) { $shapes = getShapesByMapId($map['id']); $output['message'][] = array('id' => $map['id'], 'title' => $map['name'], 'height' => $map['height'], 'width' => $map['width'], 'html' => processMapFile($map, $shapes, dirname(__FILE__) . "/../app/map/view.tpl", true)); } $output['success'] = true; } else { $output['success'] = false; $output['message'] = 'No Map Found. Please check and update your API Key under Studio Settings'; } break; case "refresh": $id = (int) $_GET['id']; $maps = getMapsByIdAndApiKey($id, $apikey); if ($maps && count($maps) > 0) { foreach ($maps as $map) { $shapes = getShapesByMapId($map['id']); $output['message'][] = array('id' => $map['id'], 'title' => $map['name'], 'height' => $map['height'], 'width' => $map['width'], 'html' => processMapFile($map, $shapes, dirname(__FILE__) . "/../app/map/view.tpl", true)); } $output['success'] = true; } else { $output['success'] = false; $output['message'] = 'No Map Found. Please check and update your API Key under Studio Settings'; } break; case "allmaps": $output = getMapsByApiKey($apikey); break; default: $output['success'] = false; $output['message'] = 'Invalid Request'; break;