Project

General

Profile

Download (6.32 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * services_checkip.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

    
24
##|+PRIV
25
##|*IDENT=page-services-checkipservices
26
##|*NAME=Services: Check IP Service
27
##|*DESCR=Allow access to the 'Services: Check IP Service' page.
28
##|*MATCH=services_checkip.php*
29
##|-PRIV
30

    
31
require_once("guiconfig.inc");
32

    
33
init_config_arr(array('checkipservices', 'checkipservice'));
34
$a_checkipservice = &$config['checkipservices']['checkipservice'];
35

    
36
$dirty = false;
37
if ($_POST['act'] == "del") {
38
	unset($a_checkipservice[$_POST['id']]);
39
	$wc_msg = gettext('Deleted a check IP service.');
40
	$dirty = true;
41
} else if ($_POST['act'] == "toggle") {
42
	if ($a_checkipservice[$_POST['id']]) {
43
		if (isset($a_checkipservice[$_POST['id']]['enable'])) {
44
			unset($a_checkipservice[$_POST['id']]['enable']);
45
			$wc_msg = gettext('Disabled a check IP service.');
46
		} else {
47
			$a_checkipservice[$_POST['id']]['enable'] = true;
48
			$wc_msg = gettext('Enabled a check IP service.');
49
		}
50
		$dirty = true;
51
	} else if ($_POST['id'] == count($a_checkipservice)) {
52
		if (isset($config['checkipservices']['disable_factory_default'])) {
53
			unset($config['checkipservices']['disable_factory_default']);
54
			$wc_msg = gettext('Enabled the default check IP service.');
55
		} else {
56
			$config['checkipservices']['disable_factory_default'] = true;
57
			$wc_msg = gettext('Disabled the default check IP service.');
58
		}
59
		$dirty = true;
60
	}
61
}
62
if ($dirty) {
63
	write_config($wc_msg);
64

    
65
	header("Location: services_checkip.php");
66
	exit;
67
}
68

    
69
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Check IP Services"));
70
$pglinks = array("", "services_dyndns.php", "@self");
71
include("head.inc");
72

    
73
$tab_array = array();
74
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
75
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
76
$tab_array[] = array(gettext("Check IP Services"), true, "services_checkip.php");
77
display_top_tabs($tab_array);
78

    
79
if ($input_errors) {
80
	print_input_errors($input_errors);
81
}
82
?>
83

    
84
<form action="services_checkip.php" method="post" name="iform" id="iform">
85
	<div class="panel panel-default">
86
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Check IP Services')?></h2></div>
87
		<div class="panel-body">
88
			<div class="table-responsive">
89
				<table class="table table-striped table-hover table-condensed">
90
					<thead>
91
						<tr>
92
							<th><?=gettext("Name")?></th>
93
							<th><?=gettext("URL")?></th>
94
							<th><?=gettext("Verify SSL/TLS Peer")?></th>
95
							<th><?=gettext("Description")?></th>
96
							<th><?=gettext("Actions")?></th>
97
						</tr>
98
					</thead>
99
					<tbody>
100
<?php
101
// Is the factory default check IP service disabled?
102
if (isset($config['checkipservices']['disable_factory_default'])) {
103
	unset($factory_default_checkipservice['enable']);
104
}
105

    
106
// Append the factory default check IP service to the list.
107
$a_checkipservice[] = $factory_default_checkipservice;
108
$factory_default = count($a_checkipservice) - 1;
109

    
110
$i = 0;
111
foreach ($a_checkipservice as $checkipservice):
112

    
113
	// Hide edit and delete controls on the factory default check IP service entry (last one; id = count-1), and retain layout positioning.
114
	if ($i == $factory_default) {
115
		$visibility = 'invisible';
116
	} else {
117
		$visibility = 'visible';
118
	}
119
?>
120
						<tr<?=(isset($checkipservice['enable']) ? '' : ' class="disabled"')?>>
121
						<td>
122
							<?=htmlspecialchars($checkipservice['name'])?>
123
						</td>
124
						<td>
125
							<?=htmlspecialchars($checkipservice['url'])?>
126
						</td>
127
						<td class="text-center">
128
							<i<?=(isset($checkipservice['verifysslpeer'])) ? ' class="fa fa-check"' : '';?>></i>
129
						</td>
130
						<td>
131
							<?=htmlspecialchars($checkipservice['descr'])?>
132
						</td>
133
						<td>
134
							<a class="fa fa-pencil <?=$visibility?>" title="<?=gettext('Edit service')?>" href="services_checkip_edit.php?id=<?=$i?>"></a>
135
						<?php if (isset($checkipservice['enable'])) {
136
						?>
137
							<a	class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
138
						<?php } else {
139
						?>
140
							<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
141
						<?php }
142
						?>
143
							<a class="fa fa-trash <?=$visibility?>" title="<?=gettext('Delete service')?>" href="services_checkip.php?act=del&amp;id=<?=$i?>" usepost></a>
144
						</td>
145
					</tr>
146
<?php
147
	$i++;
148
endforeach; ?>
149

    
150
					</tbody>
151
				</table>
152
			</div>
153
		</div>
154
	</div>
155
</form>
156

    
157
<nav class="action-buttons">
158
	<a href="services_checkip_edit.php" class="btn btn-sm btn-success btn-sm">
159
		<i class="fa fa-plus icon-embed-btn"></i>
160
		<?=gettext('Add')?>
161
	</a>
162
</nav>
163

    
164
<div class="infoblock">
165
	<?php print_info_box(gettext('The server must return the client IP address ' .
166
	'as a string in the following format: ') .
167
	'<pre>Current IP Address: x.x.x.x</pre>' .
168
	gettext(
169
	'The first (highest in list) enabled check ip service will be used to ' .
170
	'check IP addresses for Dynamic DNS services, and ' .
171
	'RFC 2136 entries that have the "Use public IP" option enabled.') .
172
	'<br/><br/>'
173
	, 'info', false);
174

    
175
	print_info_box(gettext('Sample Server Configurations') .
176
	'<br/>' .
177
	gettext('nginx with LUA') . ':' .
178
	'<pre> location = /ip {
179
	default_type text/html;
180
	content_by_lua \'
181
		ngx.say("' . htmlspecialchars('<html><head><title>Current IP Check</title></head><body>') . 'Current IP Address: ")
182
		ngx.say(ngx.var.remote_addr)
183
		ngx.say("' . htmlspecialchars('</body></html>') . '")
184
	\';
185
	}</pre>' .
186
	gettext('PHP') .
187
	'<pre>' .
188
	htmlspecialchars('<html><head><title>Current IP Check</title></head><body>Current IP Address: <?=$_SERVER[\'REMOTE_ADDR\']?></body></html>') .
189
	'</pre>'
190
	, 'info', false); ?>
191
</div>
192

    
193
<?php include("foot.inc");
(116-116/227)