Project

General

Profile

Download (10.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

    
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
/*
30
	pfSense_MODULE:	system
31
*/
32

    
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
require_once("notices.inc");
42

    
43
// Growl
44
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

    
49
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
// SMTP
61
if($config['notifications']['smtp']['ipaddress']) 
62
	$pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress'];
63
if($config['notifications']['smtp']['port'])
64
	$pconfig['smtpport'] = $config['notifications']['smtp']['port'];
65
if($config['notifications']['smtp']['notifyemailaddress']) 
66
	$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
67
if($config['notifications']['smtp']['username']) 
68
	$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
69
if($config['notifications']['smtp']['password']) 
70
	$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
71
if($config['notifications']['smtp']['fromaddress']) 
72
	$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
73

    
74
if ($_POST) {
75

    
76
	unset($input_errors);
77
	$pconfig = $_POST;
78

    
79
	/* if this is an AJAX caller then handle via JSON */
80
	if (isAjax() && is_array($input_errors)) {
81
		input_errors2Ajax($input_errors);
82
		exit;
83
	}
84

    
85
	if ($_POST['apply']) {
86
		$retval = 0;
87
		system_setup_sysctl();		
88
		$savemsg = get_std_save_message($retval);
89
	}
90

    
91
	if ($_POST['Submit'] == gettext("Save")) {
92
		$tunableent = array();
93

    
94
		// Growl
95
		$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
96
		$config['notifications']['growl']['password'] = $_POST['password'];
97
		$config['notifications']['growl']['name'] = $_POST['name'];
98
		$config['notifications']['growl']['notification_name'] = $_POST['notification_name'];
99

    
100
		// SMTP
101
		$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
102
		$config['notifications']['smtp']['port'] = $_POST['smtpport'];
103
		$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
104
		$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
105
		$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
106
		$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
107

    
108
		write_config();
109

    
110
		// Send test message via growl
111
		if($config['notifications']['growl']['ipaddress'] && 
112
		   $config['notifications']['growl']['password'] = $_POST['password']) {
113
			register_via_growl();
114
			notify_via_growl(gettext("This is a test message from pfSense.  It is safe to ignore this message."));
115
		}
116

    
117
		// Send test message via smtp
118
		if(file_exists("/var/db/notices_lastmsg.txt"))
119
			unlink("/var/db/notices_lastmsg.txt");
120
		$savemsg = notify_via_smtp(gettext("This is a test message from pfSense.  It is safe to ignore this message."));
121

    
122
		pfSenseHeader("system_advanced_notifications.php");
123
		exit;
124
    }
125
}
126

    
127
$pgtitle = array(gettext("System"),gettext("Advanced: Notifications"));
128
include("head.inc");
129

    
130
?>
131

    
132
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
133
<?php include("fbegin.inc"); ?>
134
	<form action="system_advanced_notifications.php" method="post">
135
		<?php
136
			if ($input_errors)
137
				print_input_errors($input_errors);
138
			if ($savemsg)
139
				print_info_box($savemsg);
140
		?>
141
	</form>
142
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
143
		<tr>
144
			<td>
145
				<?php
146
					$tab_array = array();
147
					$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
148
					$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
149
					$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
150
					$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
151
					$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
152
					$tab_array[] = array(gettext("Notifications"), true, "system_advanced_notifications.php");
153
					display_top_tabs($tab_array);
154
				?>
155
			</td>
156
		</tr>
157
		<tr>
158
			<td id="mainarea">
159
				<div class="tabcont">
160
					<form action="system_advanced_notifications.php" method="post" name="iform">
161
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
162
						<!-- GROWL -->
163
						<tr>
164
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Growl"); ?></td>
165
						</tr>
166
						<tr>
167
							<td width="22%" valign="top" class="vncell"><?=gettext("Registration Name"); ?></td>
168
							<td width="78%" class="vtable">
169
								<input name='name' value='<?php echo $pconfig['name']; ?>'><br/>
170
								<?=gettext("Enter the name to register with the Growl server (default: PHP-Growl)."); ?>
171
							</td>
172
						</tr>
173
  					<tr>
174
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification Name"); ?></td>
175
							<td width="78%" class="vtable">
176
								<input name='notification_name' value='<?php echo $pconfig['notification_name']; ?>'><br/>
177
								<?=gettext("Enter a name for the Growl notifications (default: pfSense growl alert)."); ?>
178
							</td>
179
						</tr>
180
						<tr>
181
							<td width="22%" valign="top" class="vncell"><?=gettext("IP Address"); ?></td>
182
							<td width="78%" class="vtable">
183
								<input name='ipaddress' value='<?php echo $pconfig['ipaddress']; ?>'><br/>
184
								<?=gettext("This is the IP address that you would like to send growl notifications to."); ?>
185
							</td>
186
						</tr>
187
						<tr>
188
							<td width="22%" valign="top" class="vncell"><?=gettext("Password"); ?></td>
189
							<td width="78%" class="vtable">
190
								<input name='password' type='password' value='<?php echo $pconfig['password']; ?>'><br/>
191
								<?=gettext("Enter the password of the remote growl notification device."); ?>
192
							</td>
193
						</tr>
194
						<tr>
195
							<td colspan="2" class="list" height="12">&nbsp;</td>
196
						</tr>	
197
						<!-- SMTP -->
198
						<tr>
199
							<td colspan="2" valign="top" class="listtopic"><?=gettext("SMTP E-Mail"); ?></td>
200
						</tr>
201
						<tr>
202
							<td width="22%" valign="top" class="vncell"><?=gettext("IP Address of E-Mail server"); ?></td>
203
							<td width="78%" class="vtable">
204
								<input name='smtpipaddress' value='<?php echo $pconfig['smtpipaddress']; ?>'><br/>
205
								<?=gettext("This is the IP address of the SMTP E-Mail server that will be used to send notifications to."); ?>
206
							</td>
207
						</tr>
208
						<tr>
209
							<td width="22%" valign="top" class="vncell"><?=gettext("SMTP Port of E-Mail server"); ?></td>
210
							<td width="78%" class="vtable">
211
								<input name='smtpport' value='<?php echo $pconfig['smtpport']; ?>'><br/>
212
								<?=gettext("This is the port of the SMTP E-Mail server, typically 25 or 587 (submission)."); ?>
213
							</td>
214
						</tr>
215
						<tr>
216
							<td width="22%" valign="top" class="vncell"><?=gettext("From e-mail address"); ?></td>
217
							<td width="78%" class="vtable">
218
								<input name='smtpfromaddress' type='input' value='<?php echo $pconfig['smtpfromaddress']; ?>'><br/>
219
								<?=gettext("This is the e-mail address that will appear in the from field."); ?>
220
							</td>
221
						</tr>
222
						<tr>
223
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail address"); ?></td>
224
							<td width="78%" class="vtable">
225
								<input name='smtpnotifyemailaddress' type='input' value='<?php echo $pconfig['smtpnotifyemailaddress']; ?>'><br/>
226
								<?=gettext("Enter the e-mail address that you would like email notifications sent to."); ?>
227
							</td>
228
						</tr>
229
						<tr>
230
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth username (optional)"); ?></td>
231
							<td width="78%" class="vtable">
232
								<input name='smtpusername' type='input' value='<?php echo $pconfig['smtpusername']; ?>'><br/>
233
								<?=gettext("Enter the e-mail address username for SMTP authentication."); ?>
234
							</td>
235
						</tr>
236
						<tr>
237
							<td width="22%" valign="top" class="vncell"><?=gettext("Notification E-Mail auth password"); ?></td>
238
							<td width="78%" class="vtable">
239
								<input name='smtppassword' type='password' value='<?php echo $pconfig['smtppassword']; ?>'><br/>
240
								<?=gettext("Enter the e-mail address password for SMTP authentication."); ?>
241
							</td>
242
						</tr>
243
						<tr>
244
							<td valign="top" class="">
245
								&nbsp;
246
							</td>
247
							<td>
248
								<br/>
249
								<input type='submit' id='Submit' name='Submit' value='<?=gettext("Save"); ?>'></form>
250
							</td>
251
						</tr>
252
					</table>
253
				</div>
254
			</td>
255
		</tr>
256
	</table>
257
<?php include("fend.inc"); ?>
258
</body>
259
</html>
(176-176/220)