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