/** * This abstract function performs the processing of the user request. * @param User $user The requesting user. If the user is not null, then by convention * actions will assume the user is authenticated, otherwise not. * @throws Exception If an error was encountered while processing this request, an exception * will be thrown. * @return void */ public function processRequest(User $user = NULL) { $returnUrl = UrlFormatter::formatRoutingItemUrl('actions/LoginAction'); $imageSearchViewUrl = UrlFormatter::formatRoutingItemUrl('views/ImageSearchView'); // if the user is already logged in redirect to the image search view if ($user != NULL) { header("Location: {$imageSearchViewUrl}"); return; } else { if (!isset($_POST[self::POST_PARAM_USERNAME]) || !isset($_POST[self::POST_PARAM_USERNAME])) { $loginView = new LoginView(); $loginView->processRequest(); exit; } $username = $_POST[self::POST_PARAM_USERNAME]; $password = $_POST[self::POST_PARAM_PASSWORD]; $user = User::loadUserByUsername(DbConnectionUtil::getDbConnection(), $username); if ($user == NULL || $user->getPassword() != md5($password)) { $loginView = new LoginView(); $loginView->setPreviousAttemptErrorMessage("Login Failed"); $loginView->processRequest(); exit; } else { UserAuthUtil::registerAuthenticatedUser($user); header("Location: {$imageSearchViewUrl}"); return; } } }
public function render($isLoggedIn, LoginView $v, DateTimeView $dtv) { ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Login Example</title> </head> <body> <h1>Assignment 2</h1> <?php if ($isLoggedIn) { echo "<h2>Logged in</h2>"; } else { echo "<h2>Not logged in</h2>"; } ?> <div class="container" > <?php echo $v->response(); $dtv->show(); ?> </div> <div> <em>This site uses cookies to improve user experience. By continuing to browse the site you are agreeing to our use of cookies.</em> </div> </body> </html> <?php }
public static function loginView($error = null) { if (isset($_SESSION["username"])) { header('Location: ' . static::$rolesAction[$_SESSION['role']]); } $view = new LoginView(); $view->show($error); }
private function renderViewResponse(LoginView $v_lv, RegisterView $v_rv, NavigationView $v_nv) { if ($v_nv->inRegistration()) { return $v_rv->response(); } else { return $v_lv->response(); } }
public function __construct(CController $controller, CFormModel $formModel, $extraHeaderContent = null) { assert('is_string($extraHeaderContent) || $extraHeaderContent == null'); $loginview = new LoginView($controller, $formModel, $extraHeaderContent); $loginview->setCssClasses(array('clearfix', 'background-' . mt_rand(1, 6))); $flashMessageView = new FlashMessageView($controller); $gridView = new GridView(3, 1); $gridView->setView($flashMessageView, 0, 0); $gridView->setView($loginview, 1, 0); $gridView->setView(new FooterView(false), 2, 0); $this->registerScripts(); parent::__construct($gridView); }
public function doAdminPanel($isLoggedIn, LoginView $v, AdminPanelView $av) { ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title><?php echo \Settings::HOMEPAGE_TITLE; ?> - Admin Panel</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> </head> <body> <main> <header> <?php if ($isLoggedIn) { echo "<h1>Admin Panel</h1>"; } else { echo "<h1>Log in</h1>"; } ?> </header> <div id="menu"> <?php if ($isLoggedIn) { echo $av->getMenuHTML(); } ?> </div> <div id="content"> <?php echo $v->response(); ?> <?php echo $av->response(); ?> </div> </main> <footer> <a href="?">Back to public page</a> <p>This site uses cookies to improve user experience. By continuing to browse the site you are agreeing to our use of cookies.</p> </footer> </body> </html> <?php }
public function render($isLoggedIn, LoginView $v, DateTimeView $dtv, RegistrationView $r, EditView $ev, ViewEntryView $vev) { ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>The Initiative for Procrastination</title> <link rel="stylesheet" type="text/css" href="css/stylesheet.css"/> </head> <body> <h1 id="headline">The Initiative for Procrastination</h1> <?php if ($isLoggedIn) { echo "<h2>Logged in</h2>"; if ($ev->clickedNewEntry()) { echo $ev->getStartLink(); } elseif ($v->userWantsToView()) { echo $vev->getStartLink(); } else { echo $ev->getEntryLink(); } } else { echo "<h2>Not logged in</h2>"; if ($r->clickedRegister()) { echo $r->getLoginLink(); } elseif (!$isLoggedIn) { echo $r->getRegLink(); } } ?> <div class="container" > <?php if ($r->clickedRegister() && $r->regSuccess() === false) { echo $r->response(); } elseif ($ev->clickedNewEntry() && $ev->saveSuccess() === false && $isLoggedIn) { echo $ev->response(); } elseif ($v->userWantsToView() && $v->clickedMenuItem() === true) { echo $vev->response(); } else { if ($isLoggedIn) { echo $v->response(); echo $v->getMenu(); echo $v->getLogoutButton(); } echo $v->response(); } $dtv->show(); ?> </div> <div> <em>This site uses cookies to improve user experience. By continuing to browse the site you are agreeing to our use of cookies.</em> </div> </body> </html> <?php }
public static function show($user) { MasterView::showHeader(null); MasterView::showNav(); LoginView::showContent($user); MasterView::showFooter(null); }
public static function show() { $_SESSION['headertitle'] = "Log into botspace"; MasterView::showHeader(); LoginView::showDetails(); MasterView::showFooter(); }
public static function run() { $user = null; $userIsLegit = false; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $user = new User($_POST); if ($user->getErrorCount() == 0) { $checkUserArray = UsersDB::getUsersBy('username', $user->getUserName()); if (count($checkUserArray) > 0) { $checkUser = $checkUserArray[0]; $user->setUserId($checkUser->getUserId()); $userIsLegit = password_verify($_POST['password'], $checkUser->getPassword()); } } } else { LoginView::show(); return; } if ($userIsLegit) { $_SESSION['authenticatedUser'] = $user; $_SESSION['authenticated'] = true; HomeView::show(); } else { $user->setError('username', 'USERNAME_PASSWORD_COMBO_INVALID'); $_SESSION['user'] = $user; LoginView::show(); } }
function __construct() { $registry = Registry::getInstance(); $i18n = new I18n($registry->get('i18n_path') . 'admin.xml'); if ($_POST['action'] == 'login') { if ($_POST['login'] . $_POST['password']) { if (LoginError::isBlocked()) { $message = $i18n->get('error_limit_exceeded'); } else { $admin = Admin::getInstance($_POST['login'], $_POST['password']); if ($admin->id) { Admin::setProperty($admin->id, 'date_login', date('Y-m-d H:i:s')); $_SESSION['admin'] = ['id' => $admin->id, 'locale' => $admin->locale, 'name' => $admin->name]; unset($_SESSION['login_error']); header("Location: /cms"); exit; } else { LoginError::register($_POST['login'], $_POST['password']); $message = $i18n->get('login_error'); $_SESSION['login_error'] = 1; } } } else { $message = $i18n->get('empty_login_of_password'); } } $renderer = new Renderer(Page::MODE_NORMAL); $pTitle = $i18n->get('login_title'); $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', LoginView::get(['message' => $message])); $renderer->loadPage(); $renderer->output(); }
/** * @param LoginModel $model */ public function __construct(LoginModel $model, Entries $entries) { self::$sessionSaveLocation = Settings::MESSAGE_SESSION_NAME . Settings::APP_SESSION_NAME; self::$userSaveLocation = Settings::USER_SESSION_NAME . Settings::APP_SESSION_NAME; $this->model = $model; $this->entries = $entries->getEntries(); }
public function testShowLoginViewWithNullUser() { ob_start(); $return = LoginView::show(null); $output = ob_get_clean(); $this->assertFalse(empty($output), "It should show a Login view when passed a null user"); }
public function testShowLoginViewWithNullUser() { $_SESSION = array('base' => 'mbcdbcrud'); ob_start(); $return = LoginView::show(); $output = ob_get_clean(); $this->assertFalse(empty($output), "It should show a Login view when passed a null user"); }
public static function show() { $_SESSION['headertitle'] = "ClassBash Login Form"; MasterView::showHeader(); LoginView::showDetails(); $_SESSION['footertitle'] = "<h3>The footer goes here</h3>"; MasterView::showFooter(); }
public static function run() { include '../models/User.class.php'; $inputform = $_SERVER["REQUEST_METHOD"] == "POST" ? $_POST : null; $user = new User($inputform); include '../views/LoginView.class.php'; LoginView::show($user); }
public static function show($user) { $nav = "<nav>\r\n\t\t<a href='signup'>Register</a> |\r\n\t\t<a href='login'>Login</a> |\r\n\t\t<a href='http://imightbejosh.com/ranks.html'>Leaderboard</a> |\r\n\t\t<a href='bet'>Betting</a> |\r\n\t\t<a href='games.html'>Recent Games</a> |\r\n\t\t<a href='tests.html'>Tests</a> |\r\n\t\t<a href='validation.html'>Validation</a>\r\n\t\t</nav>\r\n\t\t<section>\r\n\t\t<a href='home'><img src='resources/Drawing.png' alt='Home'></a>\r\n\t\t</section>"; MasterView::showHeader("Login"); MasterView::showNav(null); LoginView::showDetails($user); MasterView::showFooter(null); }
/** * @param LoginView $v * @param PostView $pv */ public function render(LoginView $v, PostView $pv) { echo '<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>The Blogster</title> </head> <body> <h1>Blogster A.K.A The Reddit of 1995</h1> <div class="container"> ' . $v->response() . ' ' . $pv->show() . ' </div> </body> </html>'; }
public function isPosted() { if (isset($_POST[self::$login])) { self::$saveName = strip_tags($_POST[self::$name]); return true; } else { return false; } }
public static function init() { session_start(); if (!isset($_SESSION['username'])) { $login_view = new LoginView(); $login_view->init_view(); } else { echo 'Something went wrong'; } if (isset($_POST['username'])) { $login = new Login($_POST['username'], $_POST['password']); try { $login->data_processing(); } catch (Exception $ex) { echo 'Failed: ', $ex->getMessage(); } } }
public static function show($user) { $_SESSION['headertitle'] = "Login"; $_SESSION['styles'] = array('jumbotron.css'); MasterView::showHeader(); MasterView::showNav(); LoginView::showDetails($user); MasterView::showPageEnd(); }
public static function show() { $_SESSION['headertitle'] = "Fireside Login Form"; MasterView::showHeader(); MasterView::showNavbar(); LoginView::showDetails(); $base = array_key_exists('base', $_SESSION) ? $_SESSION['base'] : ""; $_SESSION['footertitle'] = '<a href="/' . $base . '/index.php">FireSide</a></li>'; MasterView::showFooter(); }
public function render($isLoggedIn, LoginView $v, DateTimeView $dtv, RegisterView $rv) { ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Login Example</title> </head> <body> <h1>Assignment 2</h1> <?php if ($rv->userClickedOnRegister()) { echo $rv->getBackLink(); } else { if (!$isLoggedIn) { echo $rv->getRegistrationLink(); } } if ($isLoggedIn) { echo "<h2>Logged in</h2>"; } else { echo "<h2>Not logged in</h2>"; } ?> <div class="container" > <?php if ($rv->userClickedOnRegister() && $rv->registrationSucceeded() === FALSE) { echo $rv->response(); } else { echo $v->response(); } $dtv->show(); ?> </div> <div> <em>This site uses cookies to improve user experience. By continuing to browse the site you are agreeing to our use of cookies.</em> </div> </body> </html> <?php }
public static function show() { $_SESSION['headertitle'] = "Log into Sensor Data Repo"; $_SESSION['styles'] = array('site.css'); MasterView::showHeader(); MasterView::showNavBar(); LoginView::showDetails(); MasterView::showFooter(); MasterView::showPageEnd(); }
public function showLogin() { if (isset($_SESSION["user"])) { header("Location: dashboard"); } if (!isset($_POST["action"])) { include_once "views/login.php"; LoginView::render($this->vars, "showLogin"); } }
public function render($isLoggedIn, LoginView $v, DateTimeView $dtv) { echo '<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Login Example</title> </head> <body> <h1>Assignment 2</h1> ' . $this->renderIsLoggedIn($isLoggedIn) . ' <div class="container"> ' . $v->response() . ' ' . $dtv->show() . ' </div> </body> </html> '; }
public static function run() { if ($_SERVER["REQUEST_METHOD"] == "POST") { $user = new User($_POST); if ($user->getErrorCount() == 0) { ProfileView::show($user); } else { LoginView::show($user); } } else { LoginView::show(null); } }
public static function run() { if ($_SERVER["REQUEST_METHOD"] == "POST") { $user = new User($_POST, True); if ($user->getErrorCount() == 0) { LogController::run("In"); } else { LoginView::show($user); } } else { LoginView::show(null); } }
public function render($isLoggedIn, NavigationView $nv, LoginView $v, RegisterView $rv, DateTimeView $dtv) { $ret1 = '<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Login Example</title> </head> <body> <h1>Assignment 4</h1>'; echo $ret1; if (!$isLoggedIn) { if ($nv->userWantsToRegister()) { $ret3 = $nv->getLinkToLogin(); } else { $ret3 = $nv->getLinkToRegister("Register a new user"); } } $ret3 .= ' ' . $this->renderIsLoggedIn($isLoggedIn) . ' <div class="container"> '; echo $ret3; if ($rv->isUserDoneRegistering() || !$nv->userWantsToRegister()) { $ret2 = $v->response($rv->getProvidedUsername()); } else { $ret2 = $rv->response(); } $ret2 .= ' ' . $dtv->show() . ' </div> <div> <em>This site uses cookies to improve user experience. By continuing to browse the site you are agreeing to our use of cookies.</em> </div> </body> </html> '; echo $ret2; }
public static function run() { if ($_SERVER["REQUEST_METHOD"] == "POST") { $user = new User($_POST); // What if already logged in? if ($user->getErrorCount() == 0) { UserView::show($user); } else { LoginView::show($user); } } else { // Initial link LoginView::show(null); } }