Project

General

Profile

Download (8.08 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("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
// SMTP
50
if($config['notifications']['smtp']['ipaddress']) 
51
	$pconfig['smtpipaddress'] = $config['notifications']['smtp']['ipaddress'];
52
if($config['notifications']['smtp']['notifyemailaddress']) 
53
	$pconfig['smtpnotifyemailaddress'] = $config['notifications']['smtp']['notifyemailaddress'];
54
if($config['notifications']['smtp']['username']) 
55
	$pconfig['smtpusername'] = $config['notifications']['smtp']['username'];
56
if($config['notifications']['smtp']['password']) 
57
	$pconfig['smtppassword'] = $config['notifications']['smtp']['password'];
58
if($config['notifications']['smtp']['fromaddress']) 
59
	$pconfig['smtpfromaddress'] = $config['notifications']['smtp']['fromaddress'];
60

    
61
if ($_POST) {
62

    
63
	unset($input_errors);
64
	$pconfig = $_POST;
65

    
66
	/* if this is an AJAX caller then handle via JSON */
67
	if (isAjax() && is_array($input_errors)) {
68
		input_errors2Ajax($input_errors);
69
		exit;
70
	}
71

    
72
	if ($_POST['apply']) {
73
		$retval = 0;
74
		system_setup_sysctl();		
75
		$savemsg = get_std_save_message($retval);
76
	}
77

    
78
	if ($_POST['Submit'] == "Save") {
79
		$tunableent = array();
80

    
81
		// Growl
82
		$config['notifications']['growl']['ipaddress'] = $_POST['ipaddress'];
83
		$config['notifications']['growl']['password'] = $_POST['password'];
84

    
85
		// SMTP
86
		$config['notifications']['smtp']['ipaddress'] = $_POST['smtpipaddress'];
87
		$config['notifications']['smtp']['notifyemailaddress'] = $_POST['smtpnotifyemailaddress'];
88
		$config['notifications']['smtp']['username'] = $_POST['smtpusername'];
89
		$config['notifications']['smtp']['password'] = $_POST['smtppassword'];
90
		$config['notifications']['smtp']['fromaddress'] = $_POST['smtpfromaddress'];
91

    
92
		write_config();
93

    
94
		// Send test message via growl
95
		if($config['notifications']['growl']['ipaddress'] && 
96
		   $config['notifications']['growl']['password'] = $_POST['password']) {
97
			register_via_growl();
98
			notify_via_growl("This is a test message form pfSense.  It is safe to ignore this message.");
99
		}
100

    
101
		// Send test message via smtp
102
		if(file_exists("/var/db/notices_lastmsg.txt"))
103
			unlink("/var/db/notices_lastmsg.txt");
104
		$savemsg = notify_via_smtp("This is a test message form pfSense.  It is safe to ignore this message.");
105

    
106
		pfSenseHeader("system_advanced_notifications.php");
107
		exit;
108
    }
109
}
110

    
111
$pgtitle = array("System","Advanced: Notifications");
112
include("head.inc");
113

    
114
?>
115

    
116
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
117
<?php include("fbegin.inc"); ?>
118
	<form action="system_advanced_notifications.php" method="post">
119
		<?php
120
			if ($input_errors)
121
				print_input_errors($input_errors);
122
			if ($savemsg)
123
				print_info_box($savemsg);
124
		?>
125
	</form>
126
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
127
		<tr>
128
			<td>
129
				<?php
130
					$tab_array = array();
131
					$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
132
					$tab_array[] = array("Firewall / NAT", false, "system_advanced_firewall.php");
133
					$tab_array[] = array("Networking", false, "system_advanced_network.php");
134
					$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
135
					$tab_array[] = array("System Tunables", false, "system_advanced_sysctl.php");
136
					$tab_array[] = array("Notifications", true, "system_advanced_notifications.php");
137
					display_top_tabs($tab_array);
138
				?>
139
			</td>
140
		</tr>
141
		<tr>
142
			<td id="mainarea">
143
				<div class="tabcont">
144
					<form action="system_advanced_notifications.php" method="post" name="iform">
145
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
146
						<!-- GROWL -->
147
						<tr>
148
							<td colspan="2" valign="top" class="listtopic">Growl</td>
149
						</tr>
150
						<tr>
151
							<td width="22%" valign="top" class="vncell">IP Address</td>
152
							<td width="78%" class="vtable">
153
								<input name='ipaddress' value='<?php echo $pconfig['ipaddress']; ?>'><br/>
154
								This is the IP address that you would like to send growl notifications to.
155
							</td>
156
						</tr>
157
						<tr>
158
							<td width="22%" valign="top" class="vncell">Password</td>
159
							<td width="78%" class="vtable">
160
								<input name='password' type='password' value='<?php echo $pconfig['password']; ?>'><br/>
161
								Enter the password of the remote growl notification device.
162
							</td>
163
						</tr>
164
						<tr>
165
							<td colspan="2" class="list" height="12">&nbsp;</td>
166
						</tr>	
167
						<!-- SMTP -->
168
						<tr>
169
							<td colspan="2" valign="top" class="listtopic">SMTP E-Mail</td>
170
						</tr>
171
						<tr>
172
							<td width="22%" valign="top" class="vncell">IP Address of E-Mail server</td>
173
							<td width="78%" class="vtable">
174
								<input name='smtpipaddress' value='<?php echo $pconfig['smtpipaddress']; ?>'><br/>
175
								This is the IP address of the SMTP E-Mail server that will be used to send notifications to.
176
							</td>
177
						</tr>
178
						<tr>
179
							<td width="22%" valign="top" class="vncell">From e-mail address</td>
180
							<td width="78%" class="vtable">
181
								<input name='smtpfromaddress' type='input' value='<?php echo $pconfig['smtpfromaddress']; ?>'><br/>
182
								This is the e-mail address that will appear in the from field.
183
							</td>
184
						</tr>
185
						<tr>
186
							<td width="22%" valign="top" class="vncell">Notification E-Mail address</td>
187
							<td width="78%" class="vtable">
188
								<input name='smtpnotifyemailaddress' type='input' value='<?php echo $pconfig['smtpnotifyemailaddress']; ?>'><br/>
189
								Enter the e-mail address that you would like email notifications sent to.
190
							</td>
191
						</tr>
192
						<tr>
193
							<td width="22%" valign="top" class="vncell">Notification E-Mail auth username (optional)</td>
194
							<td width="78%" class="vtable">
195
								<input name='smtpusername' type='input' value='<?php echo $pconfig['smtpusername']; ?>'><br/>
196
								Enter the e-mail address username for SMTP authentication.
197
							</td>
198
						</tr>
199
						<tr>
200
							<td width="22%" valign="top" class="vncell">Notification E-Mail auth password</td>
201
							<td width="78%" class="vtable">
202
								<input name='smtppassword' type='password' value='<?php echo $pconfig['smtppassword']; ?>'><br/>
203
								Enter the e-mail address password for SMTP authentication.
204
							</td>
205
						</tr>
206
						<tr>
207
							<td valign="top" class="">
208
								&nbsp;
209
							</td>
210
							<td>
211
								<br/>
212
								<input type='submit' id='Submit' name='Submit' value='Save'></form>
213
							</td>
214
						</tr>
215
					</table>
216
				</div>
217
			</td>
218
		</tr>
219
	</table>
220
<?php include("fend.inc"); ?>
221
</body>
222
</html>
(171-171/215)