Project

General

Profile

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

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

1
<?php
2
/*
3
	services_captiveportal_hostname.php
4
	Copyright (C) 2011 Scott Ullrich <sullrich@gmail.com>
5
	All rights reserved.
6

    
7
	Originally part of m0n0wall (http://m0n0.ch/wall)
8
	Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
9
	All rights reserved.
10

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

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

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

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

    
37
##|+PRIV
38
##|*IDENT=page-services-captiveportal-allowedhostnames
39
##|*NAME=Services: Captive portal: Allowed Hostnames page
40
##|*DESCR=Allow access to the 'Services: Captive portal: Allowed Hostnames' page.
41
##|*MATCH=services_captiveportal_hostname.php*
42
##|-PRIV
43

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

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

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

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

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

    
66
if ($_GET['act'] == "del" && !empty($cpzone)) {
67
	$a_allowedhostnames =& $a_cp[$cpzone]['allowedhostname'];
68
	if ($a_allowedhostnames[$_GET['id']]) {
69
		$ipent = $a_allowedhostnames[$_GET['id']];
70
		
71
		if (isset($a_cp[$cpzone]['enable'])) {
72
			if (!empty($ipent['sn']))
73
				$ipent['ip'] .= "/{$ipent['sn']}";
74
			$ip = gethostbyname($ipent['ip']);
75
			if(is_ipaddr($ip)) {
76
				$ipfw = pfSense_ipfw_getTablestats($cpzone, 3, $ip);
77
				if (is_array($ipfw)) {
78
					captiveportal_free_dn_ruleno($ipfw['dnpipe']);
79
					pfSense_pipe_action("pipe delete {$ipfw['dnpipe']}");
80
					pfSense_pipe_action("pipe delete " . ($ipfw['dnpipe']+1));
81
				}
82
				pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 3, $ip);
83
				pfSense_ipfw_Tableaction($cpzone, IP_FW_TABLE_XDEL, 4, $ip);
84
			}
85
		}
86
			
87
		unset($a_allowedhostnames[$_GET['id']]);
88
		write_config();
89
		captiveportal_allowedhostname_configure();
90
		header("Location: services_captiveportal_hostname.php?zone={$cpzone}");
91
		exit;
92
	}
93
}
94

    
95

    
96
include("head.inc");
97
?>
98
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
99
<?php include("fbegin.inc"); ?>
100
<form action="services_captiveportal_hostname.php" method="post">
101
<input type="hidden" name="zone" id="zone" value="<?=htmlspecialchars($cpzone);?>" />
102
<?php if ($savemsg) print_info_box($savemsg); ?>
103
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="captiveportal hostname">
104
  <tr><td class="tabnavtbl">
105
<?php
106
	$tab_array = array();
107
	$tab_array[] = array(gettext("Captive portal(s)"), false, "services_captiveportal.php?zone={$cpzone}");
108
	$tab_array[] = array(gettext("MAC"), false, "services_captiveportal_mac.php?zone={$cpzone}");
109
	$tab_array[] = array(gettext("Allowed IP Addresses"), false, "services_captiveportal_ip.php?zone={$cpzone}");
110
	$tab_array[] = array(gettext("Allowed Hostnames"), true, "services_captiveportal_hostname.php?zone={$cpzone}");
111
	$tab_array[] = array(gettext("Vouchers"), false, "services_captiveportal_vouchers.php?zone={$cpzone}");
112
	$tab_array[] = array(gettext("File Manager"), false, "services_captiveportal_filemanager.php?zone={$cpzone}");
113
	display_top_tabs($tab_array, true);
114
?>
115
  </td></tr>
116
  <tr>
117
  <td class="tabcont">
118
  <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="main">
119
	<tr>
120
	  <td width="60%" class="listhdrr"><?=gettext("Hostname"); ?></td>
121
	  <td width="40%" class="listhdr"><?=gettext("Description"); ?></td>
122
	  <td width="10%" class="list">
123
		<table border="0" cellspacing="0" cellpadding="1" summary="add">
124
		   <tr>
125
			<td width="17" height="17"></td>
126
			<td><a href="services_captiveportal_hostname_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>
127
		   </tr>
128
		</table>
129
	  </td>
130
	</tr>
131
<?php	if (is_array($a_cp[$cpzone]['allowedhostname'])):
132
		$i = 0;	foreach ($a_cp[$cpzone]['allowedhostname'] as $ip): ?>
133
	<tr ondblclick="document.location='services_captiveportal_hostname_edit.php?zone=<?=$cpzone;?>&amp;id=<?=$i;?>'">
134
	  <td class="listlr">
135
		<?php
136
		if($ip['dir'] == "to") {
137
			echo "any <img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" align=\"middle\" alt=\"in\" /> ";
138
		}
139
		if($ip['dir'] == "both") {
140
			echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" width=\"11\" height=\"11\" align=\"middle\" alt=\"pass\" />   ";
141
		}
142
		echo strtolower($ip['hostname']);
143
		if($ip['dir'] == "from") {
144
			echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" align=\"middle\" alt=\"in\" /> any";
145
		}
146
		
147
		?>	
148
	  </td>
149
	  <td class="listbg">
150
		<?=htmlspecialchars($ip['descr']);?>&nbsp;
151
	  </td>
152
	  <td valign="middle" class="list nowrap"> <a href="services_captiveportal_hostname_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="add" /></a>
153
		 &nbsp;<a href="services_captiveportal_hostname.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>
154
	</tr>
155
  <?php $i++; endforeach; endif;  ?>
156
	<tr>
157
	  <td class="list" colspan="2">&nbsp;</td>
158
	  <td class="list">
159
		<table border="0" cellspacing="0" cellpadding="1" summary="add">
160
		   <tr>
161
			<td width="17" height="17"></td>
162
			<td><a href="services_captiveportal_hostname_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>
163
		   </tr>
164
		</table>
165
	  </td>
166
	</tr>
167
	<tr>
168
	<td colspan="2" class="list"><p class="vexpl"><span class="red"><strong>
169
	  <?=gettext("Note:"); ?><br />
170
	  </strong></span>
171
	  <?=gettext("Adding allowed Hostnames will allow a DNS hostname access to/from access 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. By specifying <em>from</em> addresses, it may be used to always allow pass-through access from a client behind the captive portal."); ?></p>
172
	  <table border="0" cellspacing="0" cellpadding="0" summary="icons">
173
		<tr>
174
		  <td><span class="vexpl"><?=gettext("any"); ?> <img src="/themes/<?=$g['theme'];?>/images/icons/icon_in.gif" width="11" height="11" align="middle" alt="in" /> x.x.x.x </span></td>
175
		  <td><span class="vexpl"><?=gettext("All connections"); ?> <strong><?=gettext("to"); ?></strong> <?=gettext("the Hostname are allowed"); ?></span></td>
176
		</tr>
177
		<tr>
178
		  <td colspan="5" height="4"></td>
179
		</tr>
180
		<tr>
181
		  <td>x.x.x.x <span class="vexpl"><img src="/themes/<?=$g['theme'];?>/images/icons/icon_in.gif" width="11" height="11" align="middle" alt="in" /></span> <?=gettext("any"); ?>&nbsp;&nbsp;&nbsp; </td>
182
		  <td><span class="vexpl"><?=gettext("All connections"); ?> <strong><?=gettext("from"); ?></strong> <?=gettext("the Hostname are allowed"); ?> </span></td>
183
		</tr>
184
		<tr>
185
		  <td><span class="vexpl"><img src="/themes/<?=$g['theme'];?>/images/icons/icon_pass.gif" width="11" height="11" align="right" alt="pass" /></span>&nbsp;&nbsp;&nbsp;&nbsp; </td>
186
		  <td><span class="vexpl"> All connections <strong>to</strong> and <strong>from</strong> the Hostname are allowed </span></td>
187
		</tr>
188
	  </table></td>
189
	<td class="list">&nbsp;</td>
190
	</tr>
191
  </table>
192
  </td>
193
  </tr>
194
  </table>
195
</form>
196
<?php include("fend.inc"); ?>
197
</body>
198
</html>
(140-140/256)