forked from rothkj1022/phppickem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_templates.php
105 lines (96 loc) · 3.23 KB
/
email_templates.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
<?php
require('includes/application_top.php');
if (!$user->is_admin) {
header('Location: ./');
exit;
}
$email_template_key = $_POST['email_template_key'];
if ($_POST['action'] == 'Update') {
$sql = "update " . DB_PREFIX . "email_templates ";
$sql .= "set subject = '" . $mysqli->real_escape_string($_POST['subject']) . "', message = '" . $mysqli->real_escape_string($_POST['message']) . "' ";
$sql .= "where email_template_key = '" . $email_template_key . "';";
if ($query = $mysqli->query($sql)) {
header('Location: email_templates.php');
exit;
} else {
die('Error updating email template.');
}
} else if (!empty($email_template_key)) {
$sql = "select * from " . DB_PREFIX . "email_templates where email_template_key = '" . $email_template_key . "'";
$query = $mysqli->query($sql);
if ($row = $query->fetch_assoc()) {
$subject = $row['subject'];
$message = $row['message'];
}
$query->free();
}
include('includes/header.php');
?>
<script language="JavaScript" type="text/javascript" src="js/cbrte/html2xhtml.js"></script>
<script language="JavaScript" type="text/javascript" src="js/cbrte/richtext_compressed.js"></script>
<script language="JavaScript" type="text/javascript">
function submitForm() {
//make sure hidden and iframe values are in sync for all rtes before submitting form
updateRTEs();
return true;
}
//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML, encHTML)
initRTE("js/cbrte/images/", "js/cbrte/", "", true);
</script>
<div class="row">
<div class="col-md-9 col-xs-12">
<h1>Email Templates</h1>
<form name="emailtemplate" action="email_templates.php" method="post" onsubmit="return submitForm();">
<p><b>Select Email Template:</b><br />
<select name="email_template_key">
<option value=""></option>
<?php
$sql = "select * from " . DB_PREFIX . "email_templates";
$query = $mysqli->query($sql);
if ($query->num_rows > 0) {
while ($row = $query->fetch_assoc()) {
echo '<option value="' . $row['email_template_key'] . '"' . (($email_template_key == $row['email_template_key']) ? ' selected="selected"' : '') . '>' . $row['email_template_title'] . '</option>' . "\n";
}
}
$query->free;
?>
</select> <input type="submit" value="Select" /></p>
<p><b>Subject:</b><br />
<input type="text" name="subject" value="<?php echo $subject; ?>" size="40"></p>
<p><b>Message:</b><br />
<script language="JavaScript" type="text/javascript">
//build new richTextEditor
var message = new richTextEditor('message');
<?php
//format content for preloading
if (!empty($message)) {
$message = rteSafe($message);
}
?>
message.html = '<?php echo $message; ?>';
//rte1.toggleSrc = false;
message.build();
</script>
</p>
<p><input name="action" type="submit" value="Update"<?php echo ((empty($email_template_key)) ? 'disabled="disabled"' : ''); ?> class="btn btn-primary" /></p>
</form>
</div>
<div class="col-md-3">Available Variables:<br />
<ul>
<li>{week}</li>
<li>{player}</li>
<li>{first_game}</li>
<li>{site_url}</li>
<li>{rules_url}</li>
<li>{winners}</li>
<li>{previousWeek}</li>
<li>{winningScore}</li>
<li>{possibleScore}</li>
<li>{currentLeaders}</li>
<li>{bestPickRatios}</li>
</ul>
</div>
</div>
<?php
include('includes/footer.php');
?>