Project

General

Profile

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