Project

General

Profile

Download (6.77 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_sysctl.php
5
	part of pfSense
6
	Copyright (C) 2005-2007 Scott Ullrich
7
	Copyright (C) 2008 Shrew Soft Inc
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
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 notice,
21
	   this list of conditions and the following disclaimer in the documentation
22
	   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
/*
36
	pfSense_MODULE:	system
37
*/
38

    
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
##|*MATCH=system_advanced_sysctl.php*
44
##|-PRIV
45

    
46
require("guiconfig.inc");
47

    
48
if (!is_array($config['sysctl'])) {
49
	$config['sysctl'] = array();
50
}
51
if (!is_array($config['sysctl']['item'])) {
52
	$config['sysctl']['item'] = array();
53
}
54

    
55
$a_tunable = &$config['sysctl']['item'];
56
$tunables = system_get_sysctls();
57

    
58
if (isset($_GET['id'])) {
59
	$id = htmlspecialchars_decode($_GET['id']);
60
}
61
if (isset($_POST['id'])) {
62
	$id = htmlspecialchars_decode($_POST['id']);
63
}
64
$act = $_GET['act'];
65
if (isset($_POST['act'])) {
66
	$act = $_POST['act'];
67
}
68
if ($act == "edit") {
69
	if (isset($a_tunable[$id])) {
70
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
71
		$pconfig['value'] = $a_tunable[$id]['value'];
72
		$pconfig['descr'] = $a_tunable[$id]['descr'];
73
	} else if (isset($tunables[$id])) {
74
		$pconfig['tunable'] = $tunables[$id]['tunable'];
75
		$pconfig['value'] = $tunables[$id]['value'];
76
		$pconfig['descr'] = $tunables[$id]['descr'];
77
	}
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
			mark_subsystem_dirty('sysctl');
90
			pfSenseHeader("system_advanced_sysctl.php");
91
			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
		system_setup_sysctl();
109
		$savemsg = get_std_save_message($retval);
110
		clear_subsystem_dirty('sysctl');
111
	}
112

    
113
	if ($_POST['Submit'] == gettext("Save")) {
114
		$tunableent = array();
115

    
116
		$tunableent['tunable'] = $_POST['tunable'];
117
		$tunableent['value'] = $_POST['value'];
118
		$tunableent['descr'] = $_POST['descr'];
119

    
120
		if (isset($id) && isset($a_tunable[$id])) {
121
			$a_tunable[$id] = $tunableent;
122
		} else {
123
			$a_tunable[] = $tunableent;
124
		}
125

    
126
		mark_subsystem_dirty('sysctl');
127
		write_config();
128
		pfSenseHeader("system_advanced_sysctl.php");
129
		exit;
130
	}
131
}
132

    
133
$pgtitle = array(gettext("System"),gettext("Advanced: System Tunables"));
134
include("head.inc");
135

    
136
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
						<a class="btn btn-xs btn-danger" href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>"><?=gettext('Delete/Reset'); ?></a>
183
						<?php endif; ?>
184
					</td>
185
				</tr>
186
				<?php
187
					endforeach;
188
					unset($tunables);
189
				?>
190
			</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
		'tunable',
202
		'Tunable',
203
		'text',
204
		$pconfig['tunable']
205
	))->setWidth(4);
206

    
207
	$section->addInput(new Form_Input(
208
		'descr',
209
		'Description',
210
		'text',
211
		$pconfig['descr']
212
	))->setWidth(4);
213

    
214
	$section->addInput(new Form_Input(
215
		'value',
216
		'Value',
217
		'text',
218
		$pconfig['value']
219
	))->setWidth(4);
220

    
221
	if (isset($id) && $a_tunable[$id]) {
222
		$form->addGlobal(new Form_Input(
223
			'id',
224
			'id',
225
			'hidden',
226
			$id
227
		));
228
	}
229

    
230
	$form->add($section);
231

    
232
	print $form;
233

    
234
endif;
235

    
236
include("fend.inc");
(192-192/237)