Project

General

Profile

Download (8.53 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 1d333258 Scott Ullrich
/*
36
	pfSense_MODULE:	system
37
*/
38 df81417f Matthew Grooms
39
##|+PRIV
40
##|*IDENT=page-system-advanced-sysctl
41
##|*NAME=System: Advanced: Tunables page
42
##|*DESCR=Allow access to the 'System: Advanced: Tunables' page.
43
##|*MATCH=system_advanced-sysctrl.php*
44
##|-PRIV
45
46
require("guiconfig.inc");
47
48
if (!is_array($config['sysctl']['item']))
49
	$config['sysctl']['item'] = array();
50
51
$a_tunable = &$config['sysctl']['item'];
52
53
$id = $_GET['id'];
54
if (isset($_POST['id']))
55
	$id = $_POST['id'];
56
57
$act = $_GET['act'];
58
if (isset($_POST['act']))
59
	$act = $_POST['act'];
60
61
if ($act == "edit") {
62
	if ($a_tunable[$id]) {
63
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
64
		$pconfig['value'] = $a_tunable[$id]['value'];
65
		$pconfig['desc'] = $a_tunable[$id]['desc'];
66
	}
67
}
68
69
if ($act == "del") {
70
	if ($a_tunable[$id]) {
71
		/* if this is an AJAX caller then handle via JSON */
72
		if(isAjax() && is_array($input_errors)) {
73
			input_errors2Ajax($input_errors);
74
			exit;
75
		}
76
		if (!$input_errors) {
77
			unset($a_tunable[$id]);
78
			write_config();
79 a368a026 Ermal Lu?i
			mark_subsystem_dirty('sysctl');
80 df81417f Matthew Grooms
			pfSenseHeader("firewall_system_tunables.php");
81
			exit;
82
		}
83
	}
84
}
85
86
if ($_POST) {
87
88
	unset($input_errors);
89
	$pconfig = $_POST;
90
91
	/* if this is an AJAX caller then handle via JSON */
92
	if (isAjax() && is_array($input_errors)) {
93
		input_errors2Ajax($input_errors);
94
		exit;
95
	}
96
97
	if ($_POST['apply']) {
98
		$retval = 0;
99 0a9251d2 Scott Ullrich
		system_setup_sysctl();		
100 df81417f Matthew Grooms
		$savemsg = get_std_save_message($retval);
101 a368a026 Ermal Lu?i
		clear_subsystem_dirty('sysctl');
102 df81417f Matthew Grooms
	}
103
104
	if ($_POST['Submit'] == "Save") {
105
		$tunableent = array();
106
107
		$tunableent['tunable'] = $_POST['tunable'];
108
		$tunableent['value'] = $_POST['value'];
109
		$tunableent['desc'] = $_POST['desc'];
110
111
		if (isset($id) && $a_tunable[$id])
112
			$a_tunable[$id] = $tunableent;
113
		else
114
			$a_tunable[] = $tunableent;
115
116 a368a026 Ermal Lu?i
		mark_subsystem_dirty('sysctl');
117 df81417f Matthew Grooms
118
		write_config();
119
120
		pfSenseHeader("system_advanced_sysctl.php");
121
		exit;
122
    }
123
}
124
125
include("head.inc");
126
127
$pgtitle = array("System","Advanced: Miscellaneous");
128
include("head.inc");
129 45849d22 sullrich
require("sysctl.inc");
130 df81417f Matthew Grooms
131
?>
132
133
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
134
<?php include("fbegin.inc"); ?>
135
	<form action="system_advanced_sysctl.php" method="post">
136
		<?php
137
			if ($input_errors)
138
				print_input_errors($input_errors);
139
			if ($savemsg)
140
				print_info_box($savemsg);
141 a368a026 Ermal Lu?i
			if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
142 df81417f Matthew Grooms
				print_info_box_np("The firewall tunables have changed.  You must apply the configuration to take affect.");
143
		?>
144
	</form>
145
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
146
		<tr>
147 ab3c8553 Matthew Grooms
			<td>
148 df81417f Matthew Grooms
				<?php
149
					$tab_array = array();
150
					$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
151
					$tab_array[] = array("Firewall / NAT", false, "system_advanced_firewall.php");
152
					$tab_array[] = array("Networking", false, "system_advanced_network.php");
153
					$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
154
					$tab_array[] = array("System Tunables", true, "system_advanced_sysctl.php");
155 487b16ec Scott Ullrich
					$tab_array[] = array("Notifications", false, "system_advanced_notifications.php");
156 df81417f Matthew Grooms
					display_top_tabs($tab_array);
157
				?>
158
			</td>
159
		</tr>
160
		<?php if ($act != "edit" ): ?>
161
		<tr>
162 2ff19bfd Matthew Grooms
			<td id="mainarea">
163
				<div class="tabcont">
164
					<span class="vexpl">
165
						<span class="red">
166
							<strong>NOTE:&nbsp</strong>
167
						</span>
168
						The options on this page are intended for use by advanced users only.
169
						<br/>
170
					</span>
171
					<br/>
172
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
173 df81417f Matthew Grooms
						<tr>
174 ab3c8553 Matthew Grooms
							<td width="20%" class="listhdrr">Tunable Name</td>
175
							<td width="60%" class="listhdrr">Description</td>
176
							<td width="20%" class="listhdrr">Value</td>
177 df81417f Matthew Grooms
						</tr>
178 ab3c8553 Matthew Grooms
						<?php $i = 0; foreach ($config['sysctl']['item'] as $tunable): ?>
179 df81417f Matthew Grooms
						<tr>
180 b6b53776 Scott Ullrich
							<td class="listlr" ondblclick="document.location='system_advanced_sysctl.php?id=<?=$i;?>';">
181 ab3c8553 Matthew Grooms
								<?php echo $tunable['tunable']; ?>
182 df81417f Matthew Grooms
							</td>
183 b6b53776 Scott Ullrich
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?id=<?=$i;?>';">
184 ab3c8553 Matthew Grooms
								<?php echo $tunable['desc']; ?>
185 df81417f Matthew Grooms
							</td>
186 b6b53776 Scott Ullrich
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?id=<?=$i;?>';">
187 ab3c8553 Matthew Grooms
								<?php echo $tunable['value']; ?>
188 45849d22 sullrich
								<?php 
189
									if($tunable['value'] == "default") 
190
										echo "(" . get_default_sysctl_value($tunable['tunable']) . ")"; 
191
								?>
192 ab3c8553 Matthew Grooms
							</td>
193
							<td class="list" nowrap>
194
								<table border="0" cellspacing="0" cellpadding="1">
195
									<tr>
196
										<td valign="middle">
197
											<a href="system_advanced_sysctl.php?act=edit&id=<?=$i;?>">
198
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
199
											</a>
200
										</td>
201
										<td valign="middle">
202
											<a href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')">
203
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
204
											</a>
205
										</td>
206
									</tr>
207
								</table>
208 df81417f Matthew Grooms
							</td>
209
						</tr>
210 ab3c8553 Matthew Grooms
						<?php $i++; endforeach; ?>
211 df81417f Matthew Grooms
						<tr>
212 ab3c8553 Matthew Grooms
						<td class="list" colspan="3">
213
							</td>
214
							<td class="list">
215
								<table border="0" cellspacing="0" cellpadding="1">
216
									<tr>
217
										<td valign="middle">
218 faf158b1 Scott Ullrich
											<a href="system_advanced_sysctl.php?act=edit">
219 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
220
											</a>
221
										</td>
222
									</tr>
223
								</table>
224 df81417f Matthew Grooms
							</td>
225
						</tr>
226
					</table>
227 ab3c8553 Matthew Grooms
				</div>
228
			</td>
229
		</tr>
230
		<? else: ?>
231
		<tr>
232
			<td>
233
				<div id="mainarea">
234
					<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
235
						<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
236
							<tr>
237
								<td colspan="2" valign="top" class="listtopic">Edit system tunable</td>
238
							</tr>
239
							<tr>
240
								<td width="22%" valign="top" class="vncellreq">Tunable</td>
241
								<td width="78%" class="vtable">
242
									<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>">
243
								</td>
244
							</tr>
245
							<tr>
246
								<td width="22%" valign="top" class="vncellreq">Description</td>
247
								<td width="78%" class="vtable">
248
									<textarea rows="7" cols="50" name="desc"><?php echo $pconfig['desc']; ?></textarea>
249
								</td>
250
							</tr>
251
							<tr>
252
								<td width="22%" valign="top" class="vncellreq">Value</td>
253
								<td width="78%" class="vtable">
254
									<input size="65" name="value" value="<?php echo $pconfig['value']; ?>">
255
								</td>
256
							</tr>
257
							<tr>
258
								<td width="22%" valign="top">&nbsp;</td>
259
								<td width="78%">
260
									<input id="submit" name="Submit" type="submit" class="formbtn" value="Save" />
261
									<input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
262
									<?php if (isset($id) && $a_tunable[$id]): ?>
263
									<input name="id" type="hidden" value="<?=$id;?>" />
264
									<?php endif; ?>
265
								</td>
266
							</tr>
267
						</table>
268
					</form>
269
				</div>
270 df81417f Matthew Grooms
			</td>
271
		</tr>
272
		<? endif; ?>
273
	</table>
274
<?php include("fend.inc"); ?>
275
</body>
276
</html>