Project

General

Profile

Download (8.25 KB) Statistics
| Branch: | Tag: | Revision:
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
##|+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
			touch($d_sysctldirty_path);
78
			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
		$savemsg = get_std_save_message($retval);
98
		unlink_if_exists($d_sysctldirty_path);
99
	}
100

    
101
	if ($_POST['Submit'] == "Save") {
102
		$tunableent = array();
103

    
104
		$tunableent['tunable'] = $_POST['tunable'];
105
		$tunableent['value'] = $_POST['value'];
106
		$tunableent['desc'] = $_POST['desc'];
107

    
108
		if (isset($id) && $a_tunable[$id])
109
			$a_tunable[$id] = $tunableent;
110
		else
111
			$a_tunable[] = $tunableent;
112

    
113
		touch($d_sysctldirty_path);
114

    
115
		write_config();
116

    
117
		pfSenseHeader("system_advanced_sysctl.php");
118
		exit;
119
    }
120
}
121

    
122
include("head.inc");
123

    
124
$pgtitle = array("System","Advanced: Miscellaneous");
125
include("head.inc");
126

    
127
?>
128

    
129
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
130
<?php include("fbegin.inc"); ?>
131
	<form action="system_advanced_sysctl.php" method="post">
132
		<?php
133
			if ($input_errors)
134
				print_input_errors($input_errors);
135
			if ($savemsg)
136
				print_info_box($savemsg);
137
			if (file_exists($d_sysctldirty_path) && ($act != "edit" ))
138
				print_info_box_np("The firewall tunables have changed.  You must apply the configuration to take affect.");
139
		?>
140
	</form>
141
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
142
		<tr>
143
			<td>
144
				<?php
145
					$tab_array = array();
146
					$tab_array[] = array("Admin Access", false, "system_advanced_admin.php");
147
					$tab_array[] = array("Firewall / NAT", false, "system_advanced_firewall.php");
148
					$tab_array[] = array("Networking", false, "system_advanced_network.php");
149
					$tab_array[] = array("Miscellaneous", false, "system_advanced_misc.php");
150
					$tab_array[] = array("System Tunables", true, "system_advanced_sysctl.php");
151
					display_top_tabs($tab_array);
152
				?>
153
			</td>
154
		</tr>
155
		<?php if ($act != "edit" ): ?>
156
		<tr>
157
			<td id="mainarea">
158
				<div class="tabcont">
159
					<span class="vexpl">
160
						<span class="red">
161
							<strong>NOTE:&nbsp</strong>
162
						</span>
163
						The options on this page are intended for use by advanced users only.
164
						<br/>
165
					</span>
166
					<br/>
167
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
168
						<tr>
169
							<td width="20%" class="listhdrr">Tunable Name</td>
170
							<td width="60%" class="listhdrr">Description</td>
171
							<td width="20%" class="listhdrr">Value</td>
172
						</tr>
173
						<?php $i = 0; foreach ($config['sysctl']['item'] as $tunable): ?>
174
						<tr>
175
							<td class="listlr" ondblclick="document.location='firewall_system_tunables_edit.php?id=<?=$i;?>';">
176
								<?php echo $tunable['tunable']; ?>
177
							</td>
178
							<td class="listr" align="left" ondblclick="document.location='firewall_system_tunables_edit.php?id=<?=$i;?>';">
179
								<?php echo $tunable['desc']; ?>
180
							</td>
181
							<td class="listr" align="left" ondblclick="document.location='firewall_system_tunables_edit.php?id=<?=$i;?>';">
182
								<?php echo $tunable['value']; ?>
183
							</td>
184
							<td class="list" nowrap>
185
								<table border="0" cellspacing="0" cellpadding="1">
186
									<tr>
187
										<td valign="middle">
188
											<a href="system_advanced_sysctl.php?act=edit&id=<?=$i;?>">
189
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="" />
190
											</a>
191
										</td>
192
										<td valign="middle">
193
											<a href="system_advanced_sysctl.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')">
194
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="" />
195
											</a>
196
										</td>
197
									</tr>
198
								</table>
199
							</td>
200
						</tr>
201
						<?php $i++; endforeach; ?>
202
						<tr>
203
						<td class="list" colspan="3">
204
							</td>
205
							<td class="list">
206
								<table border="0" cellspacing="0" cellpadding="1">
207
									<tr>
208
										<td valign="middle">
209
											<a href="firewall_system_tunables_edit.php">
210
												<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="" />
211
											</a>
212
										</td>
213
									</tr>
214
								</table>
215
							</td>
216
						</tr>
217
					</table>
218
				</div>
219
			</td>
220
		</tr>
221
		<? else: ?>
222
		<tr>
223
			<td>
224
				<div id="mainarea">
225
					<form action="system_advanced_sysctl.php" method="post" name="iform" id="iform">
226
						<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
227
							<tr>
228
								<td colspan="2" valign="top" class="listtopic">Edit system tunable</td>
229
							</tr>
230
							<tr>
231
								<td width="22%" valign="top" class="vncellreq">Tunable</td>
232
								<td width="78%" class="vtable">
233
									<input size="65" name="tunable" value="<?php echo $pconfig['tunable']; ?>">
234
								</td>
235
							</tr>
236
							<tr>
237
								<td width="22%" valign="top" class="vncellreq">Description</td>
238
								<td width="78%" class="vtable">
239
									<textarea rows="7" cols="50" name="desc"><?php echo $pconfig['desc']; ?></textarea>
240
								</td>
241
							</tr>
242
							<tr>
243
								<td width="22%" valign="top" class="vncellreq">Value</td>
244
								<td width="78%" class="vtable">
245
									<input size="65" name="value" value="<?php echo $pconfig['value']; ?>">
246
								</td>
247
							</tr>
248
							<tr>
249
								<td width="22%" valign="top">&nbsp;</td>
250
								<td width="78%">
251
									<input id="submit" name="Submit" type="submit" class="formbtn" value="Save" />
252
									<input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" onclick="history.back()" />
253
									<?php if (isset($id) && $a_tunable[$id]): ?>
254
									<input name="id" type="hidden" value="<?=$id;?>" />
255
									<?php endif; ?>
256
								</td>
257
							</tr>
258
						</table>
259
					</form>
260
				</div>
261
			</td>
262
		</tr>
263
		<? endif; ?>
264
	</table>
265
<?php include("fend.inc"); ?>
266
</body>
267
</html>
(168-168/210)