Project

General

Profile

Download (8.1 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
	firewall_shaper_queues.php
6
	Copyright (C) 2004, 2005 Scott Ullrich
7
	All rights reserved.
8

    
9
	Originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

    
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15

    
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18

    
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22

    
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34

    
35
require("guiconfig.inc");
36

    
37
if($_GET['reset'] <> "") {
38
	mwexec("killall -9 pfctl php");
39
	exit;
40
}
41

    
42
if (!is_array($config['shaper']['queue'])) {
43
	$config['shaper']['queue'] = array();
44
}
45
$a_queues = &$config['shaper']['queue'];
46

    
47
$iflist = array("lan" => "LAN", "wan" => "WAN");
48

    
49
for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
50
	$iflist['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
51
}
52

    
53
if ($_POST['apply'] || $_POST['submit']) {
54
	$config['shaper']['enable'] = true;
55
	write_config();
56

    
57
	$retval = 0;
58
	$savemsg = get_std_save_message($retval);
59
	/* Setup pf rules since the user may have changed the optimization value */
60
	config_lock();
61
	$retval = filter_configure();
62
	config_unlock();
63
	if(stristr($retval, "error") <> true)
64
	    $savemsg = get_std_save_message($retval);
65
	else
66
	    $savemsg = $retval;
67

    
68
	if(file_exists($d_shaperconfdirty_path))
69
	  unlink($d_shaperconfdirty_path);
70
}
71

    
72
if ($_GET['act'] == "del") {
73
	if ($a_queues[$_GET['id']]) {
74
		/* check that no rule references this queue */
75
		if (is_array($config['shaper']['rule'])) {
76
			foreach ($config['shaper']['rule'] as $rule) {
77
				if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
78
					$input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
79
					break;
80
				}
81
			}
82
		}
83

    
84
		if (!$input_errors) {
85
			unset($a_queues[$_GET['id']]);
86

    
87
			/* renumber all rules */
88
			if (is_array($config['shaper']['rule'])) {
89
				for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
90
					$currule = &$config['shaper']['rule'][$i];
91
					if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
92
						$currule['targetqueue']--;
93
				}
94
			}
95

    
96
			write_config();
97
			touch($d_shaperconfdirty_path);
98
			header("Location: firewall_shaper_queues.php");
99
			exit;
100
		}
101
	}
102
}
103
?>
104
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
105
<html>
106
<head>
107
<title><?=gentitle("Firewall: Traffic shaper: Queues");?></title>
108
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
109
<link href="gui.css" rel="stylesheet" type="text/css">
110
</head>
111

    
112
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
113
<?php include("fbegin.inc"); ?>
114
<p class="pgtitle">Firewall: Traffic shaper: Queues</p>
115
<form action="firewall_shaper_queues.php" method="post">
116
<?php if ($input_errors) print_input_errors($input_errors); ?>
117
<?php if ($savemsg) print_info_box($savemsg); ?>
118
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
119
<?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>
120
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
121
<?php endif; ?>
122
<table width="100%" border="0" cellpadding="0" cellspacing="0">
123
  <tr><td>
124
  <ul id="tabnav">
125
    <li class="tabinact"><a href="firewall_shaper.php">Rules</a></li>
126
    <li class="tabact">Queues</a></li>
127
    <li class="tabinact"><a href="wizard.php?xml=traffic_shaper_wizard.xml">EZ Shaper wizard</a></li>
128
  </ul>
129
  </td></tr>
130
  <tr>
131
    <td class="tabcont">
132
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
133
                      <tr>
134
                        <td width="5%" class="listhdrr">No.</td>
135
			<td width="5%" class="listhdrr">Flags</td>
136
                        <td width="5%" class="listhdrr">Priority</td>
137
			<td width="5%" class="listhdr">Default</td>
138
			<td width="5%" class="listhdr">Bandwidth</td>
139
                        <td width="70%" class="listhdr">Name</td>
140
                        <td width="10%" class="list"></td>
141
                      </tr>
142
                      <?php $i = 0; foreach ($a_queues as $queue): ?>
143
                      <tr valign="top">
144
                        <td class="listlr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
145
                          <?=($i+1);?>
146
			</td>
147
			<td class="listlr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
148
			  <?php
149
			     if($queue['red'] <> "") echo " RED";
150
			     if($queue['rio'] <> "") echo " RIO";
151
			     if($queue['ecn'] <> "") echo " ECN";
152
			     if($queue['borrow'] <> "") echo " Borrow";
153
			  ?>
154
			  &nbsp;
155
			</td>
156
                        <td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
157
                          <?=$queue['priority'];?>&nbsp;
158
			</td>
159
			<td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
160
			  <?php
161
				if($queue['defaultqueue'] <> "") {
162
					echo "Yes";
163
				} else {
164
					echo "No";
165
				}
166
			  ?>
167
			</td>
168
                        <td class="listr" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
169
                          <?=htmlspecialchars($queue['bandwidth']);?> <?=htmlspecialchars($queue['bandwidthtype']);?>
170
                          &nbsp;
171
			</td>
172
                        <td class="listbg" ondblclick="document.location='firewall_shaper_queues_edit.php?id=<?=$i;?>';">
173
                          <font color="#FFFFFF"><?=htmlspecialchars($queue['name']);?>
174
                          &nbsp;
175
			</td>
176
                        <td valign="middle" nowrap class="list">
177
                          <table border="0" cellspacing="0" cellpadding="1">
178
                            <tr>
179
                              <td valign="middle"><a href="firewall_shaper_queues_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a></td>
180
                              <td valign="middle"><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>
181
                            </tr>
182
                         </table>
183
                        </td>
184
                      </tr>
185
                      <?php $i++; endforeach; $total_queues = $i; ?>
186
                      <tr>
187
                        <td class="list" colspan="6"></td>
188
                        <td class="list">
189
                          <table border="0" cellspacing="0" cellpadding="1">
190
                            <tr>
191
                              <td valign="middle"><a href="firewall_shaper_queues_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
192
                            </tr>
193
                          </table>
194
                        </td>
195
                      </tr>
196
                    </table>
197
		    <p>
198
                    <strong><span class="red">Note:</span></strong><strong><br></strong>
199
                      1)  A queue can only be deleted if it is not referenced by any rules.<br>
200
		      2)  Queue graphs take 5 seconds to sample data.
201
		      </td>
202
		    </p>
203
	</tr>
204
</table>
205
            </form>
206
<?php include("fend.inc"); ?>
207
</body>
208
</html>
(40-40/117)