Project

General

Profile

Download (9.63 KB) Statistics
| Branch: | Tag: | Revision:
1 df81417f Matthew Grooms
<?php
2
/* $Id$ */
3
/*
4 6317d31d Phil Davis
	system_advanced_sysctl.php
5 df81417f Matthew Grooms
	part of pfSense
6 dd447bde Jim Thompson
	Copyright (C) 2005-2007 Scott Ullrich
7 29aef6c4 Jim Thompson
	Copyright (C) 2008 Shrew Soft Inc
8 6317d31d Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 df81417f Matthew Grooms
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 7997ed44 Renato Botelho
##|*MATCH=system_advanced_sysctl.php*
44 df81417f Matthew Grooms
##|-PRIV
45
46
require("guiconfig.inc");
47
48 62424bdb Renato Botelho
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_advanced_sysctl.php');
49
50 d87fcac9 Ermal
if (!is_array($config['sysctl']))
51
	$config['sysctl'] = array();
52 df81417f Matthew Grooms
if (!is_array($config['sysctl']['item']))
53
	$config['sysctl']['item'] = array();
54
55
$a_tunable = &$config['sysctl']['item'];
56 d87fcac9 Ermal
$tunables = system_get_sysctls();
57 df81417f Matthew Grooms
58 d87fcac9 Ermal
if (isset($_GET['id']))
59
	$id = htmlspecialchars_decode($_GET['id']);
60
if (isset($_POST['id']))
61
	$id = htmlspecialchars_decode($_POST['id']);
62 df81417f Matthew Grooms
63
$act = $_GET['act'];
64
if (isset($_POST['act']))
65
	$act = $_POST['act'];
66
67
if ($act == "edit") {
68 d87fcac9 Ermal
	if (isset($a_tunable[$id])) {
69 df81417f Matthew Grooms
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
70
		$pconfig['value'] = $a_tunable[$id]['value'];
71 15864861 jim-p
		$pconfig['descr'] = $a_tunable[$id]['descr'];
72 d87fcac9 Ermal
	} else if (isset($tunables[$id])) {
73
		$pconfig['tunable'] = $tunables[$id]['tunable'];
74
		$pconfig['value'] = $tunables[$id]['value'];
75
		$pconfig['descr'] = $tunables[$id]['descr'];
76 df81417f Matthew Grooms
	}
77
}
78
79
if ($act == "del") {
80
	if ($a_tunable[$id]) {
81
		/* if this is an AJAX caller then handle via JSON */
82
		if(isAjax() && is_array($input_errors)) {
83
			input_errors2Ajax($input_errors);
84
			exit;
85
		}
86
		if (!$input_errors) {
87
			unset($a_tunable[$id]);
88
			write_config();
89 a368a026 Ermal Lu?i
			mark_subsystem_dirty('sysctl');
90 25f36aaf Erik Fonnesbeck
			pfSenseHeader("system_advanced_sysctl.php");
91 df81417f Matthew Grooms
			exit;
92
		}
93
	}
94
}
95
96
if ($_POST) {
97
98
	unset($input_errors);
99
	$pconfig = $_POST;
100
101
	/* if this is an AJAX caller then handle via JSON */
102
	if (isAjax() && is_array($input_errors)) {
103
		input_errors2Ajax($input_errors);
104
		exit;
105
	}
106
107
	if ($_POST['apply']) {
108
		$retval = 0;
109 0a9251d2 Scott Ullrich
		system_setup_sysctl();		
110 df81417f Matthew Grooms
		$savemsg = get_std_save_message($retval);
111 a368a026 Ermal Lu?i
		clear_subsystem_dirty('sysctl');
112 df81417f Matthew Grooms
	}
113
114 18464b74 Carlos Eduardo Ramos
	if ($_POST['Submit'] == gettext("Save")) {
115 df81417f Matthew Grooms
		$tunableent = array();
116
117
		$tunableent['tunable'] = $_POST['tunable'];
118
		$tunableent['value'] = $_POST['value'];
119 15864861 jim-p
		$tunableent['descr'] = $_POST['descr'];
120 df81417f Matthew Grooms
121 d87fcac9 Ermal
		if (isset($id) && isset($a_tunable[$id]))
122 df81417f Matthew Grooms
			$a_tunable[$id] = $tunableent;
123
		else
124
			$a_tunable[] = $tunableent;
125
126 a368a026 Ermal Lu?i
		mark_subsystem_dirty('sysctl');
127 df81417f Matthew Grooms
128
		write_config();
129
130
		pfSenseHeader("system_advanced_sysctl.php");
131
		exit;
132
    }
133
}
134
135 87ae1a2b jim-p
$pgtitle = array(gettext("System"),gettext("Advanced: System Tunables"));
136 df81417f Matthew Grooms
include("head.inc");
137
138
?>
139
140
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
141
<?php include("fbegin.inc"); ?>
142
	<form action="system_advanced_sysctl.php" method="post">
143
		<?php
144
			if ($input_errors)
145
				print_input_errors($input_errors);
146
			if ($savemsg)
147
				print_info_box($savemsg);
148 a368a026 Ermal Lu?i
			if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
149 18464b74 Carlos Eduardo Ramos
				print_info_box_np(gettext("The firewall tunables have changed.  You must apply the configuration to take affect."));
150 df81417f Matthew Grooms
		?>
151
	</form>
152 a5a61609 Colin Fleming
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced tunables">
153 df81417f Matthew Grooms
		<tr>
154 ab3c8553 Matthew Grooms
			<td>
155 df81417f Matthew Grooms
				<?php
156
					$tab_array = array();
157 18464b74 Carlos Eduardo Ramos
					$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
158
					$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
159
					$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
160
					$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
161
					$tab_array[] = array(gettext("System Tunables"), true, "system_advanced_sysctl.php");
162
					$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
163 df81417f Matthew Grooms
					display_top_tabs($tab_array);
164
				?>
165
			</td>
166
		</tr>
167
		<?php if ($act != "edit" ): ?>
168
		<tr>
169 2ff19bfd Matthew Grooms
			<td id="mainarea">
170
				<div class="tabcont">
171
					<span class="vexpl">
172
						<span class="red">
173 a5a61609 Colin Fleming
							<strong><?=gettext("NOTE:"); ?>&nbsp;</strong>
174 2ff19bfd Matthew Grooms
						</span>
175 18464b74 Carlos Eduardo Ramos
						<?=gettext("The options on this page are intended for use by advanced users only."); ?>
176 8cd558b6 ayvis
						<br />
177 2ff19bfd Matthew Grooms
					</span>
178 8cd558b6 ayvis
					<br />
179 a5a61609 Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
180 df81417f Matthew Grooms
						<tr>
181 18464b74 Carlos Eduardo Ramos
							<td width="20%" class="listhdrr"><?=gettext("Tunable Name"); ?></td>
182
							<td width="60%" class="listhdrr"><?=gettext("Description"); ?></td>
183
							<td width="20%" class="listhdrr"><?=gettext("Value"); ?></td>
184 df81417f Matthew Grooms
						</tr>
185 d87fcac9 Ermal
						<?php foreach ($tunables as $i => $tunable):
186
187
								if (!isset($tunable['modified']))
188
									$i = $tunable['tunable'];
189
						?>
190 df81417f Matthew Grooms
						<tr>
191 a5a61609 Colin Fleming
							<td class="listlr" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
192 ab3c8553 Matthew Grooms
								<?php echo $tunable['tunable']; ?>
193 df81417f Matthew Grooms
							</td>
194 a5a61609 Colin Fleming
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
195 15864861 jim-p
								<?php echo $tunable['descr']; ?>
196 df81417f Matthew Grooms
							</td>
197 a5a61609 Colin Fleming
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
198 ab3c8553 Matthew Grooms
								<?php echo $tunable['value']; ?>
199 ab54ec9f Chris Buechler
								<?php 
200
									if($tunable['value'] == "default") 
201
										echo "(" . get_default_sysctl_value($tunable['tunable']) . ")"; 
202
								?>
203 ab3c8553 Matthew Grooms
							</td>
204 a5a61609 Colin Fleming
							<td class="list nowrap">
205
								<table border="0" cellspacing="0" cellpadding="1" summary="edit delete">
206 ab3c8553 Matthew Grooms
									<tr>
207
										<td valign="middle">
208 a5a61609 Colin Fleming
											<a href="system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>">
209 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
210
											</a>
211
										</td>
212 d87fcac9 Ermal
							<?php if (isset($tunable['modified'])): ?>
213 ab3c8553 Matthew Grooms
										<td valign="middle">
214 18464b74 Carlos Eduardo Ramos
											<a href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?"); ?>')">
215 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
216
											</a>
217
										</td>
218 d87fcac9 Ermal
							<?php endif; ?>
219 ab3c8553 Matthew Grooms
									</tr>
220
								</table>
221 df81417f Matthew Grooms
							</td>
222
						</tr>
223 d87fcac9 Ermal
						<?php endforeach; unset($tunables); ?>
224 df81417f Matthew Grooms
						<tr>
225 ab3c8553 Matthew Grooms
						<td class="list" colspan="3">
226
							</td>
227
							<td class="list">
228 a5a61609 Colin Fleming
								<table border="0" cellspacing="0" cellpadding="1" summary="edit">
229 ab3c8553 Matthew Grooms
									<tr>
230
										<td valign="middle">
231 faf158b1 Scott Ullrich
											<a href="system_advanced_sysctl.php?act=edit">
232 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
233
											</a>
234
										</td>
235
									</tr>
236
								</table>
237 df81417f Matthew Grooms
							</td>
238
						</tr>
239
					</table>
240 ab3c8553 Matthew Grooms
				</div>
241
			</td>
242
		</tr>
243 ee9933b6 Renato Botelho
		<?php else: ?>
244 ab3c8553 Matthew Grooms
		<tr>
245
			<td>
246
				<div id="mainarea">
247
					<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
248 a5a61609 Colin Fleming
						<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="edit system tunable">
249 ab3c8553 Matthew Grooms
							<tr>
250 18464b74 Carlos Eduardo Ramos
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit system tunable"); ?></td>
251 ab3c8553 Matthew Grooms
							</tr>
252
							<tr>
253 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Tunable"); ?></td>
254 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
255 a5a61609 Colin Fleming
									<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>" />
256 ab3c8553 Matthew Grooms
								</td>
257
							</tr>
258
							<tr>
259 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td>
260 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
261 15864861 jim-p
									<textarea rows="7" cols="50" name="descr"><?php echo $pconfig['descr']; ?></textarea>
262 ab3c8553 Matthew Grooms
								</td>
263
							</tr>
264
							<tr>
265 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Value"); ?></td>
266 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
267 a5a61609 Colin Fleming
									<input size="65" name="value" value="<?php echo $pconfig['value']; ?>" />
268 ab3c8553 Matthew Grooms
								</td>
269
							</tr>
270
							<tr>
271
								<td width="22%" valign="top">&nbsp;</td>
272
								<td width="78%">
273 18464b74 Carlos Eduardo Ramos
									<input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
274 62424bdb Renato Botelho
									<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
275 ab3c8553 Matthew Grooms
									<?php if (isset($id) && $a_tunable[$id]): ?>
276 e41ec584 Renato Botelho
									<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
277 ab3c8553 Matthew Grooms
									<?php endif; ?>
278
								</td>
279
							</tr>
280
						</table>
281
					</form>
282
				</div>
283 df81417f Matthew Grooms
			</td>
284
		</tr>
285 ee9933b6 Renato Botelho
		<?php endif; ?>
286 df81417f Matthew Grooms
	</table>
287
<?php include("fend.inc"); ?>
288
</body>
289
</html>