Project

General

Profile

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