$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">
$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; }