Project

General

Profile

Download (20.1 KB) Statistics
| Branch: | Tag: | Revision:
1 21d40ff9 Ermal Lu?i
<?php
2
/* $Id$ */
3
/*
4
	firewall_shaper_layer7.php
5
	Copyright (C) 2008 Helder Pereira, Andr? Ribeiro
6
	All rights reserved.
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
/*
30
	pfSense_BUILDER_BINARIES:	/usr/bin/killall
31
	pfSense_MODULE:	shaper
32
*/
33
34
##|+PRIV
35
##|*IDENT=page-firewall-trafficshaper-layer7
36
##|*NAME=Firewall: Traffic Shaper: Layer7 page
37
##|*DESCR=Allow access to the 'Firewall: Traffic Shaper: Layer7' page.
38
##|*MATCH=firewall_shaper_layer7.php*
39
##|-PRIV
40
41
require("guiconfig.inc");
42 7a927e67 Scott Ullrich
require_once("functions.inc");
43
require_once("filter.inc");
44
require_once("shaper.inc");
45 21d40ff9 Ermal Lu?i
46
// Variables protocols (dynamic) and structures (static)
47
$avail_protos =& generate_protocols_array();
48
$avail_structures = array("action","queue","limiter");
49
50
// Available behaviours
51
$avail_behaviours_action = array("block");
52
read_altq_config();
53
$avail_behaviours_altq = get_altq_name_list();
54
read_dummynet_config();
55
$avail_behaviours_limiter = get_dummynet_name_list();
56
$show_proto_form = false;
57
58
//More variables
59 bb78a6fe Vinicius Coque
$pgtitle = array(gettext("Firewall"),gettext("Traffic Shaper"), gettext("Layer7"));
60 b32dd0a6 jim-p
$shortcut_section = "trafficshaper";
61 21d40ff9 Ermal Lu?i
62
$output_form = "";
63
64
$default_layer7shaper_msg = "<tr><td colspan=\"4\">";
65 e750c0af Colin Fleming
$default_layer7shaper_msg .= "<span class=\"vexpl\"><span class=\"red\"><strong>" . gettext("Note") . ":<br/>";
66 e573ee95 Colin Fleming
$default_layer7shaper_msg .= "</strong></span>" . gettext("You can add new layer7 protocol patterns by simply uploading the file") . " <a href=\"diag_patterns.php\">" . gettext("here") . ".</a></span><br/>";
67 21d40ff9 Ermal Lu?i
$default_layer7shaper_msg .= "</td></tr>";
68
69
70
read_layer7_config();
71
72
if($_GET['reset'] <> "") {
73
	// kill all ipfw-classifyd processes
74 b11cdf92 Renato Botelho
	mwexec("killall -9 ipfw-classifyd");
75 21d40ff9 Ermal Lu?i
	exit;
76
}
77
78
if ($_GET) {
79
	if ($_GET['container'])
80 dd5bf424 Scott Ullrich
		$name = htmlspecialchars(trim($_GET['container']));
81 21d40ff9 Ermal Lu?i
        if ($_GET['action'])
82 dd5bf424 Scott Ullrich
                $action = htmlspecialchars($_GET['action']);
83 21d40ff9 Ermal Lu?i
}
84
85
if($_POST) {
86
	if ($_POST['container']) {
87 dd5bf424 Scott Ullrich
		$name = htmlspecialchars(trim($_POST['container']));
88 21d40ff9 Ermal Lu?i
	}
89
}
90
91
if ($name) {
92
	//Get the object from the 7rules list
93
	$container = $layer7_rules_list[$name];
94
}
95
96
if ($_GET) {
97
	switch ($action) {
98
		case "add":
99
			$show_proto_form = true;
100
			$container = new layer7();
101
			$output_form .= $container->build_form(); //constructs the graphical interface on the right side
102
			unset($container);
103
			break;
104
		case "show":
105
			$show_proto_form = true;
106
			if($container) {
107
				$output_form .= $container->build_form();
108
			}
109
			else {
110
				$show_proto_form = false;
111 813a3ef6 Neriberto C.Prado
				$input_errors[] = gettext("Layer7 Rules Container not found!");
112 21d40ff9 Ermal Lu?i
			}
113
			break;
114
		default:
115
			echo log_error("Get default");
116
			$show_proto_form = false;
117 e573ee95 Colin Fleming
			$output_form .= $dn_default_shaper_msg . $default_layer7shaper_msg;
118 21d40ff9 Ermal Lu?i
			break;
119
	}
120
}
121
122
//add a new l7rules container
123
else if ($_POST) {
124
	$show_proto_form = true;
125
	unset($input_errors);
126 b11cdf92 Renato Botelho
127 21d40ff9 Ermal Lu?i
	if($_POST['submit']) {
128 51b14faa Ermal Lu?i
		if (isset($layer7_rules_list[$name])) {
129
			$l7r = $layer7_rules_list[$name];
130
			$_POST['divert_port'] = $l7r->GetRPort();
131
		} else {
132
			$l7r =& new layer7();
133
			$_POST['divert_port'] = $l7r->gen_divert_port();
134
		}
135 21d40ff9 Ermal Lu?i
		for($i=0; $_POST['protocol'][$i] <> ""; $i++) {
136
			$_POST['l7rules'][$i]['protocol'] = $_POST['protocol'][$i];
137
			$_POST['l7rules'][$i]['structure'] = $_POST['structure'][$i];
138
			$_POST['l7rules'][$i]['behaviour'] = $_POST['behaviour'][$i];
139
		}
140
		$l7r->validate_input($_POST,&$input_errors);
141
		$l7r->ReadConfig($_POST['container'], $_POST);
142
		//Before writing the results, we need to test for repeated protocols
143
		$non_dupes = array();
144
		$dupes = array();
145
		for($j=0; $j<$i; $j++) {
146
			if(!$non_dupes[$_POST['protocol'][$j]])
147
				$non_dupes[$_POST['protocol'][$j]] = true;
148
			else
149
				$dupes[] = $_POST['protocol'][$j];
150
		}
151
		unset($non_dupes);
152
		if(sizeof($dupes) == 0 && !$input_errors) {
153
			$l7r->wconfig();
154 3a343d73 jim-p
			if (write_config())
155
				mark_subsystem_dirty('shaper');
156 21d40ff9 Ermal Lu?i
157
			read_layer7_config();
158
		}
159
		else {
160
			if(sizeof($dupes) > 0) {
161 bb78a6fe Vinicius Coque
				$dupe_error = gettext("Found the following repeated protocol definitions") . ": ";
162 21d40ff9 Ermal Lu?i
				foreach($dupes as $dupe)
163
					$dupe_error .= "$dupe ";
164
				$input_errors[] .= $dupe_error;
165
			}
166
		}
167
		unset($dupes);
168
		unset($dupe_error);
169 b450c94e jim-p
		//Even if there are repeated protocols, we won't lose any previous values
170 21d40ff9 Ermal Lu?i
		//The user will be able to solve the situation
171
		$output_form .= $l7r->build_form();
172
		//Necessary to correctly build the proto form
173
		$container = $layer7_rules_list[$name];
174
		if($input_errors)
175
			$container =& $l7r;
176
	} else if($_POST['apply']) {
177
		write_config();
178
179
		$retval = 0;
180
		$retval = filter_configure();
181
		$savemsg = get_std_save_message($retval);
182
183
		if(stristr($retval, "error") <> true)
184
			$savemsg = get_std_save_message($retval);
185
		else
186
			$savemsg = $retval;
187
188
		clear_subsystem_dirty('shaper');
189
190
		if($container) {
191
			$output_form .= $container->build_form();
192
		} else {
193
			$show_proto_form = false;
194 e573ee95 Colin Fleming
			$output_form .= $dn_default_shaper_msg . $default_layer7shaper_msg;
195 21d40ff9 Ermal Lu?i
		}
196
	} else if ($_POST['delete']) {
197
		$container->delete_l7c();
198 3a343d73 jim-p
		if (write_config())
199
			mark_subsystem_dirty('shaper');
200 21d40ff9 Ermal Lu?i
		unset($container);
201 b11cdf92 Renato Botelho
202 21d40ff9 Ermal Lu?i
		header("Location: firewall_shaper_layer7.php");
203
		exit;
204
	}
205
	else {
206
		$show_proto_form = false;
207
	}
208
}
209
else {
210
	$show_proto_form = false;
211 e573ee95 Colin Fleming
	$output_form .= $dn_default_shaper_msg . $default_layer7shaper_msg;
212 21d40ff9 Ermal Lu?i
}
213
214
// Builds the left tree
215
$tree = "<ul class=\"tree\" >";
216 0a173e6b N0YB
$rowIndex = 0;
217 21d40ff9 Ermal Lu?i
if (is_array($layer7_rules_list)) {
218
        foreach ($layer7_rules_list as $tmpl7) {
219 0a173e6b N0YB
			$rowIndex++;
220 21d40ff9 Ermal Lu?i
                $tree .= $tmpl7->build_tree();
221
        }
222
}
223 0a173e6b N0YB
if ($rowIndex == 0)
224
	$tree .= "<li></li>";
225 21d40ff9 Ermal Lu?i
$tree .= "</ul>";
226
227 e573ee95 Colin Fleming
$output = "<table summary=\"output form\">";
228 21d40ff9 Ermal Lu?i
$output .= $output_form;
229 e750c0af Colin Fleming
$closehead = false;
230 21d40ff9 Ermal Lu?i
include("head.inc");
231
?>
232
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
233
<script type="text/javascript" src="./tree/tree.js"></script>
234 b11cdf92 Renato Botelho
235 e750c0af Colin Fleming
<script type="text/javascript">
236
//<![CDATA[
237 21d40ff9 Ermal Lu?i
var initial_count = new Array();
238
var rows_limit = 0; // Set to 0 to disable limitation
239
240
241
/* Build the behaviours arrays in javascript */
242
var js_behaviours_action = ['block']; //static
243
244
var js_behaviours_altq = new Array();
245
js_behaviours_altq = array_altq(js_behaviours_altq);
246
247
var js_behaviours_limiter = new Array();
248
js_behaviours_limiter = array_limiter(js_behaviours_limiter);
249
250
function array_altq(a_behav) {
251
	var index;
252 b11cdf92 Renato Botelho
	<?php if (!empty($avail_behaviours_altq)) {
253 21d40ff9 Ermal Lu?i
	  foreach ($avail_behaviours_altq as $key => $queue) { ?>
254
	    name = "<?= $queue; ?>";
255 b11cdf92 Renato Botelho
	    index = <?= $key; ?>;
256 21d40ff9 Ermal Lu?i
	    a_behav[index] = name;
257 b11cdf92 Renato Botelho
	<?php }
258 21d40ff9 Ermal Lu?i
	} ?>
259
	return a_behav;
260
}
261
262
function array_limiter(a_behav) {
263
	var index;
264 b11cdf92 Renato Botelho
	<?php if (!empty($avail_behaviours_limiter)) {
265 21d40ff9 Ermal Lu?i
	  foreach ($avail_behaviours_limiter as $key => $limiter) { ?>
266
		name = "<?= $limiter; ?>";
267 b11cdf92 Renato Botelho
		index = <?= $key; ?>;
268 21d40ff9 Ermal Lu?i
		a_behav[index] = name;
269 b11cdf92 Renato Botelho
	<?php }
270 21d40ff9 Ermal Lu?i
	} ?>
271
	return a_behav;
272
}
273
274
/* Fill the variables with available protocols, structures and behaviours */
275
function fillProtocol() {
276 e573ee95 Colin Fleming
	var protocol = '<select name="protocol[]" style="font-size:8pt">';
277 21d40ff9 Ermal Lu?i
	var name;
278
279 b11cdf92 Renato Botelho
	<?php foreach ($avail_protos as $key => $proto) { ?>
280 21d40ff9 Ermal Lu?i
		name = "<?= $proto; ?>";
281 e573ee95 Colin Fleming
		protocol += "<option value=" + name + ">" + name + "<\/option>";
282 b11cdf92 Renato Botelho
	<?php } ?>
283 e573ee95 Colin Fleming
	protocol += "<\/select>";
284 b11cdf92 Renato Botelho
285 21d40ff9 Ermal Lu?i
	return protocol;
286
}
287
288
function fillStructure() {
289 e573ee95 Colin Fleming
	var structure = '<select name="structure[]" style="font-size:8pt" onchange="changeBehaviourValues(this.parentNode.parentNode);">';
290 21d40ff9 Ermal Lu?i
	var name;
291 b11cdf92 Renato Botelho
	<?php foreach ($avail_structures as $key => $struct) { ?>
292 21d40ff9 Ermal Lu?i
		name = "<?= $struct; ?>";
293
		if(name == "queue") {
294 e573ee95 Colin Fleming
		  if(js_behaviours_altq != "") { structure += "<option value=" + name + ">" + name + "<\/option>";}
295 21d40ff9 Ermal Lu?i
		}
296
		else {
297
		  if(name == "limiter") {
298 e573ee95 Colin Fleming
		    if(js_behaviours_limiter != "") { structure += "<option value=" + name + ">" + name + "<\/option>";}
299 21d40ff9 Ermal Lu?i
		  }
300 e573ee95 Colin Fleming
		  else structure += "<option value=" + name + ">" + name + "<\/option>"; //action
301 b11cdf92 Renato Botelho
		}
302
	<?php } ?>
303 e573ee95 Colin Fleming
	structure += "<\/select>";
304 b11cdf92 Renato Botelho
305 21d40ff9 Ermal Lu?i
	return structure;
306
}
307 b11cdf92 Renato Botelho
308 21d40ff9 Ermal Lu?i
//Used by default to fill the values when inserting a new row.
309
function fillBehaviour() {
310 e573ee95 Colin Fleming
	var behaviour = '<select name="behaviour[]" style="width:80px; font-size:8pt">';
311 21d40ff9 Ermal Lu?i
	var name;
312 b11cdf92 Renato Botelho
	<?php foreach ($avail_behaviours_action as $key => $behav) { ?>
313 21d40ff9 Ermal Lu?i
		name = "<?= $behav; ?>";
314 e573ee95 Colin Fleming
		behaviour += "<option value=" + name + ">" + name + "<\/option>";
315 b11cdf92 Renato Botelho
	<?php } ?>
316 e573ee95 Colin Fleming
	behaviour += "<\/select>";
317 b11cdf92 Renato Botelho
318 21d40ff9 Ermal Lu?i
	return behaviour;
319
}
320
321
/* Change the values on behaviours select when changing the structure row */
322
function changeBehaviourValues(row) {
323
	var selectedRow = row.rowIndex - 2; //because row.rowIndex returns 2, not 0
324 b11cdf92 Renato Botelho
	var structureSelected = document.getElementsByName("structure[]")[selectedRow].value;
325
326 21d40ff9 Ermal Lu?i
	//Select the behaviours values to array a_behav
327 b11cdf92 Renato Botelho
	var a_behav = new Array();
328 21d40ff9 Ermal Lu?i
	if (structureSelected == "action") {
329
		a_behav = js_behaviours_action; //static
330
	}
331
	else {
332 b11cdf92 Renato Botelho
		if (structureSelected == "queue") {
333 21d40ff9 Ermal Lu?i
			a_behav = js_behaviours_altq;
334
		}
335 b11cdf92 Renato Botelho
		else {
336 21d40ff9 Ermal Lu?i
			a_behav = js_behaviours_limiter;
337 b11cdf92 Renato Botelho
		}
338
	}
339
340 21d40ff9 Ermal Lu?i
	//Build the html statement with the array values previously selected
341
	var new_behav;
342
	var name;
343
	for(i=0; i<a_behav.length; i++) {
344 e573ee95 Colin Fleming
		new_behav += "<option value=" + a_behav[i] + ">" + a_behav[i] + "<\/option>";
345 21d40ff9 Ermal Lu?i
	}
346 b11cdf92 Renato Botelho
347
	document.getElementsByName("behaviour[]")[selectedRow].innerHTML = new_behav;
348 21d40ff9 Ermal Lu?i
}
349
350
/* Add row to the table */
351
function addRow(table_id) {
352
  var tbl = document.getElementById(table_id);
353
  // counting rows in table
354
  var rows_count = tbl.rows.length;
355
  if (initial_count[table_id] == undefined) {
356
    // if it is first adding in this table setting initial rows count
357
    initial_count[table_id] = rows_count;
358
  }
359
  // determining real count of added fields
360
  var tFielsNum =  rows_count - initial_count[table_id];
361
  if (rows_limit!=0 && tFielsNum >= rows_limit) return false;
362 b11cdf92 Renato Botelho
363 e573ee95 Colin Fleming
  var remove = '<a onclick="removeRow(\''+table_id+'\',this.parentNode.parentNode)" href="#"><img border="0" src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" alt="x" /><\/a>';
364 b11cdf92 Renato Botelho
365 21d40ff9 Ermal Lu?i
  try {
366
    var newRow = tbl.insertRow(rows_count);
367
    var newCell = newRow.insertCell(0);
368
    newCell.innerHTML = fillProtocol();
369
    var newCell = newRow.insertCell(1);
370
    newCell.innerHTML = fillStructure();
371
    var newCell = newRow.insertCell(2);
372
    newCell.innerHTML = fillBehaviour();
373
    var newCell = newRow.insertCell(3);
374
    newCell.innerHTML = remove;
375 b11cdf92 Renato Botelho
  }
376 21d40ff9 Ermal Lu?i
  catch (ex) {
377
    //if exception occurs
378
    alert(ex);
379 b11cdf92 Renato Botelho
  }
380 21d40ff9 Ermal Lu?i
}
381
382
/* Remove row from the table */
383
function removeRow(tbl,row) {
384
  var table = document.getElementById(tbl);
385
  try {
386
    table.deleteRow(row.rowIndex);
387
  } catch (ex) {
388
    alert(ex);
389
  }
390
}
391 e750c0af Colin Fleming
//]]>
392 21d40ff9 Ermal Lu?i
</script>
393 e750c0af Colin Fleming
</head>
394 21d40ff9 Ermal Lu?i
395 e750c0af Colin Fleming
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
396
397
<?php include("fbegin.inc"); ?>
398 21d40ff9 Ermal Lu?i
<div id="inputerrors"></div>
399
<?php if ($input_errors) print_input_errors($input_errors); ?>
400
401
<form action="firewall_shaper_layer7.php" method="post" id="iform" name="iform">
402
403
<?php if ($savemsg) print_info_box($savemsg); ?>
404
<?php if (is_subsystem_dirty('shaper')): ?><p>
405 e750c0af Colin Fleming
<?php print_info_box_np(gettext("The traffic shaper configuration has been changed")  .  ".<br/>" . gettext("You must apply the changes in order for them to take effect."));?><br/></p>
406 21d40ff9 Ermal Lu?i
<?php endif; ?>
407 e750c0af Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="traffic shaper layer7">
408 21d40ff9 Ermal Lu?i
  <tr><td>
409
<?php
410
	$tab_array = array();
411 813a3ef6 Neriberto C.Prado
	$tab_array[0] = array(gettext("By Interface"), false, "firewall_shaper.php");
412
	$tab_array[1] = array(gettext("By Queue"), false, "firewall_shaper_queues.php");
413
	$tab_array[2] = array(gettext("Limiter"), false, "firewall_shaper_vinterface.php");
414
	$tab_array[3] = array(gettext("Layer7"), true, "firewall_shaper_layer7.php");
415
	$tab_array[4] = array(gettext("Wizards"), false, "firewall_shaper_wizards.php");
416 21d40ff9 Ermal Lu?i
	display_top_tabs($tab_array);
417
?>
418
  </td></tr>
419
  <tr>
420
    <td>
421
	<div id="mainarea">
422 e750c0af Colin Fleming
              <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
423 b11cdf92 Renato Botelho
424 21d40ff9 Ermal Lu?i
		<?php if (count($layer7_rules_list) > 0): ?>
425
                        <tr class="tabcont"><td width="25%" align="left">
426
                        </td><td width="75%"> </td></tr>
427 b11cdf92 Renato Botelho
428
		<?php endif; ?>
429 21d40ff9 Ermal Lu?i
			<tr>
430 e750c0af Colin Fleming
			<td width="25%" valign="top" align="left">
431 21d40ff9 Ermal Lu?i
			<?php
432 b11cdf92 Renato Botelho
				echo $tree;
433 21d40ff9 Ermal Lu?i
			?>
434
			<br/><br/>
435
			<a href="firewall_shaper_layer7.php?action=add">
436 e750c0af Colin Fleming
			<img src="./themes/<?=$g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("Create new l7 rules group"); ?>" width="17" height="17" border="0" alt="add" />  <?=gettext("Create new l7 rules group"); ?>
437 21d40ff9 Ermal Lu?i
			</a><br/>
438
			</td>
439
			<td width="75%" valign="top" align="center">
440 e573ee95 Colin Fleming
			<div id="shaperarea" style="position:relative">
441 e750c0af Colin Fleming
			<?php
442 21d40ff9 Ermal Lu?i
				echo $output;
443
			?>
444 b11cdf92 Renato Botelho
445 21d40ff9 Ermal Lu?i
			<!-- Layer 7 rules form -->
446
			<?php if($show_proto_form): ?>
447 e573ee95 Colin Fleming
			<tr><td width="22%" valign="top" class="vncellreq">
448 e750c0af Colin Fleming
                                <div id="addressnetworkport">
449 813a3ef6 Neriberto C.Prado
                                        <?=gettext("Rule(s)"); ?>
450 21d40ff9 Ermal Lu?i
                                </div>
451
                        </td>
452
453 e750c0af Colin Fleming
                        <td width="78%" class="vtable">
454
                                <table width="236" id="maintable" summary="main table">
455 21d40ff9 Ermal Lu?i
					<tbody>
456 b11cdf92 Renato Botelho
457 21d40ff9 Ermal Lu?i
						<tr>
458 e750c0af Colin Fleming
                                                        <td colspan="4">
459
                                                            <div style="font-size: 8pt; padding:5px; margin-top: 16px; margin-bottom: 16px; border:1px dashed #000066;"
460
                                                                id="itemhelp">
461 813a3ef6 Neriberto C.Prado
                                                                <?=gettext("Add one or more rules"); ?>
462 21d40ff9 Ermal Lu?i
                                                            </div>
463
                                                        </td>
464
                                                </tr>
465
466
                                                <tr>
467
                                                        <td>
468 e750c0af Colin Fleming
                                                            <div style="font-size: 8pt; padding:5px;"
469
                                                                id="onecolumn">
470 813a3ef6 Neriberto C.Prado
                                                                <?=gettext("Protocol"); ?>
471 21d40ff9 Ermal Lu?i
                                                            </div>
472
                                                        </td>
473
474
                                                        <td>
475 e750c0af Colin Fleming
                                                            <div style="font-size: 8pt; padding:5px;"
476
                                                                id="twocolumn">
477 813a3ef6 Neriberto C.Prado
                                                                <?=gettext("Structure"); ?>
478 21d40ff9 Ermal Lu?i
                                                            </div>
479
                                                        </td>
480
481
                                                        <td>
482 e750c0af Colin Fleming
                                                            <div style="font-size: 8pt; padding:5px;"
483
                                                                id="threecolumn">
484 813a3ef6 Neriberto C.Prado
                                                                <?=gettext("Behaviour"); ?>
485 21d40ff9 Ermal Lu?i
                                                            </div>
486
                                                        </td>
487 b11cdf92 Renato Botelho
                                                </tr>
488 21d40ff9 Ermal Lu?i
                                                <!-- PHP Code to generate the existing rules -->
489
						<?php
490
						if($container) {
491
							foreach($container->rsets as $l7rule) {
492
						?>
493
						<tr>
494
							<td>
495 e573ee95 Colin Fleming
							<select name="protocol[]" class="formselect" style="font-size:8pt">
496 21d40ff9 Ermal Lu?i
							<?php foreach($avail_protos as $proto): ?>
497 e750c0af Colin Fleming
							<option value="<?=$proto;?>" <?php if ($proto == $l7rule->GetRProtocol()) echo "selected=\"selected\""; ?>><?=$proto;?></option>
498 b11cdf92 Renato Botelho
							<?php endforeach; ?>
499 21d40ff9 Ermal Lu?i
							</select>
500
						</td>
501
						<td>
502 e573ee95 Colin Fleming
							<select name="structure[]" class="formselect" style="font-size:8pt" onchange="changeBehaviourValues(this.parentNode.parentNode);">
503 21d40ff9 Ermal Lu?i
							<?php foreach($avail_structures as $struct) {
504
							  if($struct == "queue") {
505
							    if(!empty($avail_behaviours_altq)) { ?>
506 e750c0af Colin Fleming
							      <option value="<?=$struct ?>" <?php if ($struct == $l7rule->GetRStructure()) echo "selected=\"selected\""; ?>><?=$struct;?></option>
507 21d40ff9 Ermal Lu?i
							    <?php }
508
							  }
509
							  else {
510
							    if($struct == "limiter") {
511
								if(!empty($avail_behaviours_limiter)) { ?>
512 e750c0af Colin Fleming
								  <option value="<?=$struct ?>" <?php if ($struct == $l7rule->GetRStructure()) echo "selected=\"selected\""; ?>><?=$struct;?></option>
513 21d40ff9 Ermal Lu?i
								<?php }
514
							    }
515
							    else {
516
							      if($struct == "action") { ?>
517 e750c0af Colin Fleming
								  <option value="<?=$struct ?>" <?php if ($struct == $l7rule->GetRStructure()) echo "selected=\"selected\""; ?>><?=$struct;?></option>
518 b11cdf92 Renato Botelho
							      <?php }
519 21d40ff9 Ermal Lu?i
							    }
520
							  }
521
							} ?>
522
							</select>
523
						</td>
524
						<td>
525 e573ee95 Colin Fleming
							<select name="behaviour[]" class="formselect" style="width:80px; font-size:8pt">
526 21d40ff9 Ermal Lu?i
							<?php if($l7rule->GetRStructure() == "action"): ?>
527
								<?php foreach($avail_behaviours_action as $behaviour): ?>
528 e750c0af Colin Fleming
								<option value="<?=$behaviour ?>" <?php if ($behaviour == $l7rule->GetRBehaviour()) echo "selected=\"selected\""; ?>><?=$behaviour;?></option>
529 b11cdf92 Renato Botelho
								<?php endforeach; ?>
530 21d40ff9 Ermal Lu?i
								</select>
531 b11cdf92 Renato Botelho
							<?php endif; ?>
532 21d40ff9 Ermal Lu?i
							<?php if($l7rule->GetRStructure() == "queue"): ?>
533
								<?php foreach($avail_behaviours_altq as $behaviour): ?>
534 e750c0af Colin Fleming
								<option value="<?=$behaviour ?>" <?php if ($behaviour == $l7rule->GetRBehaviour()) echo "selected=\"selected\""; ?>><?=$behaviour;?></option>
535 b11cdf92 Renato Botelho
								<?php endforeach; ?>
536 21d40ff9 Ermal Lu?i
								</select>
537 b11cdf92 Renato Botelho
							<?php endif; ?>
538 21d40ff9 Ermal Lu?i
							<?php if($l7rule->GetRStructure() == "limiter"): ?>
539
								<?php foreach($avail_behaviours_limiter as $behaviour): ?>
540 e750c0af Colin Fleming
								<option value="<?=$behaviour ?>" <?php if ($behaviour == $l7rule->GetRBehaviour()) echo "selected=\"selected\""; ?>><?=$behaviour;?></option>
541 b11cdf92 Renato Botelho
								<?php endforeach; ?>
542 21d40ff9 Ermal Lu?i
								</select>
543 b11cdf92 Renato Botelho
							<?php endif; ?>
544 21d40ff9 Ermal Lu?i
						</td>
545
						<td>
546 e750c0af Colin Fleming
							<a onclick="removeRow('maintable',this.parentNode.parentNode); return false;" href="#"><img border="0" src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" alt="x" /></a>
547 21d40ff9 Ermal Lu?i
						</td>
548
						</tr>
549 b11cdf92 Renato Botelho
550 21d40ff9 Ermal Lu?i
						<?php
551
							} //end foreach
552
						} //end if
553 b11cdf92 Renato Botelho
						?>
554 21d40ff9 Ermal Lu?i
                                        </tbody>
555
                                </table>
556
557 e750c0af Colin Fleming
                                        <a onclick="javascript:addRow('maintable'); return false;" href="#"> <img border="0"
558
                                                src="/themes/<?=$g['theme']; ?>/images/icons/icon_plus.gif"
559
                                                alt="" title="<?=gettext("add another entry"); ?>" /> </a>
560 21d40ff9 Ermal Lu?i
                        </td>
561
			</tr>
562
563
                        <tr>
564 e750c0af Colin Fleming
                        <td width="22%" valign="top">
565 21d40ff9 Ermal Lu?i
                                &nbsp;
566
                        </td>
567
568 e750c0af Colin Fleming
                        <td width="78%">
569 e573ee95 Colin Fleming
                                <input id="submit" name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
570 21d40ff9 Ermal Lu?i
571 e750c0af Colin Fleming
				<a href="firewall_shaper_layer7.php">
572 e573ee95 Colin Fleming
                                <input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="<?=gettext("Cancel"); ?>" />
573 b11cdf92 Renato Botelho
574 21d40ff9 Ermal Lu?i
				<?php if($container): ?>
575 e573ee95 Colin Fleming
						<input id="delete" type="submit" class="formbtn" name="delete" value="<?=gettext("Delete"); ?>" />
576 b11cdf92 Renato Botelho
				<?php endif ?>
577 e573ee95 Colin Fleming
				</a>
578 21d40ff9 Ermal Lu?i
                        </td>
579
                        </tr>
580 b11cdf92 Renato Botelho
			<?php endif; ?>
581 21d40ff9 Ermal Lu?i
			<!-- End of layer7 rules form -->
582
			</table>
583 e573ee95 Colin Fleming
			</div><!-- end of div:shape area -->
584 21d40ff9 Ermal Lu?i
585
		      </td></tr>
586
                    </table>
587
		</div>
588
	  </td>
589
	</tr>
590
</table>
591
</form>
592
593 e750c0af Colin Fleming
<?php include("fend.inc"); ?>
594 21d40ff9 Ermal Lu?i
</body>
595
</html>