Project

General

Profile

Download (7.71 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	services_checkip.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Rubicon Communications, LLC (Netgate). All rights reserved.
7
 *
8
 *	Redistribution and use in source and binary forms, with or without modification,
9
 *	are permitted provided that the following conditions are met:
10
 *
11
 *	1. Redistributions of source code must retain the above copyright notice,
12
 *		this list of conditions and the following disclaimer.
13
 *
14
 *	2. Redistributions in binary form must reproduce the above copyright
15
 *		notice, this list of conditions and the following disclaimer in
16
 *		the documentation and/or other materials provided with the
17
 *		distribution.
18
 *
19
 *	3. All advertising materials mentioning features or use of this software
20
 *		must display the following acknowledgment:
21
 *		"This product includes software developed by the pfSense Project
22
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
23
 *
24
 *	4. The names "pfSense" and "pfSense Project" must not be used to
25
 *		 endorse or promote products derived from this software without
26
 *		 prior written permission. For written permission, please contact
27
 *		 coreteam@pfsense.org.
28
 *
29
 *	5. Products derived from this software may not be called "pfSense"
30
 *		nor may "pfSense" appear in their names without prior written
31
 *		permission of the Electric Sheep Fencing, LLC.
32
 *
33
 *	6. Redistributions of any form whatsoever must retain the following
34
 *		acknowledgment:
35
 *
36
 *	"This product includes software developed by the pfSense Project
37
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
38
 *
39
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
40
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
43
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
51
 *
52
 *	====================================================================
53
 *
54
 */
55

    
56
##|+PRIV
57
##|*IDENT=page-services-checkipservices
58
##|*NAME=Services: Check IP Service
59
##|*DESCR=Allow access to the 'Services: Check IP Service' page.
60
##|*MATCH=services_checkip.php*
61
##|-PRIV
62

    
63
require_once("guiconfig.inc");
64

    
65
if (!is_array($config['checkipservices']['checkipservice'])) {
66
	$config['checkipservices']['checkipservice'] = array();
67
}
68

    
69
$a_checkipservice = &$config['checkipservices']['checkipservice'];
70

    
71
$dirty = false;
72
if ($_GET['act'] == "del") {
73
	unset($a_checkipservice[$_GET['id']]);
74
	$dirty = true;
75
} else if ($_GET['act'] == "toggle") {
76
	if ($a_checkipservice[$_GET['id']]) {
77
		if (isset($a_checkipservice[$_GET['id']]['enable'])) {
78
			unset($a_checkipservice[$_GET['id']]['enable']);
79
		} else {
80
			$a_checkipservice[$_GET['id']]['enable'] = true;
81
		}
82
		$dirty = true;
83
	} else if ($_GET['id'] == count($a_checkipservice)) {
84
		if (isset($config['checkipservices']['disable_factory_default'])) {
85
			unset($config['checkipservices']['disable_factory_default']);
86
		} else {
87
			$config['checkipservices']['disable_factory_default'] = true;
88
		}
89
		$dirty = true;
90
	}
91
}
92
if ($dirty) {
93
	write_config();
94

    
95
	header("Location: services_checkip.php");
96
	exit;
97
}
98

    
99
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Check IP Services"));
100
$pglinks = array("", "services_dyndns.php", "@self");
101
include("head.inc");
102

    
103
$tab_array = array();
104
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
105
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
106
$tab_array[] = array(gettext("Check IP Services"), true, "services_checkip.php");
107
display_top_tabs($tab_array);
108

    
109
if ($input_errors) {
110
	print_input_errors($input_errors);
111
}
112
?>
113

    
114
<form action="services_checkip.php" method="post" name="iform" id="iform">
115
	<div class="panel panel-default">
116
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Check IP Services')?></h2></div>
117
		<div class="panel-body">
118
			<div class="table-responsive">
119
				<table class="table table-striped table-hover table-condensed">
120
					<thead>
121
						<tr>
122
							<th><?=gettext("Name")?></th>
123
							<th><?=gettext("URL")?></th>
124
							<th><?=gettext("Verify SSL Peer")?></th>
125
							<th><?=gettext("Description")?></th>
126
							<th><?=gettext("Actions")?></th>
127
						</tr>
128
					</thead>
129
					<tbody>
130
<?php
131
// Is the factory default check IP service disabled?
132
if (isset($config['checkipservices']['disable_factory_default'])) {
133
	unset($factory_default_checkipservice['enable']);
134
}
135

    
136
// Append the factory default check IP service to the list.
137
$a_checkipservice[] = $factory_default_checkipservice;
138
$factory_default = count($a_checkipservice) - 1;
139

    
140
$i = 0;
141
foreach ($a_checkipservice as $checkipservice):
142

    
143
	// Hide edit and delete controls on the factory default check IP service entry (last one; id = count-1), and retain layout positioning.
144
	if ($i == $factory_default) {
145
		$visibility = 'invisible';
146
	} else {
147
		$visibility = 'visible';
148
	}
149
?>
150
						<tr<?=(isset($checkipservice['enable']) ? '' : ' class="disabled"')?>>
151
						<td>
152
							<?=htmlspecialchars($checkipservice['name'])?>
153
						</td>
154
						<td>
155
							<?=htmlspecialchars($checkipservice['url'])?>
156
						</td>
157
						<td class="text-center">
158
							<i<?=(isset($checkipservice['verifysslpeer'])) ? ' class="fa fa-check"' : '';?>></i>
159
						</td>
160
						<td>
161
							<?=htmlspecialchars($checkipservice['descr'])?>
162
						</td>
163
						<td>
164
							<a class="fa fa-pencil <?=$visibility?>" title="<?=gettext('Edit service')?>" href="services_checkip_edit.php?id=<?=$i?>"></a>
165
						<?php if (isset($checkipservice['enable'])) {
166
						?>
167
							<a	class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
168
						<?php } else {
169
						?>
170
							<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>"></a>
171
						<?php }
172
						?>
173
							<a class="fa fa-trash <?=$visibility?>" title="<?=gettext('Delete service')?>" href="services_checkip.php?act=del&amp;id=<?=$i?>"></a>
174
						</td>
175
					</tr>
176
<?php
177
	$i++;
178
endforeach; ?>
179

    
180
					</tbody>
181
				</table>
182
			</div>
183
		</div>
184
	</div>
185
</form>
186

    
187
<nav class="action-buttons">
188
	<a href="services_checkip_edit.php" class="btn btn-sm btn-success btn-sm">
189
		<i class="fa fa-plus icon-embed-btn"></i>
190
		<?=gettext('Add')?>
191
	</a>
192
</nav>
193

    
194
<div class="infoblock">
195
	<?php print_info_box(gettext('The server must return the client IP address ' .
196
	'as a string in the following format: ') .
197
	'<pre>Current IP Address: x.x.x.x</pre>' .
198
	gettext(
199
	'The first (highest in list) enabled check ip service will be used to ' . 
200
	'check IP addresses for Dynamic DNS services, and ' .
201
	'RFC 2136 entries that have the "Use public IP" option enabled.') .
202
	'<br/><br/>'
203
	, 'info', false);
204

    
205
	print_info_box(gettext('Sample Server Configurations') .
206
	'<br/>' .
207
	gettext('nginx with LUA') . ':' .
208
	'<pre> location = /ip {
209
	default_type text/html;
210
	content_by_lua \'
211
		ngx.say("' . htmlspecialchars('<html><head><title>Current IP Check</title></head><body>') . 'Current IP Address: ")
212
		ngx.say(ngx.var.remote_addr)
213
		ngx.say("' . htmlspecialchars('</body></html>') . '")
214
	\';
215
	}</pre>' .
216
	gettext('PHP') .
217
	'<pre>' .
218
	htmlspecialchars('<html><head><title>Current IP Check</title></head><body>Current IP Address: <?=$_SERVER[\'REMOTE_ADDR\']?></body></html>') .
219
	'</pre>'
220
	, 'info', false); ?>
221
</div>
222

    
223
<?php include("foot.inc");
(115-115/225)