예제 #1
0
function getMapCornerPositionsAndRouteCoordinates($id)
{
    $map = new Map();
    $map->Load($id);
    $user = DataAccess::GetUserByID($map->UserID);
    $categories = DataAccess::GetCategoriesByUserID($user->ID);
    return Helper::GetOverviewMapData($map, true, false, false, $categories);
}
예제 #2
0
 public function Execute()
 {
     $viewData = array();
     // no user specified - redirect to user list page
     if (!getCurrentUser()) {
         Helper::Redirect("users.php");
     }
     // user is hidden - redirect to user list page
     if (!getCurrentUser()->Visible) {
         Helper::Redirect("users.php");
     }
     // the requested map
     $map = new Map();
     $map->Load($_GET["map"]);
     if (!$map->ID) {
         die("The map has been removed.");
     }
     DataAccess::UnprotectMapIfNeeded($map);
     if (Helper::MapIsProtected($map)) {
         die("The map is protected until " . date("Y-m-d H:i:s", Helper::StringToTime($map->ProtectedUntil, true)) . ".");
     }
     if ($map->UserID != getCurrentUser()->ID) {
         die;
     }
     $viewData["Comments"] = DataAccess::GetCommentsByMapId($map->ID);
     $viewData["Name"] = $map->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($map->Date, true)) . ')';
     // previous map in archive
     $previous = DataAccess::GetPreviousMap(getCurrentUser()->ID, $map->ID, Helper::GetLoggedInUserID());
     $viewData["PreviousName"] = $previous == null ? null : $previous->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($previous->Date, true)) . ')';
     // next map in archive
     $next = DataAccess::GetNextMap(getCurrentUser()->ID, $map->ID, Helper::GetLoggedInUserID());
     $viewData["NextName"] = $next == null ? null : $next->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($next->Date, true)) . ')';
     $size = $map->GetMapImageSize();
     $viewData["ImageWidth"] = $size["Width"];
     $viewData["ImageHeight"] = $size["Height"];
     DataAccess::IncreaseMapViews($map);
     $viewData["Map"] = $map;
     $viewData["BackUrl"] = isset($_SERVER["HTTP_REFERER"]) && basename($_SERVER["HTTP_REFERER"]) == "users.php" ? "users.php" : "index.php?" . Helper::CreateQuerystring(getCurrentUser());
     $viewData["Previous"] = $previous;
     $viewData["Next"] = $next;
     $viewData["ShowComments"] = isset($_GET["showComments"]) && ($_GET["showComments"] = true) || !__("COLLAPSE_VISITOR_COMMENTS");
     $viewData["FirstMapImageName"] = Helper::GetMapImage($map);
     if ($map->BlankMapImage) {
         $viewData["SecondMapImageName"] = Helper::GetBlankMapImage($map);
     }
     $viewData["QuickRouteJpegExtensionData"] = $map->GetQuickRouteJpegExtensionData();
     if (isset($viewData["QuickRouteJpegExtensionData"]) && $viewData["QuickRouteJpegExtensionData"]->IsValid) {
         $categories = DataAccess::GetCategoriesByUserID(getCurrentUser()->ID);
         $viewData["OverviewMapData"][] = Helper::GetOverviewMapData($map, true, false, false, $categories);
         $viewData["GoogleMapsUrl"] = "http://maps.google.com/maps" . "?q=" . urlencode(Helper::GlobalPath("export_kml.php?id=" . $map->ID . "&format=kml")) . "&language=" . Session::GetLanguageCode();
     }
     if (USE_3DRERUN == '1' && DataAccess::GetSetting("LAST_WORLDOFO_CHECK_DOMA_TIME", "0") + RERUN_FREQUENCY * 3600 < time()) {
         $viewData["RerunMaps"] = Helper::GetMapsForRerunRequest();
         $viewData["TotalRerunMaps"] = count(explode(",", $viewData["RerunMaps"]));
         $viewData["ProcessRerun"] = true;
     }
     return $viewData;
 }
 public function Execute()
 {
     $viewData = array();
     $errors = array();
     $comment = new Comment();
     // no user specified - redirect to user list page
     if (isset($_POST["comment_text"])) {
         $comment->Comment = stripslashes(strip_tags(urldecode($_POST["comment_text"])));
     } else {
         die("No comment text");
     }
     if (isset($_POST["user_name"])) {
         $comment->Name = stripslashes(strip_tags(urldecode($_POST["user_name"])));
     } else {
         die("No user name");
     }
     if (isset($_POST["map_id"]) && is_numeric($_POST["map_id"])) {
         $comment->MapID = $_POST["map_id"];
     } else {
         die("No valid map ID");
     }
     if (isset($_POST["user_email"])) {
         $comment->Email = stripslashes(strip_tags($_POST["user_email"]));
     }
     $comment->UserIP = $_SERVER['REMOTE_ADDR'];
     $comment->DateCreated = date("Y-m-d H:i:s");
     $comment->Save();
     $map = new Map();
     $map->Load($comment->MapID);
     if (__("EMAIL_VISITOR_COMMENTS") && $map->UserID != Helper::GetLoggedInUser()->ID) {
         $user = DataAccess::GetUserByID($map->UserID);
         $fromName = __("DOMA_ADMIN_EMAIL_NAME");
         $subject = __("NEW_COMMENT_EMAIL_SUBJECT");
         $mapAddress = Helper::GlobalPath("show_map.php?user="******"&map=" . $map->ID . "&showComments=true");
         $body = sprintf(__("NEW_COMMENT_EMAIL_BODY"), $map->Name, $mapAddress, $comment->Name, $comment->Email, $comment->Comment);
         $emailSentSuccessfully = Helper::SendEmail($fromName, $user->Email, $subject, $body);
         if (!$emailSentSuccessfully) {
             $errors[] = __("EMAIL_ERROR");
         }
     }
     $viewData["Errors"] = $errors;
     $viewData["Comment"] = $comment;
     $viewData["Map"] = $map;
     return $viewData;
 }
 public function Execute()
 {
     $viewData = array();
     $errors = array();
     $comment = new Comment();
     Helper::WriteToLog("Comment ID: " . $_GET["cid"]);
     if ($_GET["cid"] && is_numeric($_GET["cid"])) {
         $cid = $_GET["cid"];
     } else {
         die("No comment ID");
     }
     $comment->Load($cid);
     $userip = $_SERVER['REMOTE_ADDR'];
     $map = new Map();
     $map->Load($comment->MapID);
     if ($comment->UserIP == $userip || $map->UserID == Helper::GetLoggedInUser()->ID) {
         $comment->Delete();
     } else {
         die("No rights to delete comment!");
     }
     $viewData["Errors"] = $errors;
     return $viewData;
 }
예제 #5
0
 public function Execute()
 {
     $viewData = array();
     $errors = array();
     // no user specified - redirect to user list page
     if (!getCurrentUser()) {
         Helper::Redirect("users.php");
     }
     if (!Helper::IsLoggedInUser()) {
         Helper::Redirect("users.php");
     }
     if (isset($_GET["map"])) {
         $mapID = $_GET["map"];
     }
     foreach ($_GET as $variable => $value) {
         ${$variable} = stripslashes($value);
     }
     foreach ($_POST as $variable => $value) {
         ${$variable} = stripslashes($value);
     }
     if (isset($cancel)) {
         Helper::Redirect("index.php?" . Helper::CreateQuerystring(getCurrentUser()));
     }
     if (isset($save) || isset($delete) || isset($deleteConfirmed)) {
         $map = new Map();
         if (isset($mapID)) {
             $map->Load($mapID);
             if ($map->UserID != getCurrentUser()->ID) {
                 die("Access denied");
             }
             $isNewMap = false;
         } else {
             $isNewMap = true;
         }
         $map->UserID = getCurrentUser()->ID;
         $map->CategoryID = $categoryID;
         $map->Date = $date;
         $map->Name = $name;
         if (__("SHOW_ORGANISER")) {
             $map->Organiser = $organiser;
         }
         if (__("SHOW_COUNTRY")) {
             $map->Country = $country;
         }
         if (__("SHOW_DISCIPLINE")) {
             $map->Discipline = $discipline;
         }
         if (__("SHOW_RELAY_LEG")) {
             $map->RelayLeg = $relayLeg;
         }
         if (__("SHOW_MAP_AREA_NAME")) {
             $map->MapName = $mapName;
         }
         if (__("SHOW_RESULT_LIST_URL")) {
             $map->ResultListUrl = $resultListUrl;
         }
         if (__("SHOW_COMMENT")) {
             $map->Comment = $comment;
         }
         $map->ProtectedUntil = $protectedUntil;
     } else {
         // first page load
         if (isset($_GET["map"])) {
             $map = new Map();
             $map->Load($mapID);
             if ($map->UserID != getCurrentUser()->ID) {
                 die("Access denied");
             }
             $isNewMap = false;
         } else {
             $map = new Map();
             $map->Date = date("Y-m-d");
             $map->CategoryID = getCurrentUser()->DefaultCategoryID;
             $isNewMap = true;
         }
     }
     if (isset($save)) {
         // validate
         // name
         if (trim($map->Name) == "") {
             $errors[] = __("NO_MAP_NAME_ENTERED");
         }
         // date
         if (trim($map->Date) == "") {
             $errors[] = __("NO_DATE_ENTERED");
         }
         if (!Helper::LocalizedStringToTime($map->Date, false)) {
             $errors[] = __("INVALID_DATE");
         } else {
             $map->Date = gmdate("Y-m-d H:i:s", Helper::LocalizedStringToTime($map->Date, false));
         }
         // protected until
         if (trim($map->ProtectedUntil) == "") {
             $map->ProtectedUntil = null;
         } else {
             if (!Helper::LocalizedStringToTime($map->ProtectedUntil, false)) {
                 $errors[] = __("INVALID_PROTECTED_UNTIL");
             } else {
                 $map->ProtectedUntil = gmdate("Y-m-d H:i:s", Helper::LocalizedStringToTime($map->ProtectedUntil, false));
             }
         }
         // images
         $validMimeTypes = array("image/jpeg", "image/gif", "image/png");
         // map image
         $mapImageUploaded = $_FILES["mapImage"]["tmp_name"] != "";
         if ($mapImageUploaded) {
             $mapImageInfo = getimagesize($_FILES["mapImage"]["tmp_name"]);
         }
         if ($mapImageUploaded && !in_array($mapImageInfo["mime"], $validMimeTypes)) {
             $errors[] = sprintf(__("INVALID_MAP_IMAGE_FORMAT"), $_FILES["mapImage"]["name"]);
         }
         // map image
         $blankMapImageUploaded = $_FILES["blankMapImage"]["tmp_name"] != "";
         if ($blankMapImageUploaded) {
             $blankMapImageInfo = getimagesize($_FILES["blankMapImage"]["tmp_name"]);
         }
         if ($blankMapImageUploaded && !in_array($blankMapImageInfo["mime"], $validMimeTypes)) {
             $errors[] = sprintf(__("INVALID_BLANK_MAP_IMAGE_FORMAT"), $_FILES["mapImage"]["name"]);
         }
         if ($isNewMap && !$mapImageUploaded && !$blankMapImageUploaded) {
             $errors[] = __("NO_MAP_FILE_ENTERED");
         }
         // thumbnail image
         $thumbnailImageUploaded = $_FILES["thumbnailImage"]["tmp_name"] != "";
         if ($thumbnailImageUploaded) {
             $thumbnailImageInfo = getimagesize($_FILES["thumbnailImage"]["tmp_name"]);
         }
         if ($thumbnailImageUploaded && !in_array($thumbnailImageInfo["mime"], $validMimeTypes)) {
             $errors[] = sprintf(__("INVALID_THUMBNAIL_IMAGE_FORMAT"), $_FILES["thumbnailImage"]["name"]);
         }
         if (count($errors) == 0) {
             $thumbnailCreatedSuccessfully = false;
             $mapImageData = Helper::SaveTemporaryFileFromUploadedFile($_FILES["mapImage"]);
             if ($mapImageData["error"] == "couldNotCopyUploadedFile") {
                 $errors[] = sprintf(__("MAP_IMAGE_COULD_NOT_BE_UPLOADED"), $_FILES["mapImage"]["name"]);
             }
             $blankMapImageData = Helper::SaveTemporaryFileFromUploadedFile($_FILES["blankMapImage"]);
             if ($blankMapImageData["error"] == "couldNotCopyUploadedFile") {
                 $errors[] = sprintf(__("BLANK_MAP_IMAGE_COULD_NOT_BE_UPLOADED"), $_FILES["blankMapImage"]["name"]);
             }
             $thumbnailImageData = Helper::SaveTemporaryFileFromUploadedFile($_FILES["thumbnailImage"]);
             if ($thumbnailImageData["error"] == "couldNotCopyUploadedFile") {
                 $errors[] = sprintf(__("THUMBNAIL_IMAGE_COULD_NOT_BE_UPLOADED"), $_FILES["thumbnailImage"]["name"]);
             }
             $error = null;
             if (count($errors) == 0) {
                 DataAccess::SaveMapAndThumbnailImage($map, $mapImageData["fileName"], $blankMapImageData["fileName"], $thumbnailImageData["fileName"], $error, $thumbnailCreatedSuccessfully);
             }
             if ($error) {
                 $errors[] = $error;
             }
             if ($mapImageData["fileName"] && file_exists($mapImageData["fileName"])) {
                 unlink($mapImageData["fileName"]);
             }
             if ($blankMapImageData["fileName"] && file_exists($blankMapImageData["fileName"])) {
                 unlink($blankMapImageData["fileName"]);
             }
             if ($thumbnailImageData["fileName"] && file_exists($thumbnailImageData["fileName"])) {
                 unlink($thumbnailImageData["fileName"]);
             }
             if (count($errors) == 0) {
                 Helper::Redirect("index.php?" . Helper::CreateQuerystring(getCurrentUser()) . (!$thumbnailCreatedSuccessfully ? "&error=thumbnailCreationFailure" : ""));
             }
         }
     } elseif (isset($deleteConfirmed)) {
         DataAccess::DeleteMap($map);
         Helper::Redirect("index.php?" . Helper::CreateQuerystring(getCurrentUser()));
     }
     $viewData["Errors"] = $errors;
     $viewData["Categories"] = getCurrentUser()->GetCategories();
     $viewData["Map"] = $map;
     if (isset($mapID)) {
         $viewData["MapID"] = $mapID;
     }
     $viewData["ConfirmDeletionButtonVisible"] = isset($delete);
     $viewData["Title"] = isset($mapID) ? sprintf(__("EDIT_MAP_X"), $map->Name) : __("ADD_MAP");
     return $viewData;
 }
<?php

include_once dirname(__FILE__) . "/config.php";
include_once dirname(__FILE__) . "/include/definitions.php";
if ($_POST["id"] && is_numeric($_POST["id"])) {
    $map = new Map();
    $map->Load($_POST["id"]);
    if (!$map->IsGeocoded) {
        $map->AddGeocoding();
        if ($map->IsGeocoded) {
            $map->Save();
            Helper::WriteToLog("Added geocoding data to database for map with id " . $_POST["id"] . ".");
            print "1";
        } else {
            Helper::WriteToLog("Failed to add geocoding data to database for map with id " . $_POST["id"] . ". Probably no QuickRoute jpeg file.");
            print "2";
        }
    } else {
        print "3";
    }
}
예제 #7
0
<?php

include_once dirname(__FILE__) . "/include/main.php";
$format = $_GET["format"];
if ($format != "kmz") {
    $format = "kml";
}
$id = $_GET["id"];
$map = new Map();
$map->Load($id);
$data = $map->CreateKmlString(Helper::LocalPath(MAP_IMAGE_PATH), Helper::GlobalPath(MAP_IMAGE_PATH), $format);
if ($format == "kml") {
    header("Content-Type: application/vnd.google-earth.kml+xml; charset=UTF-8");
    header('Content-Disposition: attachment; filename="map_' . $id . '.kml";');
} else {
    header("Content-Type: application/vnd.google-earth.kmz");
    header('Content-Disposition: attachment; filename="map_' . $id . '.kmz";');
}
print $data;