Project

General

Profile

Download (15.2 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 29aef6c4 Jim Thompson
        Copyright (C) 2013-2014 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 66184513 Scott Ullrich
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 d9252b1f Scott Ullrich
51 addbcae7 Scott Ullrich
if($config['notifications']['growl']['notification_name']) 
52
	$pconfig['notification_name'] = $config['notifications']['growl']['notification_name'];
53
else
54 ebb57fe2 Warren Baker
  $pconfig['notification_name'] = "{$g['product_name']} growl alert";
55 addbcae7 Scott Ullrich
  
56
if($config['notifications']['growl']['name']) 
57
	$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 d269747b Warren Baker
if ($config['notifications']['smtp']['fromaddress'])
79 72306d5a Scott Ullrich
	$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
80 b19369b7 Scott Ullrich
81 970ca1b7 Yehuda Katz
// System Sounds
82 66a346b4 Erik Fonnesbeck
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
83 970ca1b7 Yehuda Katz
84 facd2d76 Scott Ullrich
if ($_POST) {
85
86
	unset($input_errors);
87
	$pconfig = $_POST;
88
89
	/* if this is an AJAX caller then handle via JSON */
90
	if (isAjax() && is_array($input_errors)) {
91
		input_errors2Ajax($input_errors);
92
		exit;
93
	}
94
95
	if ($_POST['apply']) {
96
		$retval = 0;
97
		system_setup_sysctl();		
98
		$savemsg = get_std_save_message($retval);
99
	}
100
101 f0d1edc9 Carlos Eduardo Ramos
	if ($_POST['Submit'] == gettext("Save")) {
102 facd2d76 Scott Ullrich
		$tunableent = array();
103
104 b19369b7 Scott Ullrich
		// Growl
105 1afa87e5 Scott Ullrich
		$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
106
		$config['notifications']['growl']['password'] = $_POST['password'];
107 addbcae7 Scott Ullrich
		$config['notifications']['growl']['name'] = $_POST['name'];
108
		$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
109 facd2d76 Scott Ullrich
110 48b86f62 jim-p
		if($_POST['disable_growl'] == "yes")
111
			$config['notifications']['growl']['disable'] = true;
112
		else
113
			unset($config['notifications']['growl']['disable']);
114
115 b19369b7 Scott Ullrich
		// SMTP
116
		$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
117 9277b7ef jim-p
		$config['notifications']['smtp']['port'] = $_POST['smtpport'];
118 d269747b Warren Baker
		if (isset($_POST['smtpssl']))
119
			$config['notifications']['smtp']['ssl'] = true;
120
		else
121
			unset($config['notifications']['smtp']['ssl']);
122
		if (isset($_POST['smtptls']))
123
			$config['notifications']['smtp']['tls'] = true;
124
		else
125
			unset($config['notifications']['smtp']['tls']);
126 b19369b7 Scott Ullrich
		$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
127 72306d5a Scott Ullrich
		$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
128
		$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
129
		$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
130 b19369b7 Scott Ullrich
131 48b86f62 jim-p
		if($_POST['disable_smtp'] == "yes")
132
			$config['notifications']['smtp']['disable'] = true;
133
		else
134
			unset($config['notifications']['smtp']['disable']);
135
136 970ca1b7 Yehuda Katz
		// System Sounds
137
		if($_POST['disablebeep'] == "yes")
138 66a346b4 Erik Fonnesbeck
			$config['system']['disablebeep'] = true;
139 970ca1b7 Yehuda Katz
		else
140 66a346b4 Erik Fonnesbeck
			unset($config['system']['disablebeep']);
141 970ca1b7 Yehuda Katz
142 facd2d76 Scott Ullrich
		write_config();
143 48b86f62 jim-p
		pfSenseHeader("system_advanced_notifications.php");
144
		return;
145 facd2d76 Scott Ullrich
146 48b86f62 jim-p
	}
147
	if ($_POST['test_growl'] == gettext("Test Growl")) {
148 b19369b7 Scott Ullrich
		// Send test message via growl
149 72306d5a Scott Ullrich
		if($config['notifications']['growl']['ipaddress'] && 
150 1e940f77 jim-p
			$config['notifications']['growl']['password'] = $_POST['password']) {
151 f670f0a2 Scott Ullrich
			unlink_if_exists($g['vardb_path'] . "/growlnotices_lastmsg.txt");
152 72306d5a Scott Ullrich
			register_via_growl();
153 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);
154 72306d5a Scott Ullrich
		}
155 48b86f62 jim-p
	}
156
	if ($_POST['test_smtp'] == gettext("Test SMTP")) {
157 b19369b7 Scott Ullrich
		// Send test message via smtp
158 8b0d920e Scott Ullrich
		if(file_exists("/var/db/notices_lastmsg.txt"))
159
			unlink("/var/db/notices_lastmsg.txt");
160 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);
161
	}
162 facd2d76 Scott Ullrich
}
163
164 f0d1edc9 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
165 facd2d76 Scott Ullrich
include("head.inc");
166
167
?>
168
169
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
170
<?php include("fbegin.inc"); ?>
171
	<form action="system_advanced_notifications.php" method="post">
172
		<?php
173
			if ($input_errors)
174
				print_input_errors($input_errors);
175
			if ($savemsg)
176
				print_info_box($savemsg);
177
		?>
178
	</form>
179 846ac60f Colin Fleming
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced notifications">
180 facd2d76 Scott Ullrich
		<tr>
181
			<td>
182
				<?php
183
					$tab_array = array();
184 f0d1edc9 Carlos Eduardo Ramos
					$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
185
					$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
186
					$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
187
					$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
188
					$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
189
					$tab_array[] = array(gettext("Notifications"), true, "system_advanced_notifications.php");
190 facd2d76 Scott Ullrich
					display_top_tabs($tab_array);
191
				?>
192
			</td>
193
		</tr>
194
		<tr>
195
			<td id="mainarea">
196
				<div class="tabcont">
197
					<form action="system_advanced_notifications.php" method="post" name="iform">
198 846ac60f Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
199 b19369b7 Scott Ullrich
						<!-- GROWL -->
200 facd2d76 Scott Ullrich
						<tr>
201 f0d1edc9 Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Growl"); ?></td>
202 facd2d76 Scott Ullrich
						</tr>
203 48b86f62 jim-p
						<tr>
204
							<td width="22%" valign="top" class="vncell"><?=gettext("Disable Growl Notifications"); ?></td>
205
							<td width="78%" class="vtable">
206 8cd558b6 ayvis
								<input type='checkbox' name='disable_growl' value="yes" <?php if ($pconfig['disable_growl']) {?>checked="checked"<?php } ?> /><br />
207 48b86f62 jim-p
								<?=gettext("Check this option to disable growl notifications but preserve the settings below."); ?>
208
							</td>
209
						</tr>
210 addbcae7 Scott Ullrich
						<tr>
211 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Registration Name"); ?></td>
212 addbcae7 Scott Ullrich
							<td width="78%" class="vtable">
213 c25d1fd7 jim-p
								<input name='name' value='<?php echo htmlspecialchars($pconfig['name']); ?>' /><br />
214 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the name to register with the Growl server (default: PHP-Growl)."); ?>
215 addbcae7 Scott Ullrich
							</td>
216
						</tr>
217
  					<tr>
218 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification Name"); ?></td>
219 addbcae7 Scott Ullrich
							<td width="78%" class="vtable">
220 c25d1fd7 jim-p
								<input name='notification_name' value='<?php echo htmlspecialchars($pconfig['notification_name']); ?>' /><br />
221 6840d0e7 Erik Fonnesbeck
								<?=sprintf(gettext("Enter a name for the Growl notifications (default: %s growl alert)."), $g['product_name']); ?>
222 addbcae7 Scott Ullrich
							</td>
223
						</tr>
224 facd2d76 Scott Ullrich
						<tr>
225 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("IP Address"); ?></td>
226 facd2d76 Scott Ullrich
							<td width="78%" class="vtable">
227 c25d1fd7 jim-p
								<input name='ipaddress' value='<?php echo htmlspecialchars($pconfig['ipaddress']); ?>' /><br />
228 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("This is the IP address that you would like to send growl notifications to."); ?>
229 facd2d76 Scott Ullrich
							</td>
230
						</tr>
231
						<tr>
232 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
233 facd2d76 Scott Ullrich
							<td width="78%" class="vtable">
234 c25d1fd7 jim-p
								<input name='password' type='password' value='<?php echo htmlspecialchars($pconfig['password']); ?>' /><br />
235 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the password of the remote growl notification device."); ?>
236 facd2d76 Scott Ullrich
							</td>
237
						</tr>
238 48b86f62 jim-p
						<tr>
239
							<td valign="top" class="">
240
								&nbsp;
241
							</td>
242
							<td>
243
								<input type='submit' id='test_growl' name='test_growl' value='<?=gettext("Test Growl"); ?>' />
244
								<br /><?= gettext("NOTE: A test notification will be sent even if the service is marked as disabled.") ?>
245
							</td>
246
						</tr>
247 7d8c8a28 Scott Ullrich
						<tr>
248
							<td colspan="2" class="list" height="12">&nbsp;</td>
249
						</tr>	
250 b19369b7 Scott Ullrich
						<!-- SMTP -->
251
						<tr>
252 f0d1edc9 Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("SMTP E-Mail"); ?></td>
253 b19369b7 Scott Ullrich
						</tr>
254 48b86f62 jim-p
						<tr>
255
							<td width="22%" valign="top" class="vncell"><?=gettext("Disable SMTP Notifications"); ?></td>
256
							<td width="78%" class="vtable">
257 8cd558b6 ayvis
								<input type='checkbox' name='disable_smtp' value="yes" <?php if ($pconfig['disable_smtp']) {?>checked="checked"<?php } ?> /><br />
258 48b86f62 jim-p
								<?=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."); ?>
259
							</td>
260
						</tr>
261 b19369b7 Scott Ullrich
						<tr>
262 d58b93d2 jim-p
							<td width="22%" valign="top" class="vncell"><?=gettext("E-Mail server"); ?></td>
263 b19369b7 Scott Ullrich
							<td width="78%" class="vtable">
264 c25d1fd7 jim-p
								<input name='smtpipaddress' value='<?php echo htmlspecialchars($pconfig['smtpipaddress']); ?>' /><br />
265 d58b93d2 jim-p
								<?=gettext("This is the FQDN or IP address of the SMTP E-Mail server to which notifications will be sent."); ?>
266 b19369b7 Scott Ullrich
							</td>
267
						</tr>
268 9277b7ef jim-p
						<tr>
269
							<td width="22%" valign="top" class="vncell"><?=gettext("SMTP Port of E-Mail server"); ?></td>
270
							<td width="78%" class="vtable">
271 c25d1fd7 jim-p
								<input name='smtpport' value='<?php echo htmlspecialchars($pconfig['smtpport']); ?>' /><br />
272 1cddd59c Warren Baker
								<?=gettext("This is the port of the SMTP E-Mail server, typically 25, 587 (submission) or 465 (smtps)"); ?>
273
							</td>
274
						</tr>
275
						<tr>
276
							<td width="22%" valign="top" class="vncell"><?=gettext("Secure SMTP Connection"); ?></td>
277
							<td width="78%" class="vtable">
278 d269747b Warren Baker
								<input type='checkbox' id='smtpssl' name='smtpssl' <?php if (isset($pconfig['smtpssl'])) echo "checked=\"checked\""; ?> />Enable SMTP over SSL/TLS<br />
279
								<input type='checkbox' id='smtptls' name='smtptls' <?php if (isset($pconfig['smtptls'])) echo "checked=\"checked\""; ?> />Enable STARTTLS<br />
280 9277b7ef jim-p
							</td>
281
						</tr>
282 72306d5a Scott Ullrich
						<tr>
283 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("From e-mail address"); ?></td>
284 72306d5a Scott Ullrich
							<td width="78%" class="vtable">
285 c25d1fd7 jim-p
								<input name='smtpfromaddress' type='text' value='<?php echo htmlspecialchars($pconfig['smtpfromaddress']); ?>' /><br />
286 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("This is the e-mail address that will appear in the from field."); ?>
287 72306d5a Scott Ullrich
							</td>
288
						</tr>
289 b19369b7 Scott Ullrich
						<tr>
290 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail address"); ?></td>
291 b19369b7 Scott Ullrich
							<td width="78%" class="vtable">
292 c25d1fd7 jim-p
								<input name='smtpnotifyemailaddress' type='text' value='<?php echo htmlspecialchars($pconfig['smtpnotifyemailaddress']); ?>' /><br />
293 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the e-mail address that you would like email notifications sent to."); ?>
294 b19369b7 Scott Ullrich
							</td>
295
						</tr>
296 72306d5a Scott Ullrich
						<tr>
297 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth username (optional)"); ?></td>
298 72306d5a Scott Ullrich
							<td width="78%" class="vtable">
299 c25d1fd7 jim-p
								<input name='smtpusername' type='text' value='<?php echo htmlspecialchars($pconfig['smtpusername']); ?>' /><br />
300 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the e-mail address username for SMTP authentication."); ?>
301 72306d5a Scott Ullrich
							</td>
302
						</tr>
303
						<tr>
304 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth password"); ?></td>
305 72306d5a Scott Ullrich
							<td width="78%" class="vtable">
306 c25d1fd7 jim-p
								<input name='smtppassword' type='password' value='<?php echo htmlspecialchars($pconfig['smtppassword']); ?>' /><br />
307 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the e-mail address password for SMTP authentication."); ?>
308 72306d5a Scott Ullrich
							</td>
309
						</tr>
310 48b86f62 jim-p
						<tr>
311
							<td valign="top" class="">
312
								&nbsp;
313
							</td>
314
							<td>
315
								<input type='submit' id='test_smtp' name='test_smtp' value='<?=gettext("Test SMTP"); ?>' />
316
								<br /><?= gettext("NOTE: A test message will be sent even if the service is marked as disabled.") ?>
317
							</td>
318
						</tr>
319 66a346b4 Erik Fonnesbeck
						<tr>
320
							<td colspan="2" class="list" height="12">&nbsp;</td>
321
						</tr>	
322 970ca1b7 Yehuda Katz
						<!-- System Sounds -->
323
						<tr>
324
							<td colspan="2" valign="top" class="listtopic"><?=gettext("System Sounds"); ?></td>
325
						</tr>
326
						<tr>
327
							<td width="22%" valign="top" class="vncell"><?=gettext("Startup/Shutdown Sound"); ?></td>
328
							<td width="78%" class="vtable">
329 846ac60f Colin Fleming
								<input name="disablebeep" type="checkbox" id="disablebeep" value="yes" <?php if ($pconfig['disablebeep']) echo "checked=\"checked\""; ?>  />
330 970ca1b7 Yehuda Katz
								<strong><?=gettext("Disable the startup/shutdown beep"); ?></strong>
331 8cd558b6 ayvis
								<br />
332 970ca1b7 Yehuda Katz
								<span class="vexpl"><?=gettext("When this is checked, startup and shutdown sounds will no longer play."); ?></span>
333
							</td>
334
						</tr>
335 66a346b4 Erik Fonnesbeck
						<tr>
336
							<td colspan="2" class="list" height="12">&nbsp;</td>
337
						</tr>	
338 facd2d76 Scott Ullrich
						<tr>
339
							<td valign="top" class="">
340
								&nbsp;
341
							</td>
342
							<td>
343 846ac60f Colin Fleming
								<input type='submit' id='Submit' name='Submit' value='<?=gettext("Save"); ?>' />
344 facd2d76 Scott Ullrich
							</td>
345
						</tr>
346
					</table>
347 846ac60f Colin Fleming
					</form>
348 facd2d76 Scott Ullrich
				</div>
349
			</td>
350
		</tr>
351
	</table>
352 1cddd59c Warren Baker
<script type="text/javascript">
353 1b244d38 Colin Fleming
//<![CDATA[
354 1cddd59c Warren Baker
	jQuery(document).ready(function() {
355
		if (jQuery('#smtpssl').is(':checked')) {
356
			jQuery('#smtptls').prop('disabled', true);
357
		} else if  (jQuery('#smtptls').is(':checked')) {
358
			jQuery('#smtpssl').prop('disabled', true);
359
		}
360
	});
361
	jQuery('#smtpssl').change( function() {
362
		jQuery('#smtptls').prop('disabled', this.checked);
363
	});
364
	jQuery('#smtptls').change( function() {
365
		jQuery('#smtpssl').prop('disabled', this.checked);
366
	});
367 1b244d38 Colin Fleming
//]]>
368 1cddd59c Warren Baker
</script>
369 facd2d76 Scott Ullrich
<?php include("fend.inc"); ?>
370
</body>
371
</html>