if (User::Logged()) { // Validation for user input if (empty($_POST["idea_title"]) || empty($_POST["idea_description"])) { $error_message = I18n::L("Please fill title and description."); } if (strlen($_POST["idea_title"]) > 115) { $error_message = I18n::L("Your idea title is too long."); } if (empty($error_message)) { $idea = Idea::Add(Idea::Create($_POST["idea_title"], $_POST["idea_description"], User::$current)); header("Location:" . PREFIX . "/idea?" . $idea->idea_id); exit; } else { Viewer::AddData("idea_title", $_POST["idea_title"]); Viewer::UseTemplate("new_idea.tpl"); Viewer::AddData("title", I18n::L("Title New Idea")); Viewer::AddData("error_message", $error_message); } } else { Viewer::Restricted(); } $action = "new_idea"; } // Default view if (!empty($id)) { if ($idea = Idea::GetById($id)) { Viewer::AddData("comments", Comments::GetByIdea($idea)); Viewer::AddData("idea", $idea); Viewer::AddData("title", $idea->idea_title); if (isset($_GET["rate_plus"])) { $rated = 3;
} else { if (User::FindUser($user_name)) { $error_message = I18n::L("Username «%s» is already taken, please find another username.", array($user_name)); } else { if (User::FindUserByEmail($user_email)) { $error_message = I18n::L("This email «%s» is already regesitered, please use another email.", array($user_email)); } else { $obj = User::Add(User::Create($user_name, $user_email, $_POST["user_password"])); if ($obj->user_id) { Session::StartUser($obj); header("Location:" . PREFIX . "/dashboard/"); exit; } else { $error_message = I18n::L("Error while registring user."); } //todo: add some error log } } } } } else { if (!empty($_POST["register"])) { $error_message = I18n::L("Please fill all required fields."); } } Viewer::AddData("title", I18n::L("Title Registration")); Viewer::AddData("error_message", $error_message); Viewer::UseTemplate("register.tpl"); Viewer::AddData("action", $action); Viewer::Show(); ob_end_flush();
<?php /** * @package zoneideas * @subpackage dashboard * @author Serg Podtynnyi <*****@*****.**> */ /** * * */ ob_start(); include_once "../core.php"; $action = false; if (User::Logged()) { Viewer::AddData("ideas", Ideas::GetByUser(User::$current)); Viewer::AddData("user", User::$current); Viewer::AddData("title", I18n::L("Title Dashboard")); Viewer::UseTemplate("dashboard.tpl"); $action = "dashboard"; } else { Viewer::Restricted(); $action = "restricted"; } if (!$action) { Viewer::RequestError(); } Viewer::AddData("action", $action); Viewer::Show(); ob_end_flush();
$user->user_email = ""; $user->user_name = $user->user_name . "_removed"; if (!User::Update($user)) { $error_message = I18n::L("Cannot update user."); $user = User::GetById($id); } else { header("Location:" . PREFIX . "/profile?" . $user->user_id); exit; } } else { header("Location:" . PREFIX . "/profile?" . $user->user_id); exit; } } Viewer::AddData("user", $user); Viewer::AddData("title", I18n::L("Title %s's profile", array($user->user_name))); Viewer::AddData("ideas_count", Ideas::GetByUser($user) ? sizeof(Ideas::GetByUser($user)) : 0); Viewer::AddData("comments_count", Comments::GetByUser($user) ? sizeof(Comments::GetByUser($user)) : 0); Viewer::UseTemplate("user_profile.tpl"); $action = "profile"; } } else { Viewer::Restricted(); $action = "profile"; } if (!$action) { Viewer::RequestError(); } Viewer::AddData("action", $action); Viewer::Show(); ob_end_flush();
/** * * */ ob_start(); include_once "../core.php"; $action = "login"; if (!empty($_POST["login"])) { if (!empty($_POST["user_name"]) && !empty($_POST["user_password"])) { $obj = User::CheckUser($_POST["user_name"], $_POST["user_password"]); User::$current = Session::StartUser($obj); } else { $error_message = I18n::L("Please fill all required fields."); } } if (User::Logged()) { header("Location:" . PREFIX . "/dashboard/"); exit; } if (!empty($_POST["login"]) && !User::Logged()) { if (empty($error_message)) { $error_message = I18n::L("Wrong password."); } Viewer::AddData("error_message", $error_message); Viewer::AddData("user_name", $_POST["user_name"]); } Viewer::AddData("title", I18n::L("Title Login")); Viewer::UseTemplate("login.tpl"); Viewer::AddData("action", $action); Viewer::Show(); ob_end_flush();