Project

General

Profile

Download (6.77 KB) Statistics
| Branch: | Tag: | Revision:
1 df81417f Matthew Grooms
<?php
2
/* $Id$ */
3
/*
4 ce77a9c4 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 ce77a9c4 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 3412275d Thane Gill
	2. Redistributions in binary form must reproduce the above copyright notice,
21
	   this list of conditions and the following disclaimer in the documentation
22
	   and/or other materials provided with the distribution.
23 df81417f Matthew Grooms
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 3412275d Thane Gill
if (!is_array($config['sysctl'])) {
49 d87fcac9 Ermal
	$config['sysctl'] = array();
50 3412275d Thane Gill
}
51
if (!is_array($config['sysctl']['item'])) {
52 df81417f Matthew Grooms
	$config['sysctl']['item'] = array();
53 3412275d Thane Gill
}
54 df81417f Matthew Grooms
55
$a_tunable = &$config['sysctl']['item'];
56 d87fcac9 Ermal
$tunables = system_get_sysctls();
57 df81417f Matthew Grooms
58 3412275d Thane Gill
if (isset($_GET['id'])) {
59 d87fcac9 Ermal
	$id = htmlspecialchars_decode($_GET['id']);
60 3412275d Thane Gill
}
61
if (isset($_POST['id'])) {
62 d87fcac9 Ermal
	$id = htmlspecialchars_decode($_POST['id']);
63 3412275d Thane Gill
}
64 df81417f Matthew Grooms
$act = $_GET['act'];
65 3412275d Thane Gill
if (isset($_POST['act'])) {
66 df81417f Matthew Grooms
	$act = $_POST['act'];
67 3412275d Thane Gill
}
68 df81417f Matthew Grooms
if ($act == "edit") {
69 d87fcac9 Ermal
	if (isset($a_tunable[$id])) {
70 df81417f Matthew Grooms
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
71
		$pconfig['value'] = $a_tunable[$id]['value'];
72 15864861 jim-p
		$pconfig['descr'] = $a_tunable[$id]['descr'];
73 d87fcac9 Ermal
	} else if (isset($tunables[$id])) {
74
		$pconfig['tunable'] = $tunables[$id]['tunable'];
75
		$pconfig['value'] = $tunables[$id]['value'];
76
		$pconfig['descr'] = $tunables[$id]['descr'];
77 df81417f Matthew Grooms
	}
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
	unset($input_errors);
98
	$pconfig = $_POST;
99
100
	/* if this is an AJAX caller then handle via JSON */
101
	if (isAjax() && is_array($input_errors)) {
102
		input_errors2Ajax($input_errors);
103
		exit;
104
	}
105
106
	if ($_POST['apply']) {
107
		$retval = 0;
108 3412275d Thane Gill
		system_setup_sysctl();
109 df81417f Matthew Grooms
		$savemsg = get_std_save_message($retval);
110 a368a026 Ermal Lu?i
		clear_subsystem_dirty('sysctl');
111 df81417f Matthew Grooms
	}
112
113 18464b74 Carlos Eduardo Ramos
	if ($_POST['Submit'] == gettext("Save")) {
114 df81417f Matthew Grooms
		$tunableent = array();
115
116
		$tunableent['tunable'] = $_POST['tunable'];
117
		$tunableent['value'] = $_POST['value'];
118 15864861 jim-p
		$tunableent['descr'] = $_POST['descr'];
119 df81417f Matthew Grooms
120 3412275d Thane Gill
		if (isset($id) && isset($a_tunable[$id])) {
121 df81417f Matthew Grooms
			$a_tunable[$id] = $tunableent;
122 3412275d Thane Gill
		} else {
123 df81417f Matthew Grooms
			$a_tunable[] = $tunableent;
124 3412275d Thane Gill
		}
125 df81417f Matthew Grooms
126 a368a026 Ermal Lu?i
		mark_subsystem_dirty('sysctl');
127 df81417f Matthew Grooms
		write_config();
128
		pfSenseHeader("system_advanced_sysctl.php");
129
		exit;
130 3412275d Thane Gill
	}
131 df81417f Matthew Grooms
}
132
133 87ae1a2b jim-p
$pgtitle = array(gettext("System"),gettext("Advanced: System Tunables"));
134 df81417f Matthew Grooms
include("head.inc");
135
136 3412275d Thane Gill
if ($input_errors)
137
	print_input_errors($input_errors);
138
if ($savemsg)
139
	print_info_box($savemsg);
140
if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
141
	print_info_box_np(gettext("The firewall tunables have changed. You must apply the configuration to take affect."));
142
143
$tab_array = array();
144
$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
145
$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
146
$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
147
$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
148
$tab_array[] = array(gettext("System Tunables"), true, "system_advanced_sysctl.php");
149
$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
150
display_top_tabs($tab_array);
151
152
if ($act != "edit" ): ?>
153
<div class="panel panel-default">
154
	<div class="panel-heading">
155
		<h2 class="panel-title"><?=gettext('System Tunables'); ?></h2>
156
	</div>
157
	<div class="panel-body">
158
		<div class="form-group">
159
			<table class="table table-responsive table-hover table-condensed">
160
				<caption><strong><?=gettext('NOTE: '); ?></strong><?=gettext('The options on this page are intended for use by advanced users only.'); ?></caption>
161
				<thead>
162
					<tr>
163
						<th class="col-sm-3"><?=gettext("Tunable Name"); ?></th>
164
						<th><?=gettext("Description"); ?></th>
165
						<th class="col-sm-1"><?=gettext("Value"); ?></th>
166
						<th><a class="btn btn-xs btn-primary" href="system_advanced_sysctl.php?act=edit"><?=gettext('New'); ?></a></th>
167
					</tr>
168
				</thead>
169
				<?php foreach ($tunables as $i => $tunable):
170
					if (!isset($tunable['modified']))
171
						$i = $tunable['tunable']; ?>
172
				<tr>
173
					<td><?=$tunable['tunable']; ?></td>
174
					<td><?=$tunable['descr']; ?></td>
175
					<td><?=$tunable['value']; ?>
176
					<?php if($tunable['value'] == "default")
177
						echo "(" . get_default_sysctl_value($tunable['tunable']) . ")"; ?>
178
					</td>
179
					<td>
180
					<a class="btn btn-xs btn-primary" href="system_advanced_sysctl.php?act=edit&amp;id=<?=$i;?>"><?=gettext('Edit'); ?></a>
181
						<?php if (isset($tunable['modified'])): ?>
182 45d6ada5 Sjon Hortensius
						<a class="btn btn-xs btn-danger" href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>"><?=gettext('Delete/Reset'); ?></a>
183 3412275d Thane Gill
						<?php endif; ?>
184
					</td>
185
				</tr>
186 df81417f Matthew Grooms
				<?php
187 3412275d Thane Gill
					endforeach;
188
					unset($tunables);
189 df81417f Matthew Grooms
				?>
190 3412275d Thane Gill
			</table>
191
		</div>
192
	</div>
193
</div>
194
195
<?php else:
196
	require('classes/Form.class.php');
197
	$form = new Form;
198
	$section = new Form_Section('Edit Tunable');
199
200
	$section->addInput(new Form_Input(
201 a97531c5 Sjon Hortensius
		'tunable',
202 3412275d Thane Gill
		'Tunable',
203
		'text',
204
		$pconfig['tunable']
205
	))->setWidth(4);
206
207
	$section->addInput(new Form_Input(
208 a97531c5 Sjon Hortensius
		'descr',
209 3412275d Thane Gill
		'Description',
210
		'text',
211
		$pconfig['descr']
212 a97531c5 Sjon Hortensius
	))->setWidth(4);
213 3412275d Thane Gill
214
	$section->addInput(new Form_Input(
215 a97531c5 Sjon Hortensius
		'value',
216 3412275d Thane Gill
		'Value',
217
		'text',
218
		$pconfig['value']
219
	))->setWidth(4);
220
221
	if (isset($id) && $a_tunable[$id]) {
222 ab9028d8 Sjon Hortensius
		$form->addGlobal(new Form_Input(
223 a97531c5 Sjon Hortensius
			'id',
224 3412275d Thane Gill
			'id',
225
			'hidden',
226 a542a625 Sjon Hortensius
			$id
227 3412275d Thane Gill
		));
228
	}
229
230
	$form->add($section);
231 b125fab2 Sjon Hortensius
232 3412275d Thane Gill
	print $form;
233
234
endif;
235
236 a542a625 Sjon Hortensius
include("fend.inc");