Projet

Général

Profil

Télécharger (9,13 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_advanced_sysctl.php @ 62424bdb

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']['item']))
51
	$config['sysctl']['item'] = array();
52

    
53
$a_tunable = &$config['sysctl']['item'];
54

    
55
if (is_numericint($_GET['id']))
56
	$id = $_GET['id'];
57
if (isset($_POST['id']) && is_numericint($_POST['id']))
58
	$id = $_POST['id'];
59

    
60
$act = $_GET['act'];
61
if (isset($_POST['act']))
62
	$act = $_POST['act'];
63

    
64
if ($act == "edit") {
65
	if ($a_tunable[$id]) {
66
		$pconfig['tunable'] = $a_tunable[$id]['tunable'];
67
		$pconfig['value'] = $a_tunable[$id]['value'];
68
		$pconfig['descr'] = $a_tunable[$id]['descr'];
69
	}
70
}
71

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

    
89
if ($_POST) {
90

    
91
	unset($input_errors);
92
	$pconfig = $_POST;
93

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

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

    
107
	if ($_POST['Submit'] == gettext("Save")) {
108
		$tunableent = array();
109

    
110
		$tunableent['tunable'] = $_POST['tunable'];
111
		$tunableent['value'] = $_POST['value'];
112
		$tunableent['descr'] = $_POST['descr'];
113

    
114
		if (isset($id) && $a_tunable[$id])
115
			$a_tunable[$id] = $tunableent;
116
		else
117
			$a_tunable[] = $tunableent;
118

    
119
		mark_subsystem_dirty('sysctl');
120

    
121
		write_config();
122

    
123
		pfSenseHeader("system_advanced_sysctl.php");
124
		exit;
125
    }
126
}
127

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

    
131
?>
132

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