1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
system_advanced_notifications.php
|
5
|
part of pfSense
|
6
|
Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
/*
|
30
|
pfSense_MODULE: system
|
31
|
*/
|
32
|
|
33
|
##|+PRIV
|
34
|
##|*IDENT=page-system-advanced-notifications
|
35
|
##|*NAME=System: Advanced: Notifications page
|
36
|
##|*DESCR=Allow access to the 'System: Advanced: Notifications' page.
|
37
|
##|*MATCH=system_advanced_notifications.php*
|
38
|
##|-PRIV
|
39
|
|
40
|
require("guiconfig.inc");
|
41
|
require_once("notices.inc");
|
42
|
|
43
|
// Growl
|
44
|
$pconfig['disable_growl'] = isset($config['notifications']['growl']['disable']);
|
45
|
if($config['notifications']['growl']['password'])
|
46
|
$pconfig['password'] = $config['notifications']['growl']['password'];
|
47
|
if($config['notifications']['growl']['ipaddress'])
|
48
|
$pconfig['ipaddress'] = $config['notifications']['growl']['ipaddress'];
|
49
|
|
50
|
if($config['notifications']['growl']['notification_name'])
|
51
|
$pconfig['notification_name'] = $config['notifications']['growl']['notification_name'];
|
52
|
else
|
53
|
$pconfig['notification_name'] = "{$g['product_name']} growl alert";
|
54
|
|
55
|
if($config['notifications']['growl']['name'])
|
56
|
$pconfig['name'] = $config['notifications']['growl']['name'];
|
57
|
else
|
58
|
$pconfig['name'] = 'PHP-Growl';
|
59
|
|
60
|
|
61
|
// SMTP
|
62
|
$pconfig['disable_smtp'] = isset($config['notifications']['smtp']['disable']);
|
63
|
if ($config['notifications']['smtp']['ipaddress'])
|
64
|
$pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress'];
|
65
|
if ($config['notifications']['smtp']['port'])
|
66
|
$pconfig['smtpport'] = $config['notifications']['smtp']['port'];
|
67
|
if (isset($config['notifications']['smtp']['ssl']))
|
68
|
$pconfig['smtpssl'] = true;
|
69
|
if (isset($config['notifications']['smtp']['tls']))
|
70
|
$pconfig['smtptls'] = true;
|
71
|
if ($config['notifications']['smtp']['notifyemailaddress'])
|
72
|
$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
|
73
|
if ($config['notifications']['smtp']['username'])
|
74
|
$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
|
75
|
if ($config['notifications']['smtp']['password'])
|
76
|
$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
|
77
|
if ($config['notifications']['smtp']['fromaddress'])
|
78
|
$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
|
79
|
|
80
|
// System Sounds
|
81
|
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
|
82
|
|
83
|
if ($_POST) {
|
84
|
|
85
|
unset($input_errors);
|
86
|
$pconfig = $_POST;
|
87
|
|
88
|
/* if this is an AJAX caller then handle via JSON */
|
89
|
if (isAjax() && is_array($input_errors)) {
|
90
|
input_errors2Ajax($input_errors);
|
91
|
exit;
|
92
|
}
|
93
|
|
94
|
if ($_POST['apply']) {
|
95
|
$retval = 0;
|
96
|
system_setup_sysctl();
|
97
|
$savemsg = get_std_save_message($retval);
|
98
|
}
|
99
|
|
100
|
if ($_POST['Submit'] == gettext("Save")) {
|
101
|
$tunableent = array();
|
102
|
|
103
|
// Growl
|
104
|
$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
|
105
|
$config['notifications']['growl']['password'] = $_POST['password'];
|
106
|
$config['notifications']['growl']['name'] = $_POST['name'];
|
107
|
$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
|
108
|
|
109
|
if($_POST['disable_growl'] == "yes")
|
110
|
$config['notifications']['growl']['disable'] = true;
|
111
|
else
|
112
|
unset($config['notifications']['growl']['disable']);
|
113
|
|
114
|
// SMTP
|
115
|
$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
|
116
|
$config['notifications']['smtp']['port'] = $_POST['smtpport'];
|
117
|
if (isset($_POST['smtpssl']))
|
118
|
$config['notifications']['smtp']['ssl'] = true;
|
119
|
else
|
120
|
unset($config['notifications']['smtp']['ssl']);
|
121
|
if (isset($_POST['smtptls']))
|
122
|
$config['notifications']['smtp']['tls'] = true;
|
123
|
else
|
124
|
unset($config['notifications']['smtp']['tls']);
|
125
|
$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
|
126
|
$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
|
127
|
$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
|
128
|
$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
|
129
|
|
130
|
if($_POST['disable_smtp'] == "yes")
|
131
|
$config['notifications']['smtp']['disable'] = true;
|
132
|
else
|
133
|
unset($config['notifications']['smtp']['disable']);
|
134
|
|
135
|
// System Sounds
|
136
|
if($_POST['disablebeep'] == "yes")
|
137
|
$config['system']['disablebeep'] = true;
|
138
|
else
|
139
|
unset($config['system']['disablebeep']);
|
140
|
|
141
|
write_config();
|
142
|
pfSenseHeader("system_advanced_notifications.php");
|
143
|
return;
|
144
|
|
145
|
}
|
146
|
if ($_POST['test_growl'] == gettext("Test Growl")) {
|
147
|
// Send test message via growl
|
148
|
if($config['notifications']['growl']['ipaddress'] &&
|
149
|
$config['notifications']['growl']['password'] = $_POST['password']) {
|
150
|
unlink_if_exists($g['vardb_path'] . "/growlnotices_lastmsg.txt");
|
151
|
register_via_growl();
|
152
|
notify_via_growl(sprintf(gettext("This is a test message from %s. It is safe to ignore this message."), $g['product_name']), true);
|
153
|
}
|
154
|
}
|
155
|
if ($_POST['test_smtp'] == gettext("Test SMTP")) {
|
156
|
// Send test message via smtp
|
157
|
if(file_exists("/var/db/notices_lastmsg.txt"))
|
158
|
unlink("/var/db/notices_lastmsg.txt");
|
159
|
$savemsg = notify_via_smtp(sprintf(gettext("This is a test message from %s. It is safe to ignore this message."), $g['product_name']), true);
|
160
|
}
|
161
|
}
|
162
|
|
163
|
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
|
164
|
include("head.inc");
|
165
|
|
166
|
?>
|
167
|
|
168
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
169
|
<?php include("fbegin.inc"); ?>
|
170
|
<form action="system_advanced_notifications.php" method="post">
|
171
|
<?php
|
172
|
if ($input_errors)
|
173
|
print_input_errors($input_errors);
|
174
|
if ($savemsg)
|
175
|
print_info_box($savemsg);
|
176
|
?>
|
177
|
</form>
|
178
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced notifications">
|
179
|
<tr>
|
180
|
<td>
|
181
|
<?php
|
182
|
$tab_array = array();
|
183
|
$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
|
184
|
$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
|
185
|
$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
|
186
|
$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
|
187
|
$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
|
188
|
$tab_array[] = array(gettext("Notifications"), true, "system_advanced_notifications.php");
|
189
|
display_top_tabs($tab_array);
|
190
|
?>
|
191
|
</td>
|
192
|
</tr>
|
193
|
<tr>
|
194
|
<td id="mainarea">
|
195
|
<div class="tabcont">
|
196
|
<form action="system_advanced_notifications.php" method="post" name="iform">
|
197
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
|
198
|
<!-- GROWL -->
|
199
|
<tr>
|
200
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Growl"); ?></td>
|
201
|
</tr>
|
202
|
<tr>
|
203
|
<td width="22%" valign="top" class="vncell"><?=gettext("Disable Growl Notifications"); ?></td>
|
204
|
<td width="78%" class="vtable">
|
205
|
<input type='checkbox' name='disable_growl' value="yes" <?php if ($pconfig['disable_growl']) {?>checked="checked"<?php } ?> /><br />
|
206
|
<?=gettext("Check this option to disable growl notifications but preserve the settings below."); ?>
|
207
|
</td>
|
208
|
</tr>
|
209
|
<tr>
|
210
|
<td width="22%" valign="top" class="vncell"><?=gettext("Registration Name"); ?></td>
|
211
|
<td width="78%" class="vtable">
|
212
|
<input name='name' value='<?php echo htmlspecialchars($pconfig['name']); ?>' /><br />
|
213
|
<?=gettext("Enter the name to register with the Growl server (default: PHP-Growl)."); ?>
|
214
|
</td>
|
215
|
</tr>
|
216
|
<tr>
|
217
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification Name"); ?></td>
|
218
|
<td width="78%" class="vtable">
|
219
|
<input name='notification_name' value='<?php echo htmlspecialchars($pconfig['notification_name']); ?>' /><br />
|
220
|
<?=sprintf(gettext("Enter a name for the Growl notifications (default: %s growl alert)."), $g['product_name']); ?>
|
221
|
</td>
|
222
|
</tr>
|
223
|
<tr>
|
224
|
<td width="22%" valign="top" class="vncell"><?=gettext("IP Address"); ?></td>
|
225
|
<td width="78%" class="vtable">
|
226
|
<input name='ipaddress' value='<?php echo htmlspecialchars($pconfig['ipaddress']); ?>' /><br />
|
227
|
<?=gettext("This is the IP address that you would like to send growl notifications to."); ?>
|
228
|
</td>
|
229
|
</tr>
|
230
|
<tr>
|
231
|
<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
|
232
|
<td width="78%" class="vtable">
|
233
|
<input name='password' type='password' value='<?php echo htmlspecialchars($pconfig['password']); ?>' /><br />
|
234
|
<?=gettext("Enter the password of the remote growl notification device."); ?>
|
235
|
</td>
|
236
|
</tr>
|
237
|
<tr>
|
238
|
<td valign="top" class="">
|
239
|
|
240
|
</td>
|
241
|
<td>
|
242
|
<input type='submit' id='test_growl' name='test_growl' value='<?=gettext("Test Growl"); ?>' />
|
243
|
<br /><?= gettext("NOTE: A test notification will be sent even if the service is marked as disabled.") ?>
|
244
|
</td>
|
245
|
</tr>
|
246
|
<tr>
|
247
|
<td colspan="2" class="list" height="12"> </td>
|
248
|
</tr>
|
249
|
<!-- SMTP -->
|
250
|
<tr>
|
251
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("SMTP E-Mail"); ?></td>
|
252
|
</tr>
|
253
|
<tr>
|
254
|
<td width="22%" valign="top" class="vncell"><?=gettext("Disable SMTP Notifications"); ?></td>
|
255
|
<td width="78%" class="vtable">
|
256
|
<input type='checkbox' name='disable_smtp' value="yes" <?php if ($pconfig['disable_smtp']) {?>checked="checked"<?php } ?> /><br />
|
257
|
<?=gettext("Check this option to disable SMTP notifications but preserve the settings below. Some other mechanisms, such as packages, may need these settings in place to function."); ?>
|
258
|
</td>
|
259
|
</tr>
|
260
|
<tr>
|
261
|
<td width="22%" valign="top" class="vncell"><?=gettext("E-Mail server"); ?></td>
|
262
|
<td width="78%" class="vtable">
|
263
|
<input name='smtpipaddress' value='<?php echo htmlspecialchars($pconfig['smtpipaddress']); ?>' /><br />
|
264
|
<?=gettext("This is the FQDN or IP address of the SMTP E-Mail server to which notifications will be sent."); ?>
|
265
|
</td>
|
266
|
</tr>
|
267
|
<tr>
|
268
|
<td width="22%" valign="top" class="vncell"><?=gettext("SMTP Port of E-Mail server"); ?></td>
|
269
|
<td width="78%" class="vtable">
|
270
|
<input name='smtpport' value='<?php echo htmlspecialchars($pconfig['smtpport']); ?>' /><br />
|
271
|
<?=gettext("This is the port of the SMTP E-Mail server, typically 25, 587 (submission) or 465 (smtps)"); ?>
|
272
|
</td>
|
273
|
</tr>
|
274
|
<tr>
|
275
|
<td width="22%" valign="top" class="vncell"><?=gettext("Secure SMTP Connection"); ?></td>
|
276
|
<td width="78%" class="vtable">
|
277
|
<input type='checkbox' id='smtpssl' name='smtpssl' <?php if (isset($pconfig['smtpssl'])) echo "checked=\"checked\""; ?> />Enable SMTP over SSL/TLS<br />
|
278
|
<input type='checkbox' id='smtptls' name='smtptls' <?php if (isset($pconfig['smtptls'])) echo "checked=\"checked\""; ?> />Enable STARTTLS<br />
|
279
|
</td>
|
280
|
</tr>
|
281
|
<tr>
|
282
|
<td width="22%" valign="top" class="vncell"><?=gettext("From e-mail address"); ?></td>
|
283
|
<td width="78%" class="vtable">
|
284
|
<input name='smtpfromaddress' type='text' value='<?php echo htmlspecialchars($pconfig['smtpfromaddress']); ?>' /><br />
|
285
|
<?=gettext("This is the e-mail address that will appear in the from field."); ?>
|
286
|
</td>
|
287
|
</tr>
|
288
|
<tr>
|
289
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail address"); ?></td>
|
290
|
<td width="78%" class="vtable">
|
291
|
<input name='smtpnotifyemailaddress' type='text' value='<?php echo htmlspecialchars($pconfig['smtpnotifyemailaddress']); ?>' /><br />
|
292
|
<?=gettext("Enter the e-mail address that you would like email notifications sent to."); ?>
|
293
|
</td>
|
294
|
</tr>
|
295
|
<tr>
|
296
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth username (optional)"); ?></td>
|
297
|
<td width="78%" class="vtable">
|
298
|
<input name='smtpusername' type='text' value='<?php echo htmlspecialchars($pconfig['smtpusername']); ?>' /><br />
|
299
|
<?=gettext("Enter the e-mail address username for SMTP authentication."); ?>
|
300
|
</td>
|
301
|
</tr>
|
302
|
<tr>
|
303
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth password"); ?></td>
|
304
|
<td width="78%" class="vtable">
|
305
|
<input name='smtppassword' type='password' value='<?php echo htmlspecialchars($pconfig['smtppassword']); ?>' /><br />
|
306
|
<?=gettext("Enter the e-mail address password for SMTP authentication."); ?>
|
307
|
</td>
|
308
|
</tr>
|
309
|
<tr>
|
310
|
<td valign="top" class="">
|
311
|
|
312
|
</td>
|
313
|
<td>
|
314
|
<input type='submit' id='test_smtp' name='test_smtp' value='<?=gettext("Test SMTP"); ?>' />
|
315
|
<br /><?= gettext("NOTE: A test message will be sent even if the service is marked as disabled.") ?>
|
316
|
</td>
|
317
|
</tr>
|
318
|
<tr>
|
319
|
<td colspan="2" class="list" height="12"> </td>
|
320
|
</tr>
|
321
|
<!-- System Sounds -->
|
322
|
<tr>
|
323
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("System Sounds"); ?></td>
|
324
|
</tr>
|
325
|
<tr>
|
326
|
<td width="22%" valign="top" class="vncell"><?=gettext("Startup/Shutdown Sound"); ?></td>
|
327
|
<td width="78%" class="vtable">
|
328
|
<input name="disablebeep" type="checkbox" id="disablebeep" value="yes" <?php if ($pconfig['disablebeep']) echo "checked=\"checked\""; ?> />
|
329
|
<strong><?=gettext("Disable the startup/shutdown beep"); ?></strong>
|
330
|
<br />
|
331
|
<span class="vexpl"><?=gettext("When this is checked, startup and shutdown sounds will no longer play."); ?></span>
|
332
|
</td>
|
333
|
</tr>
|
334
|
<tr>
|
335
|
<td colspan="2" class="list" height="12"> </td>
|
336
|
</tr>
|
337
|
<tr>
|
338
|
<td valign="top" class="">
|
339
|
|
340
|
</td>
|
341
|
<td>
|
342
|
<input type='submit' id='Submit' name='Submit' value='<?=gettext("Save"); ?>' />
|
343
|
</td>
|
344
|
</tr>
|
345
|
</table>
|
346
|
</form>
|
347
|
</div>
|
348
|
</td>
|
349
|
</tr>
|
350
|
</table>
|
351
|
<script type="text/javascript">
|
352
|
//<![CDATA[
|
353
|
jQuery(document).ready(function() {
|
354
|
if (jQuery('#smtpssl').is(':checked')) {
|
355
|
jQuery('#smtptls').prop('disabled', true);
|
356
|
} else if (jQuery('#smtptls').is(':checked')) {
|
357
|
jQuery('#smtpssl').prop('disabled', true);
|
358
|
}
|
359
|
});
|
360
|
jQuery('#smtpssl').change( function() {
|
361
|
jQuery('#smtptls').prop('disabled', this.checked);
|
362
|
});
|
363
|
jQuery('#smtptls').change( function() {
|
364
|
jQuery('#smtpssl').prop('disabled', this.checked);
|
365
|
});
|
366
|
//]]>
|
367
|
</script>
|
368
|
<?php include("fend.inc"); ?>
|
369
|
</body>
|
370
|
</html>
|