Project

General

Profile

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