/** * This function is beign used to load info that's needed for the show_ticket_info 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. * not all tickets have this page related to it, only tickets created ingame will have additional information. The returned info will be used by the template to show the show_ticket_info page. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_ticket_info() { //if logged in if (WebUsers::isLoggedIn() && isset($_GET['id'])) { $result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $target_ticket = new Ticket(); $target_ticket->load_With_TId($result['ticket_id']); if ($target_ticket->hasInfo() && ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])))) { $result['ticket_title'] = $target_ticket->getTitle(); $result['ticket_author'] = $target_ticket->getAuthor(); $ticket_info = new Ticket_Info(); $ticket_info->load_With_Ticket($result['ticket_id']); $result['shard_id'] = $ticket_info->getShardId(); $result['user_position'] = $ticket_info->getUser_Position(); $result['view_position'] = $ticket_info->getView_Position(); $result['client_version'] = $ticket_info->getClient_Version(); $result['patch_version'] = $ticket_info->getPatch_Version(); $result['server_tick'] = $ticket_info->getServer_Tick(); $result['connect_state'] = $ticket_info->getConnect_State(); $result['local_address'] = $ticket_info->getLocal_Address(); $result['memory'] = $ticket_info->getMemory(); $result['os'] = $ticket_info->getOS(); $result['processor'] = $ticket_info->getProcessor(); $result['cpu_id'] = $ticket_info->getCPUId(); $result['cpu_mask'] = $ticket_info->getCPU_Mask(); $result['ht'] = $ticket_info->getHT(); $result['nel3d'] = $ticket_info->getNel3D(); $result['user_id'] = $ticket_info->getUser_Id(); global $IMAGELOC_WEBPATH; $result['IMAGELOC_WEBPATH'] = $IMAGELOC_WEBPATH; 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 reply on a ticket. * It will first check if the user who executed this function is a mod/admin or the topic creator himself. If this is not the case the page will be redirected to an error page. * in case the isset($_POST['hidden'] is set and the user is a mod, the message will be hidden for the topic starter. The reply will be created. If $_POST['ChangeStatus']) & $_POST['ChangePriority'] is set * it will try to update the status and priority. Afterwards the page is being redirecte to the ticket again. * @author Daan Janssens, mentored by Matthew Lagoe */ function reply_on_ticket() { global $INGAME_WEBPATH; global $WEBPATH; //if logged in if (WebUsers::isLoggedIn() && isset($_POST['ticket_id'])) { $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $target_ticket = new Ticket(); $target_ticket->load_With_TId($ticket_id); //check if the user who executed this function is a mod/admin or the topic creator himself. if ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { try { $author = unserialize($_SESSION['ticket_user'])->getTUserId(); if (isset($_POST['Content'])) { $content = $_POST['Content']; } else { $content = ""; } $hidden = 0; if (isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $hidden = 1; } //create the reply Ticket::createReply($content, $author, $ticket_id, $hidden); //try to update the status & priority in case these are set. if (isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT); $newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT); Ticket::updateTicketStatusAndPriority($ticket_id, $newStatus, $newPriority, $author); } header("Cache-Control: max-age=1"); if (Helpers::check_if_game_client()) { header("Location: " . $INGAME_WEBPATH . "?page=show_ticket&id=" . $ticket_id); } else { header("Location: " . $WEBPATH . "?page=show_ticket&id=" . $ticket_id); } throw new SystemExit(); } catch (PDOException $e) { //ERROR: LIB DB is not online! print_r($e); //header("Location: index.php"); 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_reply page. * check if the person is allowed to see the reply, if not he'll be redirected to an error page. * data regarding to the reply will be returned by this function that will be used by the template. * @author Daan Janssens, mentored by Matthew Lagoe */ function show_reply() { //if logged in if (WebUsers::isLoggedIn() && isset($_GET['id'])) { $result['reply_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $reply = new Ticket_Reply(); $reply->load_With_TReplyId($result['reply_id']); $ticket = new Ticket(); $ticket->load_With_TId($reply->getTicket()); //check if the user is allowed to see the reply if ($ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && !$reply->getHidden() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { $content = new Ticket_Content(); $content->load_With_TContentId($reply->getContent()); $author = new Ticket_User(); $author->load_With_TUserId($reply->getAuthor()); $result['hidden'] = $reply->getHidden(); $result['ticket_id'] = $reply->getTicket(); $result['reply_timestamp'] = $reply->getTimestamp(); $result['author_permission'] = $author->getPermission(); $result['reply_content'] = $content->getContent(); $result['author'] = $author->getExternId(); $webUser = new WebUsers($author->getExternId()); $result['authorName'] = $webUser->getUsername(); 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(); } }
/** * Handles an incomming email * Read the content of one email by using imap's functionality. If a ticket id is found inside the message_id or else in the subject line, then a reply will be added * (if the email is not being sent from the authors email address it won't be added though and a warning will be sent to both parties). If no ticket id is found, then a new * ticket will be created. * @param $mbox a mailbox object * @param $i the email's id in the mailbox (integer) * @param $group the group object that owns the inbox. * @return a string based on the found ticket i and timestamp (will be used to store a copy of the email locally) */ function incoming_mail_handler($mbox, $i, $group) { global $MAIL_LOG_PATH; $header = imap_header($mbox, $i); $subject = self::decode_utf8($header->subject); $entire_email = imap_fetchheader($mbox, $i) . imap_body($mbox, $i); $subject = self::decode_utf8($header->subject); $to = $header->to[0]->mailbox; $from = $header->from[0]->mailbox . '@' . $header->from[0]->host; $fromEmail = $header->from[0]->mailbox . '@' . $header->from[0]->host; $txt = self::get_part($mbox, $i, "TEXT/PLAIN"); //$html = self::get_part($mbox, $i, "TEXT/HTML"); //get the id out of the email address of the person sending the email. if ($from !== NULL && !is_numeric($from)) { $from = Ticket_User::get_id_from_email($from); } //get ticket_id out of the message-id or else out of the subject line $ticket_id = 0; if (isset($header->references)) { $pieces = explode(".", $header->references); if ($pieces[0] == "<ams") { $ticket_id = $pieces[2]; } else { $ticket_id = self::get_ticket_id_from_subject($subject); } } else { $ticket_id = self::get_ticket_id_from_subject($subject); } //if ticket id is found, that means it is a reply on an existing ticket if ($ticket_id && is_numeric($ticket_id) && $ticket_id > 0) { $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); //if email is sent from an existing email address in the db (else it will give an error while loading the user object) if ($from != "FALSE") { $user = new Ticket_User(); $user->load_With_TUserId($from); //if user has access to it! if ((Ticket_User::isMod($user) or $ticket->getAuthor() == $user->getTUserId()) and $txt != "") { Ticket::createReply($txt, $user->getTUserId(), $ticket->getTId(), 0); error_log("Email found that is a reply to a ticket at:" . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH); } else { //if user has no access to it //Warn real ticket owner + person that send the mail Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, NULL, "WARNAUTHOR", $from); Mail_Handler::send_ticketing_mail($from, $ticket, NULL, "WARNSENDER", NULL); error_log("Email found that was a reply to a ticket, though send by another user to " . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH); } } else { //if a reply to a ticket is being sent by a non-user! //Warn real ticket owner + person that send the mail Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, NULL, "WARNAUTHOR", $fromEmail); Mail_Handler::send_ticketing_mail($fromEmail, $ticket, NULL, "WARNUNKNOWNSENDER", NULL); error_log("Email found that was a reply to a ticket, though send by an unknown email address to " . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH); } return $ticket_id . "." . time(); } else { if ($from != "FALSE") { //if ticket_id isn't found, create a new ticket! //if an existing email address mailed the ticket //if not default group, then forward it by giving the $group->getSGroupId's param $newTicketId = Ticket::create_Ticket($subject, $txt, 1, $from, $from, $group->getSGroupId()); error_log("Email regarding new ticket found at:" . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH); return $newTicketId . "." . time(); } else { //if it's a email that has nothing to do with ticketing, return 0; error_log("Email found that isn't a reply or new ticket, at:" . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH); return 0; } } }
/** * create a new reply for a ticket. * A reply will only be added if the content isn't empty and if the ticket isn't closed. * The ticket creator will be notified by email that someone else replied on his ticket. * @param $content the content of the reply * @param $author the author of the reply * @param $ticket_id the id of the ticket to which we want to add the reply. * @param $hidden boolean that specifies if the reply should only be shown to mods/admins or all users. */ public static function createReply($content, $author, $ticket_id, $hidden) { //if not empty if (!(Trim($content) === '')) { $content = filter_var($content, FILTER_SANITIZE_STRING); $ticket = new Ticket(); $ticket->load_With_TId($ticket_id); //if status is not closed if ($ticket->getStatus() != 3) { Ticket_Reply::createReply($content, $author, $ticket_id, $hidden, $ticket->getAuthor()); //notify ticket author that a new reply is added! if ($ticket->getAuthor() != $author) { Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, $content, "REPLY", $ticket->getForwardedGroupId()); } } else { //TODO: Show error message that ticket is closed } } else { //TODO: Show error content is empty } }
/** * 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(); } }
require '../../config.php'; require_once $AMS_LIB . '/libinclude.php'; $id = $_POST['PHPSESSID']; session_id($id); session_start(); // Set permission if (isset($_SESSION['ticket_user'])) { $return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); } else { // default permission $return['permission'] = 0; } if (WebUsers::isLoggedIn() && isset($_GET['id'])) { $ticket_id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $target_ticket = new Ticket(); $target_ticket->load_With_TId($ticket_id); if ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) { if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $fileParts = pathinfo($_FILES['Filedata']['name']); Ticket::add_Attachment($_GET['id'], $_FILES['Filedata']['name'], $_SESSION['id'], $tempFile); echo "Uploaded :" . $_FILES['Filedata']['name']; } else { echo "Upload Failed!"; } echo "Upload Failed!"; } echo "Upload Failed!"; } echo "Upload Failed!";