Project

General

Profile

Download (8.25 KB) Statistics
| Branch: | Tag: | Revision:
1 df81417f Matthew Grooms
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_misc.php
5
	part of pfSense
6
	Copyright (C) 2005-2007 Scott Ullrich
7
8
	Copyright (C) 2008 Shrew Soft Inc
9
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
##|+PRIV
37
##|*IDENT=page-system-advanced-sysctl
38
##|*NAME=System: Advanced: Tunables page
39
##|*DESCR=Allow access to the 'System: Advanced: Tunables' page.
40
##|*MATCH=system_advanced-sysctrl.php*
41
##|-PRIV
42
43
44
require("guiconfig.inc");
45
46
if (!is_array($config['sysctl']['item']))
47
	$config['sysctl']['item'] = array();
48
49
$a_tunable = &$config['sysctl']['item'];
50
51
$id = $_GET['id'];
52
if (isset($_POST['id']))
53
	$id = $_POST['id'];
54
55
$act = $_GET['act'];
56
if (isset($_POST['act']))
57
	$act = $_POST['act'];
58
59
if ($act == "edit") {
60
	if ($a_tunable[$id]) {
61
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
62
		$pconfig['value'] = $a_tunable[$id]['value'];
63
		$pconfig['desc'] = $a_tunable[$id]['desc'];
64
	}
65
}
66
67
if ($act == "del") {
68
	if ($a_tunable[$id]) {
69
		/* if this is an AJAX caller then handle via JSON */
70
		if(isAjax() && is_array($input_errors)) {
71
			input_errors2Ajax($input_errors);
72
			exit;
73
		}
74
		if (!$input_errors) {
75
			unset($a_tunable[$id]);
76
			write_config();
77
			touch($d_sysctldirty_path);
78
			pfSenseHeader("firewall_system_tunables.php");
79
			exit;
80
		}
81
	}
82
}
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 0a9251d2 Scott Ullrich
		system_setup_sysctl();		
98 df81417f Matthew Grooms
		$savemsg = get_std_save_message($retval);
99
		unlink_if_exists($d_sysctldirty_path);
100
	}
101
102
	if ($_POST['Submit'] == "Save") {
103
		$tunableent = array();
104
105
		$tunableent['tunable'] = $_POST['tunable'];
106
		$tunableent['value'] = $_POST['value'];
107
		$tunableent['desc'] = $_POST['desc'];
108
109
		if (isset($id) && $a_tunable[$id])
110
			$a_tunable[$id] = $tunableent;
111
		else
112
			$a_tunable[] = $tunableent;
113
114
		touch($d_sysctldirty_path);
115
116
		write_config();
117
118
		pfSenseHeader("system_advanced_sysctl.php");
119
		exit;
120
    }
121
}
122
123
include("head.inc");
124
125
$pgtitle = array("System","Advanced: Miscellaneous");
126
include("head.inc");
127
128
?>
129
130
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
131
<?php include("fbegin.inc"); ?>
132
	<form action="system_advanced_sysctl.php" method="post">
133
		<?php
134
			if ($input_errors)
135
				print_input_errors($input_errors);
136
			if ($savemsg)
137
				print_info_box($savemsg);
138 ab3c8553 Matthew Grooms
			if (file_exists($d_sysctldirty_path) && ($act != "edit" ))
139 df81417f Matthew Grooms
				print_info_box_np("The firewall tunables have changed.  You must apply the configuration to take affect.");
140
		?>
141
	</form>
142
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
143
		<tr>
144 ab3c8553 Matthew Grooms
			<td>
145 df81417f Matthew Grooms
				<?php
146
					$tab_array = array();
147
					$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
148
					$tab_array[] = array("Firewall / NAT", false, "system_advanced_firewall.php");
149
					$tab_array[] = array("Networking", false, "system_advanced_network.php");
150
					$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
151
					$tab_array[] = array("System Tunables", true, "system_advanced_sysctl.php");
152
					display_top_tabs($tab_array);
153
				?>
154
			</td>
155
		</tr>
156
		<?php if ($act != "edit" ): ?>
157
		<tr>
158 2ff19bfd Matthew Grooms
			<td id="mainarea">
159
				<div class="tabcont">
160
					<span class="vexpl">
161
						<span class="red">
162
							<strong>NOTE:&nbsp</strong>
163
						</span>
164
						The options on this page are intended for use by advanced users only.
165
						<br/>
166
					</span>
167
					<br/>
168
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
169 df81417f Matthew Grooms
						<tr>
170 ab3c8553 Matthew Grooms
							<td width="20%" class="listhdrr">Tunable Name</td>
171
							<td width="60%" class="listhdrr">Description</td>
172
							<td width="20%" class="listhdrr">Value</td>
173 df81417f Matthew Grooms
						</tr>
174 ab3c8553 Matthew Grooms
						<?php $i = 0; foreach ($config['sysctl']['item'] as $tunable): ?>
175 df81417f Matthew Grooms
						<tr>
176 b6b53776 Scott Ullrich
							<td class="listlr" ondblclick="document.location='system_advanced_sysctl.php?id=<?=$i;?>';">
177 ab3c8553 Matthew Grooms
								<?php echo $tunable['tunable']; ?>
178 df81417f Matthew Grooms
							</td>
179 b6b53776 Scott Ullrich
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?id=<?=$i;?>';">
180 ab3c8553 Matthew Grooms
								<?php echo $tunable['desc']; ?>
181 df81417f Matthew Grooms
							</td>
182 b6b53776 Scott Ullrich
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?id=<?=$i;?>';">
183 ab3c8553 Matthew Grooms
								<?php echo $tunable['value']; ?>
184
							</td>
185
							<td class="list" nowrap>
186
								<table border="0" cellspacing="0" cellpadding="1">
187
									<tr>
188
										<td valign="middle">
189
											<a href="system_advanced_sysctl.php?act=edit&id=<?=$i;?>">
190
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
191
											</a>
192
										</td>
193
										<td valign="middle">
194
											<a href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')">
195
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
196
											</a>
197
										</td>
198
									</tr>
199
								</table>
200 df81417f Matthew Grooms
							</td>
201
						</tr>
202 ab3c8553 Matthew Grooms
						<?php $i++; endforeach; ?>
203 df81417f Matthew Grooms
						<tr>
204 ab3c8553 Matthew Grooms
						<td class="list" colspan="3">
205
							</td>
206
							<td class="list">
207
								<table border="0" cellspacing="0" cellpadding="1">
208
									<tr>
209
										<td valign="middle">
210 faf158b1 Scott Ullrich
											<a href="system_advanced_sysctl.php?act=edit">
211 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
212
											</a>
213
										</td>
214
									</tr>
215
								</table>
216 df81417f Matthew Grooms
							</td>
217
						</tr>
218
					</table>
219 ab3c8553 Matthew Grooms
				</div>
220
			</td>
221
		</tr>
222
		<? else: ?>
223
		<tr>
224
			<td>
225
				<div id="mainarea">
226
					<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
227
						<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
228
							<tr>
229
								<td colspan="2" valign="top" class="listtopic">Edit system tunable</td>
230
							</tr>
231
							<tr>
232
								<td width="22%" valign="top" class="vncellreq">Tunable</td>
233
								<td width="78%" class="vtable">
234
									<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>">
235
								</td>
236
							</tr>
237
							<tr>
238
								<td width="22%" valign="top" class="vncellreq">Description</td>
239
								<td width="78%" class="vtable">
240
									<textarea rows="7" cols="50" name="desc"><?php echo $pconfig['desc']; ?></textarea>
241
								</td>
242
							</tr>
243
							<tr>
244
								<td width="22%" valign="top" class="vncellreq">Value</td>
245
								<td width="78%" class="vtable">
246
									<input size="65" name="value" value="<?php echo $pconfig['value']; ?>">
247
								</td>
248
							</tr>
249
							<tr>
250
								<td width="22%" valign="top">&nbsp;</td>
251
								<td width="78%">
252
									<input id="submit" name="Submit" type="submit" class="formbtn" value="Save" />
253
									<input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
254
									<?php if (isset($id) && $a_tunable[$id]): ?>
255
									<input name="id" type="hidden" value="<?=$id;?>" />
256
									<?php endif; ?>
257
								</td>
258
							</tr>
259
						</table>
260
					</form>
261
				</div>
262 df81417f Matthew Grooms
			</td>
263
		</tr>
264
		<? endif; ?>
265
	</table>
266
<?php include("fend.inc"); ?>
267
</body>
268
</html>