/** * This function is beign used to load info that's needed for the dashboard page. * check if the person who wants to view this page is a mod/admin, if this is not the case, he will be redirected to an error page. * next it will fetch a lot of information regarding to the status of the ticket system (eg return the total amount of tickets) and return this information so * it can be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function dashboard() { //if logged in if (WebUsers::isLoggedIn()) { //is Mod if (ticket_user::isMod(unserialize($_SESSION['ticket_user']))) { //return useful information about the status of the ticket system. $result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId(); $result['nrToDo'] = Ticket_Queue_Handler::getNrOfTicketsToDo(unserialize($_SESSION['ticket_user'])->getTUserId()); $result['nrAssignedWaiting'] = Ticket_Queue_Handler::getNrOfTicketsAssignedWaiting(unserialize($_SESSION['ticket_user'])->getTUserId()); $result['nrTotalTickets'] = Ticket_Queue_Handler::getNrOfTickets(); $ticket = Ticket_Queue_Handler::getNewestTicket(); $result['newestTicketId'] = $ticket->getTId(); $result['newestTicketTitle'] = $ticket->getTitle(); $result['newestTicketAuthor'] = Ticket_User::get_username_from_id($ticket->getAuthor()); global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; return $result; } else { //ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } } else { //ERROR: not logged in! header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } }
/** * This function is beign used to change the permission of a ticket_user. * It will first check if the user who executed this function is an admin. If this is not the case the page will be redirected to an error page. * in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1), the change will be executed and the page will * redirect to the users profile page. * @author Daan Janssens, mentored by Matthew Lagoe */ function change_permission() { global $INGAME_WEBPATH; global $WEBPATH; //if logged in if (WebUsers::isLoggedIn()) { //check if user who executed this function is an admin if (ticket_user::isAdmin(unserialize($_SESSION['ticket_user']))) { //in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1) if (isset($_GET['user_id']) && isset($_GET['value']) && $_GET['user_id'] != 1 && $_GET['value'] < 4) { $user_id = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT); $value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT); //execute change. Ticket_User::change_permission(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value); header("Cache-Control: max-age=1"); if (Helpers::check_if_game_client()) { header("Location: " . $INGAME_WEBPATH . "?page=show_user&id=" . $user_id); } else { header("Location: " . $WEBPATH . "?page=show_user&id=" . $user_id); } throw new SystemExit(); } else { //ERROR: GET PARAMS not given or trying to change admin header("Cache-Control: max-age=1"); if (Helpers::check_if_game_client()) { header("Location: " . $INGAME_WEBPATH . "?page=show_user&id=" . $user_id); } else { header("Location: " . $WEBPATH . "?page=show_user&id=" . $user_id); } throw new SystemExit(); } } else { //ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } } else { //ERROR: not logged in! header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } }
/** * This function is beign used to load info that's needed for the createticket page. * the $_GET['user_id'] identifies for which user you try to create a ticket. A normal user can only create a ticket for himself, a mod/admin however can also create tickets for other users. * It will also load all categories and return these, they will be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function createticket() { //if logged in if (WebUsers::isLoggedIn()) { //in case user_id-GET param set it's value as target_id, if no user_id-param is given, use the session id. if (isset($_GET['user_id'])) { //check if you are a mod/admin or you try to create a ticket for your own, if this is not the case redirect to error page if ($_GET['user_id'] != $_SESSION['id'] && !ticket_user::isMod(unserialize($_SESSION['ticket_user']))) { //ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } else { //if user_id is given, then set it as the target_id $result['target_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT); } } else { //set session_id as target_id $result['target_id'] = $_SESSION['id']; } if (Helpers::check_if_game_client()) { //get all additional info, which is needed for adding the extra info page $result[] = $_GET; $result['ingame'] = true; } //create array of category id & names $catArray = Ticket_Category::getAllCategories(); $result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, array("getName"), "getTCategoryId"); global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; $result['TITLE_ERROR'] = $INGAME_WEBPATH; return $result; } else { //ERROR: not logged in! header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } }
/** * creates a user in the shard. * incase the shard is offline it will place it in the ams_querycache. You have to create a user first in the CMS/WWW and use the id for this function. * @param $values with name,pass and mail * @param $user_id the extern id of the user (the id given by the www/CMS) * @return ok if it's get correctly added to the shard, else return lib offline and put in libDB, if libDB is also offline return liboffline. */ public static function createUser($values, $user_id) { ticket_user::createTicketUser($user_id, 1); try { //make connection with and put into shard db $values["UId"] = $user_id; $dbs = new DBLayer("shard"); $dbs->insert("user", $values); /* $dbr = new DBLayer("ring"); $valuesRing['user_id'] =$user_id; $valuesRing['user_name'] = $values['Login']; $valuesRing['user_type'] = 'ut_pioneer'; $dbr->insert("ring_users", $valuesRing); */ return "ok"; } catch (PDOException $e) { //oh noooz, the shard is offline! Put in query queue at ams_lib db! try { $dbl = new DBLayer("lib"); $dbl->insert("ams_querycache", array("type" => "createUser", "query" => json_encode(array($values["Login"], $values["Password"], $values["Email"])), "db" => "shard")); return "shardoffline"; } catch (PDOException $e) { print_r($e); return "liboffline"; } } }