forked from osTicket/osTicket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
open.php
82 lines (74 loc) · 2.76 KB
/
open.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*********************************************************************
open.php
New tickets handle.
Peter Rotich <[email protected]>
Copyright (c) 2006-2013 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require('client.inc.php');
define('SOURCE','Web'); //Ticket source.
$ticket = null;
$errors=array();
if ($_POST) {
$vars = $_POST;
$vars['deptId']=$vars['emailId']=0; //Just Making sure we don't accept crap...only topicId is expected.
if ($thisclient) {
$vars['uid']=$thisclient->getId();
} elseif($cfg->isCaptchaEnabled()) {
if(!$_POST['captcha'])
$errors['captcha']=__('Enter text shown on the image');
elseif(strcmp($_SESSION['captcha'], md5(strtoupper($_POST['captcha']))))
$errors['captcha']=__('Invalid - try again!');
}
$tform = TicketForm::objects()->one()->getForm($vars);
$messageField = $tform->getField('message');
$attachments = $messageField->getWidget()->getAttachments();
if (!$errors && $messageField->isAttachmentsEnabled())
$vars['cannedattachments'] = $attachments->getClean();
// Drop the draft.. If there are validation errors, the content
// submitted will be displayed back to the user
Draft::deleteForNamespace('ticket.client.'.substr(session_id(), -12));
//Ticket::create...checks for errors..
if(($ticket=Ticket::create($vars, $errors, SOURCE))){
$msg=__('Support ticket request created');
// Drop session-backed form data
unset($_SESSION[':form-data']);
//Logged in...simply view the newly created ticket.
if($thisclient && $thisclient->isValid()) {
session_write_close();
session_regenerate_id();
@header('Location: tickets.php?id='.$ticket->getId());
}
}else{
$errors['err']=$errors['err']?$errors['err']:__('Unable to create a ticket. Please correct errors below and try again!');
}
}
//page
$nav->setActiveNav('new');
if ($cfg->isClientLoginRequired()) {
if (!$thisclient) {
require_once 'secure.inc.php';
}
elseif ($thisclient->isGuest()) {
require_once 'login.php';
exit();
}
}
require(CLIENTINC_DIR.'header.inc.php');
if($ticket
&& (
(($topic = $ticket->getTopic()) && ($page = $topic->getPage()))
|| ($page = $cfg->getThankYouPage())
)) {
// Thank the user and promise speedy resolution!
echo Format::viewableImages($ticket->replaceVars($page->getBody()));
}
else {
require(CLIENTINC_DIR.'open.inc.php');
}
require(CLIENTINC_DIR.'footer.inc.php');
?>