Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

doticketreply.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?PHP
  2. require_once('lib/account.php');
  3. require_once('lib/dashboard.php');
  4. require_once('lib/database.php');
  5. if (get_magic_quotes_gpc() == 1) {
  6. foreach ($_POST as $k => $v) { $_POST[$k] = stripslashes($v); }
  7. }
  8. if (isset($_POST['message']) && isset($_POST['status']) && isset($_POST['thread'])) {
  9. if (USER == 'demo') {
  10. define('MESSAGE','Sorry. The demo account can\'t reply to tickets.');
  11. } elseif (!preg_match('/^[0-9]+$/', $_POST['thread'])) {
  12. define('MESSAGE', 'Invalid ticket thread.');
  13. } else {
  14. $sql = 'SELECT user_id, ticket_status, ticket_title FROM tickets WHERE ticket_id = '.$_POST['thread'];
  15. $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  16. $row = mysql_fetch_array($res);
  17. define('TTITLE', $row['ticket_title']);
  18. if ((UID != $row[0]) && (!defined('ADMIN'))) {
  19. define('MESSAGE', 'You don\'t have access to reply to that ticket.');
  20. } else {
  21. $opts = array(); $opts[($row[1])] = true;
  22. switch ($row[1]) {
  23. case 'new': case 'reopened':
  24. $opts['closed'] = true;
  25. if (defined('ADMIN')) { $opts['assigned'] = true; }
  26. break;
  27. case 'assigned':
  28. $opts['closed'] = true;
  29. break;
  30. case 'closed':
  31. $opts['reopened'] = true;
  32. break;
  33. }
  34. if (!isset($opts[($_POST['status'])])) {
  35. define('MESSAGE', 'Invalid/unknown status');
  36. } else {
  37. $sql = 'INSERT INTO tickets (user_id, ticket_title, ticket_body, ';
  38. $sql .= 'ticket_time, ticket_status, ticket_thread) VALUES ('.UID.', \'\', ';
  39. $sql .= '\''.m($_POST['message']).'\', '.time().', \'reply\', ';
  40. $sql .= $_POST['thread'].')';
  41. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  42. if (file_exists('/home/utd/common/ticketmail.php')) {
  43. require_once('/home/utd/common/ticketmail.php');
  44. ticketmail(mysql_insert_id());
  45. logger::log('Replied to ticket "'.TTITLE.'"', logger::normal);
  46. }
  47. $sql = 'UPDATE tickets SET ticket_status = \''.$_POST['status'].'\' WHERE ticket_id = '.$_POST['thread'];
  48. mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
  49. header('Location: '.CP_PATH.'viewticket/'.$_POST['thread']);
  50. die;
  51. }
  52. }
  53. }
  54. } else {
  55. define('MESSAGE', 'No ticket data submitted');
  56. }
  57. define('TITLE', 'Error');
  58. addDashboardItem('Useful links', 'Support center', 'support');
  59. addDashboardItem('Useful links', 'Raise a new ticket', 'tickets');
  60. addDashboardItem('Frequently asked questions', 'Can I file support requests without using the control panel?', 'support/005');
  61. require_once('lib/header.php');
  62. require_once('lib/footer.php');
  63. ?>