Project

General

Profile

Download (5.99 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2
<?php
3
/*
4
	firewall_shaper_queues.php
5 b49448ac Scott Ullrich
	Copyright (C) 2004, 2005 Scott Ullrich
6
	All rights reserved.
7 5b237745 Scott Ullrich
8 b49448ac Scott Ullrich
	Originally part of m0n0wall (http://m0n0.ch/wall)
9 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
11
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14
15
	1. Redistributions of source code must retain the above copyright notice,
16
	   this list of conditions and the following disclaimer.
17
18
	2. Redistributions in binary form must reproduce the above copyright
19
	   notice, this list of conditions and the following disclaimer in the
20
	   documentation and/or other materials provided with the distribution.
21
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33
34
require("guiconfig.inc");
35
36 12bcdc89 Scott Ullrich
if (!is_array($config['shaper']['pipe'])) {
37
	$config['shaper']['pipe'] = array();
38 5b237745 Scott Ullrich
}
39 12bcdc89 Scott Ullrich
if (!is_array($config['shaper']['queue'])) {
40
	$config['shaper']['queue'] = array();
41 5b237745 Scott Ullrich
}
42 12bcdc89 Scott Ullrich
$a_queues = &$config['shaper']['queue'];
43
$a_pipe = &$config['shaper']['pipe'];
44 5b237745 Scott Ullrich
45 845dc7ed Scott Ullrich
$iflist = array("lan" => "LAN", "wan" => "WAN");
46
47
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
48
	$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
49
}
50
51 5b237745 Scott Ullrich
if ($_GET['act'] == "del") {
52
	if ($a_queues[$_GET['id']]) {
53
		/* check that no rule references this queue */
54 12bcdc89 Scott Ullrich
		if (is_array($config['shaper']['rule'])) {
55
			foreach ($config['shaper']['rule'] as $rule) {
56 5b237745 Scott Ullrich
				if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
57
					$input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
58
					break;
59
				}
60
			}
61
		}
62
63
		if (!$input_errors) {
64
			unset($a_queues[$_GET['id']]);
65
66
			/* renumber all rules */
67 12bcdc89 Scott Ullrich
			if (is_array($config['shaper']['rule'])) {
68
				for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
69
					$currule = &$config['shaper']['rule'][$i];
70 5b237745 Scott Ullrich
					if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
71
						$currule['targetqueue']--;
72
				}
73
			}
74
75
			write_config();
76
			touch($d_shaperconfdirty_path);
77
			header("Location: firewall_shaper_queues.php");
78
			exit;
79
		}
80
	}
81
}
82
?>
83
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
84
<html>
85
<head>
86
<title><?=gentitle("Firewall: Traffic shaper");?></title>
87
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
88
<link href="gui.css" rel="stylesheet" type="text/css">
89
</head>
90
91
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
92
<?php include("fbegin.inc"); ?>
93
<p class="pgtitle">Firewall: Traffic shaper Queues</p>
94 54eaa3c1 Scott Ullrich
<form action="firewall_shaper_queues.php" method="post">
95 5b237745 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
96
<?php if ($savemsg) print_info_box($savemsg); ?>
97
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
98
<?php print_info_box_np("The traffic shaper configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
99
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
100
<?php endif; ?>
101
<table width="100%" border="0" cellpadding="0" cellspacing="0">
102
  <tr><td>
103
  <ul id="tabnav">
104 1b8f6d97 Scott Ullrich
    <li class="tabinact"><a href="firewall_shaper.php">Rules</a></li>
105
    <li class="tabact">Queues</a></li>
106
    <li class="tabinact"><a href="firewall_shaper_magic.php">Magic shaper wizard</a></li>
107 5b237745 Scott Ullrich
  </ul>
108
  </td></tr>
109
  <tr>
110
    <td class="tabcont">
111
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
112
                      <tr>
113
                        <td width="10%" class="listhdrr">No.</td>
114
                        <td width="5%" class="listhdrr">Priority</td>
115 12bcdc89 Scott Ullrich
			<td width="5%" class="listhdr">Default</td>
116
                        <td width="30%" class="listhdr">Name</td>
117 5b237745 Scott Ullrich
                        <td width="10%" class="list"></td>
118
                      </tr>
119
                      <?php $i = 0; foreach ($a_queues as $queue): ?>
120
                      <tr valign="top">
121
                        <td class="listlr">
122 12bcdc89 Scott Ullrich
                          <?=($i+1);?>
123
			</td>
124 5b237745 Scott Ullrich
                        <td class="listr">
125 12bcdc89 Scott Ullrich
                          <?=$queue['priority'];?>
126
			</td>
127
			<td class="listr">
128
			  <?php
129
				if($queue['default'] <> "") {
130
					echo "Yes";
131
				} else {
132
					echo "No";
133
				}
134
			  ?>
135
			</td>
136 5b237745 Scott Ullrich
                        <td class="listbg">
137 2dc6b3ad Scott Ullrich
                          <font color="#FFFFFF"><?=htmlspecialchars($queue['name']);?>
138 12bcdc89 Scott Ullrich
                          &nbsp;
139
			</td>
140 5b237745 Scott Ullrich
                        <td valign="middle" nowrap class="list"> <a href="firewall_shaper_queues_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
141
                          &nbsp;<a href="firewall_shaper_queues.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this queue?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
142
                      </tr>
143
                      <?php $i++; endforeach; ?>
144
                      <tr>
145
                        <td class="list" colspan="5"></td>
146
                        <td class="list"> <a href="firewall_shaper_queues_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
147
                      </tr>
148
                    </table>
149
			        <p>
150
                    <strong><span class="red">Note:</span></strong> a queue can
151
                    only be deleted if it is not referenced by any rules.</td></p>
152
	</tr>
153
</table>
154
            </form>
155
<?php include("fend.inc"); ?>
156
</body>
157
</html>