function process() { if ($this->_input->post("Login")) { $userName = $this->_input->post('user_name'); $passwd = md5($this->_input->post('passwd')); $this->_template->set_var("user_name", $userName); $checkArray = array('user_name' => 'Username', 'passwd' => 'Password'); if ($this->_jScript->checkFilds($checkArray)) { $userCtrl = new UserController(); $userEnt = $userCtrl->loginUser($userName, $passwd); if (is_object($userEnt)) { $userObj = $userCtrl->createUser($userEnt); $_SESSION['REGI_userObject'] = serialize($userObj); $sessionObj = unserialize($_SESSION['REGI_userObject']); if (is_object($sessionObj)) { if ($sessionObj->getActive() == 0) { $this->redirect('UserActivate'); } else { $this->redirect('Radio'); } } } else { $this->_jScript->alert("Ingevoerde gebruikersnaam en/of wachtwoord is/zijn niet correct!"); } } } $this->_template->parse($this->_outputName, $this->_mainBlock); }
* Rather than including all my application code and logic * here i moved my functions to separate php classes and routed * to them using the switch() statement in this file */ // verifies that the action post variable is set and then choses // which function to fire based on the POST['action'] value if (isset($_POST['action'])) { // instantiate classes to call functions from $UserController = new UserController(); $ProjectController = new ProjectController(); $PageController = new PageController(); // handle which function to call switch ($_POST['action']) { // User Methods case "createUser": $UserController->createUser(); break; case "deleteUser": $UserController->deleteUser(); break; case "getUser": $UserController->getUser(); break; case "checkLoggedIn": $UserController->checkLoggedIn(); break; case "isAdmin": $UserController->isAdmin(); break; case "login": $UserController->login();
checkAdminLoggedIn(); } include_once SP_CTRLPATH . "/user.ctrl.php"; include_once SP_CTRLPATH . "/website.ctrl.php"; include_once SP_CTRLPATH . "/keyword.ctrl.php"; $controller = new UserController(); $controller->view->menu = 'users'; $controller->layout = 'ajax'; $controller->spTextPanel = $controller->getLanguageTexts('panel', $_SESSION['lang_code']); $controller->set('spTextPanel', $controller->spTextPanel); $controller->spTextUser = $controller->getLanguageTexts('user', $_SESSION['lang_code']); $controller->set('spTextUser', $controller->spTextUser); if ($_SERVER['REQUEST_METHOD'] == 'POST') { switch ($_POST['sec']) { case "create": $controller->createUser($_POST); break; case "update": $controller->updateUser($_POST); break; case "updatemyprofile": $controller->updateMyProfile($_POST); break; case "activateall": if (!empty($_POST['ids'])) { foreach ($_POST['ids'] as $id) { $controller->__changeStatus($id, 1); } } $controller->listUsers($_POST); break;
<?php /** * Created by PhpStorm. * User: Francois * Date: 30/04/15 * Time: 15:05 */ include_once '../controller/ImageController.php'; include_once '../controller/UserController.php'; $user = new UserController(); $image = new ImageController(); $lines = file('../dataset/pseudoDataset.txt'); $stack_pseudo = array(); foreach ($lines as $line_num => $line) { array_push($stack_pseudo, $line); } $lines = file('../dataset/imageDataset.txt'); $stack_image = array(); foreach ($lines as $line_num => $line) { array_push($stack_image, $line); /* $get = substr($line, 0, strlen($line) - 1); $imageString = file_get_contents($get); $save = file_put_contents('../dataset/image_download/' . basename($get), $imageString); */ } foreach ($stack_pseudo as $pseudo) { $user->createUser(substr($pseudo, 0, strlen($pseudo) - 1), 'testAccount'); }
<?php include_once '../controller/UserController.php'; $reg = new UserController(); $error = "OK"; $user_created = false; if (isset($_POST["login"]) && isset($_POST["pass"])) { $error = $reg->createUser($_POST["login"], $_POST["pass"]); if ($error == "OK") { $user_created = true; } } echo '<div id="login"> <h1>Registration</h1>'; if (!$user_created && !isset($_SESSION["user"])) { echo '<form name="registration" method="post" action="layout.php?selected=register"> <input type="text" placeholder="Login" name="login"/> <input type="password" placeholder="Password" name="pass"/>'; if ($error != "OK") { echo '<div class="alert alert-danger" role="alert"> <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> <span class="sr-only">Error:</span>' . $error . '</div>'; } echo ' <input type="submit" value="Register"/> </form>'; } else { echo '<div class="alert alert-success" role="alert"> <b>Registration success !</b></br> Welcome ' . $_SESSION["user"] . '</div>'; } echo '</div>';