Project

General

Profile

Download (10.7 KB) Statistics
| Branch: | Tag: | Revision:
1 facd2d76 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_notifications.php
5
	part of pfSense
6
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>
7 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8 facd2d76 Scott Ullrich
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 1d333258 Scott Ullrich
/*
31
	pfSense_MODULE:	system
32
*/
33 facd2d76 Scott Ullrich
34
##|+PRIV
35
##|*IDENT=page-system-advanced-notifications
36 7997ed44 Renato Botelho
##|*NAME=System: Advanced: Notifications page
37
##|*DESCR=Allow access to the 'System: Advanced: Notifications' page.
38
##|*MATCH=system_advanced_notifications.php*
39 facd2d76 Scott Ullrich
##|-PRIV
40
41
require("guiconfig.inc");
42 39163f72 Ermal Lu?i
require_once("notices.inc");
43 facd2d76 Scott Ullrich
44 b19369b7 Scott Ullrich
// Growl
45 48b86f62 jim-p
$pconfig['disable_growl'] = isset($config['notifications']['growl']['disable']);
46 0453eb6e Sjon Hortensius
if($config['notifications']['growl']['password'])
47 66184513 Scott Ullrich
	$pconfig['password'] = $config['notifications']['growl']['password'];
48 0453eb6e Sjon Hortensius
if($config['notifications']['growl']['ipaddress'])
49 66184513 Scott Ullrich
	$pconfig['ipaddress'] = $config['notifications']['growl']['ipaddress'];
50 d9252b1f Scott Ullrich
51 0453eb6e Sjon Hortensius
if($config['notifications']['growl']['notification_name'])
52 addbcae7 Scott Ullrich
	$pconfig['notification_name'] = $config['notifications']['growl']['notification_name'];
53
else
54 ebb57fe2 Warren Baker
  $pconfig['notification_name'] = "{$g['product_name']} growl alert";
55 0453eb6e Sjon Hortensius
56
if($config['notifications']['growl']['name'])
57 addbcae7 Scott Ullrich
	$pconfig['name'] = $config['notifications']['growl']['name'];
58
else
59
  $pconfig['name'] = 'PHP-Growl';
60
61
62 b19369b7 Scott Ullrich
// SMTP
63 48b86f62 jim-p
$pconfig['disable_smtp'] = isset($config['notifications']['smtp']['disable']);
64 d269747b Warren Baker
if ($config['notifications']['smtp']['ipaddress'])
65 4090c90f Scott Ullrich
	$pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress'];
66 d269747b Warren Baker
if ($config['notifications']['smtp']['port'])
67 9277b7ef jim-p
	$pconfig['smtpport'] = $config['notifications']['smtp']['port'];
68 d269747b Warren Baker
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 b19369b7 Scott Ullrich
	$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
74 d269747b Warren Baker
if ($config['notifications']['smtp']['username'])
75 72306d5a Scott Ullrich
	$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
76 d269747b Warren Baker
if ($config['notifications']['smtp']['password'])
77 72306d5a Scott Ullrich
	$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
78 305856e8 Phil Davis
if ($config['notifications']['smtp']['authentication_mechanism'])
79
	$pconfig['smtpauthmech'] = $config['notifications']['smtp']['authentication_mechanism'];
80 d269747b Warren Baker
if ($config['notifications']['smtp']['fromaddress'])
81 72306d5a Scott Ullrich
	$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
82 b19369b7 Scott Ullrich
83 970ca1b7 Yehuda Katz
// System Sounds
84 66a346b4 Erik Fonnesbeck
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
85 970ca1b7 Yehuda Katz
86 facd2d76 Scott Ullrich
if ($_POST) {
87
88
	unset($input_errors);
89
	$pconfig = $_POST;
90
91 0453eb6e Sjon Hortensius
	if (isset($_POST['save'])) {
92 facd2d76 Scott Ullrich
93 b19369b7 Scott Ullrich
		// Growl
94 0453eb6e Sjon Hortensius
		$config['notifications']['growl']['ipaddress'] = $_POST['ip-address'];
95 1afa87e5 Scott Ullrich
		$config['notifications']['growl']['password'] = $_POST['password'];
96 0453eb6e Sjon Hortensius
		$config['notifications']['growl']['name'] = $_POST['registration-name'];
97
		$config['notifications']['growl']['notification_name'] = $_POST['notification-name'];
98 facd2d76 Scott Ullrich
99 0453eb6e Sjon Hortensius
		if($_POST['disable-growl'] == "yes")
100 48b86f62 jim-p
			$config['notifications']['growl']['disable'] = true;
101
		else
102 0453eb6e Sjon Hortensius
			unset($config['notif	ications']['growl']['disable']);
103 48b86f62 jim-p
104 b19369b7 Scott Ullrich
		// SMTP
105 0453eb6e Sjon Hortensius
		$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 d269747b Warren Baker
			$config['notifications']['smtp']['ssl'] = true;
109
		else
110
			unset($config['notifications']['smtp']['ssl']);
111 0453eb6e Sjon Hortensius
		if (isset($_POST['secure-starttls']))
112 d269747b Warren Baker
			$config['notifications']['smtp']['tls'] = true;
113
		else
114
			unset($config['notifications']['smtp']['tls']);
115 b19369b7 Scott Ullrich
116 0453eb6e Sjon Hortensius
		$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 b19369b7 Scott Ullrich
121 0453eb6e Sjon Hortensius
		if($_POST['disable-smtp'] == "yes")
122 48b86f62 jim-p
			$config['notifications']['smtp']['disable'] = true;
123
		else
124
			unset($config['notifications']['smtp']['disable']);
125
126 970ca1b7 Yehuda Katz
		// System Sounds
127 0453eb6e Sjon Hortensius
		if($_POST['startup-shutdown-sound'] == "yes")
128 66a346b4 Erik Fonnesbeck
			$config['system']['disablebeep'] = true;
129 970ca1b7 Yehuda Katz
		else
130 66a346b4 Erik Fonnesbeck
			unset($config['system']['disablebeep']);
131 970ca1b7 Yehuda Katz
132 facd2d76 Scott Ullrich
		write_config();
133 48b86f62 jim-p
		pfSenseHeader("system_advanced_notifications.php");
134
		return;
135 facd2d76 Scott Ullrich
136 48b86f62 jim-p
	}
137 0453eb6e Sjon Hortensius
138
	if (isset($_POST['test-growl'])) {
139 b19369b7 Scott Ullrich
		// Send test message via growl
140 0453eb6e Sjon Hortensius
		if($config['notifications']['growl']['ipaddress'] &&
141 1e940f77 jim-p
			$config['notifications']['growl']['password'] = $_POST['password']) {
142 f670f0a2 Scott Ullrich
			unlink_if_exists($g['vardb_path'] . "/growlnotices_lastmsg.txt");
143 72306d5a Scott Ullrich
			register_via_growl();
144 48b86f62 jim-p
			notify_via_growl(sprintf(gettext("This is a test message from %s.  It is safe to ignore this message."), $g['product_name']), true);
145 72306d5a Scott Ullrich
		}
146 48b86f62 jim-p
	}
147 0453eb6e Sjon Hortensius
148
	if (isset($_POST['test-smtp'])) {
149 b19369b7 Scott Ullrich
		// Send test message via smtp
150 8b0d920e Scott Ullrich
		if(file_exists("/var/db/notices_lastmsg.txt"))
151
			unlink("/var/db/notices_lastmsg.txt");
152 48b86f62 jim-p
		$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 facd2d76 Scott Ullrich
}
155
156 f0d1edc9 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
157 facd2d76 Scott Ullrich
include("head.inc");
158
159 0453eb6e Sjon Hortensius
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 f537d085 Sjon Hortensius
	'disable-growl',
181 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'registration-name',
189 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'notification-name',
197 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'ip-address',
206 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'password',
214 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'test-growl',
221 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'disable-smtp',
232 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'e-mail-server',
241 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'smtp-port-of-e-mail-server',
249 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'enable-ssl-tls',
258 0453eb6e Sjon Hortensius
	'Enable SSL/TLS',
259
	'Enable SMTP over SSL/TLS',
260
	isset($pconfig['smtpssl'])
261
));
262
263
$group->add(new Form_Checkbox(
264 f537d085 Sjon Hortensius
	'secure-starttls',
265 0453eb6e Sjon Hortensius
	'Secure STARTTLS',
266
	'Enable STARTTLS',
267
	isset($pconfig['smtptls'])
268
));
269
270
$section->add($group);
271
272
$section->addInput(new Form_Input(
273 f537d085 Sjon Hortensius
	'from-e-mail-address',
274 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'notification-e-mail-address',
281 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'notification-e-mail-auth-username-optional-',
289 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'notification-e-mail-auth-password',
296 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'test-smtp',
303 0453eb6e Sjon Hortensius
	'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 f537d085 Sjon Hortensius
	'startup-shutdown-sound',
311 0453eb6e Sjon Hortensius
	'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");