isAdmin($_SESSION['user_id']); $attachmentSettings = $TicketSettings->get(array('attachments_enabled', 'attachment_save_dir', 'attachment_limit', 'attachment_max_size', 'attachment_extensions', 'ratings_enabled')); echo '

'.get_lang('viewing_ticket').'

'; $tid = (int)$_GET['tid']; $uid = $_GET['uid']; $ticketData = $ticket->getTicket($tid, $uid); if (!$ticket->exists($tid, $uid)) { print_failure(get_lang('ticket_not_found')); $view->refresh("?m=tickets"); return; } if (!$isAdmin && !$ticket->authorized($_SESSION['user_id'], $tid, $uid)) { print_failure(get_lang('ticket_cant_read')); $view->refresh("?m=tickets"); return; } if (!$ticketData) { print_failure(get_lang('cant_view_ticket')); $view->refresh("?m=tickets"); return; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $attachments = new Attachments( $db, $_FILES['ticket_file'], $attachmentSettings['attachment_save_dir'], $attachmentSettings['attachment_limit'], $attachmentSettings['attachment_max_size'], explode(', ', $attachmentSettings['attachment_extensions']) ); if (isset($_POST['ticket_close'])) { $ticket->updateStatus($tid, $uid, 0); $view->refresh("?m=tickets&p=viewticket&tid=".$tid."&uid=".$uid, 0); return; } if (isset($_POST['ticket_submit_response'])) { $_POST = array_map('trim', $_POST); $_SESSION['ticketReply'] = strip_real_escape_string($_POST['reply_content']); $errors = array(); $fileErrors = array(); if (empty($_POST['reply_content'])) { $errors[] = get_lang('no_ticket_reply'); } elseif (strlen($_POST['reply_content']) < 4) { $errors[] = get_lang('invalid_ticket_reply_length'); } if ($attachments->checkPath() === false && $attachmentSettings['attachments_enabled']) { $fileErrors[] = get_lang('attachment_directory_not_writable'); } if ($attachments->validAttachmentCount() === false && $attachmentSettings['attachments_enabled']) { $fileErrors[] = get_lang_f('attachment_invalid_file_count', $attachmentSettings['attachment_limit']); } if (empty($errors)) { $reply = $ticket->message($tid, $_SESSION['user_id'], getClientIPAddress(), strip_real_escape_string($_POST['reply_content']), $isAdmin, $uid); if (!$reply) { echo ticketErrors(array(get_lang('failed_to_reply'))); $view->refresh("?m=tickets&p=submitticket", 60); return; } if (isset($_SESSION['ticketReply'])) { unset($_SESSION['ticketReply']); } if ($attachmentSettings['attachments_enabled']) { // Validate the uploaded files if specified path exists and is writable. and if the amount of files is valid. // if any files fail to validate, then only save/move the ones which validated successfully and show an error for the ones which didn't. if (empty($fileErrors)) { $validator = $attachments->validate(); $fileErrors[] = $validator->getErrors(); $attachments->save($tid, $reply); } setcookie('fileErrors', json_encode(array('uid' => $uid, 'fileErrors' => $fileErrors)), time() + 86400, '/'); } $view->refresh("?m=tickets&p=viewticket&tid=".$tid."&uid=".$uid, 0); return; } else { echo ticketErrors($errors); $view->refresh("?m=tickets&p=viewticket&tid=".$tid."&uid=".$uid, 60); return; } } } echo '
'. ticketErrors() .'
'; echo ticketHeader($ticketData); if ($ticketData['status'] == 0) { echo '
'.get_lang('ticket_is_closed').'
'; echo '
'; echo '
'.get_lang('reply').'
'; echo '
+
'; echo '
'; echo '
'; } echo '
'; if ($attachmentSettings['attachments_enabled']) { echo attachmentForm(); } echo ' '.($ticketData['status'] != 0 ? '' : '').'
'; if (!empty($ticketData['messages'])) { echo '
'; foreach ($ticketData['messages'] as $message) { echo ticketMessage($message, $uid, $isAdmin, $attachmentSettings['ratings_enabled']); } echo '
'; } if (empty($ticketData['messages']) && $ticketData['status'] != 0) { echo '
'.get_lang('no_ticket_replies').'
'; } require 'js/javascript_vars.php'; ?>