Project

General

Profile

Download (6.22 KB) Statistics
| Branch: | Tag: | Revision:
1 39d2f39d NOYB
<?php
2
/*
3 c5d81585 Renato Botelho
 * services_checkip.php
4 39d2f39d NOYB
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * All rights reserved.
8 39d2f39d NOYB
 *
9 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12 39d2f39d NOYB
 *
13 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
14 39d2f39d NOYB
 *
15 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20 39d2f39d NOYB
 */
21
22
##|+PRIV
23
##|*IDENT=page-services-checkipservices
24
##|*NAME=Services: Check IP Service
25
##|*DESCR=Allow access to the 'Services: Check IP Service' page.
26
##|*MATCH=services_checkip.php*
27
##|-PRIV
28
29
require_once("guiconfig.inc");
30
31 c6c398c6 jim-p
init_config_arr(array('checkipservices', 'checkipservice'));
32 39d2f39d NOYB
$a_checkipservice = &$config['checkipservices']['checkipservice'];
33
34
$dirty = false;
35 c946d721 Steve Beaver
if ($_POST['act'] == "del") {
36
	unset($a_checkipservice[$_POST['id']]);
37 9178eadc doktornotor
	$wc_msg = gettext('Deleted a check IP service.');
38 39d2f39d NOYB
	$dirty = true;
39 c946d721 Steve Beaver
} else if ($_POST['act'] == "toggle") {
40
	if ($a_checkipservice[$_POST['id']]) {
41
		if (isset($a_checkipservice[$_POST['id']]['enable'])) {
42
			unset($a_checkipservice[$_POST['id']]['enable']);
43 9178eadc doktornotor
			$wc_msg = gettext('Disabled a check IP service.');
44 39d2f39d NOYB
		} else {
45 c946d721 Steve Beaver
			$a_checkipservice[$_POST['id']]['enable'] = true;
46 9178eadc doktornotor
			$wc_msg = gettext('Enabled a check IP service.');
47 39d2f39d NOYB
		}
48
		$dirty = true;
49 c946d721 Steve Beaver
	} else if ($_POST['id'] == count($a_checkipservice)) {
50 39d2f39d NOYB
		if (isset($config['checkipservices']['disable_factory_default'])) {
51
			unset($config['checkipservices']['disable_factory_default']);
52 9178eadc doktornotor
			$wc_msg = gettext('Enabled the default check IP service.');
53 39d2f39d NOYB
		} else {
54
			$config['checkipservices']['disable_factory_default'] = true;
55 9178eadc doktornotor
			$wc_msg = gettext('Disabled the default check IP service.');
56 39d2f39d NOYB
		}
57
		$dirty = true;
58
	}
59
}
60
if ($dirty) {
61 9178eadc doktornotor
	write_config($wc_msg);
62 39d2f39d NOYB
63
	header("Location: services_checkip.php");
64
	exit;
65
}
66
67
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Check IP Services"));
68 edcd7535 Phil Davis
$pglinks = array("", "services_dyndns.php", "@self");
69 39d2f39d NOYB
include("head.inc");
70
71
$tab_array = array();
72
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
73
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
74
$tab_array[] = array(gettext("Check IP Services"), true, "services_checkip.php");
75
display_top_tabs($tab_array);
76
77
if ($input_errors) {
78
	print_input_errors($input_errors);
79
}
80
?>
81
82
<form action="services_checkip.php" method="post" name="iform" id="iform">
83
	<div class="panel panel-default">
84
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Check IP Services')?></h2></div>
85
		<div class="panel-body">
86
			<div class="table-responsive">
87
				<table class="table table-striped table-hover table-condensed">
88
					<thead>
89
						<tr>
90
							<th><?=gettext("Name")?></th>
91
							<th><?=gettext("URL")?></th>
92
							<th><?=gettext("Verify SSL Peer")?></th>
93
							<th><?=gettext("Description")?></th>
94
							<th><?=gettext("Actions")?></th>
95
						</tr>
96
					</thead>
97
					<tbody>
98
<?php
99
// Is the factory default check IP service disabled?
100
if (isset($config['checkipservices']['disable_factory_default'])) {
101
	unset($factory_default_checkipservice['enable']);
102
}
103
104
// Append the factory default check IP service to the list.
105
$a_checkipservice[] = $factory_default_checkipservice;
106
$factory_default = count($a_checkipservice) - 1;
107
108
$i = 0;
109
foreach ($a_checkipservice as $checkipservice):
110
111
	// Hide edit and delete controls on the factory default check IP service entry (last one; id = count-1), and retain layout positioning.
112
	if ($i == $factory_default) {
113
		$visibility = 'invisible';
114
	} else {
115
		$visibility = 'visible';
116
	}
117
?>
118
						<tr<?=(isset($checkipservice['enable']) ? '' : ' class="disabled"')?>>
119
						<td>
120
							<?=htmlspecialchars($checkipservice['name'])?>
121
						</td>
122
						<td>
123
							<?=htmlspecialchars($checkipservice['url'])?>
124
						</td>
125
						<td class="text-center">
126
							<i<?=(isset($checkipservice['verifysslpeer'])) ? ' class="fa fa-check"' : '';?>></i>
127
						</td>
128
						<td>
129
							<?=htmlspecialchars($checkipservice['descr'])?>
130
						</td>
131
						<td>
132
							<a class="fa fa-pencil <?=$visibility?>" title="<?=gettext('Edit service')?>" href="services_checkip_edit.php?id=<?=$i?>"></a>
133
						<?php if (isset($checkipservice['enable'])) {
134
						?>
135 c946d721 Steve Beaver
							<a	class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
136 39d2f39d NOYB
						<?php } else {
137
						?>
138 c946d721 Steve Beaver
							<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&amp;id=<?=$i?>" usepost></a>
139 39d2f39d NOYB
						<?php }
140
						?>
141 c946d721 Steve Beaver
							<a class="fa fa-trash <?=$visibility?>" title="<?=gettext('Delete service')?>" href="services_checkip.php?act=del&amp;id=<?=$i?>" usepost></a>
142 39d2f39d NOYB
						</td>
143
					</tr>
144
<?php
145
	$i++;
146
endforeach; ?>
147
148
					</tbody>
149
				</table>
150
			</div>
151
		</div>
152
	</div>
153
</form>
154
155
<nav class="action-buttons">
156
	<a href="services_checkip_edit.php" class="btn btn-sm btn-success btn-sm">
157
		<i class="fa fa-plus icon-embed-btn"></i>
158
		<?=gettext('Add')?>
159
	</a>
160
</nav>
161
162 6f3ac947 NOYB
<div class="infoblock">
163 186c7a6c jim-p
	<?php print_info_box(gettext('The server must return the client IP address ' .
164
	'as a string in the following format: ') .
165
	'<pre>Current IP Address: x.x.x.x</pre>' .
166
	gettext(
167 c946d721 Steve Beaver
	'The first (highest in list) enabled check ip service will be used to ' .
168 6f3ac947 NOYB
	'check IP addresses for Dynamic DNS services, and ' .
169 186c7a6c jim-p
	'RFC 2136 entries that have the "Use public IP" option enabled.') .
170
	'<br/><br/>'
171
	, 'info', false);
172
173
	print_info_box(gettext('Sample Server Configurations') .
174
	'<br/>' .
175
	gettext('nginx with LUA') . ':' .
176
	'<pre> location = /ip {
177
	default_type text/html;
178
	content_by_lua \'
179
		ngx.say("' . htmlspecialchars('<html><head><title>Current IP Check</title></head><body>') . 'Current IP Address: ")
180
		ngx.say(ngx.var.remote_addr)
181
		ngx.say("' . htmlspecialchars('</body></html>') . '")
182
	\';
183
	}</pre>' .
184
	gettext('PHP') .
185
	'<pre>' .
186
	htmlspecialchars('<html><head><title>Current IP Check</title></head><body>Current IP Address: <?=$_SERVER[\'REMOTE_ADDR\']?></body></html>') .
187
	'</pre>'
188
	, 'info', false); ?>
189 6f3ac947 NOYB
</div>
190
191
<?php include("foot.inc");