-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcreateticket.php
106 lines (106 loc) · 3.56 KB
/
createticket.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
if(!file_exists("mysql.php")){
header("Location: setup/index.php");
exit;
}
session_start();
require("datamanager.php");
require('assets/languages/lang_'.getSetting("lang").'.php');
if(!isset($_SESSION["username"])){
?>
<meta http-equiv="refresh" content="0; URL=login.php">
<?php
exit;
}
function create(){
require("mysql.php");
$stmt = $mysql->prepare("INSERT INTO tickets (CREATOR, TITLE, CATEGORY, MESSAGE, CREATIONDATE, LASTANSWERDATE, STATUS)
VALUES (:accid, :title, :catid, :msg, :now, null, 0)");
$id = getAccountID($_SESSION["username"]);
$stmt->bindParam(":accid", $id, PDO::PARAM_INT);
$stmt->bindParam(":title", $_POST["subject"], PDO::PARAM_STR);
$stmt->bindParam(":catid", $_POST["category"], PDO::PARAM_INT);
$stmt->bindParam(":msg", $_POST["msg"], PDO::PARAM_STR);
$now = time();
$stmt->bindParam(":now", $now, PDO::PARAM_STR);
$stmt->execute();
?>
<meta http-equiv="refresh" content="0; URL=mytickets.php">
<?php
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title><?php echo TICKET_CREATE_HEADING; ?></title>
<link rel="stylesheet" href="assets/css/main.css">
<link href="https://fonts.googleapis.com/css?family=Quicksand&display=swap" rel="stylesheet">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
<div class="flex">
<div class="flex-item">
<?php
if(isset($_POST["submit"])){
if(getSetting("captcha") == "1"){
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array(
'secret' => getSetting("captcha_private"),
'response' => $_POST["g-recaptcha-response"]
);
$options = array(
'http' => array (
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$verify = file_get_contents($url, false, $context);
$captcha_success=json_decode($verify);
if($captcha_success->success){
create();
} else {
?>
<div class="error">
<?php echo CAPTCHA_FAIL; ?>
</div>
<?php
}
} else {
create();
}
}
?>
<h1><?php echo TICKET_CREATE_HEADING; ?></h1>
<form action="createticket.php" method="post">
<select name="category">
<?php
require("mysql.php");
$stmt = $mysql->prepare("SELECT * FROM categorys WHERE STATUS = 0");
$stmt->execute();
while ($row = $stmt->fetch()) {
?>
<option value="<?php echo $row["ID"]; ?>"><?php echo $row["NAME"]; ?></option>
<?php
}
?>
</select>
<input type="text" name="subject" placeholder="<?php echo SUBJECT; ?>" minlength="3" required><br>
<textarea name="msg" rows="8" cols="80" placeholder="<?php echo MESSAGE; ?>" minlength="16" required></textarea><br>
<?php
if(getSetting("captcha") == "1"){
?>
<div class="g-recaptcha" data-sitekey="<?php echo getSetting("captcha_public"); ?>"></div><br>
<?php
}
?>
<button type="submit" name="submit"><?php echo SEND; ?></button><br>
</form>
</div>
<div class="flex-item sidebar">
<?php require('assets/inc/sidebar.inc.php'); ?>
</div>
</div>
</body>
</html>