Project

General

Profile

Download (5.77 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	firewall_shaper_queues.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	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

    
32
require("guiconfig.inc");
33

    
34
if (!is_array($config['pfqueueing']['pipe'])) {
35
	$config['pfqueueing']['pipe'] = array();
36
}
37
if (!is_array($config['pfqueueing']['queue'])) {
38
	$config['pfqueueing']['queue'] = array();
39
}
40
$a_queues = &$config['pfqueueing']['queue'];
41
$a_pipe = &$config['pfqueueing']['pipe'];
42

    
43
if ($_GET['act'] == "del") {
44
	if ($a_queues[$_GET['id']]) {
45
		/* check that no rule references this queue */
46
		if (is_array($config['pfqueueing']['rule'])) {
47
			foreach ($config['pfqueueing']['rule'] as $rule) {
48
				if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
49
					$input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
50
					break;
51
				}
52
			}
53
		}
54

    
55
		if (!$input_errors) {
56
			unset($a_queues[$_GET['id']]);
57

    
58
			/* renumber all rules */
59
			if (is_array($config['pfqueueing']['rule'])) {
60
				for ($i = 0; isset($config['pfqueueing']['rule'][$i]); $i++) {
61
					$currule = &$config['pfqueueing']['rule'][$i];
62
					if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
63
						$currule['targetqueue']--;
64
				}
65
			}
66

    
67
			write_config();
68
			touch($d_shaperconfdirty_path);
69
			header("Location: firewall_shaper_queues.php");
70
			exit;
71
		}
72
	}
73
}
74
?>
75
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
76
<html>
77
<head>
78
<title><?=gentitle("Firewall: Traffic shaper");?></title>
79
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
80
<link href="gui.css" rel="stylesheet" type="text/css">
81
</head>
82

    
83
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
84
<?php include("fbegin.inc"); ?>
85
<p class="pgtitle">Firewall: Traffic shaper Queues</p>
86
<form action="firewall_shaper.php" method="post">
87
<?php if ($input_errors) print_input_errors($input_errors); ?>
88
<?php if ($savemsg) print_info_box($savemsg); ?>
89
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
90
<?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>
91
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
92
<?php endif; ?>
93
<table width="100%" border="0" cellpadding="0" cellspacing="0">
94
  <tr><td>
95
  <ul id="tabnav">
96
    <li class="tabinact"><a href="firewall_rules.php">Rules</a></li>
97
    <li class="tabact">Queues</li>
98
  </ul>
99
  </td></tr>
100
  <tr>
101
    <td class="tabcont">
102
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
103
                      <tr>
104
                        <td width="10%" class="listhdrr">No.</td>
105
                        <td width="5%" class="listhdrr">Priority</td>
106
                        <td width="20%" class="listhdrr">Options</td>
107
                        <td width="30%" class="listhdr">Description</td>
108
                        <td width="10%" class="list"></td>
109
                      </tr>
110
                      <?php $i = 0; foreach ($a_queues as $queue): ?>
111
                      <tr valign="top">
112
                        <td class="listlr">
113
                          <?=($i+1);?></td>
114
                        <td class="listr">
115
                          <?=$queue['priority'];?></td>
116
                        <td class="listr">
117
                          <?php if ($queue['options']): ?>
118
                          <?=$queue['options'];?>
119
                          <?php endif; ?>
120
                          &nbsp; </td>
121
                        <td class="listbg">
122
                          <?=htmlspecialchars($queue['name']);?>
123
                          &nbsp; </td>
124
                        <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>
125
                          &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>
126
                      </tr>
127
                      <?php $i++; endforeach; ?>
128
                      <tr>
129
                        <td class="list" colspan="5"></td>
130
                        <td class="list"> <a href="firewall_shaper_queues_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
131
                      </tr>
132
                    </table>
133
			        <p>
134
                    <strong><span class="red">Note:</span></strong> a queue can
135
                    only be deleted if it is not referenced by any rules.</td></p>
136
	</tr>
137
</table>
138
            </form>
139
<?php include("fend.inc"); ?>
140
</body>
141
</html>
(32-32/86)