Project

General

Profile

Download (15.2 KB) Statistics
| Branch: | Tag: | Revision:
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']['fromaddress'])
79
	$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
80

    
81
// System Sounds
82
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
83

    
84
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
	if ($_POST['Submit'] == gettext("Save")) {
102
		$tunableent = array();
103

    
104
		// Growl
105
		$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
106
		$config['notifications']['growl']['password'] = $_POST['password'];
107
		$config['notifications']['growl']['name'] = $_POST['name'];
108
		$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
109

    
110
		if($_POST['disable_growl'] == "yes")
111
			$config['notifications']['growl']['disable'] = true;
112
		else
113
			unset($config['notifications']['growl']['disable']);
114

    
115
		// SMTP
116
		$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
117
		$config['notifications']['smtp']['port'] = $_POST['smtpport'];
118
		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
		$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
127
		$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
128
		$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
129
		$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
130

    
131
		if($_POST['disable_smtp'] == "yes")
132
			$config['notifications']['smtp']['disable'] = true;
133
		else
134
			unset($config['notifications']['smtp']['disable']);
135

    
136
		// System Sounds
137
		if($_POST['disablebeep'] == "yes")
138
			$config['system']['disablebeep'] = true;
139
		else
140
			unset($config['system']['disablebeep']);
141

    
142
		write_config();
143
		pfSenseHeader("system_advanced_notifications.php");
144
		return;
145

    
146
	}
147
	if ($_POST['test_growl'] == gettext("Test Growl")) {
148
		// Send test message via growl
149
		if($config['notifications']['growl']['ipaddress'] && 
150
			$config['notifications']['growl']['password'] = $_POST['password']) {
151
			unlink_if_exists($g['vardb_path'] . "/growlnotices_lastmsg.txt");
152
			register_via_growl();
153
			notify_via_growl(sprintf(gettext("This is a test message from %s.  It is safe to ignore this message."), $g['product_name']), true);
154
		}
155
	}
156
	if ($_POST['test_smtp'] == gettext("Test SMTP")) {
157
		// Send test message via smtp
158
		if(file_exists("/var/db/notices_lastmsg.txt"))
159
			unlink("/var/db/notices_lastmsg.txt");
160
		$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
}
163

    
164
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
165
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
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced notifications">
180
		<tr>
181
			<td>
182
				<?php
183
					$tab_array = array();
184
					$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
					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
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
199
						<!-- GROWL -->
200
						<tr>
201
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Growl"); ?></td>
202
						</tr>
203
						<tr>
204
							<td width="22%" valign="top" class="vncell"><?=gettext("Disable Growl Notifications"); ?></td>
205
							<td width="78%" class="vtable">
206
								<input type='checkbox' name='disable_growl' value="yes" <?php if ($pconfig['disable_growl']) {?>checked="checked"<?php } ?> /><br />
207
								<?=gettext("Check this option to disable growl notifications but preserve the settings below."); ?>
208
							</td>
209
						</tr>
210
						<tr>
211
							<td width="22%" valign="top" class="vncell"><?=gettext("Registration Name"); ?></td>
212
							<td width="78%" class="vtable">
213
								<input name='name' value='<?php echo htmlspecialchars($pconfig['name']); ?>' /><br />
214
								<?=gettext("Enter the name to register with the Growl server (default: PHP-Growl)."); ?>
215
							</td>
216
						</tr>
217
  					<tr>
218
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification Name"); ?></td>
219
							<td width="78%" class="vtable">
220
								<input name='notification_name' value='<?php echo htmlspecialchars($pconfig['notification_name']); ?>' /><br />
221
								<?=sprintf(gettext("Enter a name for the Growl notifications (default: %s growl alert)."), $g['product_name']); ?>
222
							</td>
223
						</tr>
224
						<tr>
225
							<td width="22%" valign="top" class="vncell"><?=gettext("IP Address"); ?></td>
226
							<td width="78%" class="vtable">
227
								<input name='ipaddress' value='<?php echo htmlspecialchars($pconfig['ipaddress']); ?>' /><br />
228
								<?=gettext("This is the IP address that you would like to send growl notifications to."); ?>
229
							</td>
230
						</tr>
231
						<tr>
232
							<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
233
							<td width="78%" class="vtable">
234
								<input name='password' type='password' value='<?php echo htmlspecialchars($pconfig['password']); ?>' /><br />
235
								<?=gettext("Enter the password of the remote growl notification device."); ?>
236
							</td>
237
						</tr>
238
						<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
						<tr>
248
							<td colspan="2" class="list" height="12">&nbsp;</td>
249
						</tr>	
250
						<!-- SMTP -->
251
						<tr>
252
							<td colspan="2" valign="top" class="listtopic"><?=gettext("SMTP E-Mail"); ?></td>
253
						</tr>
254
						<tr>
255
							<td width="22%" valign="top" class="vncell"><?=gettext("Disable SMTP Notifications"); ?></td>
256
							<td width="78%" class="vtable">
257
								<input type='checkbox' name='disable_smtp' value="yes" <?php if ($pconfig['disable_smtp']) {?>checked="checked"<?php } ?> /><br />
258
								<?=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
						<tr>
262
							<td width="22%" valign="top" class="vncell"><?=gettext("E-Mail server"); ?></td>
263
							<td width="78%" class="vtable">
264
								<input name='smtpipaddress' value='<?php echo htmlspecialchars($pconfig['smtpipaddress']); ?>' /><br />
265
								<?=gettext("This is the FQDN or IP address of the SMTP E-Mail server to which notifications will be sent."); ?>
266
							</td>
267
						</tr>
268
						<tr>
269
							<td width="22%" valign="top" class="vncell"><?=gettext("SMTP Port of E-Mail server"); ?></td>
270
							<td width="78%" class="vtable">
271
								<input name='smtpport' value='<?php echo htmlspecialchars($pconfig['smtpport']); ?>' /><br />
272
								<?=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
								<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
							</td>
281
						</tr>
282
						<tr>
283
							<td width="22%" valign="top" class="vncell"><?=gettext("From e-mail address"); ?></td>
284
							<td width="78%" class="vtable">
285
								<input name='smtpfromaddress' type='text' value='<?php echo htmlspecialchars($pconfig['smtpfromaddress']); ?>' /><br />
286
								<?=gettext("This is the e-mail address that will appear in the from field."); ?>
287
							</td>
288
						</tr>
289
						<tr>
290
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail address"); ?></td>
291
							<td width="78%" class="vtable">
292
								<input name='smtpnotifyemailaddress' type='text' value='<?php echo htmlspecialchars($pconfig['smtpnotifyemailaddress']); ?>' /><br />
293
								<?=gettext("Enter the e-mail address that you would like email notifications sent to."); ?>
294
							</td>
295
						</tr>
296
						<tr>
297
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth username (optional)"); ?></td>
298
							<td width="78%" class="vtable">
299
								<input name='smtpusername' type='text' value='<?php echo htmlspecialchars($pconfig['smtpusername']); ?>' /><br />
300
								<?=gettext("Enter the e-mail address username for SMTP authentication."); ?>
301
							</td>
302
						</tr>
303
						<tr>
304
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth password"); ?></td>
305
							<td width="78%" class="vtable">
306
								<input name='smtppassword' type='password' value='<?php echo htmlspecialchars($pconfig['smtppassword']); ?>' /><br />
307
								<?=gettext("Enter the e-mail address password for SMTP authentication."); ?>
308
							</td>
309
						</tr>
310
						<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
						<tr>
320
							<td colspan="2" class="list" height="12">&nbsp;</td>
321
						</tr>	
322
						<!-- 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
								<input name="disablebeep" type="checkbox" id="disablebeep" value="yes" <?php if ($pconfig['disablebeep']) echo "checked=\"checked\""; ?>  />
330
								<strong><?=gettext("Disable the startup/shutdown beep"); ?></strong>
331
								<br />
332
								<span class="vexpl"><?=gettext("When this is checked, startup and shutdown sounds will no longer play."); ?></span>
333
							</td>
334
						</tr>
335
						<tr>
336
							<td colspan="2" class="list" height="12">&nbsp;</td>
337
						</tr>	
338
						<tr>
339
							<td valign="top" class="">
340
								&nbsp;
341
							</td>
342
							<td>
343
								<input type='submit' id='Submit' name='Submit' value='<?=gettext("Save"); ?>' />
344
							</td>
345
						</tr>
346
					</table>
347
					</form>
348
				</div>
349
			</td>
350
		</tr>
351
	</table>
352
<script type="text/javascript">
353
//<![CDATA[
354
	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
//]]>
368
</script>
369
<?php include("fend.inc"); ?>
370
</body>
371
</html>
(206-206/252)