Project

General

Profile

Download (8.96 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 7997ed44 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
$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 15864861 jim-p
		$pconfig['descr'] = $a_tunable[$id]['descr'];
66 df81417f Matthew Grooms
	}
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 25f36aaf Erik Fonnesbeck
			pfSenseHeader("system_advanced_sysctl.php");
81 df81417f Matthew Grooms
			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 18464b74 Carlos Eduardo Ramos
	if ($_POST['Submit'] == gettext("Save")) {
105 df81417f Matthew Grooms
		$tunableent = array();
106
107
		$tunableent['tunable'] = $_POST['tunable'];
108
		$tunableent['value'] = $_POST['value'];
109 15864861 jim-p
		$tunableent['descr'] = $_POST['descr'];
110 df81417f Matthew Grooms
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 87ae1a2b jim-p
$pgtitle = array(gettext("System"),gettext("Advanced: System Tunables"));
126 df81417f Matthew Grooms
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 a368a026 Ermal Lu?i
			if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
139 18464b74 Carlos Eduardo Ramos
				print_info_box_np(gettext("The firewall tunables have changed.  You must apply the configuration to take affect."));
140 df81417f Matthew Grooms
		?>
141
	</form>
142 a5a61609 Colin Fleming
	<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced tunables">
143 df81417f Matthew Grooms
		<tr>
144 ab3c8553 Matthew Grooms
			<td>
145 df81417f Matthew Grooms
				<?php
146
					$tab_array = array();
147 18464b74 Carlos Eduardo Ramos
					$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
148
					$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
149
					$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
150
					$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
151
					$tab_array[] = array(gettext("System Tunables"), true, "system_advanced_sysctl.php");
152
					$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
153 df81417f Matthew Grooms
					display_top_tabs($tab_array);
154
				?>
155
			</td>
156
		</tr>
157
		<?php if ($act != "edit" ): ?>
158
		<tr>
159 2ff19bfd Matthew Grooms
			<td id="mainarea">
160
				<div class="tabcont">
161
					<span class="vexpl">
162
						<span class="red">
163 a5a61609 Colin Fleming
							<strong><?=gettext("NOTE:"); ?>&nbsp;</strong>
164 2ff19bfd Matthew Grooms
						</span>
165 18464b74 Carlos Eduardo Ramos
						<?=gettext("The options on this page are intended for use by advanced users only."); ?>
166 2ff19bfd Matthew Grooms
						<br/>
167
					</span>
168
					<br/>
169 a5a61609 Colin Fleming
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
170 df81417f Matthew Grooms
						<tr>
171 18464b74 Carlos Eduardo Ramos
							<td width="20%" class="listhdrr"><?=gettext("Tunable Name"); ?></td>
172
							<td width="60%" class="listhdrr"><?=gettext("Description"); ?></td>
173
							<td width="20%" class="listhdrr"><?=gettext("Value"); ?></td>
174 df81417f Matthew Grooms
						</tr>
175 ab3c8553 Matthew Grooms
						<?php $i = 0; foreach ($config['sysctl']['item'] as $tunable): ?>
176 df81417f Matthew Grooms
						<tr>
177 a5a61609 Colin Fleming
							<td class="listlr" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
178 ab3c8553 Matthew Grooms
								<?php echo $tunable['tunable']; ?>
179 df81417f Matthew Grooms
							</td>
180 a5a61609 Colin Fleming
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
181 15864861 jim-p
								<?php echo $tunable['descr']; ?>
182 df81417f Matthew Grooms
							</td>
183 a5a61609 Colin Fleming
							<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>';">
184 ab3c8553 Matthew Grooms
								<?php echo $tunable['value']; ?>
185 45849d22 sullrich
								<?php 
186
									if($tunable['value'] == "default") 
187
										echo "(" . get_default_sysctl_value($tunable['tunable']) . ")"; 
188
								?>
189 ab3c8553 Matthew Grooms
							</td>
190 a5a61609 Colin Fleming
							<td class="list nowrap">
191
								<table border="0" cellspacing="0" cellpadding="1" summary="edit delete">
192 ab3c8553 Matthew Grooms
									<tr>
193
										<td valign="middle">
194 a5a61609 Colin Fleming
											<a href="system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>">
195 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
196
											</a>
197
										</td>
198
										<td valign="middle">
199 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?"); ?>')">
200 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
201
											</a>
202
										</td>
203
									</tr>
204
								</table>
205 df81417f Matthew Grooms
							</td>
206
						</tr>
207 ab3c8553 Matthew Grooms
						<?php $i++; endforeach; ?>
208 df81417f Matthew Grooms
						<tr>
209 ab3c8553 Matthew Grooms
						<td class="list" colspan="3">
210
							</td>
211
							<td class="list">
212 a5a61609 Colin Fleming
								<table border="0" cellspacing="0" cellpadding="1" summary="edit">
213 ab3c8553 Matthew Grooms
									<tr>
214
										<td valign="middle">
215 faf158b1 Scott Ullrich
											<a href="system_advanced_sysctl.php?act=edit">
216 ab3c8553 Matthew Grooms
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
217
											</a>
218
										</td>
219
									</tr>
220
								</table>
221 df81417f Matthew Grooms
							</td>
222
						</tr>
223
					</table>
224 ab3c8553 Matthew Grooms
				</div>
225
			</td>
226
		</tr>
227 ee9933b6 Renato Botelho
		<?php else: ?>
228 ab3c8553 Matthew Grooms
		<tr>
229
			<td>
230
				<div id="mainarea">
231
					<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
232 a5a61609 Colin Fleming
						<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="edit system tunable">
233 ab3c8553 Matthew Grooms
							<tr>
234 18464b74 Carlos Eduardo Ramos
								<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit system tunable"); ?></td>
235 ab3c8553 Matthew Grooms
							</tr>
236
							<tr>
237 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Tunable"); ?></td>
238 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
239 a5a61609 Colin Fleming
									<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>" />
240 ab3c8553 Matthew Grooms
								</td>
241
							</tr>
242
							<tr>
243 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td>
244 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
245 15864861 jim-p
									<textarea rows="7" cols="50" name="descr"><?php echo $pconfig['descr']; ?></textarea>
246 ab3c8553 Matthew Grooms
								</td>
247
							</tr>
248
							<tr>
249 18464b74 Carlos Eduardo Ramos
								<td width="22%" valign="top" class="vncellreq"><?=gettext("Value"); ?></td>
250 ab3c8553 Matthew Grooms
								<td width="78%" class="vtable">
251 a5a61609 Colin Fleming
									<input size="65" name="value" value="<?php echo $pconfig['value']; ?>" />
252 ab3c8553 Matthew Grooms
								</td>
253
							</tr>
254
							<tr>
255
								<td width="22%" valign="top">&nbsp;</td>
256
								<td width="78%">
257 18464b74 Carlos Eduardo Ramos
									<input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
258
									<input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" onclick="history.back()" />
259 ab3c8553 Matthew Grooms
									<?php if (isset($id) && $a_tunable[$id]): ?>
260
									<input name="id" type="hidden" value="<?=$id;?>" />
261
									<?php endif; ?>
262
								</td>
263
							</tr>
264
						</table>
265
					</form>
266
				</div>
267 df81417f Matthew Grooms
			</td>
268
		</tr>
269 ee9933b6 Renato Botelho
		<?php endif; ?>
270 df81417f Matthew Grooms
	</table>
271
<?php include("fend.inc"); ?>
272
</body>
273
</html>