Project

General

Profile

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