forked from mike-koch/Mods-for-HESK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verifyemail.php
124 lines (113 loc) · 6.02 KB
/
verifyemail.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
define('IN_SCRIPT', 1);
define('HESK_PATH', './');
// Get all the required files and functions
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');
hesk_load_database_functions();
hesk_dbConnect();
require(HESK_PATH . 'inc/posting_functions.inc.php');
require(HESK_PATH . 'inc/htmLawed.php');
require(HESK_PATH . 'inc/email_functions.inc.php');
require_once(HESK_PATH . 'inc/header.inc.php');
?>
<ol class="breadcrumb">
<li><a href="<?php echo $hesk_settings['site_url']; ?>"><?php echo $hesk_settings['site_title']; ?></a></li>
<li><a href="<?php echo $hesk_settings['hesk_url']; ?>"><?php echo $hesk_settings['hesk_title']; ?></a></li>
<li class="active"><?php echo $hesklang['verify_email']; ?></li>
</ol>
<div class="row">
<div class="col-md-8 col-md-offset-2 col-sm-12">
<h3><?php echo $hesklang['verify_email']; ?></h3>
<div class="footerWithBorder blankSpace"></div>
<?php
$showForm = true;
if (isset($_GET['key']) || isset($_POST['key'])) {
$key = isset($_GET['key'])
? $_GET['key']
: $_POST['key'];
$submittedTickets = array();
$email = '';
$getRs = hesk_dbQuery("SELECT `Email` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "pending_verification_emails`
WHERE `ActivationKey` = '" . hesk_dbEscape($key) . "'");
while ($result = hesk_dbFetchAssoc($getRs)) {
$email = $result['Email'];
$ticketRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`
WHERE `email` = '" . hesk_dbEscape($result['Email']) . "'");
while ($innerResult = hesk_dbFetchAssoc($ticketRs)) {
$ticket = hesk_newTicket($innerResult);
// Notify the customer
$modsForHesk_settings = mfh_getSettings();
hesk_notifyCustomer($modsForHesk_settings);
// Need to notify staff?
// --> From autoassign?
$getOwnerRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE ID = " . intval($ticket['owner']));
$autoassign_owner = hesk_dbFetchAssoc($getOwnerRs);
if ($ticket['owner'] && $autoassign_owner['notify_assigned']) {
hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings);
} // --> No autoassign, find and notify appropriate staff
elseif (!$ticket['owner']) {
hesk_notifyStaff('new_ticket_staff', " `notify_new_unassigned` = '1' ", $modsForHesk_settings);
}
array_push($submittedTickets, $innerResult['trackid']);
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "stage_tickets`
WHERE `id` = " . $innerResult['id']);
}
//Add email address to the verified emails table
hesk_dbQuery('INSERT INTO `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'verified_emails` (`Email`) VALUES (\'' . hesk_dbEscape($email) . '\')');
}
hesk_dbQuery("DELETE FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "pending_verification_emails`
WHERE `ActivationKey` = '" . hesk_dbEscape($key) . "'");
//-- was there an email recorded for the key?
if (!empty($email)) {
$showForm = false;
?>
<div class="alert alert-success">
<p><i class="fa fa-check"></i> <?php echo sprintf($hesklang['email_verified'], $email) ?></p>
<ul>
<?php
foreach ($submittedTickets as $ticket) {
echo '<li><a href="' . $hesk_settings['hesk_url'] . '/ticket.php?track=' . $ticket . '">' . $ticket . '</a></li>';
}
if (count($submittedTickets) == 0) {
echo '<li>' . $hesklang['no_tickets_created'] . '</li>';
}
?>
</ul>
</div>
<?php
} else {
//-- no tickets were activated. invalid key, or was email already activated??
?>
<div class="alert alert-warning">
<p><i class="fa fa-exclamation-triangle"></i> <?php echo $hesklang['verify_no_records']; ?></p>
</div>
<?php
}
}
if ($showForm) {
?>
<form class="form-horizontal" action="verifyemail.php" method="post">
<div class="form-group">
<label for="key"
class="col-sm-3 control-label"><?php echo $hesklang['activation_key']; ?></label>
<div class="col-sm-9">
<input type="text" class="form-control" id="key" name="key"
placeholder="<?php echo htmlspecialchars($hesklang['activation_key']); ?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-9 col-sm-offset-3">
<input type="submit" class="btn btn-default"
value="<?php echo $hesklang['verify_email']; ?>">
</div>
</div>
</form>
<?php
}
?>
</div>
</div>
<?php
require_once(HESK_PATH . 'inc/footer.inc.php');
?>