Project

General

Profile

Download (5.71 KB) Statistics
| Branch: | Tag: | Revision:
1 0ec2fdf0 Ermal Lu?i
<?php
2
/*
3
	Copyright (C) 2009 Ermal Lu?i
4
	Copyright (C) 2004 Scott Ullrich
5
	All rights reserved.
6
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12
13
	2. Redistributions in binary form must reproduce the above copyright
14
	   notice, this list of conditions and the following disclaimer in the
15
	   documentation and/or other materials provided with the distribution.
16
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
##|+PRIV
30
##|*IDENT=page-interfaces-groups
31
##|*NAME=Interfaces: Groups page
32
##|*DESCR=Create interface groups
33
##|*MATCH=interfaces_groups.php*
34
##|-PRIV
35
36
37
require("guiconfig.inc");
38
39
if (!is_array($config['ifgroups']['ifgroupentry']))
40
	$config['ifgroups']['ifgroupentry'] = array();
41
42
$a_ifgroups = &$config['ifgroups']['ifgroupentry'];
43
44
if ($_GET['act'] == "del") {
45
	if ($a_ifgroups[$_GET['id']]) {
46 42753d25 Ermal Lu?i
		$members = explode(" ", $a_ifgroups[$_GET[$id]]);
47
		foreach ($members as $ifs) {
48
			$realif = get_real_interface($ifs);
49
			if ($realif)
50
				mwexec("/sbin/ifconfig  {$realif} -group " . $a_ifgroups[$_GET[$id]]['ifname']);
51
		}
52 0ec2fdf0 Ermal Lu?i
		unset($a_ifgroups[$_GET['id']]);
53
		write_config();
54
		header("Location: interfaces_groups.php");
55
		exit;
56
	}
57
}
58
59
$pgtitle = array("Interfaces","Groups");
60
include("head.inc");
61
62
?>
63
64
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
65
<?php include("fbegin.inc"); ?>
66
67
<table width="100%" border="0" cellpadding="0" cellspacing="0">
68
  <tr><td>
69
<?php
70
        $tab_array = array();
71
        $tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
72
	$tab_array[1] = array("Interface Groups", true, "interfaces_groups.php");
73
        $tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
74 5f1e1d26 Ermal Lu?i
        $tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
75
        $tab_array[4] = array("PPP", false, "interfaces_ppp.php");
76
        $tab_array[5] = array("GRE", false, "interfaces_gre.php");
77
        $tab_array[6] = array("GIF", false, "interfaces_gif.php");
78
        $tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
79
        $tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
80 0ec2fdf0 Ermal Lu?i
        display_top_tabs($tab_array);
81
?>
82
  </td></tr>
83
<tr>
84
    <td>
85
        <div id="mainarea">
86
        <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
87
88
<tr>
89
  <td width="15%" class="listhdrr">Name</td>
90
  <td width="35%" class="listhdrr">Members</td>
91
  <td width="25%" class="listhdr">Description</td>
92
  <td width="5%" class="list"></td>
93
</tr>
94
	  <?php if (count ($a_ifgroups)):
95
		$i = 0; foreach ($a_ifgroups as $ifgroupentry): ?>
96
<tr>
97
  <td class="listlr" ondblclick="document.location='interfaces_groups_edit.php?id=<?=$i;?>';">
98 22e6d572 Ermal Lu?i
	<a href="/firewall_rules.php?if=<?=htmlspecialchars($ifgroupentry['ifname']);?>"><?=htmlspecialchars($ifgroupentry['ifname']);?></a>
99 0ec2fdf0 Ermal Lu?i
  </td>
100
  <td class="listr" ondblclick="document.location='interfaces_groups_edit.php?id=<?=$i;?>';">
101
      <?php
102 42753d25 Ermal Lu?i
	$members_arr = explode(" ", $ifgroupentry['members']);
103 0ec2fdf0 Ermal Lu?i
	$iflist = get_configured_interface_with_descr();
104 22e6d572 Ermal Lu?i
	$memberses_arr = array();
105 0ec2fdf0 Ermal Lu?i
	foreach ($members_arr as $memb)
106
		$memberses_arr[] = $iflist[$memb] ? $iflist[$memb] : $memb;
107
	$memberses = implode(", ", $memberses_arr);
108
	echo $memberses;
109
	if(count($members_arr) < 10) {
110
		echo " ";
111
	} else {
112
		echo "...";
113
	}
114
    ?>
115
  </td>
116
  <td class="listbg" ondblclick="document.location='interfaces_groups_edit.php?id=<?=$i;?>';">
117
    <?=htmlspecialchars($ifgroupentry['descr']);?>&nbsp;
118
  </td>
119
  <td valign="middle" nowrap class="list">
120
    <table border="0" cellspacing="0" cellpadding="1">
121
      <tr>
122
        <td valign="middle"><a href="interfaces_groups_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="edit group"></a></td>
123 42753d25 Ermal Lu?i
        <td><a href="interfaces_groups.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this group? All elements that still use it will become invalid (e.g. filter rules)!')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete ifgroupentry"></a></td>
124 0ec2fdf0 Ermal Lu?i
      </tr>
125
    </table>
126
  </td>
127
</tr>
128
	  <?php $i++; endforeach; endif;?>
129
<tr>
130
  <td class="list" colspan="3"></td>
131
  <td class="list">
132
    <table border="0" cellspacing="0" cellpadding="1">
133
      <tr>
134
	<td valign="middle" width="17">&nbsp;</td>
135
        <td valign="middle"><a href="interfaces_groups_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" title="add a new group"></a></td>
136
        </td>
137
      </tr>
138
    </table>
139
  </td>
140
</tr>
141
<tr>
142
  <td class="tabcont" colspan="3">
143
	<p><span class="vexpl"><span class="red"><strong>Note:<br></strong></span>Interface Groups allow you to create rules that apply to multiple interface at once. If you remove members from an interface group the rules do not apply anymore to that interface.</span></p>
144
	</td>
145
</tr>
146
	</table>
147
	</div>
148
 </td>
149
</tr>
150
</table>
151
<?php include("fend.inc"); ?>
152
</body>
153
</html>