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;
 }
Beispiel #2
0
 public function CreateKmlString($localMapImagePath, $globalMapImagePath, $format = "kmz")
 {
     if (!$this->IsGeocoded) {
         return null;
     }
     $ed = $this->GetQuickRouteJpegExtensionData();
     $size = $this->GetMapImageSize();
     $latLngs = array(new LatLng($ed->ImageCornerPositions["NW"]->Latitude, $ed->ImageCornerPositions["NW"]->Longitude), new LatLng($ed->ImageCornerPositions["SE"]->Latitude, $ed->ImageCornerPositions["SE"]->Longitude));
     $points = array(new Point(0, 0), new Point($size["Width"] - 1, $size["Height"] - 1));
     $geocodedMap = new GeocodedMap();
     $geocodedMap->createFromCoordinatePairs($latLngs, $points, $localMapImagePath . "/" . $this->MapImage, $globalMapImagePath . "/" . $this->MapImage);
     $title = $this->GetUser()->FirstName . " " . $this->GetUser()->LastName . ": " . $this->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($this->Date, true)) . ")";
     return $geocodedMap->saveToString($title, $format);
 }
Beispiel #3
0
<div class="container">
<label for="thumbnailImage"><?php 
print __("THUMBNAIL_IMAGE_FILE");
?>
</label>
<input type="file" id="thumbnailImage" name="thumbnailImage" class="tooltipControl" />
<div class="tooltip hidden"><?php 
printf(__("THUMBNAIL_INFO"), THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
?>
</div>
</div>

<div class="container">
<?php 
$protectedUntil = $map->ProtectedUntil;
$protectedUntilTime = $protectedUntil != null ? Helper::StringToTime($protectedUntil, true) : null;
if ($protectedUntilTime != null) {
    $protectedUntil = date(__("DATETIME_FORMAT"), $protectedUntilTime);
}
?>
<label for="protectedUntil"><?php 
print __("PROTECTED_UNTIL");
?>
</label>
<input type="text" id="protectedUntil" class="text tooltipControl" name="protectedUntil" value="<?php 
print hsc($protectedUntil);
?>
" />
<div class="tooltip hidden"><?php 
print __("PROTECTED_UNTIL_INFO");
?>
 public function Execute()
 {
     $viewData = array();
     // check if user is not specified or hidden
     if (!getCurrentUser()) {
         // all maps in archive
         $mode = "all";
         $count = $_GET["count"];
         if (!$count) {
             $count = 30;
         }
         $maps = DataAccess::GetMaps(0, 0, 0, 0, null, $count, "ID");
         $categories = DataAccess::GetCategoriesByUserID();
         $users = DataAccess::GetAllUsers(true);
         $viewData["Title"] = _SITE_TITLE;
         $viewData["LastCreatedTime"] = date("r", DataAccess::GetLastCreatedTime());
         $viewData["Description"] = _SITE_DESCRIPTION;
         $viewData["WebsiteUrl"] = Helper::GlobalPath("index.php");
     } else {
         // specified archive
         $mode = "user";
         if (!getCurrentUser()->Visible) {
             die;
         }
         $users[getCurrentUser()->ID] = getCurrentUser();
         $maps = DataAccess::GetMaps(getCurrentUser()->ID);
         $categories = DataAccess::GetCategoriesByUserID(getCurrentUser()->ID);
         $viewData["Title"] = __("PAGE_TITLE");
         $viewData["LastCreatedTime"] = date("r", DataAccess::GetLastCreatedTime(getCurrentUser()->ID));
         $viewData["Description"] = __("RSS_DESCRIPTION");
         $viewData["WebsiteUrl"] = Helper::GlobalPath("index.php?" . Helper::CreateQuerystring(getCurrentUser()));
     }
     $viewData["Items"] = array();
     foreach ($maps as $map) {
         $item = array();
         $user = $users[$map->UserID];
         $item["Title"] = hsc(Helper::DateToLongString(Helper::StringToTime($map->Date, true)) . ": " . $map->Name);
         $item["URL"] = $map->MapImage ? Helper::GlobalPath('show_map.php?user='******'&amp;map=' . $map->ID) : "";
         $atoms = array();
         if (__("SHOW_MAP_AREA_NAME") && $map->MapName != "") {
             $atoms[] = $map->MapName;
         }
         if (__("SHOW_ORGANISER") && $map->Organiser != "") {
             $atoms[] = $map->Organiser;
         }
         if (__("SHOW_COUNTRY") && $map->Country != "") {
             $atoms[] = $map->Country;
         }
         $atoms2 = array();
         if (__("SHOW_DISCIPLINE") && $map->Discipline != "") {
             $atoms2[] = hsc($map->Discipline);
         }
         if (__("SHOW_RELAY_LEG") && $map->RelayLeg != "") {
             $atoms2[] = __("RELAY_LEG_LOWERCASE") . ' ' . hsc($map->RelayLeg);
         }
         $item["Description"] = ($mode == "all" ? hsc($user->FirstName . " " . $user->LastName . '<br />') : '') . __("CATEGORY") . ": " . hsc($categories[$map->CategoryID]->Name) . hsc('<br />') . hsc(join(", ", $atoms)) . hsc('<br />') . join(", ", $atoms2);
         $item["PubDate"] = hsc(date("r", Helper::StringToTime($map->CreatedTime, true)));
         $viewData["Items"][] = $item;
     }
     return $viewData;
 }
Beispiel #5
0
function PublishMapHelper($username, $password, $mapInfo, $mapImageFileName, $blankMapImageFileName, $thumbnailImageFileName)
{
    $success = false;
    // validate username and password
    $user = DataAccess::GetUserByUsernameAndPassword($username, $password);
    if (!$user) {
        $errorMessage = "Invalid username and/or password.";
    } else {
        $map = new Map();
        $map->ID = $mapInfo["ID"];
        $map->UserID = $user->ID;
        $map->CategoryID = $mapInfo["CategoryID"];
        $map->Date = gmdate("Y-m-d H:i:s", Helper::StringToTime($mapInfo["Date"], true));
        $map->Name = $mapInfo["Name"];
        $map->Organiser = $mapInfo["Organiser"];
        $map->Country = $mapInfo["Country"];
        $map->Discipline = $mapInfo["Discipline"];
        $map->RelayLeg = $mapInfo["RelayLeg"];
        $map->MapName = $mapInfo["MapName"];
        $map->ResultListUrl = $mapInfo["ResultListUrl"];
        $map->Comment = $mapInfo["Comment"];
        $map->LastChangedTime = gmdate("Y-m-d H:i:s");
        if (!$mapInfo["ID"]) {
            $map->CreatedTime = gmdate("Y-m-d H:i:s");
        }
        $thumbnailCreatedSuccessfully = false;
        $error = null;
        DataAccess::SaveMapAndThumbnailImage($map, $mapImageFileName, $blankMapImageFileName, $thumbnailImageFileName, $error, $thumbnailCreatedSuccessfully);
        if ($mapImageFileName) {
            unlink($mapImageFileName);
        }
        if ($blankMapImageFileName) {
            unlink($blankMapImageFileName);
        }
        if ($thumbnailImageFileName) {
            unlink($thumbnailImageFileName);
        }
        if (!$mapInfo["ID"]) {
            Helper::LogUsage("addMapWS", "user="******"&map=" . $map->ID);
        }
        $errorMessage = mysql_error();
        $success = $errorMessage == "";
        $url = Helper::GlobalPath("show_map.php?user="******"&map=" . $map->ID);
    }
    return array('Success' => $success, 'ErrorMessage' => $errorMessage, 'URL' => $url);
}
Beispiel #6
0
</th>
    <th><?php 
        print __("UPDATED");
        ?>
</th>
  </tr>
</thead>
<tbody>
      <?php 
        $count = 0;
        foreach ($vd["LastComments"] as $last_comment) {
            $count++;
            $url = "index.php?user="******"UserName"];
            $nameLink = Helper::EncapsulateLink(hsc($last_comment["UserFLName"]), $url);
            $mapLink = '<a href="show_map.php?user='******'&map=' . $last_comment["ID"] . '&showComments=true" class="thumbnailHoverLink">' . hsc($last_comment["Name"]) . '</a>';
            $updated = date(__("DATETIME_FORMAT"), Helper::StringToTime($last_comment["CommentDate"], true));
            ?>
        <tr class="<?php 
            print $count % 2 == 1 ? "odd" : "even";
            ?>
">
          <td><?php 
            print $nameLink;
            ?>
</td>
          <td>
            <?php 
            print $mapLink;
            ?>
          </td>
          <td><?php 
Beispiel #7
0
 public static function GetLastCreatedTime($userID = 0, $requestingUserID = 0)
 {
     $requestingUserID = mysql_real_escape_string($requestingUserID);
     $now = mysql_real_escape_string(gmdate("Y-m-d H:i:s"));
     $userID = mysql_real_escape_string($userID);
     $sql = "SELECT MAX(CreatedTime) AS LastCreatedTime FROM `" . DB_MAP_TABLE . "` " . "WHERE (ProtectedUntil IS NULL OR ProtectedUntil<='{$now}' OR UserID='{$requestingUserID}')" . ($userID ? " AND UserID='{$userID}'" : "");
     $r = mysql_fetch_assoc(self::Query($sql));
     return Helper::StringToTime($r["LastCreatedTime"], true);
 }
 public function Execute()
 {
     $viewData = array();
     // no user specified - redirect to user list page
     if (!getCurrentUser()) {
         $singleUserID = DataAccess::GetSingleUserID();
         if (!$singleUserID) {
             Helper::Redirect("users.php");
         }
         Helper::SetUser(DataAccess::GetUserByID($singleUserID));
     }
     // user is hidden - redirect to user list page
     if (!getCurrentUser()->Visible) {
         Helper::Redirect("users.php");
     }
     $searchCriteria = Session::GetSearchCriteria(getCurrentUser()->ID);
     if (!isset($searchCriteria)) {
         // default search criteria
         $searchCriteria = array("selectedYear" => date("Y"), "selectedCategoryID" => getCurrentUser()->DefaultCategoryID, "filter" => null);
     }
     $viewData["Errors"] = array();
     if (isset($_GET["error"]) && $_GET["error"] == "thumbnailCreationFailure") {
         // calculate max image size for auto-generation of thumbnail
         $memoryLimit = ini_get("memory_limit");
         if (stripos($memoryLimit, "M")) {
             $memoryLimit = (int) str_replace("M", "", $memoryLimit) * 1024 * 1024;
         }
         $memoryLimit -= memory_get_usage();
         $size = round(sqrt($memoryLimit / 4) / 100) * 100;
         $viewData["Errors"][] = sprintf(__("THUMBNAIL_CREATION_FAILURE"), $size . "x" . $size);
     }
     // get all categories
     $allCategoriesItem = new Category();
     $allCategoriesItem->ID = 0;
     $allCategoriesItem->Name = __("ALL_CATEGORIES");
     $categories = DataAccess::GetCategoriesByUserID(getCurrentUser()->ID);
     $viewData["Categories"] = $categories;
     $viewData["CategoriesWithText"] = array_merge(array(0 => $allCategoriesItem), $categories);
     // get all years
     $years = DataAccess::GetYearsByUserID(getCurrentUser()->ID, Helper::GetLoggedInUserID());
     $years = array_reverse($years);
     $viewData["YearsWithText"][0] = array("value" => 0, "text" => __("ALL_YEARS"));
     foreach ($years as $year) {
         $viewData["YearsWithText"][$year] = array("value" => $year, "text" => $year);
     }
     if (!in_array($searchCriteria["selectedYear"], array_keys($viewData["YearsWithText"])) && count($years) > 0) {
         $searchCriteria["selectedYear"] = $years[0];
     }
     $categoryIds = array_keys($categories);
     if ($searchCriteria["selectedCategoryID"] != 0 && !in_array($searchCriteria["selectedCategoryID"], $categoryIds) && count($categories) > 0) {
         $searchCriteria["selectedCategoryID"] = $categoryIds[0];
     }
     if (isset($_GET["year"])) {
         $searchCriteria["selectedYear"] = $_GET["year"];
     }
     if (isset($_GET["categoryID"])) {
         $searchCriteria["selectedCategoryID"] = $_GET["categoryID"];
     }
     if (isset($_GET["filter"])) {
         $searchCriteria["filter"] = $_GET["filter"];
     }
     if (isset($_GET["displayMode"])) {
         $viewData["DisplayMode"] = $_GET["displayMode"];
     } else {
         $viewData["DisplayMode"] = "list";
     }
     $startDate = $searchCriteria["selectedYear"] == 0 ? 0 : Helper::StringToTime($searchCriteria["selectedYear"] . "-01-01", true);
     $endDate = $searchCriteria["selectedYear"] == 0 ? 0 : Helper::StringToTime($searchCriteria["selectedYear"] . "-12-31", true);
     $viewData["SearchCriteria"] = $searchCriteria;
     // get map data
     $viewData["Maps"] = DataAccess::GetMaps(getCurrentUser()->ID, $startDate, $endDate, $searchCriteria["selectedCategoryID"], $searchCriteria["filter"], 0, "date", Helper::GetLoggedInUserID());
     $viewData["GeocodedMapsExist"] = false;
     foreach ($viewData["Maps"] as $map) {
         $mapInfo = array();
         $mapInfo["URL"] = $map->MapImage ? 'show_map.php?' . Helper::CreateQuerystring(getCurrentUser(), $map->ID) : "";
         $mapInfo["Name"] = $map->Name . ' (' . date(__("DATE_FORMAT"), Helper::StringToTime($map->Date, true)) . ')';
         $mapInfo["MapThumbnailHtml"] = Helper::EncapsulateLink('<img src="' . Helper::GetThumbnailImage($map) . '" alt="' . $mapInfo["Name"] . '" height="' . THUMBNAIL_HEIGHT . '" width="' . THUMBNAIL_WIDTH . '" />', $mapInfo["URL"]);
         $atoms = array();
         if (__("SHOW_MAP_AREA_NAME") && $map->MapName) {
             $atoms[] = $map->MapName;
         }
         if (__("SHOW_ORGANISER") && $map->Organiser) {
             $atoms[] = $map->Organiser;
         }
         if (__("SHOW_COUNTRY") && $map->Country) {
             $atoms[] = $map->Country;
         }
         $mapInfo["MapAreaOrganiserCountry"] = join(", ", $atoms);
         if ($map->Comment) {
             $maxLength = 130;
             $strippedComment = strip_tags($map->Comment);
             $mapInfo["IsExpandableComment"] = !($strippedComment == $map->Comment && strlen($map->Comment) <= $maxLength);
             if ($mapInfo["IsExpandableComment"]) {
                 $mapInfo["ContractedComment"] = substr($strippedComment, 0, $maxLength) . "...";
             }
         }
         $viewData["MapInfo"][$map->ID] = $mapInfo;
         if ($viewData["DisplayMode"] == "overviewMap" && $map->IsGeocoded) {
             $viewData["OverviewMapData"][] = Helper::GetOverviewMapData($map, false, true, false, $categories, $searchCriteria["selectedCategoryID"]);
         }
         if ($map->IsGeocoded) {
             $viewData["GeocodedMapsExist"] = true;
         }
     }
     if (!$viewData["GeocodedMapsExist"]) {
         $viewData["DisplayMode"] = "list";
     }
     Session::SetSearchCriteria(getCurrentUser()->ID, $searchCriteria);
     return $viewData;
 }
Beispiel #9
0
        ?>
"><?php 
        print __("EDIT_MAP");
        ?>
</a>
        </div>
      <?php 
    }
    ?>
      
      <?php 
    if ($map->ProtectedUntil != null && $map->ProtectedUntil > gmdate("Y-m-d H:i:s")) {
        ?>
        <div class="protected">
          <?php 
        print sprintf(__("MAP_IS_PROTECTED_UNTIL_X"), date(__("DATETIME_FORMAT"), Helper::StringToTime($map->ProtectedUntil, true)));
        ?>
        </div>
      <?php 
    }
    ?>

    </div>

    <?php 
    if (__("SHOW_COMMENT") && $map->Comment) {
        if (!$mapInfo["IsExpandableComment"]) {
            ?>
          <div class="comment"><?php 
            print $map->Comment;
            ?>