Project

General

Profile

Download (9.19 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 1d333258 Scott Ullrich
/*
36
	pfSense_MODULE:	igmpproxy
37
*/
38 ce9abebd Ermal Luci
39
##|+PRIV
40
##|*IDENT=page-services-igmpproxy
41
##|*NAME=Firewall: Igmpproxy: Edit page
42
##|*DESCR=Allow access to the 'Firewall: Igmpproxy' page.
43
##|*MATCH=services_igmpproxy_edit.php*
44
##|-PRIV
45
46 fcf384b1 Chris Buechler
$pgtitle = array("Firewall","IGMP Proxy", "Edit");
47 ce9abebd Ermal Luci
48
require("guiconfig.inc");
49
50
if (!is_array($config['igmpproxy']['igmpentry']))
51
	$config['igmpproxy']['igmpentry'] = array();
52
53
//igmpproxy_sort();
54
$a_igmpproxy = &$config['igmpproxy']['igmpentry'];
55
56
$id = $_GET['id'];
57
if (isset($_POST['id']))
58
	$id = $_POST['id'];
59
60
if (isset($id) && $a_igmpproxy[$id]) {
61
	$pconfig['ifname'] = $a_igmpproxy[$id]['ifname'];
62
	$pconfig['threshold'] = $a_igmpproxy[$id]['threshold'];
63
	$pconfig['type'] = $a_igmpproxy[$id]['type'];
64
	$pconfig['address'] = $a_igmpproxy[$id]['address'];
65
	$pconfig['descr'] = html_entity_decode($a_igmpproxy[$id]['descr']);
66
67
}
68
69
if ($_POST) {
70
71
	unset($input_errors);
72
	$pconfig = $_POST;
73
74
	if ($_POST['type'] == "upstream")
75
		foreach ($a_igmpproxy as $proxyentry)
76
			if ($proxyentry['type'] == "upstream" && $proxyentry['ifname'] != $_POST['interface'])
77
				$input_errors[] = "Only one 'upstream' interface can be configured.";
78
	$igmpentry = array();
79
	$igmpentry['ifname'] = $_POST['ifname'];
80
	$igmpentry['threshold'] = $_POST['threshold'];
81
	$igmpentry['type'] = $_POST['type'];
82
	$address = "";
83
	$isfirst = 0;
84
	/* item is a normal igmpentry type */
85
	for($x=0; $x<4999; $x++) {
86
		if($_POST["address{$x}"] <> "") {
87
			if ($isfirst > 0)
88
				$address .= " ";
89
			$address .= $_POST["address{$x}"];
90
			$address .= "/" . $_POST["address_subnet{$x}"];
91
			$isfirst++;
92
		}
93
	}
94
95
	if (!$input_errors) {
96
		$igmpentry['address'] = $address;
97
		$igmpentry['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
98
99
		if (isset($id) && $a_igmpproxy[$id])
100
			$a_igmpproxy[$id] = $igmpentry;
101
		else
102
			$a_igmpproxy[] = $igmpentry;
103
104
		write_config();
105
106
		header("Location: services_igmpproxy.php");
107
		exit;		
108
	}
109
	//we received input errors, copy data to prevent retype
110
	else
111
	{
112
		$pconfig['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto");
113
		$pconfig['address'] = $address;
114
		$pconfig['type'] = $_POST['type'];
115
	}
116
}
117
118
include("head.inc");
119
120
?>
121
122
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
123
<?php
124
	include("fbegin.inc");
125
?>
126
127 625dcc40 Bill Marquette
<script type="text/javascript" src="/javascript/row_helper.js">
128 ce9abebd Ermal Luci
</script>
129
130 6327599d Bill Marquette
<input type='hidden' name='address_type' value='textbox' class="formfld unknown" />
131 ce9abebd Ermal Luci
<input type='hidden' name='address_subnet_type' value='select' />
132
133
<script type="text/javascript">
134
	rowname[0] = "address";
135
	rowtype[0] = "textbox";
136
	rowsize[0] = "30";
137
138
	rowname[1] = "address_subnet";
139
	rowtype[1] = "select";
140
	rowsize[1] = "1";
141
142
	rowname[2] = "detail";
143
	rowtype[2] = "textbox";
144
	rowsize[2] = "50";
145
</script>
146
147
<?php if ($input_errors) print_input_errors($input_errors); ?>
148
<div id="inputerrors"></div>
149
150
<form action="services_igmpproxy_edit.php" method="post" name="iform" id="iform">
151
<table width="100%" border="0" cellpadding="6" cellspacing="0">
152
  <tr>
153 fcf384b1 Chris Buechler
	<td colspan="2" valign="top" class="listtopic">IGMP Proxy Edit</td>
154 ce9abebd Ermal Luci
  </tr>
155
  <tr>
156
    <td valign="top" class="vncellreq">Interface</td>
157
    <td class="vtable"> <select name="ifname" id="ifname" >
158
		<?php $iflist = get_configured_interface_with_descr();
159
			foreach ($iflist as $ifnam => $ifdescr) {
160
				echo "<option value={$ifnam}";
161
				if ($ifnam == $pconfig['ifname'])
162
					echo " selected";
163
				echo ">{$ifdescr}</option>";
164
			}		
165
		?>
166
			</select>
167
    </td>
168
  </tr>
169
  <tr>
170
    <td width="22%" valign="top" class="vncell">Description</td>
171
    <td width="78%" class="vtable">
172
      <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=$pconfig['descr'];?>" />
173
      <br />
174
      <span class="vexpl">
175
        You may enter a description here for your reference (not parsed).
176
      </span>
177
    </td>
178
  </tr>
179
  <tr>
180
    <td valign="top" class="vncellreq">Type</td>
181
    <td class="vtable">
182
      <select name="type" class="formselect" id="type" >
183
        <option value="upstream" <?php if ($pconfig['type'] == "upstream") echo "selected"; ?>>Upstream Interface</option>
184
        <option value="downstream" <?php if ($pconfig['type'] == "downstream") echo "selected"; ?>>Downstream Interface</option>
185
      </select>
186
      <br />
187
      <span class="vexpl">
188 fcf384b1 Chris Buechler
        The <b>upstream</b> network interface is the outgoing interface which is
189
       responsible for communicating to available multicast data sources.
190 ce9abebd Ermal Luci
       There can only be one upstream interface.
191
	</span>
192
	<br />
193
	<span class="vexpl">
194
       <b>Downstream</b> network interfaces are the distribution  interfaces  to  the
195
       destination  networks,  where  multicast  clients  can  join groups and
196 fcf384b1 Chris Buechler
       receive multicast data. One or more downstream interfaces must be configured.
197 ce9abebd Ermal Luci
      </span>
198
    </td>
199
  </tr>
200
  <tr>
201
    <td valign="top" class="vncell">Threshold</td>
202
    <td class="vtable">
203 6327599d Bill Marquette
      <input name="threshold" class="formfld unknown" id="threshold" value="<?php echo $pconfig['threshold'];?>">
204 ce9abebd Ermal Luci
      <br />
205
      <span class="vexpl">
206
	      Defines the TTL threshold for  the  network  interface.  Packets
207
              with  a lower TTL than the threshols value will be ignored. This
208
              setting is optional, and by default the threshold is 1.
209
      </span>
210
    </td>
211
  </tr>
212
  <tr>
213
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Network (s)</div></td>
214
    <td width="78%" class="vtable">
215
      <table id="maintable">
216
        <tbody>
217
          <tr>
218
            <td><div id="onecolumn">Network</div></td>
219
            <td><div id="twocolumn">CIDR</div></td>
220
          </tr>
221
222
	<?php
223
	$counter = 0;
224
	$address = $pconfig['address'];
225
	if ($address <> "") {
226
		$item = explode(" ", $address);
227
		foreach($item as $ww) {
228
			$address = $item[$counter];
229
			$address_subnet = "";
230
			$item2 = explode("/", $address);
231
			foreach($item2 as $current) {
232
				if($item2[1] <> "") {
233
					$address = $item2[0];
234
					$address_subnet = $item2[1];
235
				}
236
			}
237
			$item4 = $item3[$counter];
238
			$tracker = $counter;
239
	?>
240
          <tr>
241
            <td>
242
              <input name="address<?php echo $tracker; ?>" type="text" class="formfld unknown" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
243
            </td>
244
            <td>
245
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
246
			          <option></option>
247
			          <?php for ($i = 32; $i >= 1; $i--): ?>
248
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
249
			          <?php endfor; ?>
250
			        </select>
251
			      </td>
252
            <td>
253
    		<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
254
	      </td>
255
          </tr>
256
<?php
257
        	$counter++;
258
259
       		} // end foreach
260
	} // end if
261
?>
262
        </tbody>
263
        <tfoot>
264
265
        </tfoot>
266
		  </table>
267
			<a onclick="javascript:addRowTo('maintable'); return false;" href="#">
268
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
269
      </a>
270
		</td>
271
  </tr>
272
  <tr>
273
    <td width="22%" valign="top">&nbsp;</td>
274
    <td width="78%">
275
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
276
      <a href="services_igmpproxy.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" /></a>
277
      <?php if (isset($id) && $a_igmpproxy[$id]): ?>
278
      <input name="id" type="hidden" value="<?=$id;?>" />
279
      <?php endif; ?>
280
    </td>
281
  </tr>
282
</table>
283
</form>
284
285
<script type="text/javascript">
286
	field_counter_js = 2;
287
	rows = 1;
288
	totalrows = <?php echo $counter; ?>;
289
	loaded = <?php echo $counter; ?>;
290
</script>
291
292
<?php include("fend.inc"); ?>
293
</body>
294
</html>