<?php /** * This is a Branax pagecontroller. * */ // Include the essential config-file which also creates the $branax variable with its defaults. include __DIR__ . '/config.php'; // Create the user object $user = new CUser($branax['database']); // Check if user is authenticated. $output = $user->isAuthenticated() ? "Du är inloggad som: {$user->getAcronym()} ({$user->getName()})" : "Du är INTE inloggad."; // Check if user and password is okey and login the user if (isset($_POST['login'])) { $user->login($_POST['acronym'], $_POST['password']); header('Location: user_status.php'); } // Do it and store it all in variables in the Branax container. $branax['title'] = "Login"; $branax['main'] = <<<EOD <h1>{$branax['title']}</h1> <form method=post> <fieldset> <legend>Login</legend> <p><label>Användare:<br/><input type='text' name='acronym' value=''/></label></p> <p><label>Lösenord:<br/><input type='password' name='password' value=''/></label></p> <p><input type='submit' name='login' value='Login'/></p> <p><a href='user_logout.php'>Logout</a></p> <p><a href='user_register.php'>Skapa ny användare</a></p> <output><b>{$output}</b></output>
<?php /** * This is a Branax pagecontroller. * */ // Include the essential config-file which also creates the $branax variable with its defaults. include __DIR__ . '/config.php'; $user = new CUser($branax['database']); $user->isAuthenticated() or die('Check: You must login to edit.'); $content = new CContent($branax['database']); // Do it and store it all in variables in the Anax container. $branax['title'] = "Lägg till"; $branax['main'] = <<<EOD <h1>Lägg till nytt innehåll</h1> {$content->create($user->getAcronym())} EOD; // Finally, leave it all to the rendering phase of Anax. include BRANAX_THEME_PATH;
<?php /** * This is a Branax pagecontroller. * */ // Include the essential config-file which also creates the $branax variable with its defaults. include __DIR__ . '/config.php'; // Create the user object $user = new CUser($branax['database']); // Check if logged in user $admin = $user->isAdmin() ? 'med administratörsrättigheter' : null; $output = $user->isUser() ? "Du är inloggad som {$user->getAcronym()} ({$user->getName()}) {$admin}" : "Du är INTE inloggad."; // Do it and store it all in variables in the Anax container. $branax['title'] = "User status"; $branax['main'] = <<<EOD <h1>{$branax['title']}</h1> <form method=post> <fieldset> <legend>Login status</legend> <output><b>{$output}</b></output> <p><a href='user_login.php'>Login</a></p> <p><a href='user_logout.php'>Logout</a></p> </fieldset> </form> EOD; // Finally, leave it all to the rendering phase of Branax. include BRANAX_THEME_PATH;