Project

General

Profile

Download (8.83 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
	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']['item']))
49
	$config['sysctl']['item'] = array();
50

    
51
$a_tunable = &$config['sysctl']['item'];
52

    
53
$id = $_GET['id'];
54
if (isset($_POST['id']))
55
	$id = $_POST['id'];
56

    
57
$act = $_GET['act'];
58
if (isset($_POST['act']))
59
	$act = $_POST['act'];
60

    
61
if ($act == "edit") {
62
	if ($a_tunable[$id]) {
63
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
64
		$pconfig['value'] = $a_tunable[$id]['value'];
65
		$pconfig['desc'] = $a_tunable[$id]['desc'];
66
	}
67
}
68

    
69
if ($act == "del") {
70
	if ($a_tunable[$id]) {
71
		/* if this is an AJAX caller then handle via JSON */
72
		if(isAjax() && is_array($input_errors)) {
73
			input_errors2Ajax($input_errors);
74
			exit;
75
		}
76
		if (!$input_errors) {
77
			unset($a_tunable[$id]);
78
			write_config();
79
			mark_subsystem_dirty('sysctl');
80
			pfSenseHeader("system_advanced_sysctl.php");
81
			exit;
82
		}
83
	}
84
}
85

    
86
if ($_POST) {
87

    
88
	unset($input_errors);
89
	$pconfig = $_POST;
90

    
91
	/* if this is an AJAX caller then handle via JSON */
92
	if (isAjax() && is_array($input_errors)) {
93
		input_errors2Ajax($input_errors);
94
		exit;
95
	}
96

    
97
	if ($_POST['apply']) {
98
		$retval = 0;
99
		system_setup_sysctl();		
100
		$savemsg = get_std_save_message($retval);
101
		clear_subsystem_dirty('sysctl');
102
	}
103

    
104
	if ($_POST['Submit'] == gettext("Save")) {
105
		$tunableent = array();
106

    
107
		$tunableent['tunable'] = $_POST['tunable'];
108
		$tunableent['value'] = $_POST['value'];
109
		$tunableent['desc'] = $_POST['desc'];
110

    
111
		if (isset($id) && $a_tunable[$id])
112
			$a_tunable[$id] = $tunableent;
113
		else
114
			$a_tunable[] = $tunableent;
115

    
116
		mark_subsystem_dirty('sysctl');
117

    
118
		write_config();
119

    
120
		pfSenseHeader("system_advanced_sysctl.php");
121
		exit;
122
    }
123
}
124

    
125
include("head.inc");
126

    
127
$pgtitle = array(gettext("System"),gettext("Advanced: Miscellaneous"));
128
include("head.inc");
129

    
130
?>
131

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