Project

General

Profile

Download (7.48 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / services_captiveportal_ip.php @ a1b66bec

1
<?php
2
/*
3
	services_captiveportal_ip.php
4
	part of m0n0wall (http://m0n0.ch/wall)
5

    
6
	Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
/*
31
	pfSense_BUILDER_BINARIES:	/sbin/ipfw
32
	pfSense_MODULE:	captiveportal
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-services-captiveportal-allowedips
37
##|*NAME=Services: Captive portal: Allowed IPs page
38
##|*DESCR=Allow access to the 'Services: Captive portal: Allowed IPs' page.
39
##|*MATCH=services_captiveportal_ip.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require("functions.inc");
44
require_once("filter.inc");
45
require("shaper.inc");
46
require("captiveportal.inc");
47

    
48
$cpzone = $_GET['zone'];
49
if (isset($_POST['zone']))
50
        $cpzone = $_POST['zone'];
51

    
52
if (empty($cpzone) || empty($config['captiveportal'][$cpzone])) {
53
        header("Location: services_captiveportal_zones.php");
54
        exit;
55
}
56

    
57
if (!is_array($config['captiveportal']))
58
        $config['captiveportal'] = array();
59
$a_cp =& $config['captiveportal'];
60

    
61
$pgtitle = array(gettext("Services"),gettext("Captive portal"), $a_cp[$cpzone]['zone']);
62
$shortcut_section = "captiveportal";
63

    
64
if ($_GET['act'] == "del") {
65
	$a_allowedips =& $config['captiveportal'][$cpzone]['allowedip'];
66
	if ($a_allowedips[$_GET['id']]) {
67
		$ipent = $a_allowedips[$_GET['id']];
68
		
69
		if (isset($config['captiveportal'][$cpzone]['enable'])) {
70
			$mask = (!empty($ipent['sn'])) ? $ipent['sn'] : 32;
71
			
72
			$ipfw = pfSense_ipfw_getTablestats($cpzone, 3, $ipent['ip'], $mask);
73
			pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 3, $ipent['ip'], $mask);
74
			pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 4, $ipent['ip'], $mask);
75
			
76
			if (is_array($ipfw)) {
77
				captiveportal_free_dn_ruleno($ipfw['dnpipe']);
78
				pfSense_pipe_action("pipe delete {$ipfw['dnpipe']}");
79
				pfSense_pipe_action("pipe delete " . ($ipfw['dnpipe']+1));
80
			}
81
		}
82
		
83
		unset($a_allowedips[$_GET['id']]);
84
		write_config();
85
		header("Location: services_captiveportal_ip.php?zone={$cpzone}");
86
		exit;
87
	}
88
}
89

    
90

    
91
include("head.inc");
92
?>
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<?php include("fbegin.inc"); ?>
95
<form action="services_captiveportal_ip.php" method="post">
96
<input type="hidden" name="zone" id="zone" value="<?=htmlspecialchars($cpzone);?>" />
97
<?php if ($savemsg) print_info_box($savemsg); ?>
98
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="captiveportal ip addresses">
99
  <tr><td class="tabnavtbl">
100
<?php
101
	$tab_array = array();
102
	$tab_array[] = array(gettext("Captive portal(s)"), false, "services_captiveportal.php?zone={$cpzone}");
103
	$tab_array[] = array(gettext("MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
104
	$tab_array[] = array(gettext("Allowed IP addresses"), true, "services_captiveportal_ip.php?zone={$cpzone}");
105
	$tab_array[] = array(gettext("Allowed Hostnames"), false, "services_captiveportal_hostname.php?zone={$cpzone}");
106
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
107
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
108
	display_top_tabs($tab_array, true);
109
?>
110
  </td></tr>
111
  <tr>
112
  <td class="tabcont">
113
  <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main">
114
	<tr>
115
	  <td width="40%" class="listhdrr"><?=gettext("IP address"); ?></td>
116
	  <td width="50%" class="listhdr"><?=gettext("Description"); ?></td>
117
	  <td width="10%" class="list">
118
		<table border="0" cellspacing="0" cellpadding="1" summary="add">
119
		   <tr>
120
			<td width="17" height="17"></td>
121
			<td><a href="services_captiveportal_ip_edit.php?zone=<?=$cpzone;?>"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add address"); ?>" width="17" height="17" border="0" alt="add" /></a></td>
122
		   </tr>
123
		</table>
124
	  </td>
125
	</tr>
126
<?php	if (is_array($a_cp[$cpzone]['allowedip'])):
127
		$i = 0; foreach ($a_cp[$cpzone]['allowedip'] as $ip): ?>
128
	<tr ondblclick="document.location='services_captiveportal_ip_edit.php?zone=<?=$cpzone;?>&amp;id=<?=$i;?>'">
129
	  <td class="listlr">
130
		<?php
131
		if($ip['dir'] == "to") {
132
			echo "any <img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" align=\"middle\" alt=\"in\" /> ";
133
		}
134
		if($ip['dir'] == "both") {
135
			echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" width=\"11\" height=\"11\" align=\"middle\" alt=\"pass\" />   ";
136
		}
137
		echo strtolower($ip['ip']);
138
		if($ip['sn'] != "32" && is_numeric($ip['sn'])) {
139
			$sn = $ip['sn'];
140
			echo "/$sn";	
141
		}
142
		if($ip['dir'] == "from") {
143
			echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" align=\"middle\" alt=\"any\" /> any";
144
		}
145
		
146
		?>	
147
	  </td>
148
	  <td class="listbg">
149
		<?=htmlspecialchars($ip['descr']);?>&nbsp;
150
	  </td>
151
	  <td valign="middle" class="list nowrap"><a href="services_captiveportal_ip_edit.php?zone=<?=$cpzone;?>&amp;id=<?=$i;?>"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_e.gif" title="<?=gettext("edit address"); ?>" width="17" height="17" border="0" alt="edit" /></a>
152
		 &nbsp;<a href="services_captiveportal_ip.php?zone=<?=$cpzone;?>&amp;act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this address?"); ?>')"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete address"); ?>" width="17" height="17" border="0" alt="delete" /></a></td>
153
	</tr>
154
  <?php $i++; endforeach; endif; ?>
155
	<tr>
156
	  <td class="list" colspan="2">&nbsp;</td>
157
	  <td class="list">
158
		<table border="0" cellspacing="0" cellpadding="1" summary="add">
159
		   <tr>
160
			<td width="17" height="17"></td>
161
			<td><a href="services_captiveportal_ip_edit.php?zone=<?=$cpzone;?>"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add address"); ?>" width="17" height="17" border="0" alt="add" /></a></td>
162
		   </tr>
163
		</table>
164
	  </td>
165
	</tr>
166
	<tr>
167
	<td colspan="2" class="list"><p class="vexpl"><span class="red"><strong>
168
	  <?=gettext("Note:"); ?><br />
169
	  </strong></span>
170
	  <?=gettext("Adding allowed IP addresses will allow IP access to/from these addresses through the captive portal without being taken to the portal page. This can be used for a web server serving images for the portal page or a DNS server on another network, for example."); ?></p>
171
	</td>
172
	<td class="list">&nbsp;</td>
173
	</tr>
174
  </table>
175
  </td>
176
  </tr>
177
  </table>
178
</form>
179
<?php include("fend.inc"); ?>
180
</body>
181
</html>
(142-142/256)