-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreply.php
120 lines (104 loc) · 4.36 KB
/
reply.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
<?php
/**
* Message reply, detail of message.
*
* @author Adam Studenic
*
*/
require_once 'header.php';
$rowString = "";
$sent = "";
$from="";
$to = "";
$subject = "";
$domain="";
$id = 0;
if(isset($_GET["sent"])) {
$sent = $_GET["sent"];
}
if (isset($_GET["id"])) {
$id = $_GET["id"];
$row = getMessageById($id);
$form = getFormById($row["form_id"]);
markMessageAsRead((int) $id);
$rowString = "\n\n------------------------------------------------------------------------------\n";
$informMessage = "Customer Message from: ";
if ($row["replied"]) {
$informMessage = "Administrator reply from: ";
}
$rowString .= $informMessage . date("d.m.Y H:i:s", strtotime($row["date_create"])) . "\n\n";
$rowString .= formatMessage($row);
$domain = $row["domain"];
$from = $form["send-to"];
$to = "";
$matches = array();
$pattern = '/[a-z\d._%+-]+@[a-z\d.-]+\.[a-z]{2,4}\b/i';
preg_match_all($pattern, $formatedMessage, $matches);
$i = 0;
foreach ($matches[0] as $match) {
if ($i) {
$to .= ", ";
}
$to .= $match;
$i++;
}
$subject = "Reply to query no. " . $row["id"] . " from " . $domain;
}
if ($sent == "success") {
echo '<div class="alert alert-success">Well done! The message has been successfully sent.</div>';
} else if ($sent == "danger") {
echo '<div class="alert alert-danger">Oh snap! There was an error while sending this message.</div>';
}
?>
<div class="page-header mt0">
<h1><?php if($_GET){ echo "Reply to customer <small>Your reply will be saved</small>"; } else { echo "Send an email <small>Your email message will not be saved</small>"; } ?>
</h1>
</div>
<?php if($_GET){ echo '<a href="/mails.php"><button id="goBack" class="mb20 btn btn-primary " type="button">Back to Query List</button></a>'; } ?>
<div class="well well-new">
<form id="replyForm" class="form-horizontal" name="reply-form" role="form" action="reply-submit.php" method="post">
<div id="email">
<div class="row well well-new-2">
<div class="col-sm-6 no-pl">
<label for="fromInput">From</label>
<input name="from" type="email" multiple class="form-control input-new" id="fromInput" placeholder="From" required value="<?php echo $from; ?>">
</div>
<div class="col-sm-6 no-pl">
<label for="toInput">To</label>
<input name="to" type="email" multiple class="form-control input-new" id="toInput" placeholder="[email protected]" value="<?php echo $to; ?>" required>
</div>
<div class="col-sm-6 no-pl">
<label for="toCcInput">Send copy to (Cc)</label>
<input name="cc" type="email" multiple class="form-control input-new" id="toCcInput" placeholder="[email protected]">
</div>
<div class="col-sm-6 no-pl">
<label for="tobccInput">Send copy to (Bcc)</label>
<input name="bcc" type="email" multiple class="form-control input-new" id="toBccInput" placeholder="[email protected]">
</div>
</div>
<div class="row well well-new-2">
<div class="col-md-12 no-pl">
<label for="subject">Subject</label>
<input name="subject" type="text" class="form-control input-new" id="subject" placeholder="Subject" required value="<?php echo $subject ?>">
</div>
<div class="col-md-12 no-pl">
<label for="message">Message</label>
<textarea id="message" name="message" class="form-control" rows="10"><?php echo $rowString; ?></textarea>
</div>
</div>
<input name="messageId" type="hidden" value="<?php echo $id; ?>" />
</div>
<br>
<div class="separator mt15"/></div>
<div class=" center add mt15">
<div class=" col-md-12 no-pl">
<input id="send" name="send" type="submit" class="btn btn-success" value="Send message">
<input id="delete" name="delete" type="submit" class="btn btn-success hide" value="delete">
<button class="btn btn-danger" data-toggle="modal" data-target="#deleteConfirmation">Delete</button>
</div>
</div>
</form>
</div> <!-- /container -->
<?php
require_once 'footer.php';
?>