Project

General

Profile

Download (11.8 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
##|*NAME=System: Advanced: Tunables page
36
##|*DESCR=Allow access to the 'System: Advanced: Tunables' page.
37
##|*MATCH=system_advanced-sysctrl.php*
38
##|-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 66184513 Scott Ullrich
if($config['notifications']['growl']['password']) 
45
	$pconfig['password'] = $config['notifications']['growl']['password'];
46
if($config['notifications']['growl']['ipaddress']) 
47
	$pconfig['ipaddress'] = $config['notifications']['growl']['ipaddress'];
48 d9252b1f Scott Ullrich
49 addbcae7 Scott Ullrich
if($config['notifications']['growl']['notification_name']) 
50
	$pconfig['notification_name'] = $config['notifications']['growl']['notification_name'];
51
else
52 ebb57fe2 Warren Baker
  $pconfig['notification_name'] = "{$g['product_name']} growl alert";
53 addbcae7 Scott Ullrich
  
54
if($config['notifications']['growl']['name']) 
55
	$pconfig['name'] = $config['notifications']['growl']['name'];
56
else
57
  $pconfig['name'] = 'PHP-Growl';
58
59
60 b19369b7 Scott Ullrich
// SMTP
61 4090c90f Scott Ullrich
if($config['notifications']['smtp']['ipaddress']) 
62
	$pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress'];
63 9277b7ef jim-p
if($config['notifications']['smtp']['port'])
64
	$pconfig['smtpport'] = $config['notifications']['smtp']['port'];
65 2d74f1cf Albert S. Causing
if($config['notifications']['smtp']['ssl'])
66
	$pconfig['smtpssl'] = $config['notifications']['smtp']['ssl'];
67 b19369b7 Scott Ullrich
if($config['notifications']['smtp']['notifyemailaddress']) 
68
	$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
69 72306d5a Scott Ullrich
if($config['notifications']['smtp']['username']) 
70
	$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
71
if($config['notifications']['smtp']['password']) 
72
	$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
73
if($config['notifications']['smtp']['fromaddress']) 
74
	$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
75 b19369b7 Scott Ullrich
76 970ca1b7 Yehuda Katz
// System Sounds
77 66a346b4 Erik Fonnesbeck
$pconfig['disablebeep'] = isset($config['system']['disablebeep']);
78 970ca1b7 Yehuda Katz
79 facd2d76 Scott Ullrich
if ($_POST) {
80
81
	unset($input_errors);
82
	$pconfig = $_POST;
83
84
	/* if this is an AJAX caller then handle via JSON */
85
	if (isAjax() && is_array($input_errors)) {
86
		input_errors2Ajax($input_errors);
87
		exit;
88
	}
89
90
	if ($_POST['apply']) {
91
		$retval = 0;
92
		system_setup_sysctl();		
93
		$savemsg = get_std_save_message($retval);
94
	}
95
96 f0d1edc9 Carlos Eduardo Ramos
	if ($_POST['Submit'] == gettext("Save")) {
97 facd2d76 Scott Ullrich
		$tunableent = array();
98
99 b19369b7 Scott Ullrich
		// Growl
100 1afa87e5 Scott Ullrich
		$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
101
		$config['notifications']['growl']['password'] = $_POST['password'];
102 addbcae7 Scott Ullrich
		$config['notifications']['growl']['name'] = $_POST['name'];
103
		$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
104 facd2d76 Scott Ullrich
105 b19369b7 Scott Ullrich
		// SMTP
106
		$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
107 9277b7ef jim-p
		$config['notifications']['smtp']['port'] = $_POST['smtpport'];
108 2d74f1cf Albert S. Causing
		$config['notifications']['smtp']['ssl'] = isset($_POST['smtpssl']) ? 'checked' : 'unchecked';
109 b19369b7 Scott Ullrich
		$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
110 72306d5a Scott Ullrich
		$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
111
		$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
112
		$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
113 b19369b7 Scott Ullrich
114 970ca1b7 Yehuda Katz
		// System Sounds
115
		if($_POST['disablebeep'] == "yes")
116 66a346b4 Erik Fonnesbeck
			$config['system']['disablebeep'] = true;
117 970ca1b7 Yehuda Katz
		else
118 66a346b4 Erik Fonnesbeck
			unset($config['system']['disablebeep']);
119 970ca1b7 Yehuda Katz
120 facd2d76 Scott Ullrich
		write_config();
121
122 b19369b7 Scott Ullrich
		// Send test message via growl
123 72306d5a Scott Ullrich
		if($config['notifications']['growl']['ipaddress'] && 
124
		   $config['notifications']['growl']['password'] = $_POST['password']) {
125 f670f0a2 Scott Ullrich
			unlink_if_exists($g['vardb_path'] . "/growlnotices_lastmsg.txt");
126 72306d5a Scott Ullrich
			register_via_growl();
127 6840d0e7 Erik Fonnesbeck
			notify_via_growl(sprintf(gettext("This is a test message from %s.  It is safe to ignore this message."), $g['product_name']));
128 72306d5a Scott Ullrich
		}
129 b19369b7 Scott Ullrich
130
		// Send test message via smtp
131 8b0d920e Scott Ullrich
		if(file_exists("/var/db/notices_lastmsg.txt"))
132
			unlink("/var/db/notices_lastmsg.txt");
133 6840d0e7 Erik Fonnesbeck
		$savemsg = notify_via_smtp(sprintf(gettext("This is a test message from %s.  It is safe to ignore this message."), $g['product_name']));
134 b19369b7 Scott Ullrich
135 facd2d76 Scott Ullrich
		pfSenseHeader("system_advanced_notifications.php");
136
		exit;
137
    }
138
}
139
140 f0d1edc9 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
141 facd2d76 Scott Ullrich
include("head.inc");
142
143
?>
144
145
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
146
<?php include("fbegin.inc"); ?>
147
	<form action="system_advanced_notifications.php" method="post">
148
		<?php
149
			if ($input_errors)
150
				print_input_errors($input_errors);
151
			if ($savemsg)
152
				print_info_box($savemsg);
153
		?>
154
	</form>
155 846ac60f Colin Fleming
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced notifications">
156 facd2d76 Scott Ullrich
		<tr>
157
			<td>
158
				<?php
159
					$tab_array = array();
160 f0d1edc9 Carlos Eduardo Ramos
					$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
161
					$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
162
					$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
163
					$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
164
					$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
165
					$tab_array[] = array(gettext("Notifications"), true, "system_advanced_notifications.php");
166 facd2d76 Scott Ullrich
					display_top_tabs($tab_array);
167
				?>
168
			</td>
169
		</tr>
170
		<tr>
171
			<td id="mainarea">
172
				<div class="tabcont">
173
					<form action="system_advanced_notifications.php" method="post" name="iform">
174 846ac60f Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
175 b19369b7 Scott Ullrich
						<!-- GROWL -->
176 facd2d76 Scott Ullrich
						<tr>
177 f0d1edc9 Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Growl"); ?></td>
178 facd2d76 Scott Ullrich
						</tr>
179 addbcae7 Scott Ullrich
						<tr>
180 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Registration Name"); ?></td>
181 addbcae7 Scott Ullrich
							<td width="78%" class="vtable">
182 846ac60f Colin Fleming
								<input name='name' value='<?php echo $pconfig['name']; ?>' /><br/>
183 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the name to register with the Growl server (default: PHP-Growl)."); ?>
184 addbcae7 Scott Ullrich
							</td>
185
						</tr>
186
  					<tr>
187 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification Name"); ?></td>
188 addbcae7 Scott Ullrich
							<td width="78%" class="vtable">
189 846ac60f Colin Fleming
								<input name='notification_name' value='<?php echo $pconfig['notification_name']; ?>' /><br/>
190 6840d0e7 Erik Fonnesbeck
								<?=sprintf(gettext("Enter a name for the Growl notifications (default: %s growl alert)."), $g['product_name']); ?>
191 addbcae7 Scott Ullrich
							</td>
192
						</tr>
193 facd2d76 Scott Ullrich
						<tr>
194 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("IP Address"); ?></td>
195 facd2d76 Scott Ullrich
							<td width="78%" class="vtable">
196 846ac60f Colin Fleming
								<input name='ipaddress' value='<?php echo $pconfig['ipaddress']; ?>' /><br/>
197 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("This is the IP address that you would like to send growl notifications to."); ?>
198 facd2d76 Scott Ullrich
							</td>
199
						</tr>
200
						<tr>
201 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
202 facd2d76 Scott Ullrich
							<td width="78%" class="vtable">
203 846ac60f Colin Fleming
								<input name='password' type='password' value='<?php echo $pconfig['password']; ?>' /><br/>
204 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the password of the remote growl notification device."); ?>
205 facd2d76 Scott Ullrich
							</td>
206
						</tr>
207 7d8c8a28 Scott Ullrich
						<tr>
208
							<td colspan="2" class="list" height="12">&nbsp;</td>
209
						</tr>	
210 b19369b7 Scott Ullrich
						<!-- SMTP -->
211
						<tr>
212 f0d1edc9 Carlos Eduardo Ramos
							<td colspan="2" valign="top" class="listtopic"><?=gettext("SMTP E-Mail"); ?></td>
213 b19369b7 Scott Ullrich
						</tr>
214
						<tr>
215 d58b93d2 jim-p
							<td width="22%" valign="top" class="vncell"><?=gettext("E-Mail server"); ?></td>
216 b19369b7 Scott Ullrich
							<td width="78%" class="vtable">
217 846ac60f Colin Fleming
								<input name='smtpipaddress' value='<?php echo $pconfig['smtpipaddress']; ?>' /><br/>
218 d58b93d2 jim-p
								<?=gettext("This is the FQDN or IP address of the SMTP E-Mail server to which notifications will be sent."); ?>
219 b19369b7 Scott Ullrich
							</td>
220
						</tr>
221 9277b7ef jim-p
						<tr>
222
							<td width="22%" valign="top" class="vncell"><?=gettext("SMTP Port of E-Mail server"); ?></td>
223
							<td width="78%" class="vtable">
224 846ac60f Colin Fleming
								<input name='smtpport' value='<?php echo $pconfig['smtpport']; ?>' />
225
								<input type='checkbox' name='smtpssl' <?php echo $pconfig['smtpssl']; ?> />Enable SSL/TLS Authentication<br/>
226 2d74f1cf Albert S. Causing
								<?=gettext("This is the port of the SMTP E-Mail server, typically 25, 587 (submission) or 465 (smtps, tick ssl/tls checkbox)"); ?>
227 9277b7ef jim-p
							</td>
228
						</tr>
229 72306d5a Scott Ullrich
						<tr>
230 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("From e-mail address"); ?></td>
231 72306d5a Scott Ullrich
							<td width="78%" class="vtable">
232 846ac60f Colin Fleming
								<input name='smtpfromaddress' type='text' value='<?php echo $pconfig['smtpfromaddress']; ?>' /><br/>
233 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("This is the e-mail address that will appear in the from field."); ?>
234 72306d5a Scott Ullrich
							</td>
235
						</tr>
236 b19369b7 Scott Ullrich
						<tr>
237 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail address"); ?></td>
238 b19369b7 Scott Ullrich
							<td width="78%" class="vtable">
239 846ac60f Colin Fleming
								<input name='smtpnotifyemailaddress' type='text' value='<?php echo $pconfig['smtpnotifyemailaddress']; ?>' /><br/>
240 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the e-mail address that you would like email notifications sent to."); ?>
241 b19369b7 Scott Ullrich
							</td>
242
						</tr>
243 72306d5a Scott Ullrich
						<tr>
244 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth username (optional)"); ?></td>
245 72306d5a Scott Ullrich
							<td width="78%" class="vtable">
246 846ac60f Colin Fleming
								<input name='smtpusername' type='text' value='<?php echo $pconfig['smtpusername']; ?>' /><br/>
247 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the e-mail address username for SMTP authentication."); ?>
248 72306d5a Scott Ullrich
							</td>
249
						</tr>
250
						<tr>
251 f0d1edc9 Carlos Eduardo Ramos
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth password"); ?></td>
252 72306d5a Scott Ullrich
							<td width="78%" class="vtable">
253 846ac60f Colin Fleming
								<input name='smtppassword' type='password' value='<?php echo $pconfig['smtppassword']; ?>' /><br/>
254 f0d1edc9 Carlos Eduardo Ramos
								<?=gettext("Enter the e-mail address password for SMTP authentication."); ?>
255 72306d5a Scott Ullrich
							</td>
256
						</tr>
257 66a346b4 Erik Fonnesbeck
						<tr>
258
							<td colspan="2" class="list" height="12">&nbsp;</td>
259
						</tr>	
260 970ca1b7 Yehuda Katz
						<!-- System Sounds -->
261
						<tr>
262
							<td colspan="2" valign="top" class="listtopic"><?=gettext("System Sounds"); ?></td>
263
						</tr>
264
						<tr>
265
							<td width="22%" valign="top" class="vncell"><?=gettext("Startup/Shutdown Sound"); ?></td>
266
							<td width="78%" class="vtable">
267 846ac60f Colin Fleming
								<input name="disablebeep" type="checkbox" id="disablebeep" value="yes" <?php if ($pconfig['disablebeep']) echo "checked=\"checked\""; ?>  />
268 970ca1b7 Yehuda Katz
								<strong><?=gettext("Disable the startup/shutdown beep"); ?></strong>
269
								<br/>
270
								<span class="vexpl"><?=gettext("When this is checked, startup and shutdown sounds will no longer play."); ?></span>
271
							</td>
272
						</tr>
273 66a346b4 Erik Fonnesbeck
						<tr>
274
							<td colspan="2" class="list" height="12">&nbsp;</td>
275
						</tr>	
276 facd2d76 Scott Ullrich
						<tr>
277
							<td valign="top" class="">
278
								&nbsp;
279
							</td>
280
							<td>
281 846ac60f Colin Fleming
								<input type='submit' id='Submit' name='Submit' value='<?=gettext("Save"); ?>' />
282 facd2d76 Scott Ullrich
							</td>
283
						</tr>
284
					</table>
285 846ac60f Colin Fleming
					</form>
286 facd2d76 Scott Ullrich
				</div>
287
			</td>
288
		</tr>
289
	</table>
290
<?php include("fend.inc"); ?>
291
</body>
292
</html>