Project

General

Profile

Download (20.3 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 d44d26c1 Ermal
	if (isset($a_gateways[$id]['dynamic']))
72
		$pconfig['dynamic'] = true;
73
	$pconfig['gateway'] = $a_gateways[$id]['gateway'];
74 883c53c9 Ermal Lu?i
	$pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']);
75 023920e7 Ermal
	$pconfig['latencylow'] = $a_gateway_item[$id]['latencylow'];
76
        $pconfig['latencyhigh'] = $a_gateway_item[$id]['latencyhigh'];
77
        $pconfig['losslow'] = $a_gateway_item[$id]['losslow'];
78
        $pconfig['losshigh'] = $a_gateway_item[$id]['losshigh'];
79
        $pconfig['down'] = $a_gateway_item[$id]['down'];
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 d44d26c1 Ermal
	$reqdfields = explode(" ", "name interface");
96
	$reqdfieldsn = array(gettext("Name"), gettext("Interface"));
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 d44d26c1 Ermal
	if ($_POST['gateway'] && (is_ipaddr($_POST['gateway'])) && !$_REQUEST['isAjax']) {
112
		if (!empty($config['interfaces'][$_POST['interface']]['ipaddr'])) {
113 78ae2b14 Ermal
			if (is_ipaddr($config['interfaces'][$_POST['interface']]['ipaddr']) && (empty($_POST['gateway']) || $_POST['gateway'] == "dynamic"))
114 d44d26c1 Ermal
				$input_errors[] = gettext("Dynamic gateway values cannot be specified for interfaces with a static ip configuration.");
115
		}
116 47593ac6 Seth Mos
		if(is_ipaddrv6($_POST['gateway'])) {
117
			$parent_ip = get_interface_ipv6($_POST['interface']);
118
		} else {		
119
			$parent_ip = get_interface_ip($_POST['interface']);
120
		}
121 7617e245 Seth Mos
		if (is_ipaddrv4($parent_ip)) {
122 e227df57 Ermal Lu?i
			$parent_sn = get_interface_subnet($_POST['interface']);
123 54ac51b5 Seth Mos
			$subnet = gen_subnet($parent_ip, $parent_sn) . "/" . $parent_sn;
124
			if(!ip_in_subnet($_POST['gateway'], $subnet) && !ip_in_interface_alias_subnet($_POST['interface'], $_POST['gateway'])) {
125 d1d0a1ad Vinicius Coque
				$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within the chosen interface's subnet '%2\$s'."), $_POST['gateway'],$subnet);
126 e227df57 Ermal Lu?i
			}
127 e7d3b8f4 Seth Mos
		}
128 7617e245 Seth Mos
		if (is_ipaddrv6($parent_ip)) {
129
			$parent_sn = get_interface_subnetv6($_POST['interface']);
130 54ac51b5 Seth Mos
			$subnet = gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn;
131
			if(!ip_in_subnet($_POST['gateway'], $subnet)) {
132 d1d0a1ad Vinicius Coque
				$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within the chosen interface's subnet '%2\$s'."), $_POST['gateway'],$subnet);
133 7617e245 Seth Mos
			}
134
		}
135 e7d3b8f4 Seth Mos
	}
136 883c53c9 Ermal Lu?i
	if (($_POST['monitor'] <> "") && !is_ipaddr($_POST['monitor']) && $_POST['monitor'] != "dynamic") {
137 df152a88 Carlos Eduardo Ramos
		$input_errors[] = gettext("A valid monitor IP address must be specified.");
138 d173230c Seth Mos
	}
139
140 8b060357 Seth Mos
	if (isset($_POST['name'])) {
141 31ace93c Seth Mos
		/* check for overlaps */
142
		foreach ($a_gateways as $gateway) {
143 2328dcc5 Seth Mos
			if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway)) {
144 23fafd14 Ermal
				if ($gateway['name'] != $_POST['name'])
145 33802679 Chris Buechler
					$input_errors[] = gettext("Changing name on a gateway is not allowed.");
146 31ace93c Seth Mos
				continue;
147
			}
148 2328dcc5 Seth Mos
			if($_POST['name'] <> "") {
149 883c53c9 Ermal Lu?i
				if (($gateway['name'] <> "") && ($_POST['name'] == $gateway['name']) && ($gateway['attribute'] != "system")) {
150 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The gateway name "%s" already exists.'), $_POST['name']);
151 2328dcc5 Seth Mos
					break;
152
				}
153
			}
154
			if(is_ipaddr($_POST['gateway'])) {
155 883c53c9 Ermal Lu?i
				if (($gateway['gateway'] <> "") && ($_POST['gateway'] == $gateway['gateway']) && ($gateway['attribute'] != "system")) {
156 0e94685b Renato Botelho
					$input_errors[] = sprintf(gettext('The gateway IP address "%s" already exists.'), $_POST['gateway']);
157 2328dcc5 Seth Mos
					break;
158
				}
159 31ace93c Seth Mos
			}
160 2328dcc5 Seth Mos
			if(is_ipaddr($_POST['monitor'])) {
161 883c53c9 Ermal Lu?i
				if (($gateway['monitor'] <> "") && ($_POST['monitor'] == $gateway['monitor']) && ($gateway['attribute'] != "system")) {
162 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']);
163 2328dcc5 Seth Mos
					break;
164
				}
165 31ace93c Seth Mos
			}
166 d173230c Seth Mos
		}
167
	}
168
169 023920e7 Ermal
	/* input validation */
170
        if($_POST['latencylow']) {
171
                if (! is_numeric($_POST['latencylow'])) {
172
                        $input_errors[] = gettext("The low latency watermark needs to be a numeric value.");
173
                }
174
        }
175
176
        if($_POST['latencyhigh']) {
177
                if (! is_numeric($_POST['latencyhigh'])) {
178
                        $input_errors[] = gettext("The high latency watermark needs to be a numeric value.");
179
                }
180
        }
181
        if($_POST['losslow']) {
182
                if (! is_numeric($_POST['losslow'])) {
183
                        $input_errors[] = gettext("The low loss watermark needs to be a numeric value.");
184
                }
185
        }
186
        if($_POST['losshigh']) {
187
                if (! is_numeric($_POST['losshigh'])) {
188
                        $input_errors[] = gettext("The high loss watermark needs to be a numeric value.");
189
                }
190
        }
191
192
        if(($_POST['latencylow']) && ($_POST['latencyhigh'])){
193
                if(($_POST['latencylow'] > $_POST['latencyhigh'])) {
194
                        $input_errors[] = gettext("The High latency watermark needs to be higher then the low latency watermark");
195
                }
196
        }
197
198
        if(($_POST['losslow']) && ($_POST['losshigh'])){
199
                if($_POST['losslow'] > $_POST['losshigh']) {
200
                        $input_errors[] = gettext("The High packet loss watermark needs to be higher then the low packet loss watermark");
201
                }
202
        }
203
	if($_POST['down']) {
204
                if (! is_numeric($_POST['down']) || $_POST['down'] < 1) {
205
                        $input_errors[] = gettext("The low latency watermark needs to be a numeric value.");
206
                }
207
        }
208
209 d173230c Seth Mos
	if (!$input_errors) {
210 7fa03a98 gnhb
		if (!($_POST['weight'] > 1 || $_POST['latencylow'] || $_POST['latencyhigh'] ||
211 c568e682 Ermal
		    $_POST['losslow'] || $_POST['losshigh'] || $_POST['down'] ||
212 7fa03a98 gnhb
		    $_POST['defaultgw'] || is_ipaddr($_POST['monitor']) || is_ipaddr($_POST['gateway']))) {
213
		/* Delete from config if gw is dynamic and user is not saving any additional gateway data that system doesn't know */
214 c568e682 Ermal
			if (isset($id) && $a_gateway_item[$id])
215
				unset($a_gateway_item[$id]);
216
			write_config();
217 d44d26c1 Ermal
			header("Location: system_gateways.php");
218
			exit;
219
		}
220
221
222 c6865c5e Ermal
		$reloadif = "";
223 d44d26c1 Ermal
		$gateway = array();
224
225
		if (empty($_POST['interface']))
226
			$gateway['interface'] = $pconfig['friendlyiface'];
227
		else
228 3befe730 Ermal
			$gateway['interface'] = $_POST['interface'];
229 d44d26c1 Ermal
		if (is_ipaddr($_POST['gateway']))
230
			$gateway['gateway'] = $_POST['gateway'];
231
		else
232
			$gateway['gateway'] = "dynamic";
233
		$gateway['name'] = $_POST['name'];
234
		$gateway['weight'] = $_POST['weight'];
235
		$gateway['descr'] = $_POST['descr'];
236
		if (is_ipaddr($_POST['monitor']))
237
			$gateway['monitor'] = $_POST['monitor'];
238
239
		if ($_POST['defaultgw'] == "yes" || $_POST['defaultgw'] == "on") {
240
			$i = 0;
241 2f14d021 Seth Mos
			/* remove the default gateway bits for all gateways with the same address family */
242 a531d687 Ermal
			foreach($a_gateway_item as $gw) {
243 2f14d021 Seth Mos
				if(is_ipaddrv4($gateway['gateway']) && is_ipaddrv4($gw['gateway'])) {
244
					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
245
					if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
246
						$reloadif = $gw['interface'];
247
				}
248
				if(is_ipaddrv6($gateway['gateway']) && is_ipaddrv6($gw['gateway'])) {
249
					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
250
					if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
251
						$reloadif = $gw['interface'];
252
				}
253 d44d26c1 Ermal
				$i++;
254 bb849003 Ermal
			}
255 d44d26c1 Ermal
			$gateway['defaultgw'] = true;
256 124aee67 Chris Buechler
		}
257 d44d26c1 Ermal
258
		if ($_POST['latencylow'])
259
			$gateway['latencylow'] = $_POST['latencylow'];
260
		if ($_POST['latencyhigh'])
261
               		$gateway['latencyhigh'] = $_POST['latencyhigh'];
262
		if ($_POST['losslow'])
263
              			$gateway['losslow'] = $_POST['losslow'];
264
		if ($_POST['losshigh'])
265
               		$gateway['losshigh'] = $_POST['losshigh'];
266
		if ($_POST['down'])
267
               		$gateway['down'] = $_POST['down'];
268
269
		/* when saving the manual gateway we use the attribute which has the corresponding id */
270
		if (isset($id) && $a_gateway_item[$id])
271
			$a_gateway_item[$id] = $gateway;
272
		else
273
			$a_gateway_item[] = $gateway;
274
275 a368a026 Ermal Lu?i
		mark_subsystem_dirty('staticroutes');
276 d44d26c1 Ermal
	
277 d173230c Seth Mos
		write_config();
278 d44d26c1 Ermal
279 ad862220 Charlie
		if($_REQUEST['isAjax']) {
280
			echo $_POST['name'];
281
			exit;
282 c6865c5e Ermal
		} else if (!empty($reloadif))
283
			send_event("interface reconfigure {$reloadif}");
284 ad862220 Charlie
		
285 d173230c Seth Mos
		header("Location: system_gateways.php");
286
		exit;
287 ea939fc3 Ermal
	} else {
288 883c53c9 Ermal Lu?i
		$pconfig = $_POST;
289 ea939fc3 Ermal
		if (empty($_POST['friendlyiface']))
290
			$pconfig['friendlyiface'] = $_POST['interface'];
291
	}
292 d173230c Seth Mos
}
293
294 2328dcc5 Seth Mos
295 df152a88 Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Gateways"),gettext("Edit gateway"));
296 02ca24c9 jim-p
$statusurl = "status_gateways.php";
297
298 d173230c Seth Mos
include("head.inc");
299
300
?>
301
302
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
303
<?php include("fbegin.inc"); ?>
304 883c53c9 Ermal Lu?i
<script language="JavaScript">
305 023920e7 Ermal
function show_advanced_gateway() {
306
        document.getElementById("showadvgatewaybox").innerHTML='';
307
        aodiv = document.getElementById('showgatewayadv');
308
        aodiv.style.display = "block";
309
}
310 883c53c9 Ermal Lu?i
</script>
311 d173230c Seth Mos
<?php if ($input_errors) print_input_errors($input_errors); ?>
312
            <form action="system_gateways_edit.php" method="post" name="iform" id="iform">
313 124aee67 Chris Buechler
	<?php
314 e9df5769 Seth Mos
315
	/* If this is a system gateway we need this var */
316 124aee67 Chris Buechler
	if(($pconfig['attribute'] == "system") || is_numeric($pconfig['attribute'])) {
317
		echo "<input type='hidden' name='attribute' id='attribute' value='{$pconfig['attribute']}' >\n";
318
	}
319 883c53c9 Ermal Lu?i
	echo "<input type='hidden' name='friendlyiface' id='friendlyiface' value='{$pconfig['friendlyiface']}' >\n";
320 124aee67 Chris Buechler
	?>
321 d173230c Seth Mos
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
322 56d4e7fb Scott Ullrich
				<tr>
323 df152a88 Carlos Eduardo Ramos
					<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit gateway"); ?></td>
324 56d4e7fb Scott Ullrich
				</tr>	
325 d173230c Seth Mos
                <tr> 
326 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
327 d173230c Seth Mos
                  <td width="78%" class="vtable">
328 d44d26c1 Ermal
		 	<select name='interface' class='formselect' >
329 bb849003 Ermal
330 11d2be54 Ermal
		<?php 
331 883c53c9 Ermal Lu?i
                      	$interfaces = get_configured_interface_with_descr(false, true);
332
			foreach ($interfaces as $iface => $ifacename) {
333
				echo "<option value=\"{$iface}\"";
334
				if ($iface == $pconfig['friendlyiface'])
335
					echo " selected";
336
				echo ">" . htmlspecialchars($ifacename) . "</option>";
337
			}
338
			if (is_package_installed("openbgpd") == 1) {
339
				echo "<option value=\"bgpd\"";
340
				if ($pconfig['interface'] == "bgpd") 
341
					echo " selected";
342 df152a88 Carlos Eduardo Ramos
				echo ">" . gettext("Use BGPD") . "</option>";
343 883c53c9 Ermal Lu?i
			}
344
 		  ?>
345 d173230c Seth Mos
                    </select> <br>
346 df152a88 Carlos Eduardo Ramos
                    <span class="vexpl"><?=gettext("Choose which interface this gateway applies to."); ?></span></td>
347 d173230c Seth Mos
                </tr>
348
                <tr>
349 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Name"); ?></td>
350 d173230c Seth Mos
                  <td width="78%" class="vtable"> 
351
                    <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"> 
352 df152a88 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("Gateway name"); ?></span></td>
353 d173230c Seth Mos
                </tr>
354
		<tr>
355 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncellreq"><?=gettext("Gateway"); ?></td>
356 d173230c Seth Mos
                  <td width="78%" class="vtable"> 
357 9498c8d7 Seth Mos
                    <input name="gateway" type="text" class="formfld host" id="gateway" size="28" value="<?php if ($pconfig['dynamic']) echo "dynamic"; else echo $pconfig['gateway']; ?>">
358 df152a88 Carlos Eduardo Ramos
                    <br> <span class="vexpl"><?=gettext("Gateway IP address"); ?></span></td>
359 d173230c Seth Mos
                </tr>
360
		<tr>
361 df152a88 Carlos Eduardo Ramos
		  <td width="22%" valign="top" class="vncell"><?=gettext("Default Gateway"); ?></td>
362 d173230c Seth Mos
		  <td width="78%" class="vtable">
363 d44d26c1 Ermal
			<input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if ($pconfig['defaultgw'] == true) echo "checked"; ?> />
364 df152a88 Carlos Eduardo Ramos
			<strong><?=gettext("Default Gateway"); ?></strong><br />
365
			<?=gettext("This will select the above gateway as the default gateway"); ?>
366 d173230c Seth Mos
		  </td>
367
		</tr>
368
		<tr>
369 df152a88 Carlos Eduardo Ramos
		  <td width="22%" valign="top" class="vncell"><?=gettext("Monitor IP"); ?></td>
370 d173230c Seth Mos
		  <td width="78%" class="vtable">
371 616e1956 Seth Mos
			<?php
372 d44d26c1 Ermal
				if ($pconfig['gateway'] == $pconfig['monitor'])
373 616e1956 Seth Mos
					$monitor = "";
374 d44d26c1 Ermal
				else
375 616e1956 Seth Mos
					$monitor = htmlspecialchars($pconfig['monitor']);
376
			?>
377 9498c8d7 Seth Mos
			<input name="monitor" type="text" id="monitor" value="<?php echo $monitor; ?>" size="28" />
378 df152a88 Carlos Eduardo Ramos
			<strong><?=gettext("Alternative monitor IP"); ?></strong> <br />
379 e88ace75 Chris Buechler
			<?=gettext("Enter an alternative address here to be used to monitor the link. This is used for the " .
380 0e94685b Renato Botelho
			"quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond " .
381
			"to ICMP echo requests (pings)"); ?>.</strong>
382 d173230c Seth Mos
			<br />
383
		  </td>
384
		</tr>
385 5f53260a Ermal
		<tr>
386 023920e7 Ermal
		  <td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td>
387 5f53260a Ermal
		  <td width="78%" class="vtable">
388 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'"; ?>>
389
				<input type="button" onClick="show_advanced_gateway()" value="Advanced"></input> - Show advanced option</a>
390
			</div>
391
			<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'"; ?>>
392
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
393
			<tr>
394
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td>
395
                                <td width="78%" class="vtable">
396
					<select name='weight' class='formfldselect' id='weight'>
397
				<?php
398
					for ($i = 1; $i < 6; $i++) {
399
                                        	$selected = "";
400
                                        	if ($pconfig['weight'] == $i)
401
                                                	$selected = "selected";
402
                                        	echo "<option value='{$i}' {$selected} >{$i}</option>";
403
                                	}
404
				?>
405
					</select>
406
					<br /><?=gettext("Weight for this gateway when used in a Gateway Group.");?> <br />
407
		   		</td>
408
			</tr>
409
                        <tr>
410
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td>
411
                                <td width="78%" class="vtable">
412
                                <?=gettext("From");?>
413
                                    <input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2"
414
                                        value="<?=htmlspecialchars($pconfig['latencylow']);?>">
415
                                <?=gettext("To");?>
416
                                    <input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2"
417
                                        value="<?=htmlspecialchars($pconfig['latencyhigh']);?>">
418
                                    <br> <span class="vexpl"><?=gettext("These define the low and high water marks for latency in milliseconds.");?></span></td>
419
                                </td>
420
                        </tr>
421
                        <tr>
422
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td>
423
                                <td width="78%" class="vtable">
424
                                <?=gettext("From");?>
425
                                    <input name="losslow" type="text" class="formfld unknown" id="losslow" size="2"
426
                                        value="<?=htmlspecialchars($pconfig['losslow']);?>">
427
                                <?=gettext("To");?>
428
                                    <input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2"
429
                                        value="<?=htmlspecialchars($pconfig['losshigh']);?>">
430
                                    <br> <span class="vexpl"><?=gettext("These define the low and high water marks for packet loss in %.");?></span></td>
431
                                </td>
432
                        </tr>
433
			<tr>
434
                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Down");?></td>
435
                                <td width="78%" class="vtable">
436
                                    <input name="down" type="text" class="formfld unknown" id="down" size="2"
437
                                        value="<?=htmlspecialchars($pconfig['down']);?>">
438
                                    <br> <span class="vexpl"><?=gettext("This defines the down time for the alarm to fire, in seconds.");?></span></td>
439
                                </td>
440
                        </tr>
441
                        </table>
442
			</div>
443 5f53260a Ermal
		   </td>
444
		</tr>
445 d173230c Seth Mos
		<tr>
446 df152a88 Carlos Eduardo Ramos
                  <td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
447 d173230c Seth Mos
                  <td width="78%" class="vtable"> 
448
                    <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
449 0e94685b Renato Botelho
                    <br> <span class="vexpl"><?=gettext("You may enter a description here for your reference (not parsed)"); ?>.</span></td>
450 d173230c Seth Mos
                </tr>
451
                <tr>
452
                  <td width="22%" valign="top">&nbsp;</td>
453
                  <td width="78%"> 
454 bfb0b9dc Vinicius Coque
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>"> <input type="button" value="<?=gettext("Cancel");?>" class="formbtn"  onclick="history.back()">
455 d173230c Seth Mos
                    <?php if (isset($id) && $a_gateways[$id]): ?>
456 225a2f0b Scott Ullrich
                    <input name="id" type="hidden" value="<?=htmlspecialchars($id);?>">
457 d173230c Seth Mos
                    <?php endif; ?>
458
                  </td>
459
                </tr>
460
              </table>
461
</form>
462
<?php include("fend.inc"); ?>
463
<script language="JavaScript">
464 883c53c9 Ermal Lu?i
enable_change(document.iform.defaultgw);
465 d173230c Seth Mos
</script>
466
</body>
467
</html>