Project

General

Profile

Download (19.8 KB) Statistics
| Branch: | Tag: | Revision:
1 d173230c Seth Mos
<?php 
2 124aee67 Chris Buechler
/* $Id$ */
3 d173230c Seth Mos
/*
4
	system_gateways_edit.php
5
	part of pfSense (http://pfsense.com)
6
	
7 6216690b smos
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8 d173230c Seth Mos
	All rights reserved.
9
	
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
	
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
	
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
	
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 1d333258 Scott Ullrich
/*
32
	pfSense_MODULE:	routing
33
*/
34 d173230c Seth Mos
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-system-gateways-editgateway
37
##|*NAME=System: Gateways: Edit Gateway page
38
##|*DESCR=Allow access to the 'System: Gateways: Edit Gateway' page.
39
##|*MATCH=system_gateways_edit.php*
40
##|-PRIV
41
42 124aee67 Chris Buechler
require("guiconfig.inc");
43 4666b787 Ermal Lu?i
require("pkg-utils.inc");
44 d173230c Seth Mos
45 99c61352 Ermal
$a_gateways = return_gateways_array(true);
46 87f0be87 Chris Buechler
$a_gateways_arr = array();
47
foreach($a_gateways as $gw) {
48
	$a_gateways_arr[] = $gw;
49
}
50
$a_gateways = $a_gateways_arr;
51 d173230c Seth Mos
52 616e1956 Seth Mos
if (!is_array($config['gateways']['gateway_item']))
53
        $config['gateways']['gateway_item'] = array();
54
        
55
$a_gateway_item = &$config['gateways']['gateway_item'];
56
57 87f0be87 Chris Buechler
$id = $_GET['id'];
58
if (isset($_POST['id']))
59 d173230c Seth Mos
	$id = $_POST['id'];
60
61
if (isset($_GET['dup'])) {
62
	$id = $_GET['dup'];
63
}
64
65
if (isset($id) && $a_gateways[$id]) {
66 bb849003 Ermal
	$pconfig = array();
67 e90db2b4 Ermal Lu?i
	$pconfig['name'] = $a_gateways[$id]['name'];
68 5f53260a Ermal
	$pconfig['weight'] = $a_gateways[$id]['weight'];
69 e90db2b4 Ermal Lu?i
	$pconfig['interface'] = $a_gateways[$id]['interface'];
70 883c53c9 Ermal Lu?i
	$pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface'];
71 e90db2b4 Ermal Lu?i
	$pconfig['gateway'] = $a_gateways[$id]['gateway'];
72 883c53c9 Ermal Lu?i
	$pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']);
73 023920e7 Ermal
	$pconfig['latencylow'] = $a_gateway_item[$id]['latencylow'];
74
        $pconfig['latencyhigh'] = $a_gateway_item[$id]['latencyhigh'];
75
        $pconfig['losslow'] = $a_gateway_item[$id]['losslow'];
76
        $pconfig['losshigh'] = $a_gateway_item[$id]['losshigh'];
77
        $pconfig['down'] = $a_gateway_item[$id]['down'];
78 a2532739 Ermal Lu?i
	if (isset($a_gateways[$id]['dynamic']))
79
		$pconfig['dynamic'] = true;
80 99c61352 Ermal
	$pconfig['monitor'] = $a_gateways[$id]['monitor'];
81 e90db2b4 Ermal Lu?i
	$pconfig['descr'] = $a_gateways[$id]['descr'];
82
	$pconfig['attribute'] = $a_gateways[$id]['attribute'];
83 d173230c Seth Mos
}
84
85 124aee67 Chris Buechler
if (isset($_GET['dup'])) {
86 d173230c Seth Mos
	unset($id);
87 124aee67 Chris Buechler
	unset($pconfig['attribute']);
88
}
89 d173230c Seth Mos
90
if ($_POST) {
91
92
	unset($input_errors);
93
94
	/* input validation */
95 0c4846ff Ermal
	$reqdfields = explode(" ", "name");
96
	$reqdfieldsn = array(gettext("Name"));
97 883c53c9 Ermal Lu?i
98 d173230c Seth Mos
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
99 883c53c9 Ermal Lu?i
100 d173230c Seth Mos
	if (! isset($_POST['name'])) {
101
		$input_errors[] = "A valid gateway name must be specified.";
102
	}
103 31ace93c Seth Mos
	if (! is_validaliasname($_POST['name'])) {
104 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("The gateway name must not contain invalid characters.");
105 31ace93c Seth Mos
	}
106 87f0be87 Chris Buechler
	/* skip system gateways which have been automatically added */
107 d52b71c7 Ermal Lu?i
	if (($_POST['gateway'] && (!is_ipaddr($_POST['gateway'])) && ($_POST['attribute'] != "system")) && ($_POST['gateway'] != "dynamic")) {
108 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid gateway IP address must be specified.");
109 87f0be87 Chris Buechler
	}
110 15a13dab Scott Ullrich
111
	if ($_POST['gateway'] && (is_ipaddr($_POST['gateway'])) && ($pconfig['attribute'] != "system") && !$_REQUEST['isAjax']) {
112 b29b1a33 Chris Buechler
		$parent_ip = get_interface_ip($_POST['interface']);
113 e227df57 Ermal Lu?i
		if (is_ipaddr($parent_ip)) {
114
			$parent_sn = get_interface_subnet($_POST['interface']);
115
			if(!ip_in_subnet($_POST['gateway'], gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn)) {
116 181b29ca Vinicius Coque
				$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']);
117 e227df57 Ermal Lu?i
			}
118 e7d3b8f4 Seth Mos
		}
119
	}
120 883c53c9 Ermal Lu?i
	if (($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
121 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid monitor IP address must be specified.");
122 d173230c Seth Mos
	}
123
124 8b060357 Seth Mos
	if (isset($_POST['name'])) {
125 31ace93c Seth Mos
		/* check for overlaps */
126
		foreach ($a_gateways as $gateway) {
127 2328dcc5 Seth Mos
			if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway)) {
128 31ace93c Seth Mos
				continue;
129
			}
130 2328dcc5 Seth Mos
			if($_POST['name'] <> "") {
131 883c53c9 Ermal Lu?i
				if (($gateway['name'] <> "") && ($_POST['name'] == $gateway['name']) && ($gateway['attribute'] != "system")) {
132 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The gateway name "%s" already exists.'), $_POST['name']);
133 2328dcc5 Seth Mos
					break;
134
				}
135
			}
136
			if(is_ipaddr($_POST['gateway'])) {
137 883c53c9 Ermal Lu?i
				if (($gateway['gateway'] <> "") && ($_POST['gateway'] == $gateway['gateway']) && ($gateway['attribute'] != "system")) {
138 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The gateway IP address "%s" already exists.'), $_POST['gateway']);
139 2328dcc5 Seth Mos
					break;
140
				}
141 31ace93c Seth Mos
			}
142 2328dcc5 Seth Mos
			if(is_ipaddr($_POST['monitor'])) {
143 883c53c9 Ermal Lu?i
				if (($gateway['monitor'] <> "") && ($_POST['monitor'] == $gateway['monitor']) && ($gateway['attribute'] != "system")) {
144 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The monitor IP address "%s" is already in use. You must choose a different monitor IP.'), $_POST['monitor']);
145 2328dcc5 Seth Mos
					break;
146
				}
147 31ace93c Seth Mos
			}
148 d173230c Seth Mos
		}
149
	}
150
151 023920e7 Ermal
	/* input validation */
152
        if($_POST['latencylow']) {
153
                if (! is_numeric($_POST['latencylow'])) {
154
                        $input_errors[] = gettext("The low latency watermark needs to be a numeric value.");
155
                }
156
        }
157
158
        if($_POST['latencyhigh']) {
159
                if (! is_numeric($_POST['latencyhigh'])) {
160
                        $input_errors[] = gettext("The high latency watermark needs to be a numeric value.");
161
                }
162
        }
163
        if($_POST['losslow']) {
164
                if (! is_numeric($_POST['losslow'])) {
165
                        $input_errors[] = gettext("The low loss watermark needs to be a numeric value.");
166
                }
167
        }
168
        if($_POST['losshigh']) {
169
                if (! is_numeric($_POST['losshigh'])) {
170
                        $input_errors[] = gettext("The high loss watermark needs to be a numeric value.");
171
                }
172
        }
173
174
        if(($_POST['latencylow']) && ($_POST['latencyhigh'])){
175
                if(($_POST['latencylow'] > $_POST['latencyhigh'])) {
176
                        $input_errors[] = gettext("The High latency watermark needs to be higher then the low latency watermark");
177
                }
178
        }
179
180
        if(($_POST['losslow']) && ($_POST['losshigh'])){
181
                if($_POST['losslow'] > $_POST['losshigh']) {
182
                        $input_errors[] = gettext("The High packet loss watermark needs to be higher then the low packet loss watermark");
183
                }
184
        }
185
	if($_POST['down']) {
186
                if (! is_numeric($_POST['down']) || $_POST['down'] < 1) {
187
                        $input_errors[] = gettext("The low latency watermark needs to be a numeric value.");
188
                }
189
        }
190
191 d173230c Seth Mos
	if (!$input_errors) {
192 c6d1c7de Ermal
		$reloadif = false;
193 5a5447ab Ermal
		$save = false;
194 3befe730 Ermal
		if (($_POST['weight'] && $_POST['weight'] > 1) ||
195
		    $_POST['latencylow'] || $_POST['latencyhigh'] || $_POST['losslow'] || $_POST['losshigh'] || $_POST['down'] ||
196 58611e3a gnhb
		    $_POST['defaultgw'] || ($_POST['gateway'] && $_POST['gateway'] != "dynamic") || $_POST['monitor'])
197 5a5447ab Ermal
			$save = true;
198 124aee67 Chris Buechler
		/* if we are processing a system gateway only save the monitorip */
199 99c61352 Ermal
		if (!$save && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic")) {
200 883c53c9 Ermal Lu?i
			if (is_ipaddr($_POST['monitor'])) {
201 0c4846ff Ermal
				if (empty($_POST['interface']))
202
					$interface = $pconfig['friendlyiface'];
203
				else
204
					$interface = $_POST['interface'];
205 883c53c9 Ermal Lu?i
				$config['interfaces'][$interface]['monitorip'] = $_POST['monitor'];
206
			}
207
			/* when dynamic gateway is not anymore a default the entry is no more needed. */
208 99c61352 Ermal
                        if (isset($id) && $a_gateway_item[$id])
209 883c53c9 Ermal Lu?i
                                unset($a_gateway_item[$id]);
210
		} else {
211 124aee67 Chris Buechler
212 883c53c9 Ermal Lu?i
			/* Manual gateways are handled differently */
213
			/* rebuild the array with the manual entries only */
214 124aee67 Chris Buechler
215
			$gateway = array();
216 3befe730 Ermal
			$gateway['interface'] = $_POST['interface'];
217 58611e3a gnhb
			if (is_ipaddr($_POST['gateway']))
218
				$gateway['gateway'] = $_POST['gateway'];
219
			else
220
				$gateway['gateway'] = "dynamic";
221 124aee67 Chris Buechler
			$gateway['name'] = $_POST['name'];
222 5f53260a Ermal
			$gateway['weight'] = $_POST['weight'];
223 124aee67 Chris Buechler
			$gateway['descr'] = $_POST['descr'];
224 99c61352 Ermal
			if (is_ipaddr($_POST['monitor']))
225 616e1956 Seth Mos
				$gateway['monitor'] = $_POST['monitor'];
226 99c61352 Ermal
227
			if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
228 87f0be87 Chris Buechler
				$i = 0;
229 883c53c9 Ermal Lu?i
				foreach($a_gateway_item as $gw) {
230
					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
231 124aee67 Chris Buechler
					$i++;
232
				}
233 87f0be87 Chris Buechler
				$gateway['defaultgw'] = true;
234 c0f5182c Ermal Lu?i
				$reloadif = true;
235 bb849003 Ermal
			}
236 124aee67 Chris Buechler
237 023920e7 Ermal
			if ($_POST['latencylow'])
238
				$gateway['latencylow'] = $_POST['latencylow'];
239
			if ($_POST['latencyhigh'])
240
                		$gateway['latencyhigh'] = $_POST['latencyhigh'];
241
			if ($_POST['losslow'])
242
               			$gateway['losslow'] = $_POST['losslow'];
243
			if ($_POST['losshigh'])
244
                		$gateway['losshigh'] = $_POST['losshigh'];
245
			if ($_POST['down'])
246
                		$gateway['down'] = $_POST['down'];
247
248 124aee67 Chris Buechler
			/* when saving the manual gateway we use the attribute which has the corresponding id */
249 99c61352 Ermal
			if (isset($id) && $a_gateway_item[$id])
250 883c53c9 Ermal Lu?i
				$a_gateway_item[$id] = $gateway;
251 99c61352 Ermal
			else
252 883c53c9 Ermal Lu?i
				$a_gateway_item[] = $gateway;
253 124aee67 Chris Buechler
		}
254 a368a026 Ermal Lu?i
		mark_subsystem_dirty('staticroutes');
255 d173230c Seth Mos
		
256
		write_config();
257
		
258 ad862220 Charlie
		if($_REQUEST['isAjax']) {
259
			echo $_POST['name'];
260
			exit;
261 c0f5182c Ermal Lu?i
		} else if ($reloadif == true)
262 99c61352 Ermal
			send_event("interface reconfigure {$_POST['interface']}");
263 ad862220 Charlie
		
264 d173230c Seth Mos
		header("Location: system_gateways.php");
265
		exit;
266 ea939fc3 Ermal
	} else {
267 883c53c9 Ermal Lu?i
		$pconfig = $_POST;
268 ea939fc3 Ermal
		if (empty($_POST['friendlyiface']))
269
			$pconfig['friendlyiface'] = $_POST['interface'];
270
	}
271 d173230c Seth Mos
}
272
273 2328dcc5 Seth Mos
274 df152a88 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Gateways"),gettext("Edit gateway"));
275 02ca24c9 jim-p
$statusurl = "status_gateways.php";
276
277 d173230c Seth Mos
include("head.inc");
278
279
?>
280
281
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
282
<?php include("fbegin.inc"); ?>
283 883c53c9 Ermal Lu?i
<script language="JavaScript">
284
function enable_change(obj) {
285
	if (document.iform.gateway.disabled) {
286
		if (obj.checked)
287
			document.iform.interface.disabled=false;
288
		else
289
			document.iform.interface.disabled=true;
290
	}	
291
	
292
}
293 023920e7 Ermal
function show_advanced_gateway() {
294
        document.getElementById("showadvgatewaybox").innerHTML='';
295
        aodiv = document.getElementById('showgatewayadv');
296
        aodiv.style.display = "block";
297
}
298 883c53c9 Ermal Lu?i
</script>
299 d173230c Seth Mos
<?php if ($input_errors) print_input_errors($input_errors); ?>
300
            <form action="system_gateways_edit.php" method="post" name="iform" id="iform">
301 124aee67 Chris Buechler
	<?php
302 e9df5769 Seth Mos
303
	/* If this is a system gateway we need this var */
304 124aee67 Chris Buechler
	if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
305
		echo "<input type='hidden' name='attribute' id='attribute' value='{$pconfig['attribute']}' >\n";
306
	}
307 883c53c9 Ermal Lu?i
	echo "<input type='hidden' name='friendlyiface' id='friendlyiface' value='{$pconfig['friendlyiface']}' >\n";
308 124aee67 Chris Buechler
	?>
309 d173230c Seth Mos
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
310 56d4e7fb Scott Ullrich
				<tr>
311 df152a88 Carlos Eduardo Ramos
					<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit gateway"); ?></td>
312 56d4e7fb Scott Ullrich
				</tr>	
313 d173230c Seth Mos
                <tr> 
314 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
315 d173230c Seth Mos
                  <td width="78%" class="vtable">
316 883c53c9 Ermal Lu?i
		<?php 
317 bb849003 Ermal
			if ($pconfig['dynamic'] == true && $pconfig['attribute'] == "system") {
318
				echo "<input name='interface' type='hidden' value='{$pconfig['friendlyiface']}' />";
319
		  		echo "<select name='interface' class='formselect' disabled >\n";
320
			} else
321
		  		echo "<select name='interface' class='formselect'>\n";
322
323 883c53c9 Ermal Lu?i
                      	$interfaces = get_configured_interface_with_descr(false, true);
324
			foreach ($interfaces as $iface => $ifacename) {
325
				echo "<option value=\"{$iface}\"";
326
				if ($iface == $pconfig['friendlyiface'])
327
					echo " selected";
328
				echo ">" . htmlspecialchars($ifacename) . "</option>";
329
			}
330
			if (is_package_installed("openbgpd") == 1) {
331
				echo "<option value=\"bgpd\"";
332
				if ($pconfig['interface'] == "bgpd") 
333
					echo " selected";
334 df152a88 Carlos Eduardo Ramos
				echo ">" . gettext("Use BGPD") . "</option>";
335 883c53c9 Ermal Lu?i
			}
336
 		  ?>
337 d173230c Seth Mos
                    </select> <br>
338 df152a88 Carlos Eduardo Ramos
                    <span class="vexpl"><?=gettext("Choose which interface this gateway applies to."); ?></span></td>
339 d173230c Seth Mos
                </tr>
340
                <tr>
341 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td>
342 d173230c Seth Mos
                  <td width="78%" class="vtable"> 
343
                    <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"> 
344 df152a88 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("Gateway name"); ?></span></td>
345 d173230c Seth Mos
                </tr>
346
		<tr>
347 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
348 d173230c Seth Mos
                  <td width="78%" class="vtable"> 
349 41d98471 jim-p
                    <input name="gateway" type="text" class="formfld host" id="gateway" size="40" value="<?php if ($pconfig['dynamic']) echo "dynamic"; else echo $pconfig['gateway']; ?>" <?php if ($pconfig['dynamic'] && $pconfig['attribute'] == "system") echo "disabled"; ?>>
350 df152a88 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("Gateway IP address"); ?></span></td>
351 d173230c Seth Mos
                </tr>
352
		<tr>
353 df152a88 Carlos Eduardo Ramos
		  <td width="22%" valign="top" class="vncell"><?=gettext("Default Gateway"); ?></td>
354 d173230c Seth Mos
		  <td width="78%" class="vtable">
355 883c53c9 Ermal Lu?i
			<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) echo "checked"; ?> onclick="enable_change(this)" />
356 df152a88 Carlos Eduardo Ramos
			<strong><?=gettext("Default Gateway"); ?></strong><br />
357
			<?=gettext("This will select the above gateway as the default gateway"); ?>
358 d173230c Seth Mos
		  </td>
359
		</tr>
360
		<tr>
361 df152a88 Carlos Eduardo Ramos
		  <td width="22%" valign="top" class="vncell"><?=gettext("Monitor IP"); ?></td>
362 d173230c Seth Mos
		  <td width="78%" class="vtable">
363 616e1956 Seth Mos
			<?php
364 3dd81dea jim-p
				if(($pconfig['attribute'] == "system") && ($pconfig['gateway'] == "dynamic") && ($pconfig['monitor'] == "")) {
365 616e1956 Seth Mos
					$monitor = "";
366
				} else {
367
					$monitor = htmlspecialchars($pconfig['monitor']);
368
				}
369
			?>
370
			<input name="monitor" type="text" id="monitor" value="<?php echo $monitor; ?>" />
371 df152a88 Carlos Eduardo Ramos
			<strong><?=gettext("Alternative monitor IP"); ?></strong> <br />
372 e88ace75 Chris Buechler
			<?=gettext("Enter an alternative address here to be used to monitor the link. This is used for the " .
373 0e94685b Renato Botelho
			"quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond " .
374
			"to ICMP echo requests (pings)"); ?>.</strong>
375 d173230c Seth Mos
			<br />
376
		  </td>
377
		</tr>
378 5f53260a Ermal
		<tr>
379 023920e7 Ermal
		  <td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td>
380 5f53260a Ermal
		  <td width="78%" class="vtable">
381 023920e7 Ermal
			<div id="showadvgatewaybox" <? if (!empty($pconfig['latencylow']) || !empty($pconfig['latencyhigh']) || !empty($pconfig['losslow']) || !empty($pconfig['losshigh']) || (isset($pconfig['weight']) && $pconfig['weight'] > 1)) echo "style='display:none'"; ?>>
382
				<input type="button" onClick="show_advanced_gateway()" value="Advanced"></input> - Show advanced option</a>
383
			</div>
384
			<div id="showgatewayadv" <? if (empty($pconfig['latencylow']) && empty($pconfig['latencyhigh']) && empty($pconfig['losslow']) && empty($pconfig['losshigh']) && (empty($pconfig['weight']) || $pconfig['weight'] == 1)) echo "style='display:none'"; ?>>
385
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
386
			<tr>
387
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td>
388
                                <td width="78%" class="vtable">
389
					<select name='weight' class='formfldselect' id='weight'>
390
				<?php
391
					for ($i = 1; $i < 6; $i++) {
392
                                        	$selected = "";
393
                                        	if ($pconfig['weight'] == $i)
394
                                                	$selected = "selected";
395
                                        	echo "<option value='{$i}' {$selected} >{$i}</option>";
396
                                	}
397
				?>
398
					</select>
399
					<br /><?=gettext("Weight for this gateway when used in a Gateway Group.");?> <br />
400
		   		</td>
401
			</tr>
402
                        <tr>
403
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td>
404
                                <td width="78%" class="vtable">
405
                                <?=gettext("From");?>
406
                                    <input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2"
407
                                        value="<?=htmlspecialchars($pconfig['latencylow']);?>">
408
                                <?=gettext("To");?>
409
                                    <input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2"
410
                                        value="<?=htmlspecialchars($pconfig['latencyhigh']);?>">
411
                                    <br> <span class="vexpl"><?=gettext("These define the low and high water marks for latency in milliseconds.");?></span></td>
412
                                </td>
413
                        </tr>
414
                        <tr>
415
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td>
416
                                <td width="78%" class="vtable">
417
                                <?=gettext("From");?>
418
                                    <input name="losslow" type="text" class="formfld unknown" id="losslow" size="2"
419
                                        value="<?=htmlspecialchars($pconfig['losslow']);?>">
420
                                <?=gettext("To");?>
421
                                    <input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2"
422
                                        value="<?=htmlspecialchars($pconfig['losshigh']);?>">
423
                                    <br> <span class="vexpl"><?=gettext("These define the low and high water marks for packet loss in %.");?></span></td>
424
                                </td>
425
                        </tr>
426
			<tr>
427
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Down");?></td>
428
                                <td width="78%" class="vtable">
429
                                    <input name="down" type="text" class="formfld unknown" id="down" size="2"
430
                                        value="<?=htmlspecialchars($pconfig['down']);?>">
431
                                    <br> <span class="vexpl"><?=gettext("This defines the down time for the alarm to fire, in seconds.");?></span></td>
432
                                </td>
433
                        </tr>
434
                        </table>
435
			</div>
436 5f53260a Ermal
		   </td>
437
		</tr>
438 d173230c Seth Mos
		<tr>
439 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
440 d173230c Seth Mos
                  <td width="78%" class="vtable"> 
441
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
442 0e94685b Renato Botelho
                    <br> <span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span></td>
443 d173230c Seth Mos
                </tr>
444
                <tr>
445
                  <td width="22%" valign="top">&nbsp;</td>
446
                  <td width="78%"> 
447 bfb0b9dc Vinicius Coque
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>"> <input type="button" value="<?=gettext("Cancel");?>" class="formbtn"  onclick="history.back()">
448 d173230c Seth Mos
                    <?php if (isset($id) && $a_gateways[$id]): ?>
449
                    <input name="id" type="hidden" value="<?=$id;?>">
450
                    <?php endif; ?>
451
                  </td>
452
                </tr>
453
              </table>
454
</form>
455
<?php include("fend.inc"); ?>
456
<script language="JavaScript">
457 883c53c9 Ermal Lu?i
enable_change(document.iform.defaultgw);
458 d173230c Seth Mos
</script>
459
</body>
460
</html>