Project

General

Profile

Download (9.49 KB) Statistics
| Branch: | Tag: | Revision:
1 df81417f Matthew Grooms
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_misc.php
5
	part of pfSense
6 dd447bde Jim Thompson
	Copyright (C) 2005-2007 Scott Ullrich
7 29aef6c4 Jim Thompson
	Copyright (C) 2008 Shrew Soft Inc
8
        Copyright (C) 2013-2014 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
							</td>
200 a5a61609 Colin Fleming
							<td class="list nowrap">
201
								<table border="0" cellspacing="0" cellpadding="1" summary="edit delete">
202 ab3c8553 Matthew Grooms
									<tr>
203
										<td valign="middle">
204 a5a61609 Colin Fleming
											<a href="system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>">
205 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
206
											</a>
207
										</td>
208 d87fcac9 Ermal
							<?php if (isset($tunable['modified'])): ?>
209 ab3c8553 Matthew Grooms
										<td valign="middle">
210 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?"); ?>')">
211 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
212
											</a>
213
										</td>
214 d87fcac9 Ermal
							<?php endif; ?>
215 ab3c8553 Matthew Grooms
									</tr>
216
								</table>
217 df81417f Matthew Grooms
							</td>
218
						</tr>
219 d87fcac9 Ermal
						<?php endforeach; unset($tunables); ?>
220 df81417f Matthew Grooms
						<tr>
221 ab3c8553 Matthew Grooms
						<td class="list" colspan="3">
222
							</td>
223
							<td class="list">
224 a5a61609 Colin Fleming
								<table border="0" cellspacing="0" cellpadding="1" summary="edit">
225 ab3c8553 Matthew Grooms
									<tr>
226
										<td valign="middle">
227 faf158b1 Scott Ullrich
											<a href="system_advanced_sysctl.php?act=edit">
228 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
229
											</a>
230
										</td>
231
									</tr>
232
								</table>
233 df81417f Matthew Grooms
							</td>
234
						</tr>
235
					</table>
236 ab3c8553 Matthew Grooms
				</div>
237
			</td>
238
		</tr>
239 ee9933b6 Renato Botelho
		<?php else: ?>
240 ab3c8553 Matthew Grooms
		<tr>
241
			<td>
242
				<div id="mainarea">
243
					<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
244 a5a61609 Colin Fleming
						<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="edit system tunable">
245 ab3c8553 Matthew Grooms
							<tr>
246 18464b74 Carlos Eduardo Ramos
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit system tunable"); ?></td>
247 ab3c8553 Matthew Grooms
							</tr>
248
							<tr>
249 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Tunable"); ?></td>
250 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
251 a5a61609 Colin Fleming
									<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>" />
252 ab3c8553 Matthew Grooms
								</td>
253
							</tr>
254
							<tr>
255 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td>
256 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
257 15864861 jim-p
									<textarea rows="7" cols="50" name="descr"><?php echo $pconfig['descr']; ?></textarea>
258 ab3c8553 Matthew Grooms
								</td>
259
							</tr>
260
							<tr>
261 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Value"); ?></td>
262 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
263 a5a61609 Colin Fleming
									<input size="65" name="value" value="<?php echo $pconfig['value']; ?>" />
264 ab3c8553 Matthew Grooms
								</td>
265
							</tr>
266
							<tr>
267
								<td width="22%" valign="top">&nbsp;</td>
268
								<td width="78%">
269 18464b74 Carlos Eduardo Ramos
									<input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
270 62424bdb Renato Botelho
									<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
271 ab3c8553 Matthew Grooms
									<?php if (isset($id) && $a_tunable[$id]): ?>
272 e41ec584 Renato Botelho
									<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
273 ab3c8553 Matthew Grooms
									<?php endif; ?>
274
								</td>
275
							</tr>
276
						</table>
277
					</form>
278
				</div>
279 df81417f Matthew Grooms
			</td>
280
		</tr>
281 ee9933b6 Renato Botelho
		<?php endif; ?>
282 df81417f Matthew Grooms
	</table>
283
<?php include("fend.inc"); ?>
284
</body>
285
</html>