1
|
<?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
|
/*
|
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
|
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_advanced_sysctl.php');
|
49
|
|
50
|
if (!is_array($config['sysctl']))
|
51
|
$config['sysctl'] = array();
|
52
|
if (!is_array($config['sysctl']['item']))
|
53
|
$config['sysctl']['item'] = array();
|
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
|
if (isset($_POST['id']))
|
61
|
$id = htmlspecialchars_decode($_POST['id']);
|
62
|
|
63
|
$act = $_GET['act'];
|
64
|
if (isset($_POST['act']))
|
65
|
$act = $_POST['act'];
|
66
|
|
67
|
if ($act == "edit") {
|
68
|
if (isset($a_tunable[$id])) {
|
69
|
$pconfig['tunable'] = $a_tunable[$id]['tunable'];
|
70
|
$pconfig['value'] = $a_tunable[$id]['value'];
|
71
|
$pconfig['descr'] = $a_tunable[$id]['descr'];
|
72
|
} else if (isset($tunables[$id])) {
|
73
|
$pconfig['tunable'] = $tunables[$id]['tunable'];
|
74
|
$pconfig['value'] = $tunables[$id]['value'];
|
75
|
$pconfig['descr'] = $tunables[$id]['descr'];
|
76
|
}
|
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
|
|
98
|
unset($input_errors);
|
99
|
$pconfig = $_POST;
|
100
|
|
101
|
/* if this is an AJAX caller then handle via JSON */
|
102
|
if (isAjax() && is_array($input_errors)) {
|
103
|
input_errors2Ajax($input_errors);
|
104
|
exit;
|
105
|
}
|
106
|
|
107
|
if ($_POST['apply']) {
|
108
|
$retval = 0;
|
109
|
system_setup_sysctl();
|
110
|
$savemsg = get_std_save_message($retval);
|
111
|
clear_subsystem_dirty('sysctl');
|
112
|
}
|
113
|
|
114
|
if ($_POST['Submit'] == gettext("Save")) {
|
115
|
$tunableent = array();
|
116
|
|
117
|
$tunableent['tunable'] = $_POST['tunable'];
|
118
|
$tunableent['value'] = $_POST['value'];
|
119
|
$tunableent['descr'] = $_POST['descr'];
|
120
|
|
121
|
if (isset($id) && isset($a_tunable[$id]))
|
122
|
$a_tunable[$id] = $tunableent;
|
123
|
else
|
124
|
$a_tunable[] = $tunableent;
|
125
|
|
126
|
mark_subsystem_dirty('sysctl');
|
127
|
|
128
|
write_config();
|
129
|
|
130
|
pfSenseHeader("system_advanced_sysctl.php");
|
131
|
exit;
|
132
|
}
|
133
|
}
|
134
|
|
135
|
$pgtitle = array(gettext("System"),gettext("Advanced: System Tunables"));
|
136
|
include("head.inc");
|
137
|
|
138
|
?>
|
139
|
|
140
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
141
|
<?php include("fbegin.inc"); ?>
|
142
|
<form action="system_advanced_sysctl.php" method="post">
|
143
|
<?php
|
144
|
if ($input_errors)
|
145
|
print_input_errors($input_errors);
|
146
|
if ($savemsg)
|
147
|
print_info_box($savemsg);
|
148
|
if (is_subsystem_dirty('sysctl') && ($act != "edit" ))
|
149
|
print_info_box_np(gettext("The firewall tunables have changed. You must apply the configuration to take affect."));
|
150
|
?>
|
151
|
</form>
|
152
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system advanced tunables">
|
153
|
<tr>
|
154
|
<td>
|
155
|
<?php
|
156
|
$tab_array = array();
|
157
|
$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
|
158
|
$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
|
159
|
$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
|
160
|
$tab_array[] = array(gettext("Miscellaneous"), false, "system_advanced_misc.php");
|
161
|
$tab_array[] = array(gettext("System Tunables"), true, "system_advanced_sysctl.php");
|
162
|
$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
|
163
|
display_top_tabs($tab_array);
|
164
|
?>
|
165
|
</td>
|
166
|
</tr>
|
167
|
<?php if ($act != "edit" ): ?>
|
168
|
<tr>
|
169
|
<td id="mainarea">
|
170
|
<div class="tabcont">
|
171
|
<span class="vexpl">
|
172
|
<span class="red">
|
173
|
<strong><?=gettext("NOTE:"); ?> </strong>
|
174
|
</span>
|
175
|
<?=gettext("The options on this page are intended for use by advanced users only."); ?>
|
176
|
<br />
|
177
|
</span>
|
178
|
<br />
|
179
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
|
180
|
<tr>
|
181
|
<td width="20%" class="listhdrr"><?=gettext("Tunable Name"); ?></td>
|
182
|
<td width="60%" class="listhdrr"><?=gettext("Description"); ?></td>
|
183
|
<td width="20%" class="listhdrr"><?=gettext("Value"); ?></td>
|
184
|
</tr>
|
185
|
<?php foreach ($tunables as $i => $tunable):
|
186
|
|
187
|
if (!isset($tunable['modified']))
|
188
|
$i = $tunable['tunable'];
|
189
|
?>
|
190
|
<tr>
|
191
|
<td class="listlr" ondblclick="document.location='system_advanced_sysctl.php?act=edit&id=<?=$i;?>';">
|
192
|
<?php echo $tunable['tunable']; ?>
|
193
|
</td>
|
194
|
<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&id=<?=$i;?>';">
|
195
|
<?php echo $tunable['descr']; ?>
|
196
|
</td>
|
197
|
<td class="listr" align="left" ondblclick="document.location='system_advanced_sysctl.php?act=edit&id=<?=$i;?>';">
|
198
|
<?php echo $tunable['value']; ?>
|
199
|
</td>
|
200
|
<td class="list nowrap">
|
201
|
<table border="0" cellspacing="0" cellpadding="1" summary="edit delete">
|
202
|
<tr>
|
203
|
<td valign="middle">
|
204
|
<a href="system_advanced_sysctl.php?act=edit&id=<?=$i;?>">
|
205
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
|
206
|
</a>
|
207
|
</td>
|
208
|
<?php if (isset($tunable['modified'])): ?>
|
209
|
<td valign="middle">
|
210
|
<a href="system_advanced_sysctl.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this entry?"); ?>')">
|
211
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
|
212
|
</a>
|
213
|
</td>
|
214
|
<?php endif; ?>
|
215
|
</tr>
|
216
|
</table>
|
217
|
</td>
|
218
|
</tr>
|
219
|
<?php endforeach; unset($tunables); ?>
|
220
|
<tr>
|
221
|
<td class="list" colspan="3">
|
222
|
</td>
|
223
|
<td class="list">
|
224
|
<table border="0" cellspacing="0" cellpadding="1" summary="edit">
|
225
|
<tr>
|
226
|
<td valign="middle">
|
227
|
<a href="system_advanced_sysctl.php?act=edit">
|
228
|
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
|
229
|
</a>
|
230
|
</td>
|
231
|
</tr>
|
232
|
</table>
|
233
|
</td>
|
234
|
</tr>
|
235
|
</table>
|
236
|
</div>
|
237
|
</td>
|
238
|
</tr>
|
239
|
<?php else: ?>
|
240
|
<tr>
|
241
|
<td>
|
242
|
<div id="mainarea">
|
243
|
<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
|
244
|
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="edit system tunable">
|
245
|
<tr>
|
246
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit system tunable"); ?></td>
|
247
|
</tr>
|
248
|
<tr>
|
249
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Tunable"); ?></td>
|
250
|
<td width="78%" class="vtable">
|
251
|
<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>" />
|
252
|
</td>
|
253
|
</tr>
|
254
|
<tr>
|
255
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Description"); ?></td>
|
256
|
<td width="78%" class="vtable">
|
257
|
<textarea rows="7" cols="50" name="descr"><?php echo $pconfig['descr']; ?></textarea>
|
258
|
</td>
|
259
|
</tr>
|
260
|
<tr>
|
261
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Value"); ?></td>
|
262
|
<td width="78%" class="vtable">
|
263
|
<input size="65" name="value" value="<?php echo $pconfig['value']; ?>" />
|
264
|
</td>
|
265
|
</tr>
|
266
|
<tr>
|
267
|
<td width="22%" valign="top"> </td>
|
268
|
<td width="78%">
|
269
|
<input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
|
270
|
<input type="button" class="formbtn" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=$referer;?>'" />
|
271
|
<?php if (isset($id) && $a_tunable[$id]): ?>
|
272
|
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
|
273
|
<?php endif; ?>
|
274
|
</td>
|
275
|
</tr>
|
276
|
</table>
|
277
|
</form>
|
278
|
</div>
|
279
|
</td>
|
280
|
</tr>
|
281
|
<?php endif; ?>
|
282
|
</table>
|
283
|
<?php include("fend.inc"); ?>
|
284
|
</body>
|
285
|
</html>
|