Project

General

Profile

Download (5.97 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	firewall_shaper_queues.php
5
	Copyright (C) 2004, 2005 Scott Ullrich
6
	Copyright (C) 2008 Ermal Lu?i
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

    
46
/* on HEAD it has to use vc_* api on variable_cache.inc */
47
if (!is_array($GLOBALS['allqueue_list'])) {
48
        $GLOBALS['allqueue_list'] = array();
49
}
50

    
51
/* XXX: NOTE: When dummynet is implemented these will be moved from here */
52
read_altq_config();
53

    
54
$tree = "<ul class=\"tree\" >";
55
foreach ($GLOBALS['allqueue_list'] as $queue) {
56
	$tree .= "<li><a href=\"firewall_shaper_queues.php?queue={$queue}&action=show\" >{$queue}</a></li>";
57
}
58
$tree .= "</ul>";
59

    
60
if ($_GET) {
61
	if ($_GET['queue'])
62
        	$qname = trim($_GET['queue']);
63
        if ($_GET['interface'])
64
                $interface = trim($_GET['interface']);
65
        if ($_GET['action'])
66
                $action = $_GET['action'];
67

    
68
	switch ($action) {
69
	case "delete":
70
			$altq =& $altq_list_queues[$interface];
71
			$qtmp =& $altq->find_queue("", $qname);
72
			if ($qtmp) {
73
				$qtmp->delete_queue(); 
74
				write_config();
75
				touch($d_shaperconfdirty_path);
76
			}
77
			header("Location: firewall_shaper_queues.php");
78
			exit;
79
		break;
80
	case "add":
81
			/* 
82
			 * XXX: WARNING: This returns the first it finds.
83
			 * Maybe the user expects something else?!
84
			 */
85
			foreach ($altq_list_queues as $altq) {
86
				$qtmp =& $altq->find_queue("", $qname);
87
				if ($qtmp) {
88
					$aq =& $altq_list_queues[$interface];
89
					if ($aq) {
90
						//$link =& get_reference_to_me_in_config(&$link);
91
						$aq->copy_queue($interface, &$qtmp);
92
						write_config();
93
                        			touch($d_shaperconfdirty_path);
94
						break;
95
					}
96
				}
97
			}
98
			header("Location: firewall_shaper_queues.php?queue=".$qname."&action=show");
99
			exit;
100
		break;
101
	case "show":
102
			$iflist = get_interface_list();
103
			foreach ($iflist as $if) {
104
				$altq = $altq_list_queues[$if['friendly']];
105
				if ($altq) {
106
					$qtmp =& $altq->find_queue("", $qname);
107
					if ($qtmp) 
108
						$output .= $qtmp->build_shortform();
109
					else
110
						$output .= build_iface_without_this_queue($if['friendly'], $qname);
111
				} else 
112
					$output .= build_iface_without_this_queue($if['friendly'], $qname);
113
			}	
114
		break;
115
	}
116
}
117

    
118
if ($_POST['apply']) {
119
          write_config();
120

    
121
          $retval = 0;
122
         $savemsg = get_std_save_message($retval);
123
        /* Setup pf rules since the user may have changed the optimization value */
124

    
125
                        config_lock();
126
                        $retval = filter_configure();
127
                        config_unlock();
128
                        if (stristr($retval, "error") <> true)
129
                                $savemsg = get_std_save_message($retval);
130
                        else
131
                                $savemsg = $retval;
132

    
133
			enable_rrd_graphing();
134

    
135
            unlink($d_shaperconfdirty_path);
136
}
137

    
138
$pgtitle = "Firewall: Shaper: By Queues View";
139

    
140
include("head.inc");
141
?>
142
<link rel="stylesheet" type="text/css" media="all" href="./tree/tree.css" />
143
<script type="text/javascript" src="./tree/tree.js"></script>
144

    
145
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
146
<?php include("fbegin.inc"); ?>
147
<div id="inputerrors"></div>
148
<?php if ($input_errors) print_input_errors($input_errors); ?>
149
<form action="firewall_shaper_queues.php" method="post" name="iform" id="iform">
150
<?php if ($savemsg) print_info_box($savemsg); ?>
151
<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
152
<?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>
153
<?php endif; ?>
154
<table width="100%" border="0" cellpadding="0" cellspacing="0">
155
  <tr><td>
156
<?php
157
	$tab_array = array();
158
	$tab_array[0] = array("By Interface", false, "firewall_shaper.php");
159
	$tab_array[1] = array("By Queue", true, "firewall_shaper_queues.ph");
160
	$tab_array[2] = array("EZ Shaper wizard", false, "wizard.php?xml=traffic_shaper_wizard.xml");
161
	display_top_tabs($tab_array);
162
?>
163
  </td></tr>
164
  <tr> 
165
    <td valign="top">
166
	<div id="mainarea">
167
		<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
168
		<tr>
169
		<td width="30%" valign="top" algin="left">
170
                <?      echo $tree; ?>
171
		</td>
172
		<td width="70%" valign="top" align="center">
173
			<? 
174
				if ($qname)
175
        				echo "<pr class=\"pgtitle\">" . $qname . "</pr><br />";
176
				echo "<table align=\"center\" class=\"tabcont\" width=\"80%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">";
177
				echo $output;
178
				echo "</table>";
179
			?>	
180
			</td></tr>
181
			</table>
182

    
183
		      </td></tr>
184
		</div>
185
	  </td>
186
	</tr>
187
</table>
188
            </form>
189
<?php include("fend.inc"); 
190
?>
191
</body>
192
</html>
(56-56/187)