public function Run($action, $args) { $action = strtolower($action); if ($action == 'index') { userController::index(); } elseif ($action == 'login') { userController::login(); } elseif ($action == 'new') { userController::newUser(); } elseif ($action == 'logout') { userController::logout(); } elseif ($action == 'view') { userController::view((int) $args[0]); } }
<?php include 'init.php'; if (isset($_GET['logout'])) { } if (isset($_POST['sso'])) { $controller = new userController(); $result = $controller->login($_POST['sso'], $_POST['password']); if ($result == true) { header('location: index.php'); } if ($result == false) { echo '<div class="alert alert-warning alert-dismissible" role="alert" style="width: 620px; margin: auto;"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> There was an error with your login, please try again. </div>'; } } ?> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <meta name="description" content="ITLP value reward system"> <meta name="author" content="Purple B"> <link rel="icon" href=""><!-- to fill in--> <title>ITLP Value Reward System</title>
groupmemoController::create(); }); $routes->get('/groupmemo/:id', function ($id) { groupmemoController::show($id); }); $routes->get('/groupmemo/:id/edit', function ($id) { groupmemoController::edit($id); }); $routes->post('/groupmemo/:id/edit', function ($id) { groupmemoController::update($id); }); $routes->post('/groupmemo/:id/destroy', function ($id) { groupmemoController::destroy($id); }); $routes->get('/login', function () { userController::login(); }); $routes->post('/login', function () { userController::handle_login(); }); $routes->post('/logout', function () { userController::logout(); }); $routes->get('/user', function () { userController::index(); }); $routes->post('/user', function () { userController::store(); }); $routes->get('/user/new', function () { userController::create();
<?php include_once "/home/andreslaley/public_html/happy/controller/user/userController.php"; session_start(); $user = $_POST['user']; $nick = $user['nick']; $email = $user['email']; $password = $user['password']; $name = $user['name']; $userControoler = new userController(); try { $userControoler->addMe($nick, $password, $email, $name); $user = $userControoler->login($nick, $password); if (is_null($user->id)) { echo "Invalid user or password."; } else { $_SESSION["userSession"] = $user; mkdir("/home/andreslaley/public_html/happy/image/users/" . $user->nick, 0777); if (!copy("/home/andreslaley/public_html/happy/image/users/andreslaley/default-profile-pic.png", "/home/andreslaley/public_html/happy/image/users/" . $user->nick . "/default-profile-pic.png")) { echo "Error al copiar {$fichero}...\n"; } header("Location: http://www.andreseloysv.com/happy/view/home/home.php"); die; } header("Location: http://www.andreseloysv.com/happy/view/home/home.php"); die; } catch (Exception $e) { //echo "User add failed: " . $e->getMessage(); header("Location: http://www.andreseloysv.com/happy/view/register/register.php"); die; }