예제 #1
0
파일: site.php 프로젝트: silmith/IChooseYou
 public static function RequiresLoggedInUser($redirectTo)
 {
     if (!UserFacade::IsUserLoggenIn()) {
         $error = new Error(Error::NotAuthenticated, "You have to log in to get access to that page.");
         Site::Redirect($redirectTo, $error);
     }
 }
예제 #2
0
 /**
  * Redirects the page to the root of the website
  * @param logout, if set to true will also log out the user.
  */
 public static function BackToHome($logout = false)
 {
     if ($logout != false) {
         Site::Redirect(Site::GetBaseURL(true) . 'Logout' . URLPAGEEXT);
     } else {
         Site::Redirect(Site::GetBaseURL() . 'Home' . URLPAGEEXT);
     }
 }
예제 #3
0
$recipe = null;
$id = Site::GetArgumentSafely('id');
if (Value::SetAndNotNull($id)) {
    $recipe = Recipe::Load($id);
    if (Value::SetAndNotNull($recipe)) {
        $recipe->LoadSteps();
        $edit = false;
        //Value::SetAndEqualTo($recipe->GetUsertrue, $GLOBALS, 'EDIT', true);
        if (Value::SetAndNotNull($_POST, 'CommentInput') && Site::CheckSecurityToken()) {
            $message = Site::GetPostValueSafely('CommentInput');
            $commentid = Site::GetPostValueSafely('CommentSelect');
            if (!is_numeric($commentid)) {
                $commentid = EMPTYSTRING;
            }
            Comment::Insert($message, $id, $commentid);
            Site::Redirect(EMPTYSTRING);
        }
    } else {
        Site::BackToHome();
    }
} else {
    Site::BackToHome();
}
// Page Output
include_once 'Pages/OnAllPages.php';
$recipebox = new RTK_Box('recipebox');
$recipedescription = new RTK_Box(null, 'recipedescription');
$recipedescription->AddChild(new RTK_Header($recipe->GetTitle()));
//if (!$edit) { $recipedescription->AddChild(new RTK_Link('EditRecipe'.URLPAGEEXT, 'Edit')); }
if ($recipe->GetPicture() != null) {
    $recipedescription->AddChild(new RTK_Image('/' . $recipe->GetPicture()->GetFileName()));
예제 #4
0
    if ($error->code != Error::NoError) {
        Site::Redirect("/register.php", $error);
    }
    $error = UserFacade::RegisterUser($user, $password);
    if ($error->code != Error::NoError) {
        Site::Redirect("/register.php", $error);
    }
    $error = UserFacade::LogUserIn($user, $password);
    if ($error->code != Error::NoError) {
        Site::Redirect("/log-in.php", $error);
    }
} else {
    $error = new Error(Error::InvalidParameter, "No parameter has been sent.");
    Site::Redirect("/register.php", $error);
}
Site::Redirect("/index.php");
//Checks whether parameters are correct
function ValidateParameters($user, $password, $retypedPassword)
{
    if (empty($user)) {
        return new Error(Error::InvalidParameter, "User name cannot be empty.");
    }
    if (UserFacade::IsUserRegistered($user)) {
        return new Error(Error::NotUniqueValue, "User with provided name is already registered.");
    }
    if (empty($password)) {
        return new Error(Error::InvalidParameter, "Password cannot be empty.");
    }
    if (strcmp($password, $retypedPassword)) {
        return new Error(Error::InvalidParameter, "Passwords don't match to each other.");
    }
예제 #5
0
    $actionName = $_POST["submit"];
    $userId = UserFacade::GetLoggedUserId();
    $error = new Error();
    if ($championId == 0) {
        $error = new Error(Error::InvalidParameter, "Invalid champion chosen.");
        Site::Redirect("/manage-champions.php", $error);
    }
    $error = PerformAction($actionName, $championId, $userId);
    if ($error->code != Error::NoError) {
        Site::Redirect("/manage-champions.php", $error);
    }
} else {
    $error = new Error(Error::InvalidParameter, "No parameter has been sent.");
    Site::Redirect("/manage-champions.php", $error);
}
Site::Redirect("/manage-champions.php");
//Based by provided action name, adds or removes provided champion.
//Returns error code
function PerformAction($actionName, $championId, $userId)
{
    $error = new Error();
    if (strcmp($actionName, "Add") == 0) {
        $error = ChampionFacade::AddChampionToUser($championId, $userId);
    } else {
        if (strcmp($actionName, "Remove") == 0) {
            $error = ChampionFacade::RemoveChampionFromUser($championId, $userId);
        } else {
            $error = new Error(Error::InvalidParameter, "Invalid action: " . $actionName);
        }
    }
    return $error;
예제 #6
0
        Site::Redirect("/add-new-champion.php", $error);
    }
    $fileName = GenerateFileNameWithPath($championName);
    $error = SaveFile($file, $fileName);
    if ($error->code != Error::NoError) {
        Site::Redirect("/add-new-champion.php", $error);
    }
    $error = ChampionFacade::AddChampion($championName, $fileName);
    if ($error->code != Error::NoError) {
        Site::Redirect("/add-new-champion.php", $error);
    }
} else {
    $error = new Error(Error::InvalidParameter, "No parameter has been sent.");
    Site::Redirect("/add-new-champion.php", $error);
}
Site::Redirect("/add-new-champion.php");
//Checks whether all provided parameters are correct
function ValidateParameters($championName, $file)
{
    if (strlen($championName) == 0) {
        return new Error(Error::InvalidParameter, "Invalid champion name.");
    }
    if (ChampionFacade::DoesChampionExists($championName)) {
        return new Error(Error::NotUniqueValue, "Provided champion already exists.");
    }
    if (!isset($file) || $file === null) {
        return new Error(Error::InvalidFile, "File has not been uploaded.");
    }
    $error = ValidateFile($file);
    if ($error->code != Error::NoError) {
        return $error;
예제 #7
0
 /**
  * Logs the user out.
  **/
 public static function LogOut()
 {
     // Clear the session and regenerate the id, on logout
     // ...but make sure that the failed attempts carry over to the new session
     $attempts = Login::GetAttempts();
     session_unset();
     session_regenerate_id();
     Login::SetAttempts($attempts);
     Site::Redirect('http://' . BASEURL . 'Home' . URLPAGEEXT);
 }
예제 #8
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/include/scripts/include-all.php";
Site::Redirect("/process/log-out.php");