use src\ProjectWhisky\exceptions\EmptyDataException; use Doctrine\Common\ClassLoader; require_once "rolestarter.php"; require_once "adminRights.php"; // Redirects users ir guest from control panel to index.php if is not admin require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new ClassLoader("src"); $classLoader->register(); require_once "lib/Twig/Autoloader.php"; Twig_Autoloader::register(); if (!isset($_GET["id"]) || empty($_GET["id"]) || !is_numeric($_GET["id"])) { header("Location: cp_user.php"); } $userId = $_GET["id"]; //GET userdata by id $userBiz = new UserBusiness(); $userdata = $userBiz->getUserbyId($_GET["id"]); if (!isset($_SESSION['userDialogBlock'])) { $_SESSION['userDialogBlock'] = ""; } if (isset($_POST['userUsername'])) { try { //form POST data $userId = $_GET["id"]; $username = $_POST['userUsername']; if (!empty($_POST['userPassword'])) { $newPass = true; $password = $_POST['userPassword']; } else { $newPass = false; $password = $userdata->getPassword();
/** * Connecting doctrine autoloader */ require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new ClassLoader("src"); $classLoader->register(); require_once "lib/Twig/Autoloader.php"; Twig_Autoloader::register(); $whiskyBiz = new WhiskyBusiness(); $whisky = $whiskyBiz->getWhisky($_GET["id"]); $barrelBiz = new BarrelBusiness(); $barrel = $barrelBiz->showBarrel($_GET["id"]); $distilleryBiz = new DistilleryBusiness(); $distillery = $distilleryBiz->getByWhisky($_GET["id"]); $commentBiz = new CommentBusiness(); $userBiz = new UserBusiness(); /** * Put comments data with user info into an array $participatedUsers */ if (!empty($commentBiz->showComments($_GET["id"]))) { foreach ($commentBiz->showComments($_GET["id"]) as $key => $comment) { $usersDataFromComments = $userBiz->getUserByComment($comment->getId()); $participatedUsers[$key]['userId'] = $usersDataFromComments->getId(); $participatedUsers[$key]['username'] = $usersDataFromComments->getUsername(); $participatedUsers[$key]['imagePath'] = $usersDataFromComments->getImagePath(); $participatedUsers[$key]['commentId'] = $comment->getId(); $participatedUsers[$key]['comment'] = $comment->getComment(); // Formatting time $participatedUsers[$key]['commentTime'] = new DateTime($comment->getCommentTime()); $participatedUsers[$key]['commentTime'] = $participatedUsers[$key]['commentTime']->format('H:i'); // Formatting date
use src\ProjectWhisky\exceptions\ImageException; use src\ProjectWhisky\exceptions\UserExistsException; use src\ProjectWhisky\exceptions\EmptyDataException; use Doctrine\Common\ClassLoader; require_once "rolestarter.php"; require_once "adminRights.php"; // Redirects users ir guest from control panel to index.php if is not admin require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new ClassLoader("src"); $classLoader->register(); require_once "lib/Twig/Autoloader.php"; Twig_Autoloader::register(); // check form submit if (isset($_POST["userUsername"])) { try { $userBiz = new UserBusiness(); //form POST data $_SESSION['savedData']['username'] = $_POST['userUsername']; $_SESSION['savedData']['password'] = $_POST['userPassword']; $_SESSION['savedData']['email'] = $_POST['userEmail']; $_SESSION['savedData']['firstname'] = $_POST['userFirstName']; $_SESSION['savedData']['lastname'] = $_POST['userLastName']; $_SESSION['savedData']['admin'] = false; if (isset($_POST['userAdmin'])) { $_SESSION['savedData']['admin'] = true; } $_SESSION['savedData']['blocked'] = false; if (isset($_POST['userBlocked'])) { $_SESSION['savedData']['blocked'] = true; } if (empty($_SESSION['savedData']['username']) || empty($_SESSION['savedData']['password']) || empty($_SESSION['savedData']['email']) || empty($_SESSION['savedData']['firstname']) || empty($_SESSION['savedData']['lastname'])) {
// validate username if (!$passwordValidated) { throw new WrongPasswordPatternException(); } // validate pass if (!$rpasswordValidated) { throw new WrongPasswordPatternException(); } // validate repeated pass /** * Check whether passwords are the same */ if ($password !== $rpassword) { throw new PasswordsDontMatchException(); } $user = new UserBusiness(); /** * Look if user with entered e-mail already exists */ if (!empty($user->checkUserByEmail($email))) { throw new EmailExistsException(); } /** * Look if user with entered username already exists */ if (!empty($user->checkUserByUsername($username))) { throw new UsernameExistsException(); } /** * Create user */
<?php session_start(); ob_start(); error_reporting(E_ALL); ini_set("display_errors", 1); use src\ProjectWhisky\business\UserBusiness; use Doctrine\Common\ClassLoader; require_once "rolestarter.php"; require_once "adminRights.php"; // Redirects users ir guest from control panel to index.php if is not admin require_once 'Doctrine/Common/ClassLoader.php'; $classLoader = new ClassLoader("src"); $classLoader->register(); require_once "lib/Twig/Autoloader.php"; Twig_Autoloader::register(); $userBiz = new UserBusiness(); if (isset($_GET['search_username']) && !empty($_GET['search_username'])) { $usernameTrim = trim($_GET['search_username']); $userlist = $userBiz->getUsersByUsername($usernameTrim); $loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation"); $twig = new Twig_Environment($loader); $view = $twig->render("CP_user.twig", array("user" => $_SESSION['user'], "users" => $userlist, "searchInputUsername" => $usernameTrim)); } else { $userlist = $userBiz->getAllUsers(); $loader = new Twig_Loader_Filesystem("src/ProjectWhisky/presentation"); $twig = new Twig_Environment($loader); $view = $twig->render("CP_user.twig", array("user" => $_SESSION['user'], "users" => $userlist)); } print $view; ob_flush();