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 |
|
|
$pconfig['notification_name'] = 'pfSense growl alert';
|
53 |
|
|
|
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 |
b19369b7
|
Scott Ullrich
|
if($config['notifications']['smtp']['notifyemailaddress'])
|
64 |
|
|
$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
|
65 |
72306d5a
|
Scott Ullrich
|
if($config['notifications']['smtp']['username'])
|
66 |
|
|
$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
|
67 |
|
|
if($config['notifications']['smtp']['password'])
|
68 |
|
|
$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
|
69 |
|
|
if($config['notifications']['smtp']['fromaddress'])
|
70 |
|
|
$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
|
71 |
b19369b7
|
Scott Ullrich
|
|
72 |
facd2d76
|
Scott Ullrich
|
if ($_POST) {
|
73 |
|
|
|
74 |
|
|
unset($input_errors);
|
75 |
|
|
$pconfig = $_POST;
|
76 |
|
|
|
77 |
|
|
/* if this is an AJAX caller then handle via JSON */
|
78 |
|
|
if (isAjax() && is_array($input_errors)) {
|
79 |
|
|
input_errors2Ajax($input_errors);
|
80 |
|
|
exit;
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
if ($_POST['apply']) {
|
84 |
|
|
$retval = 0;
|
85 |
|
|
system_setup_sysctl();
|
86 |
|
|
$savemsg = get_std_save_message($retval);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
f0d1edc9
|
Carlos Eduardo Ramos
|
if ($_POST['Submit'] == gettext("Save")) {
|
90 |
facd2d76
|
Scott Ullrich
|
$tunableent = array();
|
91 |
|
|
|
92 |
b19369b7
|
Scott Ullrich
|
// Growl
|
93 |
1afa87e5
|
Scott Ullrich
|
$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
|
94 |
|
|
$config['notifications']['growl']['password'] = $_POST['password'];
|
95 |
addbcae7
|
Scott Ullrich
|
$config['notifications']['growl']['name'] = $_POST['name'];
|
96 |
|
|
$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
|
97 |
facd2d76
|
Scott Ullrich
|
|
98 |
b19369b7
|
Scott Ullrich
|
// SMTP
|
99 |
|
|
$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
|
100 |
|
|
$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
|
101 |
72306d5a
|
Scott Ullrich
|
$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
|
102 |
|
|
$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
|
103 |
|
|
$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
|
104 |
b19369b7
|
Scott Ullrich
|
|
105 |
facd2d76
|
Scott Ullrich
|
write_config();
|
106 |
|
|
|
107 |
b19369b7
|
Scott Ullrich
|
// Send test message via growl
|
108 |
72306d5a
|
Scott Ullrich
|
if($config['notifications']['growl']['ipaddress'] &&
|
109 |
|
|
$config['notifications']['growl']['password'] = $_POST['password']) {
|
110 |
|
|
register_via_growl();
|
111 |
f0d1edc9
|
Carlos Eduardo Ramos
|
notify_via_growl(gettext("This is a test message form pfSense. It is safe to ignore this message."));
|
112 |
72306d5a
|
Scott Ullrich
|
}
|
113 |
b19369b7
|
Scott Ullrich
|
|
114 |
|
|
// Send test message via smtp
|
115 |
8b0d920e
|
Scott Ullrich
|
if(file_exists("/var/db/notices_lastmsg.txt"))
|
116 |
|
|
unlink("/var/db/notices_lastmsg.txt");
|
117 |
f0d1edc9
|
Carlos Eduardo Ramos
|
$savemsg = notify_via_smtp(gettext("This is a test message form pfSense. It is safe to ignore this message."));
|
118 |
b19369b7
|
Scott Ullrich
|
|
119 |
facd2d76
|
Scott Ullrich
|
pfSenseHeader("system_advanced_notifications.php");
|
120 |
|
|
exit;
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
f0d1edc9
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
|
125 |
facd2d76
|
Scott Ullrich
|
include("head.inc");
|
126 |
|
|
|
127 |
|
|
?>
|
128 |
|
|
|
129 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
130 |
|
|
<?php include("fbegin.inc"); ?>
|
131 |
|
|
<form action="system_advanced_notifications.php" method="post">
|
132 |
|
|
<?php
|
133 |
|
|
if ($input_errors)
|
134 |
|
|
print_input_errors($input_errors);
|
135 |
|
|
if ($savemsg)
|
136 |
|
|
print_info_box($savemsg);
|
137 |
|
|
?>
|
138 |
|
|
</form>
|
139 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
140 |
|
|
<tr>
|
141 |
|
|
<td>
|
142 |
|
|
<?php
|
143 |
|
|
$tab_array = array();
|
144 |
f0d1edc9
|
Carlos Eduardo Ramos
|
$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
|
145 |
|
|
$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
|
146 |
|
|
$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
|
147 |
|
|
$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
|
148 |
|
|
$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
|
149 |
|
|
$tab_array[] = array(gettext("Notifications"), true, "system_advanced_notifications.php");
|
150 |
facd2d76
|
Scott Ullrich
|
display_top_tabs($tab_array);
|
151 |
|
|
?>
|
152 |
|
|
</td>
|
153 |
|
|
</tr>
|
154 |
|
|
<tr>
|
155 |
|
|
<td id="mainarea">
|
156 |
|
|
<div class="tabcont">
|
157 |
|
|
<form action="system_advanced_notifications.php" method="post" name="iform">
|
158 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
159 |
b19369b7
|
Scott Ullrich
|
<!-- GROWL -->
|
160 |
facd2d76
|
Scott Ullrich
|
<tr>
|
161 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Growl"); ?></td>
|
162 |
facd2d76
|
Scott Ullrich
|
</tr>
|
163 |
addbcae7
|
Scott Ullrich
|
<tr>
|
164 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Registration Name"); ?></td>
|
165 |
addbcae7
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
166 |
|
|
<input name='name' value='<?php echo $pconfig['name']; ?>'><br/>
|
167 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("Enter the name to register with the Growl server (default: PHP-Growl)."); ?>
|
168 |
addbcae7
|
Scott Ullrich
|
</td>
|
169 |
|
|
</tr>
|
170 |
|
|
<tr>
|
171 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification Name"); ?></td>
|
172 |
addbcae7
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
173 |
|
|
<input name='notification_name' value='<?php echo $pconfig['notification_name']; ?>'><br/>
|
174 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("Enter a name for the Growl notifications (default: pfSense growl alert)."); ?>
|
175 |
addbcae7
|
Scott Ullrich
|
</td>
|
176 |
|
|
</tr>
|
177 |
facd2d76
|
Scott Ullrich
|
<tr>
|
178 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("IP Address"); ?></td>
|
179 |
facd2d76
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
180 |
d0e705e1
|
Scott Ullrich
|
<input name='ipaddress' value='<?php echo $pconfig['ipaddress']; ?>'><br/>
|
181 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("This is the IP address that you would like to send growl notifications to."); ?>
|
182 |
facd2d76
|
Scott Ullrich
|
</td>
|
183 |
|
|
</tr>
|
184 |
|
|
<tr>
|
185 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
|
186 |
facd2d76
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
187 |
d0e705e1
|
Scott Ullrich
|
<input name='password' type='password' value='<?php echo $pconfig['password']; ?>'><br/>
|
188 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("Enter the password of the remote growl notification device."); ?>
|
189 |
facd2d76
|
Scott Ullrich
|
</td>
|
190 |
|
|
</tr>
|
191 |
7d8c8a28
|
Scott Ullrich
|
<tr>
|
192 |
|
|
<td colspan="2" class="list" height="12"> </td>
|
193 |
|
|
</tr>
|
194 |
b19369b7
|
Scott Ullrich
|
<!-- SMTP -->
|
195 |
|
|
<tr>
|
196 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("SMTP E-Mail"); ?></td>
|
197 |
b19369b7
|
Scott Ullrich
|
</tr>
|
198 |
|
|
<tr>
|
199 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("IP Address of E-Mail server"); ?></td>
|
200 |
b19369b7
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
201 |
|
|
<input name='smtpipaddress' value='<?php echo $pconfig['smtpipaddress']; ?>'><br/>
|
202 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("This is the IP address of the SMTP E-Mail server that will be used to send notifications to."); ?>
|
203 |
b19369b7
|
Scott Ullrich
|
</td>
|
204 |
|
|
</tr>
|
205 |
72306d5a
|
Scott Ullrich
|
<tr>
|
206 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("From e-mail address"); ?></td>
|
207 |
72306d5a
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
208 |
|
|
<input name='smtpfromaddress' type='input' value='<?php echo $pconfig['smtpfromaddress']; ?>'><br/>
|
209 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("This is the e-mail address that will appear in the from field."); ?>
|
210 |
72306d5a
|
Scott Ullrich
|
</td>
|
211 |
|
|
</tr>
|
212 |
b19369b7
|
Scott Ullrich
|
<tr>
|
213 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail address"); ?></td>
|
214 |
b19369b7
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
215 |
|
|
<input name='smtpnotifyemailaddress' type='input' value='<?php echo $pconfig['smtpnotifyemailaddress']; ?>'><br/>
|
216 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("Enter the e-mail address that you would like email notifications sent to."); ?>
|
217 |
b19369b7
|
Scott Ullrich
|
</td>
|
218 |
|
|
</tr>
|
219 |
72306d5a
|
Scott Ullrich
|
<tr>
|
220 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth username (optional)"); ?></td>
|
221 |
72306d5a
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
222 |
|
|
<input name='smtpusername' type='input' value='<?php echo $pconfig['smtpusername']; ?>'><br/>
|
223 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("Enter the e-mail address username for SMTP authentication."); ?>
|
224 |
72306d5a
|
Scott Ullrich
|
</td>
|
225 |
|
|
</tr>
|
226 |
|
|
<tr>
|
227 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth password"); ?></td>
|
228 |
72306d5a
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
229 |
|
|
<input name='smtppassword' type='password' value='<?php echo $pconfig['smtppassword']; ?>'><br/>
|
230 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<?=gettext("Enter the e-mail address password for SMTP authentication."); ?>
|
231 |
72306d5a
|
Scott Ullrich
|
</td>
|
232 |
|
|
</tr>
|
233 |
facd2d76
|
Scott Ullrich
|
<tr>
|
234 |
|
|
<td valign="top" class="">
|
235 |
|
|
|
236 |
|
|
</td>
|
237 |
|
|
<td>
|
238 |
|
|
<br/>
|
239 |
f0d1edc9
|
Carlos Eduardo Ramos
|
<input type='submit' id='Submit' name='Submit' value='<?=gettext("Save"); ?>'></form>
|
240 |
facd2d76
|
Scott Ullrich
|
</td>
|
241 |
|
|
</tr>
|
242 |
|
|
</table>
|
243 |
|
|
</div>
|
244 |
|
|
</td>
|
245 |
|
|
</tr>
|
246 |
|
|
</table>
|
247 |
|
|
<?php include("fend.inc"); ?>
|
248 |
|
|
</body>
|
249 |
|
|
</html>
|