Project

General

Profile

Download (9.16 KB) Statistics
| Branch: | Tag: | Revision:
1 ce9abebd Ermal Luci
<?php
2
/* $Id$ */
3
/*
4
	services_igmpproxy_edit_edit.php
5 8ec0b9d0 Ermal Luci
6
	Copyright (C) 2009 Ermal Lu?i
7 ce9abebd Ermal Luci
	Copyright (C) 2004 Scott Ullrich
8
	All rights reserved.
9
10
	originially part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23
24
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
26
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
	POSSIBILITY OF SUCH DAMAGE.
34
*/
35
36
##|+PRIV
37
##|*IDENT=page-services-igmpproxy
38
##|*NAME=Firewall: Igmpproxy: Edit page
39
##|*DESCR=Allow access to the 'Firewall: Igmpproxy' page.
40
##|*MATCH=services_igmpproxy_edit.php*
41
##|-PRIV
42
43
44 fcf384b1 Chris Buechler
$pgtitle = array("Firewall","IGMP Proxy", "Edit");
45 ce9abebd Ermal Luci
46
require("guiconfig.inc");
47
48
if (!is_array($config['igmpproxy']['igmpentry']))
49
	$config['igmpproxy']['igmpentry'] = array();
50
51
//igmpproxy_sort();
52
$a_igmpproxy = &$config['igmpproxy']['igmpentry'];
53
54
$id = $_GET['id'];
55
if (isset($_POST['id']))
56
	$id = $_POST['id'];
57
58
if (isset($id) && $a_igmpproxy[$id]) {
59
	$pconfig['ifname'] = $a_igmpproxy[$id]['ifname'];
60
	$pconfig['threshold'] = $a_igmpproxy[$id]['threshold'];
61
	$pconfig['type'] = $a_igmpproxy[$id]['type'];
62
	$pconfig['address'] = $a_igmpproxy[$id]['address'];
63
	$pconfig['descr'] = html_entity_decode($a_igmpproxy[$id]['descr']);
64
65
}
66
67
if ($_POST) {
68
69
	unset($input_errors);
70
	$pconfig = $_POST;
71
72
	if ($_POST['type'] == "upstream")
73
		foreach ($a_igmpproxy as $proxyentry)
74
			if ($proxyentry['type'] == "upstream" && $proxyentry['ifname'] != $_POST['interface'])
75
				$input_errors[] = "Only one 'upstream' interface can be configured.";
76
	$igmpentry = array();
77
	$igmpentry['ifname'] = $_POST['ifname'];
78
	$igmpentry['threshold'] = $_POST['threshold'];
79
	$igmpentry['type'] = $_POST['type'];
80
	$address = "";
81
	$isfirst = 0;
82
	/* item is a normal igmpentry type */
83
	for($x=0; $x<4999; $x++) {
84
		if($_POST["address{$x}"] <> "") {
85
			if ($isfirst > 0)
86
				$address .= " ";
87
			$address .= $_POST["address{$x}"];
88
			$address .= "/" . $_POST["address_subnet{$x}"];
89
			$isfirst++;
90
		}
91
	}
92
93
	if (!$input_errors) {
94
		$igmpentry['address'] = $address;
95
		$igmpentry['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
96
97
		if (isset($id) && $a_igmpproxy[$id])
98
			$a_igmpproxy[$id] = $igmpentry;
99
		else
100
			$a_igmpproxy[] = $igmpentry;
101
102
		write_config();
103
104
		header("Location: services_igmpproxy.php");
105
		exit;		
106
	}
107
	//we received input errors, copy data to prevent retype
108
	else
109
	{
110
		$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
111
		$pconfig['address'] = $address;
112
		$pconfig['type'] = $_POST['type'];
113
	}
114
}
115
116
include("head.inc");
117
118
?>
119
120
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
121
<?php
122
	include("fbegin.inc");
123
?>
124
125 625dcc40 Bill Marquette
<script type="text/javascript" src="/javascript/row_helper.js">
126 ce9abebd Ermal Luci
</script>
127
128 6327599d Bill Marquette
<input type='hidden' name='address_type' value='textbox' class="formfld unknown" />
129 ce9abebd Ermal Luci
<input type='hidden' name='address_subnet_type' value='select' />
130
131
<script type="text/javascript">
132
	rowname[0] = "address";
133
	rowtype[0] = "textbox";
134
	rowsize[0] = "30";
135
136
	rowname[1] = "address_subnet";
137
	rowtype[1] = "select";
138
	rowsize[1] = "1";
139
140
	rowname[2] = "detail";
141
	rowtype[2] = "textbox";
142
	rowsize[2] = "50";
143
</script>
144
145
<?php if ($input_errors) print_input_errors($input_errors); ?>
146
<div id="inputerrors"></div>
147
148
<form action="services_igmpproxy_edit.php" method="post" name="iform" id="iform">
149
<table width="100%" border="0" cellpadding="6" cellspacing="0">
150
  <tr>
151 fcf384b1 Chris Buechler
	<td colspan="2" valign="top" class="listtopic">IGMP Proxy Edit</td>
152 ce9abebd Ermal Luci
  </tr>
153
  <tr>
154
    <td valign="top" class="vncellreq">Interface</td>
155
    <td class="vtable"> <select name="ifname" id="ifname" >
156
		<?php $iflist = get_configured_interface_with_descr();
157
			foreach ($iflist as $ifnam => $ifdescr) {
158
				echo "<option value={$ifnam}";
159
				if ($ifnam == $pconfig['ifname'])
160
					echo " selected";
161
				echo ">{$ifdescr}</option>";
162
			}		
163
		?>
164
			</select>
165
    </td>
166
  </tr>
167
  <tr>
168
    <td width="22%" valign="top" class="vncell">Description</td>
169
    <td width="78%" class="vtable">
170
      <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
171
      <br />
172
      <span class="vexpl">
173
        You may enter a description here for your reference (not parsed).
174
      </span>
175
    </td>
176
  </tr>
177
  <tr>
178
    <td valign="top" class="vncellreq">Type</td>
179
    <td class="vtable">
180
      <select name="type" class="formselect" id="type" >
181
        <option value="upstream" <?php if ($pconfig['type'] == "upstream") echo "selected"; ?>>Upstream Interface</option>
182
        <option value="downstream" <?php if ($pconfig['type'] == "downstream") echo "selected"; ?>>Downstream Interface</option>
183
      </select>
184
      <br />
185
      <span class="vexpl">
186 fcf384b1 Chris Buechler
        The <b>upstream</b> network interface is the outgoing interface which is
187
       responsible for communicating to available multicast data sources.
188 ce9abebd Ermal Luci
       There can only be one upstream interface.
189
	</span>
190
	<br />
191
	<span class="vexpl">
192
       <b>Downstream</b> network interfaces are the distribution  interfaces  to  the
193
       destination  networks,  where  multicast  clients  can  join groups and
194 fcf384b1 Chris Buechler
       receive multicast data. One or more downstream interfaces must be configured.
195 ce9abebd Ermal Luci
      </span>
196
    </td>
197
  </tr>
198
  <tr>
199
    <td valign="top" class="vncell">Threshold</td>
200
    <td class="vtable">
201 6327599d Bill Marquette
      <input name="threshold" class="formfld unknown" id="threshold" value="<?php echo $pconfig['threshold'];?>">
202 ce9abebd Ermal Luci
      <br />
203
      <span class="vexpl">
204
	      Defines the TTL threshold for  the  network  interface.  Packets
205
              with  a lower TTL than the threshols value will be ignored. This
206
              setting is optional, and by default the threshold is 1.
207
      </span>
208
    </td>
209
  </tr>
210
  <tr>
211
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Network (s)</div></td>
212
    <td width="78%" class="vtable">
213
      <table id="maintable">
214
        <tbody>
215
          <tr>
216
            <td><div id="onecolumn">Network</div></td>
217
            <td><div id="twocolumn">CIDR</div></td>
218
          </tr>
219
220
	<?php
221
	$counter = 0;
222
	$address = $pconfig['address'];
223
	if ($address <> "") {
224
		$item = explode(" ", $address);
225
		foreach($item as $ww) {
226
			$address = $item[$counter];
227
			$address_subnet = "";
228
			$item2 = explode("/", $address);
229
			foreach($item2 as $current) {
230
				if($item2[1] <> "") {
231
					$address = $item2[0];
232
					$address_subnet = $item2[1];
233
				}
234
			}
235
			$item4 = $item3[$counter];
236
			$tracker = $counter;
237
	?>
238
          <tr>
239
            <td>
240
              <input name="address<?php echo $tracker; ?>" type="text" class="formfld unknown" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
241
            </td>
242
            <td>
243
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
244
			          <option></option>
245
			          <?php for ($i = 32; $i >= 1; $i--): ?>
246
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
247
			          <?php endfor; ?>
248
			        </select>
249
			      </td>
250
            <td>
251
    		<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
252
	      </td>
253
          </tr>
254
<?php
255
        	$counter++;
256
257
       		} // end foreach
258
	} // end if
259
?>
260
        </tbody>
261
        <tfoot>
262
263
        </tfoot>
264
		  </table>
265
			<a onclick="javascript:addRowTo('maintable'); return false;" href="#">
266
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
267
      </a>
268
		</td>
269
  </tr>
270
  <tr>
271
    <td width="22%" valign="top">&nbsp;</td>
272
    <td width="78%">
273
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
274
      <a href="services_igmpproxy.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" /></a>
275
      <?php if (isset($id) && $a_igmpproxy[$id]): ?>
276
      <input name="id" type="hidden" value="<?=$id;?>" />
277
      <?php endif; ?>
278
    </td>
279
  </tr>
280
</table>
281
</form>
282
283
<script type="text/javascript">
284
	field_counter_js = 2;
285
	rows = 1;
286
	totalrows = <?php echo $counter; ?>;
287
	loaded = <?php echo $counter; ?>;
288
</script>
289
290
<?php include("fend.inc"); ?>
291
</body>
292
</html>