/*
eTicket, Open Source Support Ticket System
http://eticket.sourceforge.net/
Released under the GNU General Public License
*/
@header('Cache-control: private');
require_once('init.php');
if ($_SESSION['user']['type'] == 'client') {
$login = $login;
if ($login) {
switch ($a) {
case "view":
$id = preg_replace('/\D+/', '', $_REQUEST['id']);
$titles['viewticket'] .= htmlspecialchars(' [#' . $id . ']');
$inc = 'viewticket';
break;
case "close":
if (count($_POST['t'])) {
foreach ($_POST['t'] as $id => $val) {
CloseTicket($id);
}
}
break;
case "reopen":
if (count($_POST['t'])) {
foreach ($_POST['t'] as $id => $val) {
ReopenTicket($id);
}
}
break;
case "post":
if ($_POST['message']) {
$id = preg_replace('/\D+/', '', $_POST['id']);
$iid = PostMessage($_POST['id'], $_POST['message']);
$ext = preg_replace("/.*\.(.{3,4})$/", "$1", $_FILES['attachment']['name']);
if ($_FILES['attachment']['name']) {
if ($config['attachment_dir'] and stristr($config['filetypes'], ".$ext;")) {
mt_srand(time());
$rand = mt_rand(100000, 999999);
$filename = $rand . '_' . $_FILES['attachment']['name'];
copy($_FILES['attachment']['tmp_name'], $config['attachment_dir'] . $filename);
mysql_query("INSERT INTO ticket_attachments (ticket, ref, filename, type) VALUES ('$id', '$iid', '$filename', 'q')");
} else {
$err = $ext . ' ' . LANG_ERROR_BAD_FILETYPE . '
';
}
}
header('Location: '.$_SERVER['REQUEST_URI'].'#end');
die();
} else {
$err = LANG_ERROR_MISSING_FIELDS . '
';
}
$inc = 'viewticket';
break;
case "logout":
logout($_SERVER['PHP_SERVER']);
break;
}
} else {
if ($_POST) {
$err = LANG_ERROR_LOGIN;
session_destroy();
}
$inc = 'user_login';
}
}
else { $inc = 'user_login'; }
if (!isset($inc)) $inc='main';
$include = $site_header; if (file_exists($include)) { include_once($include); }
include_once(INC_DIR."$inc.php");
echo '';
$include = $site_footer; if (file_exists($include)) { include_once($include); }
?>