Project

General

Profile

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