/** * This function is beign used to load info that's needed for the userlist page. * this function will return all users by using he pagination class, so that it can be used in the template. Only Mods and Admins can browse this page though. * @author Daan Janssens, mentored by Matthew Lagoe */ function userlist() { if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $pagination = new Pagination(WebUsers::getAllUsersQuery(), "web", 10, "WebUsers"); $pageResult['userlist'] = Gui_Elements::make_table($pagination->getElements(), array("getUId", "getUsername", "getEmail"), array("id", "username", "email")); $pageResult['links'] = $pagination->getLinks(5); $pageResult['lastPage'] = $pagination->getLast(); $pageResult['currentPage'] = $pagination->getCurrent(); $i = 0; foreach ($pageResult['userlist'] as $user) { $pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission(); $i++; } if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { $pageResult['isAdmin'] = "TRUE"; } global $INGAME_WEBPATH; $pageResult['ingame_webpath'] = $INGAME_WEBPATH; global $BASE_WEBPATH; $pageResult['base_webpath'] = $BASE_WEBPATH; return $pageResult; } else { //ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } }
/** * This function is beign used to load info that's needed for the syncing page. * this function is used for notifying admins that there are unsynced changes, a brief overview of the non syned changes will be shown. The entries are being loaded here * so that they can be passed to the template itself. Only admins can browse this page, others will be redirected to an error page. * @author Daan Janssens, mentored by Matthew Lagoe */ function syncing() { if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { //return a paginated version of all unsynced changes. $pagination = new Pagination("SELECT * FROM ams_querycache", "lib", 5, "Querycache"); $pageResult['liblist'] = Gui_Elements::make_table($pagination->getElements(), array("getSID", "getType"), array("id", "type")); $pageResult['links'] = $pagination->getLinks(5); $pageResult['lastPage'] = $pagination->getLast(); $pageResult['currentPage'] = $pagination->getCurrent(); global $INGAME_WEBPATH; $pageResult['ingame_webpath'] = $INGAME_WEBPATH; //check if shard is online try { $dbs = new DBLayer("shard"); $pageResult['shard'] = "online"; } catch (PDOException $e) { $pageResult['shard'] = "offline"; } return $pageResult; } else { //ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } }
/** * function plugins_update to get * plugins updates from the Database using pagination object. * * @author shubham meena mentored by Matthew Lagoe */ function plugins_update() { if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $pagination = new Pagination("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId", "lib", 5, "Plugincache"); $pageResult['plug'] = Gui_Elements::make_table($pagination->getElements(), array("getId", "getPluginName", "getPluginInfo", "getUpdateInfo"), array("id", "plugin_name", "plugin_info", "update_info")); $pageResult['links'] = $pagination->getLinks(5); $pageResult['lastPage'] = $pagination->getLast(); $pageResult['currentPage'] = $pagination->getCurrent(); global $INGAME_WEBPATH; $pageResult['ingame_webpath'] = $INGAME_WEBPATH; // check if shard is online try { $dbs = new DBLayer("shard"); $pageResult['shard'] = "online"; } catch (PDOException $e) { $pageResult['shard'] = "offline"; } return $pageResult; } else { // ERROR: No access! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } }
/** * This function is beign used to load info that's needed for the show_user page. * Users can only browse their own user page, while mods/admins can browse all user pages. The current settings of the user being browsed will be loaded, as also their created tickets * and this info will be returned so it can be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_user() { //if logged in if (WebUsers::isLoggedIn()) { //Users can only browse their own user page, while mods/admins can browse all user pages if (!isset($_GET['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id']) { if (isset($_GET['id'])) { $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); } else { $result['target_id'] = $_SESSION['id']; } $webUser = new WebUsers($result['target_id']); $result['target_name'] = $webUser->getUsername(); $result['mail'] = $webUser->getEmail(); $info = $webUser->getInfo(); $result['firstName'] = $info['FirstName']; $result['lastName'] = $info['LastName']; $result['country'] = $info['Country']; $result['gender'] = $info['Gender']; $ticket_user = Ticket_User::constr_ExternId($result['target_id']); $result['userPermission'] = $ticket_user->getPermission(); if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { $result['isAdmin'] = "TRUE"; } $ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId()); $result['ticketlist'] = Gui_Elements::make_table($ticketlist, array("getTId", "getTimestamp", "getTitle", "getStatus", "getStatusText", "getStatusText", "getCategoryName"), array("tId", "timestamp", "title", "status", "statustext", "statusText", "category")); 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 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(); } }
/** * This function is beign used to load info that's needed for the sgroup_list 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. * It will return all suppport groups information. Also if the $_GET['delete'] var is set and the user is an admin, he will delete a specific entry. * @author Daan Janssens, mentored by Matthew Lagoe */ function sgroup_list() { global $INGAME_WEBPATH; global $WEBPATH; //if logged in if (WebUsers::isLoggedIn()) { if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { //if delete GET var is set and user is admin, then delete the groups entry. if (isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT); $result['delete'] = Support_Group::deleteSupportGroup($delete_id); header("Cache-Control: max-age=1"); if (Helpers::check_if_game_client()) { header("Location: " . $INGAME_WEBPATH . "?page=sgroup_list"); } else { header("Location: " . $WEBPATH . "?page=sgroup_list"); } throw new SystemExit(); } if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { $result['isAdmin'] = "TRUE"; } $result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), array("getSGroupId", "getName", "getTag", "getGroupEmail"), array("sGroupId", "name", "tag", "groupemail")); 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(); } }
/** * Global Hook to return global variables which contains * the content to use in the smarty templates extracted from * the database * * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_get_db() { global $domain_management_return_set; if (isset($_GET['ModifyDomain']) && ($_GET['ModifyDomain'] = '1' && isset($_POST['domain_name']))) { try { $dbs = new DBLayer('shard'); $dbs->update("domain", array('domain_name' => $_POST['domain_name'], 'status' => $_POST['status'], 'patch_version' => $_POST['patch_version'], 'backup_patch_url' => $_POST['backup_patch_url'], 'patch_urls' => $_POST['patch_urls'], 'login_address' => $_POST['login_address'], 'session_manager_address' => $_POST['session_manager_address'], 'ring_db_name' => $_POST['ring_db_name'], 'web_host' => $_POST['web_host'], 'web_host_php' => $_POST['web_host_php'], 'description' => $_POST['description']), '`domain_id` = ' . $_GET['edit_domain']); } catch (Exception $e) { return null; } } if (isset($_GET['ModifyPermission']) && ($_GET['ModifyPermission'] = '1' && isset($_POST['user']))) { try { $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", array('setting' => 'Domain_Auto_Add')); $json = $statement->fetch(); $json = json_decode($json['Value'], true); $json[$_GET['edit_domain']]['1'] = $_POST['user']; $json[$_GET['edit_domain']]['2'] = $_POST['moderator']; $json[$_GET['edit_domain']]['3'] = $_POST['admin']; $update = json_encode($json); $dbl->update("settings", array('Value' => $update), "`Setting` = 'Domain_Auto_Add'"); } catch (Exception $e) { return null; } } try { $db = new DBLayer('shard'); // get all domains $statement = $db->executeWithoutParams("SELECT * FROM domain"); $rows = $statement->fetchAll(); $domain_management_return_set['domains'] = $rows; if (isset($_GET['edit_domain'])) { // get permissions $statement = $db->executeWithoutParams("SELECT * FROM `domain` WHERE `domain_id` = '" . $_GET['edit_domain'] . "'"); $rows = $statement->fetchAll(); $domain_management_return_set['domains'] = $rows; $statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `DomainId` = '" . $_GET['edit_domain'] . "'"); $rows = $statement->fetchAll(); $domain_management_return_set['permissions'] = $rows; // get all users $pagination = new Pagination(WebUsers::getAllUsersQuery(), "web", 10, "WebUsers"); $domain_management_return_set['userlist'] = Gui_Elements::make_table($pagination->getElements(), array("getUId", "getUsername", "getEmail"), array("id", "username", "email")); $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", array('setting' => 'Domain_Auto_Add')); $json = $statement->fetch(); $json = json_decode($json['Value'], true); $domain_management_return_set['Domain_Auto_Add'] = $json[$_GET['edit_domain']]; } return $rows; } catch (Exception $e) { return null; } }
/** * This function is beign used to load info that's needed for the show_ticket_log page. * This page shows the logs related to a ticket: who created the ticket, who replied on it, who viewed it, assigned or forwarded it. * Only mods/admins are able to browse the log though. The found information is returned so it can be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_ticket_log() { global $INGAME_WEBPATH; global $WEBPATH; //if logged in if (WebUsers::isLoggedIn() && isset($_GET['id'])) { //only allow admins to browse the log! if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $target_ticket = new Ticket(); $target_ticket->load_With_TId($result['ticket_id']); $result['ticket_title'] = $target_ticket->getTitle(); //return all logs related to a ticket. $ticket_logs = Ticket_Log::getLogsOfTicket($result['ticket_id']); $log_action_array = Ticket_Log::getActionTextArray(); //fetch information about each returned ticket in a format that is usable for the template $result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, array("getTLogId", "getTimestamp", "getAuthor()->getExternId", "getAction", "getArgument()"), array("tLogId", "timestamp", "authorExtern", "action", "argument")); $i = 0; //for each ticket add action specific informaton to the to-be-shown text: uses the query_backpart foreach ($result['ticket_logs'] as $log) { $webUser = new WebUsers($log['authorExtern']); $author = $webUser->getUsername(); $result['ticket_logs'][$i]['author'] = $author; $query_backpart = ""; if ($log['action'] == 2) { $webUser2 = new WebUsers($log['argument']); $query_backpart = $webUser2->getUsername(); } else { if ($log['action'] == 4) { if (Helpers::check_if_game_client()) { $query_backpart = "<a href='" . $INGAME_WEBPATH . "?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>"; } else { $query_backpart = "<a href='" . $WEBPATH . "?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>"; } } else { if ($log['action'] == 5) { $statusArray = Ticket::getStatusArray(); $query_backpart = $statusArray[$log['argument']]; } else { if ($log['action'] == 6) { $priorityArray = Ticket::getPriorityArray(); $query_backpart = $priorityArray[$log['argument']]; } else { if ($log['action'] == 8) { if (Helpers::check_if_game_client()) { $query_backpart = "<a href='" . $INGAME_WEBPATH . "?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group::getGroup($log['argument'])->getName() . "</a>"; } else { $query_backpart = "<a href='" . $WEBPATH . "?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group::getGroup($log['argument'])->getName() . "</a>"; } } } } } } $result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart; $result['ticket_logs'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($log['timestamp']); $i++; } if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $result['isMod'] = "TRUE"; } 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 load info that's needed for the show_ticket page. * check if the person browsing this page is a mod/admin or the ticket creator himself, if not he'll be redirected to an error page. * if the $_GET['action'] var is set and the user executing is a mod/admin, it will try to execute the action. The actions here are: forwarding of a ticket, * assigning a ticket and unassigning a ticket. This function returns a lot of information that will be used by the template to show the ticket. Mods/admins will be able to * also see hidden replies to a ticket. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_ticket() { //if logged in if (WebUsers::isLoggedIn() && isset($_GET['id'])) { $result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId(); $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $target_ticket = new Ticket(); $target_ticket->load_With_TId($result['ticket_id']); if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { if (isset($_POST['action'])) { switch ($_POST['action']) { case "forward": $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $group_id = filter_var($_POST['group'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::forwardTicket($result['user_id'], $ticket_id, $group_id); break; case "assignTicket": $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::assignTicket($result['user_id'], $ticket_id); break; case "unAssignTicket": $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::unAssignTicket($result['user_id'], $ticket_id); break; } } } if ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $show_as_admin = false; if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $show_as_admin = true; } $entire_ticket = Ticket::getEntireTicket($result['ticket_id'], $show_as_admin); Ticket_Log::createLogEntry($result['ticket_id'], unserialize($_SESSION['ticket_user'])->getTUserId(), 3); $result['ticket_tId'] = $entire_ticket['ticket_obj']->getTId(); $result['ticket_forwardedGroupName'] = $entire_ticket['ticket_obj']->getForwardedGroupName(); $result['ticket_forwardedGroupId'] = $entire_ticket['ticket_obj']->getForwardedGroupId(); $result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle(); $result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp(); $result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus(); $result['ticket_author'] = $entire_ticket['ticket_obj']->getAuthor(); $result['ticket_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText(); $result['ticket_priorities'] = Ticket::getPriorityArray(); $result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority(); $result['ticket_statustext'] = $entire_ticket['ticket_obj']->getStatusText(); $result['ticket_lastupdate'] = Gui_Elements::time_elapsed_string(Ticket::getLatestReply($result['ticket_id'])->getTimestamp()); $result['ticket_category'] = $entire_ticket['ticket_obj']->getCategoryName(); $webUser = new WebUsers(Assigned::getUserAssignedToTicket($result['ticket_tId'])); $result['ticket_assignedToText'] = $webUser->getUsername(); $result['ticket_assignedTo'] = Assigned::getUserAssignedToTicket($result['ticket_tId']); $result['ticket_replies'] = Gui_Elements::make_table($entire_ticket['reply_array'], array("getTReplyId", "getContent()->getContent", "getTimestamp", "getAuthor()->getExternId", "getAuthor()->getPermission", "getHidden"), array("tReplyId", "replyContent", "timestamp", "authorExtern", "permission", "hidden")); $i = 0; global $FILE_WEB_PATH; $result['FILE_WEB_PATH'] = $FILE_WEB_PATH; global $BASE_WEBPATH; $result['BASE_WEBPATH'] = $BASE_WEBPATH; foreach ($result['ticket_replies'] as $reply) { $webReplyUser = new WebUsers($reply['authorExtern']); $result['ticket_replies'][$i]['author'] = $webReplyUser->getUsername(); $i++; } if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $result['isMod'] = "TRUE"; $result['statusList'] = Ticket::getStatusArray(); $result['sGroups'] = Gui_Elements::make_table_with_key_is_id(Support_Group::getAllSupportGroups(), array("getName"), "getSGroupId"); } $result['hasInfo'] = $target_ticket->hasInfo(); global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; //get attachments $result['ticket_attachments'] = Ticket::getAttachments($result['ticket_id']); 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 load info that's needed for the show_queue 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. * if an action is set (this is done by $_GET['action']) it will try to execute it first, actions are: assign a ticket, unassign a ticket an create a queue. * There are a few predefined queues which is the 'all tickets' queue, 'archive' queue, 'todo' queue, .. these are passed by $_GET['get']. * if $_GET['get'] = create; then it's a custom made queue, this will call the createQueue function which builds the query that we will later use to get the tickets. * The tickets fetched will be returned and used in the template. Now why use POST and GET params here and have a createQueue function twice? Well the first time someone creates * a queue the POST variables will be used, however after going to the next page it will use the GET params. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_queue() { global $INGAME_WEBPATH; global $WEBPATH; //if logged in & queue id is given if (WebUsers::isLoggedIn() && isset($_GET['get'])) { if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { //the queue you want to see. $result['queue_view'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING); $user_id = unserialize($_SESSION['ticket_user'])->getTUserId(); $queueArray = array(); $queue_handler = new Ticket_Queue_handler(); //Pagination Base Links if (Helpers::check_if_game_client()) { $result['pagination_base_link'] = $INGAME_WEBPATH . "?page=show_queue&get=" . $result['queue_view']; } else { $result['pagination_base_link'] = $WEBPATH . "?page=show_queue&get=" . $result['queue_view']; } //form url to keep the getters constant if (Helpers::check_if_game_client()) { $result['getURL'] = $INGAME_WEBPATH . "?page=show_queue&get=" . $result['queue_view']; } else { $result['getURL'] = $WEBPATH . "?page=show_queue&get=" . $result['queue_view']; } if (isset($_GET['pagenum'])) { $result['getURL'] = $result['getURL'] . "&pagenum=" . $_GET['pagenum']; } if (isset($_GET['get']) && $_GET['get'] == "create" && isset($_GET['userid']) && isset($_GET['groupid']) && isset($_GET['what']) && isset($_GET['how']) && isset($_GET['who'])) { $userid = filter_var($_GET['userid'], FILTER_SANITIZE_NUMBER_INT); $groupid = filter_var($_GET['groupid'], FILTER_SANITIZE_NUMBER_INT); $what = filter_var($_GET['what'], FILTER_SANITIZE_STRING); $how = filter_var($_GET['how'], FILTER_SANITIZE_STRING); $who = filter_var($_GET['who'], FILTER_SANITIZE_STRING); //create the custom queue $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); if (Helpers::check_if_game_client()) { $result['pagination_base_link'] = $INGAME_WEBPATH . "?page=show_queue&get=create&userid=" . $userid . "&groupid=" . $groupid . "&what=" . $what . "&how=" . $how . "&who=" . $who; } else { $result['pagination_base_link'] = $WEBPATH . "?page=show_queue&get=create&userid=" . $userid . "&groupid=" . $groupid . "&what=" . $what . "&how=" . $how . "&who=" . $who; } $result['prev_created_userid'] = $userid; $result['prev_created_groupid'] = $groupid; $result['prev_created_what'] = $what; $result['prev_created_how'] = $how; $result['prev_created_who'] = $who; $result['getURL'] = $result['getURL'] . "&userid=" . $userid . "&groupid=" . $groupid . "&what=" . $what . "&how=" . $how . "&who=" . $who; } //if an action is set if (isset($_POST['action'])) { switch ($_POST['action']) { case "assignTicket": $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id); break; case "unAssignTicket": $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id); break; case "create_queue": $userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT); if (isset($_POST['groupid'])) { $groupid = filter_var($_POST['groupid'], FILTER_SANITIZE_NUMBER_INT); } else { $groupid = 0; } $what = filter_var($_POST['what'], FILTER_SANITIZE_STRING); $how = filter_var($_POST['how'], FILTER_SANITIZE_STRING); $who = filter_var($_POST['who'], FILTER_SANITIZE_STRING); //create the custom queue $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); if (Helpers::check_if_game_client()) { $result['pagination_base_link'] = $INGAME_WEBPATH . "?page=show_queue&get=create&userid=" . $userid . "&groupid=" . $groupid . "&what=" . $what . "&how=" . $how . "&who=" . $who; } else { $result['pagination_base_link'] = $WEBPATH . "?page=show_queue&get=create&userid=" . $userid . "&groupid=" . $groupid . "&what=" . $what . "&how=" . $how . "&who=" . $who; } $result['prev_created_userid'] = $userid; $result['prev_created_groupid'] = $groupid; $result['prev_created_what'] = $what; $result['prev_created_how'] = $how; $result['prev_created_who'] = $who; $result['getURL'] = $result['getURL'] . "&userid=" . $userid . "&groupid=" . $groupid . "&what=" . $what . "&how=" . $how . "&who=" . $who; break; } } $queueArray = $queue_handler->getTickets($result['queue_view'], $user_id); //pagination $result['links'] = $queue_handler->getPagination()->getLinks(5); $result['lastPage'] = $queue_handler->getPagination()->getLast(); $result['currentPage'] = $queue_handler->getPagination()->getCurrent(); //if queue_view is a valid parameter value if ($queueArray != "ERROR") { $result['tickets'] = Gui_Elements::make_table($queueArray, array("getTId", "getTitle", "getTimestamp", "getAuthor()->getExternId", "getTicket_Category()->getName", "getStatus", "getStatusText", "getAssigned", "getForwardedGroupName", "getForwardedGroupId"), array("tId", "title", "timestamp", "authorExtern", "category", "status", "statusText", "assigned", "forwardedGroupName", "forwardedGroupId")); $i = 0; foreach ($result['tickets'] as $ticket) { $web_author = new WebUsers($ticket['authorExtern']); $result['tickets'][$i]['author'] = $web_author->getUsername(); $web_assigned = new WebUsers($ticket['assigned']); $result['tickets'][$i]['assignedText'] = $web_assigned->getUsername(); $result['tickets'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($ticket['timestamp']); $i++; } $result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId(); //Queue creator field info $result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), array("getSGroupId", "getName"), array("sGroupId", "name")); $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), array("getTUserId", "getExternId"), array("tUserId", "externId")); $i = 0; foreach ($result['teamlist'] as $member) { $web_teammember = new Webusers($member['externId']); $result['teamlist'][$i]['name'] = $web_teammember->getUsername(); $i++; } global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; return $result; } else { //ERROR: Doesn't exist! $_SESSION['error_code'] = "404"; header("Cache-Control: max-age=1"); header("Location: ams?page=error"); 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 show_sgroup page. * check if the person browsing this page is a mod/admin, if not he'll be redirected to an error page. * if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group. * A list of users that are member of the group will be returned, which can be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_sgroup() { global $INGAME_WEBPATH; global $WEBPATH; //if logged in if (WebUsers::isLoggedIn()) { if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { if (isset($_GET['id'])) { //['target_id'] holds the id of the group! $result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); //if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group. if (isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT); $result['delete'] = Support_Group::deleteUserOfSupportGroup($delete_id, $result['target_id']); header("Cache-Control: max-age=1"); if (Helpers::check_if_game_client()) { header("Location: " . $INGAME_WEBPATH . "?page=show_sgroup&id=" . $result['target_id']); } else { header("Location: " . $WEBPATH . "?page=show_sgroup&id=" . $result['target_id']); } throw new SystemExit(); } if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) { $result['isAdmin'] = "TRUE"; } $group = Support_Group::getGroup($result['target_id']); $result['groupsname'] = $group->getName(); $result['groupemail'] = $group->getGroupEmail(); $result['imap_mailserver'] = $group->getIMAP_MailServer(); $result['imap_username'] = $group->getIMAP_Username(); $result['userlist'] = Gui_Elements::make_table(Support_Group::getAllUsersOfSupportGroup($result['target_id']), array("getTUserId", "getPermission", "getExternId"), array("tUserId", "permission", "externId")); $i = 0; foreach ($result['userlist'] as $user) { $webuser = new Webusers($user['externId']); $result['userlist'][$i]['name'] = $webuser->getUsername(); $i++; } global $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH; $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), array("getTUserId", "getExternId"), array("tUserId", "externId")); $i = 0; foreach ($result['teamlist'] as $member) { $web_teammember = new Webusers($member['externId']); if (!In_Support_Group::userExistsInSGroup($member['externId'], $result['target_id'])) { $result['users'][$i]['name'] = $web_teammember->getUsername(); } $i++; } return $result; } else { //ERROR: No page specified! $_SESSION['error_code'] = "404"; header("Cache-Control: max-age=1"); header("Location: ams?page=error"); 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 create a new ticket. * It will first check if the user who executed this function is the person of whom the setting is or if it's a mod/admin. If this is not the case the page will be redirected to an error page. * next it will filter the POST data and it will try to create the new ticket. Afterwards a redirecion to the ticket will occur. * @author Daan Janssens, mentored by Matthew Lagoe */ function create_ticket() { //if logged in global $INGAME_WEBPATH; global $WEBPATH; $return = array(); $error = false; if (WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])) { if (strlen(preg_replace('/\\s\\s+/', ' ', $_POST['Title'])) < 2) { $return = array_merge($_POST, $return); $return['no_visible_elements'] = 'FALSE'; $catArray = Ticket_Category::getAllCategories(); $return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); $return['category'] = Gui_Elements::make_table_with_key_is_id($catArray, array("getName"), "getTCategoryId"); $return['TITLE_ERROR_MESSAGE'] = "Title must not be blank!"; $return['TITLE_ERROR'] = true; $error = true; } if (strlen(preg_replace('/\\s\\s+/', ' ', $_POST['Content'])) < 2) { $return = array_merge($_POST, $return); $return['no_visible_elements'] = 'FALSE'; $catArray = Ticket_Category::getAllCategories(); $return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); $return['category'] = Gui_Elements::make_table_with_key_is_id($catArray, array("getName"), "getTCategoryId"); $return['CONTENT_ERROR_MESSAGE'] = "Content must not be blank!"; $return['CONTENT_ERROR'] = true; $error = true; } if ($error) { helpers::loadTemplate('createticket', $return); throw new SystemExit(); } if (isset($_POST['target_id'])) { //if target_id is the same as session id or is admin if ($_POST['target_id'] == $_SESSION['id'] || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT); $title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING); $content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING); try { if ($_POST['target_id'] == $_SESSION['id']) { //if the ticket is being made for the executing user himself $author = unserialize($_SESSION['ticket_user'])->getTUserId(); } else { //if a mod tries to make a ticket for someone else $author = Ticket_User::constr_ExternId($_POST['target_id'])->getTUserId(); } //create the ticket & return the id of the newly created ticket. $ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(), 0, $_POST); //redirect to the new ticket. if (Helpers::check_if_game_client()) { header("Cache-Control: max-age=1"); header("Location: " . $INGAME_WEBPATH . "?page=show_ticket&id=" . $ticket_id); } else { header("Cache-Control: max-age=1"); header("Location: " . $WEBPATH . "?page=show_ticket&id=" . $ticket_id); throw new SystemExit(); } } catch (PDOException $e) { //ERROR: LIB DB is not online! print_r($e); throw new SystemExit(); header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } } else { //ERROR: permission denied! $_SESSION['error_code'] = "403"; header("Cache-Control: max-age=1"); header("Location: index.php?page=error"); throw new SystemExit(); } } else { //ERROR: The form was not filled in correclty header("Cache-Control: max-age=1"); header("Location: index.php?page=createticket"); throw new SystemExit(); } } else { //ERROR: user is not logged in header("Cache-Control: max-age=1"); header("Location: index.php"); throw new SystemExit(); } }