ungetestet, vorher ein backup machen: include/contents/ticket.php
<?php
########################################
# Support Ticket System by legalsauger #
# Version 1.3 #
# © by ilch-module.de #
########################################
defined('main') or die('no direct access');
require_once('include/includes/func/ticketfunc.php');
$title = $allgAr['title'] . ' :: Support Ticket';
$hmenu = 'Support Ticket';
$design = new design($title, $hmenu);
$design->header();
if (loggedin()) {
switch ($menu->get(1)) {
default:
$limit = $allgAr['sitetickets'];
$page = ($menu->getA(1) == 'p' ? $menu->getE(1) : 1);
$mpl = db_make_sites($page, 'WHERE uid = ' . $_SESSION['authid'], $limit, '?ticket', 'tickets');
$anfang = ($page - 1) * $limit;
$tickets = '';
$class = 'Cmite';
$count = db_count_query("SELECT COUNT(*) FROM prefix_tickets WHERE uid = " . $_SESSION['authid']);
$abf = db_query("SELECT * FROM prefix_tickets WHERE uid = " . $_SESSION['authid'] . " ORDER BY status ASC,time DESC LIMIT " . $anfang . "," . $limit);
if (db_num_rows($abf) != 0) {
while ($row = db_fetch_assoc($abf)) {
$tposts = db_count_query("SELECT COUNT(*) FROM prefix_tposts WHERE tid = " . $row['id']);
$tickets .= '<tr class="' . $class . '">
<td>' . $row['id'] . '</td>
<td><a href="index.php?ticket-reply-' . $row['id'] . '">' . $row['name'] . '</a></td>
<td align="center">' . dateformat($row['time']) . '</td>
<td align="center">' . getstatus($row['id']) . '</td>
<td align="center">' . $tposts . '</td>
</tr>';
if ($class == 'Cmite') {
$class = 'Cnorm';
} else {
$class = 'Cmite';
}
}
} else {
$tickets = '<tr class="Cmite"><td colspan="5">Du hast noch keine Tickets verfasst!</td></tr>';
}
$tpl = new tpl('ticket/ticket');
$tpl->set('tickets', $tickets);
$tpl->set('count', $count);
$tpl->set('MPL', $mpl);
$tpl->out(0);
break;
case 'new':
$tpl = new tpl('ticket/new_ticket');
$tpl->out(0);
break;
case 'sendnew':
$name = escape($_POST['name'], 'string');
$text = escape($_POST['text'], 'textarea');
$file = false;
$fehler = 'Fehler:\n';
if ($name AND $text) {
if (!empty($_FILES['file']['tmp_name'])) {
$file = true;
if (is_writeable('include/downs/files')) {
$end = array('jpg', 'png', 'zip', 'rar');
if (in_array(get_file_ext($_FILES['file']['name']), $end)) {
$fname = genkey(5) . '_' . $_FILES['file']['name'];
if (move_uploaded_file($_FILES['file']['tmp_name'], 'include/downs/files/' . $fname)) {
$fehler = false;
} else {
$fehler = 'Die Datei konnte nicht verschoben werden!';
}
} else {
$fehler = 'Bitte beachte die erlaubten Dateiendungen!';
}
} else {
$fehler = 'Der Zielordner hat nicht die nötigen chmod Rechte!';
}
}
if ($fehler == false OR $file == false) {
$abf = db_query("SELECT id FROM prefix_modules WHERE url = 'tickets'");
$row = db_fetch_assoc($abf);
$abf = db_query("SELECT u.* FROM prefix_user u LEFT JOIN prefix_modulerights mr ON u.id = mr.uid AND mr.mid = " . $row['id'] . " WHERE u.recht < -7 OR !ISNULL(mr.uid)");
while ($row = db_fetch_assoc($abf)) {
sendpm($_SESSION['authid'], $row['id'], 'Neues Support Ticket', 'Der User [b]' . $_SESSION['authname'] . '[/b] hat ein Support Ticket erstellt. Dieses kann [url=http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/admin.php?tickets]hier[/url] bearbeitet werden.');
}
$c = @db_count_query("SELECT * FROM prefix_tickets WHERE name = '" . $name . "'");
$c2 = db_count_query("SELECT COUNT(*) FROM prefix_tickets WHERE uid = " . $_SESSION['authid']);
if ($c != 0) {
$name = $name . ' - ' . $c2;
}
db_query("INSERT INTO prefix_tickets (name,uid,time) VALUES ('" . $name . "'," . $_SESSION['authid'] . ",NOW())");
$tid = db_last_id();
if ($file) {
db_query("INSERT INTO prefix_tposts (uid,tid,tuid,time,text,file) VALUES (" . $_SESSION['authid'] . "," . $tid . "," . $_SESSION['authid'] . ",NOW(),'" . $text . "','" . $fname . "')");
} else {
db_query("INSERT INTO prefix_tposts (uid,tid,tuid,time,text) VALUES (" . $_SESSION['authid'] . "," . $tid . "," . $_SESSION['authid'] . ",NOW(),'" . $text . "')");
}
echo '<script type="text/javascript">alert("Dein Support Ticket wurde erstellt und wird schnellstmöglich bearbeitet!");document.location.href="index.php?ticket";</script>';
} else {
echo '<script type="text/javascript">alert("' . $fehler . '");document.location.href="index.php?ticket-new";</script>';
}
} else {
echo '<script type="text/javascript">alert("Du musst alle Felder ausfüllen!");document.location.href="index.php?ticket-new";</script>';
}
break;
case 'reply':
$id = $menu->get(2);
$abf = db_query("SELECT uid,name FROM prefix_tickets WHERE id = " . $id);
$row = db_fetch_assoc($abf);
$name = $row['name'];
if ($row['uid'] != $_SESSION['authid']) {
echo '<script type="text/javascript">alert("Du darfst nur deine eigenen Tickets ansehen!");document.location.href="index.php?ticket";</script>';
} else {
$limit = $allgAr['replyticket'];
$page = ($menu->getA(3) == 'p' ? $menu->getE(3) : 1);
$mpl = db_make_sites($page, 'WHERE tid = ' . $id, $limit, '?ticket-reply-' . $id, 'tposts');
$anfang = ($page - 1) * $limit;
$rep = '';
$count = 1;
$class = 'Cmite';
$abf = db_query("SELECT * FROM prefix_tposts WHERE tid = " . $id . " ORDER BY time ASC LIMIT " . $anfang . "," . $limit);
while ($row = db_fetch_assoc($abf)) {
if ($row['file'] != '') {
$text = bbcode($row['text']) . '<br><br>Dateianhang: <a href="include/downs/files/' . $row['file'] . '"><i>' . $row['file'] . '</i></a>';
} else {
$text = bbcode($row['text']);
}
$rep .= '<tr class="' . $class . '" valign="top">
<td>' . $count . '.</td>
<td><a href="index.php?user-details-' . $row['uid'] . '">' . get_n($row['uid']) . '</a></td>
<td>' . $text . '</td>
<td align="center">' . dateformat($row['time']) . '</td>
</tr>';
if ($class == 'Cmite') {
$class = 'Cnorm';
} else {
$class = 'Cmite';
}
$count++;
}
$tpl = new tpl('ticket/reply_ticket');
$tpl->set('name', $name);
$tpl->set('rep', $rep);
$tpl->set('id', $id);
$tpl->set('MPL', $mpl);
$tpl->out(0);
}
break;
case 'sendreply':
$id = escape($_POST['id'], 'integer');
$text = escape($_POST['text'], 'textarea');
$file = false;
$fehler = 'Fehler:\n';
if ($text) {
if (!empty($_FILES['file']['tmp_name'])) {
$file = true;
if (is_writeable('include/downs/files')) {
$end = array('jpg', 'png', 'zip', 'rar');
if (in_array(get_file_ext($_FILES['file']['name']), $end)) {
$fname = genkey(5) . '_' . $_FILES['file']['name'];
if (move_uploaded_file($_FILES['file']['tmp_name'], 'include/downs/files/' . $fname)) {
$fehler = false;
} else {
$fehler = 'Die Datei konnte nicht verschoben werden!';
}
} else {
$fehler = 'Bitte beachte die erlaubten Dateiendungen!';
}
} else {
$fehler = 'Der Zielordner hat nicht die nötigen chmod Rechte!';
}
}
if ($fehler == false OR $file == false) {
$abf = db_query("SELECT aid,status FROM prefix_tickets WHERE id = " . $id);
$row = db_fetch_assoc($abf);
if ($row['status'] == 2 AND $allgAr['closedtickets'] == 0) {
echo '<script type="text/javascript">alert("Du kannst auf geschlossene Tickets nicht antworten!");document.location.href="index.php?ticket";</script>';
} else {
if ($row['aid'] != 0) {
//sendpm($_SESSION['authid'], $row['aid'], 'Antwort auf ein Support Ticket', 'Der User [b]' . $_SESSION['authname'] . '[/b] hat auf [url=http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']) . '/admin.php?tickets-reply-' . $id . ']dieses[/url] Ticket geantwortet.');
$mailempfaenger = db_result(db_query("SELECT email FROM prefix_user WHERE id = " . $row['aid']), 0, 0);
$mailname = db_result(db_query("SELECT name FROM prefix_user WHERE id = " . $row['aid']), 0, 0);
$mail = $mailempfaenger;
$betreff = 'Ihr Ticket wurde bearbeitet!';
$text = 'Hallo '.$mailname.', Sie haben eine Antwort auf ihre Anfrage erhalten, diese können sie im Ticket System der Seite www.domain.tdl nachlesen.';
$from = 'www.domain.tdl';
$html = false;
icmail($mail, $betreff, $text [, $from] [, $html]);
}
if ($file) {
db_query("INSERT INTO prefix_tposts (uid,tid,tuid,time,text,file) VALUES (" . $_SESSION['authid'] . "," . $id . "," . $_SESSION['authid'] . ",NOW(),'" . $text . "','" . $fname . "')");
} else {
db_query("INSERT INTO prefix_tposts (uid,tid,tuid,time,text) VALUES (" . $_SESSION['authid'] . "," . $id . "," . $_SESSION['authid'] . ",NOW(),'" . $text . "')");
}
if ($row['status'] == 2) {
db_query("UPDATE prefix_tickets SET status = 1 WHERE id = " . $id);
}
echo '<script type="text/javascript">alert("Der zuständige Admin wurde über deinen Beitrag benachrichtigt!");document.location.href="index.php?ticket-reply-' . $id . '";</script>';
}
} else {
echo '<script type="text/javascript">alert("' . $fehler . '");document.location.href="index.php?ticket-reply-' . $id . '";</script>';
}
} else {
echo '<script type="text/javascript">alert("Du musst einen Text eingeben!");document.location.href="index.php?ticket-reply-' . $id . '";</script>';
}
break;
}
} else {
echo 'Du musst <a href="index.php?user-regist">registriert</a> bzw. <a href="index.php?user-login">eingeloggt</a> sein um ein Support Ticket zu erstellen!';
// DO NOT REMOVE THIS LINE
echo '<br><br><br><div align="center"><font size="3"><a href="http://bitworld-gaming.de">© by bitworld-gaming.de</a></font></div>';
// DO NOT REMOVE THIS LINE
}
$design->footer();
?>