public function Execute() { $viewData = array(); $errors = array(); if (Helper::IsLoggedInAdmin() && isset($_GET["loginAsUser"])) { // login as a certain user and redirect to his page if (Helper::LoginUserByUsername($_GET["loginAsUser"])) { Helper::Redirect("index.php?" . Helper::CreateQuerystring(getCurrentUser())); } } $viewData["Users"] = DataAccess::GetAllUsers(!Helper::IsLoggedInAdmin()); $viewData["LastMapForEachUser"] = DataAccess::GetLastMapsForUsers("date"); // last x maps $numberOfMaps = isset($_GET["lastMaps"]) && is_numeric($_GET["lastMaps"]) ? (int) $_GET["lastMaps"] : (isset($_GET["lastMaps"]) && $_GET["lastMaps"] == "all" ? 999999 : 10); $viewData["LastMaps"] = DataAccess::GetMaps(0, 0, 0, 0, null, $numberOfMaps, "createdTime", Helper::GetLoggedInUserID()); // last x comments $numberOfComments = isset($_GET["lastComments"]) && is_numeric($_GET["lastComments"]) ? (int) $_GET["lastComments"] : (isset($_GET["lastComments"]) && $_GET["lastComments"] == "all" ? 999999 : 10); $viewData["LastComments"] = DataAccess::GetLastComments($numberOfComments, Helper::GetLoggedInUserID()); $viewData["OverviewMapData"] = null; $categories = DataAccess::GetCategoriesByUserID(); foreach ($viewData["LastMaps"] as $map) { $data = Helper::GetOverviewMapData($map, false, true, true, $categories); if ($data != null) { $viewData["OverviewMapData"][] = $data; } } if (isset($_GET["error"]) && $_GET["error"] == "email") { $errors[] = sprintf(__("ADMIN_EMAIL_ERROR"), ADMIN_EMAIL); } $viewData["Errors"] = $errors; return $viewData; }
public function Execute() { $viewData = array(); $errors = 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"); } if (isset($_POST["cancel"])) { Helper::Redirect("index.php?" . Helper::CreateQuerystring(getCurrentUser())); } if (isset($_GET["action"]) && $_GET["action"] == "logout") { $location = "index.php?" . Helper::CreateQuerystring(getCurrentUser()); Helper::LogoutUser(); Helper::Redirect($location); } if (isset($_POST["login"])) { $currentUserID = getCurrentUser()->ID; if (Helper::LoginUser(stripslashes($_POST["username"]), stripslashes($_POST["password"]))) { if (getCurrentUser()->ID == $currentUserID) { Helper::Redirect("index.php?" . Helper::CreateQuerystring(getCurrentUser())); } } $errors[] = __("INVALID_USERNAME_OR_PASSWORD"); } if (isset($_POST["forgotPassword"])) { Helper::Redirect("send_new_password.php?" . Helper::CreateQuerystring(getCurrentUser())); } $viewData["Errors"] = $errors; return $viewData; }
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(); // 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"); } // no email address for user is not specified if (!getCurrentUser()->Email) { Helper::Redirect("users.php"); } if ($_POST["cancel"]) { Helper::Redirect("login.php?" . Helper::CreateQuerystring(getCurrentUser())); } if ($_POST["send"]) { $password = Helper::CreatePassword(6); $user = getCurrentUser(); $user->Password = md5($password); $user->Save(); $fromName = __("DOMA_ADMIN_EMAIL_NAME"); $subject = __("NEW_PASSWORD_EMAIL_SUBJECT"); $baseAddress = Helper::GlobalPath(""); $userAddress = Helper::GlobalPath("index.php?user="******"NEW_PASSWORD_EMAIL_BODY"), $user->FirstName, $baseAddress, $userAddress, $user->Username, $password); $emailSentSuccessfully = Helper::SendEmail($fromName, $user->Email, $subject, $body); if ($emailSentSuccessfully) { Helper::Redirect("login.php?" . Helper::CreateQuerystring(getCurrentUser()) . "&action=newPasswordSent"); } $errors[] = __("EMAIL_ERROR"); } $viewData["Errors"] = $errors; return $viewData; }
print DOMA_VERSION; ?> " type="text/javascript"></script> </head> <body id="loginBody"> <div id="wrapper"> <?php Helper::CreateTopbar(); ?> <div id="content"> <form class="wide" method="post" action="<?php print $_SERVER["PHP_SELF"]; ?> ?<?php print Helper::CreateQuerystring(getCurrentUser()); ?> "> <h1><?php print __("LOGIN"); ?> </h1> <?php if (isset($_GET["action"]) && $_GET["action"] == "newPasswordSent") { print '<p>' . sprintf(__("NEW_PASSWORD_SENT"), getCurrentUser()->Email) . '</p>'; } ?> <?php
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='******'&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; }
if ($vd["Previous"]) { ?> <a href="show_map.php?<?php print Helper::CreateQuerystring(getCurrentUser(), $vd["Previous"]->ID); ?> "><?php print "<< " . $vd["PreviousName"]; ?> </a><?php } ?> <?php if ($vd["Next"]) { ?> <span class="separator">|</span><a href="show_map.php?<?php print Helper::CreateQuerystring(getCurrentUser(), $vd["Next"]->ID); ?> "><?php print $vd["NextName"] . " >>"; ?> </a> <?php } ?> </div> <div class="clear"></div> </div> <div id="content"> <form id="frm" method="post" action="<?php
public function Execute() { $viewData = array(); $isAdmin = isset($_GET["mode"]) && $_GET["mode"] == "admin" && Helper::IsLoggedInAdmin(); // no user specified and not admin mode - redirect to user list page if (!$isAdmin && !getCurrentUser() && !Session::GetPublicCreationCodeEntered()) { Helper::Redirect("users.php"); } $errors = array(); $user = getCurrentUser(); $isNewUser = !isset($user) || !$user->ID; if ($isNewUser) { $user = new User(); } if (isset($_POST["cancel"])) { Helper::Redirect($isAdmin ? "users.php" : "index.php?" . Helper::CreateQuerystring($user)); } if ($isAdmin && isset($_POST["deleteConfirmed"])) { DataAccess::DeleteUserByID($user->ID); Helper::Redirect($isAdmin ? "users.php" : "index.php?" . Helper::CreateQuerystring($user)); } // any category handling button clicked? $addCategory = null; $deleteCategory = null; foreach ($_POST as $key => $value) { if (substr($key, 0, 15) == "deleteCategory_") { $deleteCategory = substr($key, 15); break; } if ($key == "addCategory") { $addCategory = true; break; } } if (isset($_POST["save"]) || isset($_POST["delete"]) || $deleteCategory || $addCategory) { // populate user object with data from form elements $user->Username = stripslashes($_POST["username"]); $password = stripslashes($_POST["password"]); if ($password) { $user->Password = md5($password); } $user->FirstName = stripslashes($_POST["firstName"]); $user->LastName = stripslashes($_POST["lastName"]); $user->Email = stripslashes($_POST["email"]); if ($isAdmin) { $user->Visible = $_POST["visible"] ? 1 : 0; } if (!$isAdmin && $isNewUser) { $user->Visible = 1; } $defaultCategory = $_POST["defaultCategory"]; $noOfCategoriesAdded = $_POST["noOfCategoriesAdded"]; // the category array foreach ($_POST as $key => $value) { if (substr($key, 0, 17) == "categoryName_new_") { $id = "1_" . sprintf("%08d", substr($key, 17)); $categories[$id] = new Category(); $categories[$id]->Name = stripslashes($value); $categories[$id]->UserID = $user->ID; } elseif (substr($key, 0, 13) == "categoryName_") { $id = "0_" . sprintf("%08d", substr($key, 13)); $categories[$id] = new Category(); $categories[$id]->Name = stripslashes($value); $categories[$id]->UserID = $user->ID; $categories[$id]->ID = substr($key, 13); } } ksort($categories); // shall we delete a category? if ($deleteCategory) { if (count($categories) <= 1) { $errors[] = __("CAN_NOT_DELETE_ALL_CATEGORIES"); } else { if (substr($deleteCategory, 0, 4) == "new_") { // unsaved categories can be deleted directly $id = "1_" . sprintf("%08d", substr($deleteCategory, 4)); unset($categories[$id]); } else { // for saved categories, we need to check for existing maps $id = "0_" . sprintf("%08d", $deleteCategory); $noOfMapsInCategory = DataAccess::NoOfMapsInCategory($deleteCategory); if ($noOfMapsInCategory > 0) { $errors[] = sprintf(__("CAN_NOT_DELETE_NONEMPTY_CATEGORY"), $categories[$id]->Name, $noOfMapsInCategory); } else { unset($categories[$id]); } } } } if ($addCategory) { $id = "1_" . sprintf("%08d", $noOfCategoriesAdded); $categories[$id] = new Category(); $categories[$id]->UserID = $user->ID; $noOfCategoriesAdded++; } } else { // first page visit if ($isNewUser) { $noOfCategoriesAdded = 0; if ($isAdmin) { $_POST["sendEmail"] = 1; } $defaultCategoryNames = @explode(";", __("DEFAULT_CATEGORY_NAMES")); sort($defaultCategoryNames); $categories = array(); foreach ($defaultCategoryNames as $dcn) { $c = new Category(); $c->Name = $dcn; $categories["1_" . sprintf("%08d", $noOfCategoriesAdded)] = $c; $noOfCategoriesAdded++; } $defaultCategory = "new_0"; } else { $categories = $user->GetCategories(); $defaultCategory = $user->DefaultCategoryID; } $customizableSettings = Helper::GetCustomizableStrings(); foreach ($customizableSettings["settings"] as $key => $value) { $_POST["CV_{$key}"] = __($key); } } // create category data for output and make sure that there is a default category $categoryData = array(); $defaultCategoryIndex = -1; foreach ($categories as $key => $c) { $d = array(); $d["category"] = $c; if ($c->ID) { $d["nameId"] = "categoryName_" . $c->ID; $d["defaultValue"] = $c->ID; $d["deleteId"] = "deleteCategory_" . $c->ID; } else { $id = (int) substr($key, 2); $d["nameId"] = "categoryName_new_{$id}"; $d["defaultValue"] = "new_{$id}"; $d["deleteId"] = "deleteCategory_new_{$id}"; } $d["defaultId"] = "categoryDefault_" . $d["defaultValue"]; if ($defaultCategory == $d["defaultValue"]) { $defaultCategoryIndex = count($categoryData); } $categoryData[] = $d; } $defaultCategory = $defaultCategoryIndex == -1 ? 0 : $categoryData[$defaultCategoryIndex]["defaultValue"]; if (isset($_POST["save"])) { // validate if (DataAccess::UsernameExists($user->Username, $user->ID)) { $errors[] = __("USERNAME_EXISTS"); } if (trim($user->Username) == "") { $errors[] = __("NO_USERNAME_ENTERED"); } if (!$user->ID && trim($password) == "") { $errors[] = __("NO_PASSWORD_ENTERED"); } if (trim($user->FirstName) == "") { $errors[] = __("NO_FIRST_NAME_ENTERED"); } if (trim($user->LastName) == "") { $errors[] = __("NO_LAST_NAME_ENTERED"); } if ($user->Email == "") { $errors[] = __("NO_EMAIL_ENTERED"); } if ($user->Email != "" && !Helper::IsValidEmailAddress($user->Email)) { $errors[] = __("INVALID_EMAIL"); } foreach ($categories as $c) { if (trim($c->Name) == "") { $emptyCategoryNameFound = true; } } if (isset($emptyCategoryNameFound)) { $errors[] = __("CATEGORY_NAME_CANNOT_BE_EMPTY"); } if (count($errors) == 0) { $userSettings = array(); foreach ($_POST as $key => $value) { if (substr($key, 0, 3) == "CV_") { $key = substr($key, 3); $userSettings[$key] = stripslashes($value); } } DataAccess::SaveUser($user, $categories, $defaultCategoryIndex, $userSettings); // send welcome email if ($isNewUser && !($isAdmin && !$_POST["sendEmail"])) { $fromName = __("DOMA_ADMIN_EMAIL_NAME"); $subject = __("NEW_USER_EMAIL_SUBJECT"); $baseAddress = Helper::GlobalPath(""); $userAddress = Helper::GlobalPath("index.php?user="******"NEW_USER_EMAIL_BODY"), $user->FirstName, $baseAddress, $userAddress, $user->Username, $password); $emailSent = true; $emailSentSuccessfully = Helper::SendEmail($fromName, $user->Email, $subject, $body); } // clear language cache Session::SetLanguageStrings(null); if ($isAdmin) { Helper::Redirect("users.php" . ($emailSent && !$emailSentSuccessfully ? "?error=email" : "")); } else { Helper::Redirect("index.php?" . Helper::CreateQuerystring($user)); } } } if ($isAdmin) { $viewData["Title"] = $user->ID ? sprintf(__("EDIT_USER_X"), $user->FirstName . " " . $user->LastName) : __("ADD_USER"); $viewData["Info"] = ($user->ID ? __("ADMIN_EDIT_USER_INFO") : __("ADMIN_ADD_USER_INFO")) . " " . sprintf(__("REQUIRED_FIELDS_INFO"), '<span class="required">*</span>'); } else { $viewData["Title"] = $isNewUser ? __("ADD_USER_PROFILE_TITLE") : __("EDIT_USER_PROFILE_TITLE"); $viewData["Info"] = sprintf(__("REQUIRED_FIELDS_INFO"), '<span class="required">*</span>'); } $atoms = array(); if ($isAdmin) { $atoms[] = "mode=admin"; } if ($user->ID) { $atoms[] = Helper::CreateQuerystring($user); } $viewData["FormActionURL"] = $_SERVER["PHP_SELF"] . (count($atoms) > 0 ? "?" . join("&", $atoms) : ""); $viewData["Errors"] = $errors; $viewData["IsAdmin"] = $isAdmin; $viewData["IsNewUser"] = $isNewUser; $viewData["User"] = $user; $viewData["SendEmail"] = isset($_POST["sendEmail"]); $viewData["CategoryData"] = $categoryData; $viewData["DefaultCategory"] = $defaultCategory; $viewData["DeleteButtonClicked"] = isset($_POST["delete"]); $viewData["NoOfCategoriesAdded"] = isset($noOfCategoriesAdded) ? $noOfCategoriesAdded : 0; $viewData["CustomizableSettings"] = Helper::GetCustomizableStrings(); return $viewData; }
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; }
print DOMA_VERSION; ?> " type="text/javascript"></script> </head> <body id="editMapBody"> <div id="wrapper"> <?php Helper::CreateTopbar(); ?> <div id="content"> <form class="wide" method="post" action="<?php print $_SERVER["PHP_SELF"]; ?> ?<?php print Helper::CreateQuerystring(getCurrentUser(), isset($vd["MapID"]) ? $vd["MapID"] : null); ?> " enctype="multipart/form-data"> <h1><?php print $vd["Title"]; ?> </h1> <?php if (count($vd["Errors"]) > 0) { ?> <ul class="error"> <?php foreach ($vd["Errors"] as $e) { print "<li>{$e}</li>";
?> </th> <th><?php print __("UPDATED"); ?> </th> </tr> </thead> <tbody> <?php $count = 0; foreach ($vd["LastMaps"] as $map) { $count++; $url = "index.php?" . Helper::CreateQuerystring($map->GetUser()); $nameLink = Helper::EncapsulateLink(hsc($map->GetUser()->FirstName . " " . $map->GetUser()->LastName), $url); $mapLink = '<a href="show_map.php?' . Helper::CreateQuerystring($map->GetUser(), $map->ID) . '" class="thumbnailHoverLink">' . hsc($map->Name) . '</a>'; $date = date(__("DATE_FORMAT"), Helper::StringToTime($map->Date, true)); $updated = date(__("DATETIME_FORMAT"), Helper::StringToTime($map->LastChangedTime, true)); $thumbnailImage = '<img src="' . Helper::GetThumbnailImage($map) . '" alt="' . hsc($map->Name) . '" height="' . THUMBNAIL_HEIGHT . '" width="' . THUMBNAIL_WIDTH . '" />'; ?> <tr class="<?php print $count % 2 == 1 ? "odd" : "even"; ?> "> <td><?php print $nameLink; ?> </td> <td> <span class="hoverThumbnailContainer"> <span class="hoverThumbnail hidden">
public static function CreateTopbar() { $isLoggedIn = Helper::IsLoggedInUser() && Helper::GetLoggedInUser()->ID == getCurrentUser()->ID; ?> <div id="topbar"> <div class="left"> <a href="index.php?<?php print Helper::CreateQuerystring(getCurrentUser()); ?> "><?php printf(__("DOMA_FOR_X"), getCurrentUser()->FirstName . " " . getCurrentUser()->LastName); ?> </a> <span class="separator">|</span> <?php if (!$isLoggedIn) { ?> <a href="login.php?<?php print Helper::CreateQuerystring(getCurrentUser()); ?> "><?php print __("LOGIN"); ?> </a> <?php } else { ?> <a href="edit_map.php?<?php print Helper::CreateQuerystring(getCurrentUser()); ?> "><?php print __("ADD_MAP"); ?> </a> <span class="separator">|</span> <a href="edit_user.php?<?php print Helper::CreateQuerystring(getCurrentUser()); ?> "><?php print __("USER_PROFILE"); ?> </a> <span class="separator">|</span> <a href="login.php?<?php print Helper::CreateQuerystring(getCurrentUser()); ?> &action=logout"><?php print __("LOGOUT"); ?> </a> <?php } ?> </div> <div class="right"> <a href="users.php"><?php print __("ALL_USERS"); ?> </a> <span class="separator">|</span> <?php if (SHOW_LANGUAGES_IN_TOPBAR == "1") { Helper::ShowLanguages(); ?> <span class="separator">|</span> <?php } ?> <a href="http://www.matstroeng.se/doma/?version=<?php print DOMA_VERSION; ?> "><?php printf(__("DOMA_VERSION_X"), DOMA_VERSION); ?> </a> </div> <div class="clear"></div> </div> <?php }
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; }
<?php if (Helper::IsLoggedInUser() && Helper::GetLoggedInUser()->ID == getCurrentUser()->ID) { ?> <div class="admin"> <?php print $map->Views; ?> <?php print __("VIEWS"); ?> <span class="separator">|</span> <a href="edit_map.php?<?php print Helper::CreateQuerystring(getCurrentUser(), $map->ID); ?> "><?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