Project

General

Profile

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