Project

General

Profile

Download (9.18 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	services_igmpproxy_edit_edit.php
5

    
6
	Copyright (C) 2009 Ermal Lu?i
7
	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
$pgtitle = array("Firewall","Igmpproxy", "Edit");
45

    
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
<script type="text/javascript" src="/javascript/row_helper.js">
126
</script>
127

    
128
<input type='hidden' name='address_type' value='textbox' class="formfld unknown" />
129
<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
	<td colspan="2" valign="top" class="listtopic">Igmpproxy Edit</td>
152
  </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
        The <b>upstream</b> network interface  is  the  outgoing  interface  which  is
187
       responsible  for  communicating  to  availible  multicast data sources.
188
       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
       receive multicast data. One or more downstream interfaces must be  con-
195
       figured.
196
      </span>
197
    </td>
198
  </tr>
199
  <tr>
200
    <td valign="top" class="vncell">Threshold</td>
201
    <td class="vtable">
202
      <input name="threshold" class="formfld unknown" id="threshold" value="<?php echo $pconfig['threshold'];?>">
203
      <br />
204
      <span class="vexpl">
205
	      Defines the TTL threshold for  the  network  interface.  Packets
206
              with  a lower TTL than the threshols value will be ignored. This
207
              setting is optional, and by default the threshold is 1.
208
      </span>
209
    </td>
210
  </tr>
211
  <tr>
212
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport">Network (s)</div></td>
213
    <td width="78%" class="vtable">
214
      <table id="maintable">
215
        <tbody>
216
          <tr>
217
            <td><div id="onecolumn">Network</div></td>
218
            <td><div id="twocolumn">CIDR</div></td>
219
          </tr>
220

    
221
	<?php
222
	$counter = 0;
223
	$address = $pconfig['address'];
224
	if ($address <> "") {
225
		$item = explode(" ", $address);
226
		foreach($item as $ww) {
227
			$address = $item[$counter];
228
			$address_subnet = "";
229
			$item2 = explode("/", $address);
230
			foreach($item2 as $current) {
231
				if($item2[1] <> "") {
232
					$address = $item2[0];
233
					$address_subnet = $item2[1];
234
				}
235
			}
236
			$item4 = $item3[$counter];
237
			$tracker = $counter;
238
	?>
239
          <tr>
240
            <td>
241
              <input name="address<?php echo $tracker; ?>" type="text" class="formfld unknown" id="address<?php echo $tracker; ?>" size="30" value="<?=htmlspecialchars($address);?>" />
242
            </td>
243
            <td>
244
			        <select name="address_subnet<?php echo $tracker; ?>" class="formselect" id="address_subnet<?php echo $tracker; ?>">
245
			          <option></option>
246
			          <?php for ($i = 32; $i >= 1; $i--): ?>
247
			          <option value="<?=$i;?>" <?php if ($i == $address_subnet) echo "selected"; ?>><?=$i;?></option>
248
			          <?php endfor; ?>
249
			        </select>
250
			      </td>
251
            <td>
252
    		<input type="image" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete" />
253
	      </td>
254
          </tr>
255
<?php
256
        	$counter++;
257

    
258
       		} // end foreach
259
	} // end if
260
?>
261
        </tbody>
262
        <tfoot>
263

    
264
        </tfoot>
265
		  </table>
266
			<a onclick="javascript:addRowTo('maintable'); return false;" href="#">
267
        <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
268
      </a>
269
		</td>
270
  </tr>
271
  <tr>
272
    <td width="22%" valign="top">&nbsp;</td>
273
    <td width="78%">
274
      <input id="submit" name="submit" type="submit" class="formbtn" value="Save" />
275
      <a href="services_igmpproxy.php"><input id="cancelbutton" name="cancelbutton" type="button" class="formbtn" value="Cancel" /></a>
276
      <?php if (isset($id) && $a_igmpproxy[$id]): ?>
277
      <input name="id" type="hidden" value="<?=$id;?>" />
278
      <?php endif; ?>
279
    </td>
280
  </tr>
281
</table>
282
</form>
283

    
284
<script type="text/javascript">
285
	field_counter_js = 2;
286
	rows = 1;
287
	totalrows = <?php echo $counter; ?>;
288
	loaded = <?php echo $counter; ?>;
289
</script>
290

    
291
<?php include("fend.inc"); ?>
292
</body>
293
</html>
(127-127/203)