Projet

Général

Profil

Télécharger (9,78 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / services_igmpproxy_edit.php @ 7e736f38

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
	pfSense_MODULE:	igmpproxy
37
*/
38

    
39
##|+PRIV
40
##|*IDENT=page-services-igmpproxy-edit
41
##|*NAME=Firewall: Igmpproxy: Edit page
42
##|*DESCR=Allow access to the 'Services: Igmpproxy: Edit' page.
43
##|*MATCH=services_igmpproxy_edit.php*
44
##|-PRIV
45

    
46
$pgtitle = array(gettext("Firewall"),gettext("IGMP Proxy"), gettext("Edit"));
47

    
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
if (is_numericint($_GET['id']))
57
	$id = $_GET['id'];
58
if (isset($_POST['id']) && is_numericint($_POST['id']))
59
	$id = $_POST['id'];
60

    
61
if (isset($id) && $a_igmpproxy[$id]) {
62
	$pconfig['ifname'] = $a_igmpproxy[$id]['ifname'];
63
	$pconfig['threshold'] = $a_igmpproxy[$id]['threshold'];
64
	$pconfig['type'] = $a_igmpproxy[$id]['type'];
65
	$pconfig['address'] = $a_igmpproxy[$id]['address'];
66
	$pconfig['descr'] = html_entity_decode($a_igmpproxy[$id]['descr']);
67

    
68
}
69

    
70
if ($_POST) {
71

    
72
	unset($input_errors);
73
	$pconfig = $_POST;
74

    
75
	if ($_POST['type'] == "upstream") {
76
		foreach ($a_igmpproxy as $pid => $proxyentry) {
77
			if (isset($id) && $id == $pid)
78
				continue;
79
			if ($proxyentry['type'] == "upstream" && $proxyentry['ifname'] != $_POST['interface'])
80
				$input_errors[] = gettext("Only one 'upstream' interface can be configured.");
81
		}
82
	}
83
	$igmpentry = array();
84
	$igmpentry['ifname'] = $_POST['ifname'];
85
	$igmpentry['threshold'] = $_POST['threshold'];
86
	$igmpentry['type'] = $_POST['type'];
87
	$address = "";
88
	$isfirst = 0;
89
	/* item is a normal igmpentry type */
90
	for($x=0; $x<4999; $x++) {
91
		if($_POST["address{$x}"] <> "") {
92
			if ($isfirst > 0)
93
				$address .= " ";
94
			$address .= $_POST["address{$x}"];
95
			$address .= "/" . $_POST["address_subnet{$x}"];
96
			$isfirst++;
97
		}
98
	}
99

    
100
	if (!$input_errors) {
101
		$igmpentry['address'] = $address;
102
		$igmpentry['descr'] = $_POST['descr'];
103

    
104
		if (isset($id) && $a_igmpproxy[$id])
105
			$a_igmpproxy[$id] = $igmpentry;
106
		else
107
			$a_igmpproxy[] = $igmpentry;
108

    
109
		write_config();
110

    
111
		mark_subsystem_dirty('igmpproxy');
112
		header("Location: services_igmpproxy.php");
113
		exit;		
114
	}
115
	//we received input errors, copy data to prevent retype
116
	else
117
	{
118
		$pconfig['descr'] = $_POST['descr'];
119
		$pconfig['address'] = $address;
120
		$pconfig['type'] = $_POST['type'];
121
	}
122
}
123

    
124
include("head.inc");
125

    
126
?>
127

    
128
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
129
<?php
130
	include("fbegin.inc");
131
?>
132

    
133
<script type="text/javascript" src="/javascript/jquery.ipv4v6ify.js">
134
</script>
135
<script type="text/javascript" src="/javascript/row_helper.js">
136
</script>
137

    
138
<input type='hidden' name='address_type' value='textbox' class="formfld unknown" />
139
<input type='hidden' name='address_subnet_type' value='select' />
140

    
141
<script type="text/javascript">
142
	rowname[0] = "address";
143
	rowtype[0] = "textbox,ipv4v6";
144
	rowsize[0] = "30";
145

    
146
	rowname[1] = "address_subnet";
147
	rowtype[1] = "select,ipv4v6";
148
	rowsize[1] = "1";
149

    
150
	rowname[2] = "detail";
151
	rowtype[2] = "textbox";
152
	rowsize[2] = "50";
153
</script>
154

    
155
<?php if ($input_errors) print_input_errors($input_errors); ?>
156
<div id="inputerrors"></div>
157

    
158
<form action="services_igmpproxy_edit.php" method="post" name="iform" id="iform">
159
<table width="100%" border="0" cellpadding="6" cellspacing="0">
160
  <tr>
161
	<td colspan="2" valign="top" class="listtopic"><?=gettext("IGMP Proxy Edit");?></td>
162
  </tr>
163
  <tr>
164
    <td valign="top" class="vncellreq"><?=gettext("Interface");?></td>
165
    <td class="vtable"> <select name="ifname" id="ifname" >
166
		<?php $iflist = get_configured_interface_with_descr();
167
			foreach ($iflist as $ifnam => $ifdescr) {
168
				echo "<option value={$ifnam}";
169
				if ($ifnam == $pconfig['ifname'])
170
					echo " selected";
171
				echo ">{$ifdescr}</option>";
172
			}		
173
		?>
174
			</select>
175
    </td>
176
  </tr>
177
  <tr>
178
    <td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
179
    <td width="78%" class="vtable">
180
      <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>" />
181
      <br />
182
      <span class="vexpl">
183
        <?=gettext("You may enter a description here for your reference (not parsed).");?>
184
      </span>
185
    </td>
186
  </tr>
187
  <tr>
188
    <td valign="top" class="vncellreq"><?=gettext("Type");?></td>
189
    <td class="vtable">
190
      <select name="type" class="formselect" id="type" >
191
        <option value="upstream" <?php if ($pconfig['type'] == "upstream") echo "selected"; ?>><?=gettext("Upstream Interface");?></option>
192
        <option value="downstream" <?php if ($pconfig['type'] == "downstream") echo "selected"; ?>><?=gettext("Downstream Interface");?></option>
193
      </select>
194
      <br />
195
      <span class="vexpl">
196
        <?=gettext("The <b>upstream</b> network interface is the outgoing interface which is".
197
      " responsible for communicating to available multicast data sources.".
198
      " There can only be one upstream interface.");?>
199
	</span>
200
	<br />
201
	<span class="vexpl">
202
       <b><?=gettext("Downstream"); ?></b> <?=gettext("network interfaces are the distribution  interfaces  to  the".
203
      " destination  networks,  where  multicast  clients  can  join groups and".
204
      " receive multicast data. One or more downstream interfaces must be configured.");?>
205
      </span>
206
    </td>
207
  </tr>
208
  <tr>
209
    <td valign="top" class="vncell"><?=gettext("Threshold");?></td>
210
    <td class="vtable">
211
      <input name="threshold" class="formfld unknown" id="threshold" value="<?php echo htmlspecialchars($pconfig['threshold']);?>">
212
      <br />
213
      <span class="vexpl">
214
	      <?=gettext("Defines the TTL threshold for  the  network  interface.  Packets".
215
             " with  a lower TTL than the threshols value will be ignored. This".
216
             " setting is optional, and by default the threshold is 1.");?>
217
      </span>
218
    </td>
219
  </tr>
220
  <tr>
221
    <td width="22%" valign="top" class="vncellreq"><div id="addressnetworkport"><?=gettext("Network (s)");?></div></td>
222
    <td width="78%" class="vtable">
223
      <table id="maintable">
224
        <tbody>
225
          <tr>
226
            <td><div id="onecolumn"><?=gettext("Network");?></div></td>
227
            <td><div id="twocolumn"><?=gettext("CIDR");?></div></td>
228
          </tr>
229

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

    
267
       		} // end foreach
268
	} // end if
269
?>
270
        </tbody>
271
        <tfoot>
272

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

    
293
<script type="text/javascript">
294
	field_counter_js = 2;
295
	rows = 1;
296
	totalrows = <?php echo $counter; ?>;
297
	loaded = <?php echo $counter; ?>;
298
</script>
299

    
300
<?php include("fend.inc"); ?>
301
</body>
302
</html>
(160-160/246)