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 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
8f2f85c3
|
Luiz Otavio O Souza
|
* Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
39d2f39d
|
NOYB
|
*
|
11 |
b12ea3fb
|
Renato Botelho
|
* 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 |
39d2f39d
|
NOYB
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16 |
39d2f39d
|
NOYB
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* 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 |
39d2f39d
|
NOYB
|
*/
|
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 |
c6c398c6
|
jim-p
|
init_config_arr(array('checkipservices', 'checkipservice'));
|
34 |
39d2f39d
|
NOYB
|
$a_checkipservice = &$config['checkipservices']['checkipservice'];
|
35 |
|
|
|
36 |
|
|
$dirty = false;
|
37 |
c946d721
|
Steve Beaver
|
if ($_POST['act'] == "del") {
|
38 |
|
|
unset($a_checkipservice[$_POST['id']]);
|
39 |
9178eadc
|
doktornotor
|
$wc_msg = gettext('Deleted a check IP service.');
|
40 |
39d2f39d
|
NOYB
|
$dirty = true;
|
41 |
c946d721
|
Steve Beaver
|
} 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 |
9178eadc
|
doktornotor
|
$wc_msg = gettext('Disabled a check IP service.');
|
46 |
39d2f39d
|
NOYB
|
} else {
|
47 |
c946d721
|
Steve Beaver
|
$a_checkipservice[$_POST['id']]['enable'] = true;
|
48 |
9178eadc
|
doktornotor
|
$wc_msg = gettext('Enabled a check IP service.');
|
49 |
39d2f39d
|
NOYB
|
}
|
50 |
|
|
$dirty = true;
|
51 |
c946d721
|
Steve Beaver
|
} else if ($_POST['id'] == count($a_checkipservice)) {
|
52 |
39d2f39d
|
NOYB
|
if (isset($config['checkipservices']['disable_factory_default'])) {
|
53 |
|
|
unset($config['checkipservices']['disable_factory_default']);
|
54 |
9178eadc
|
doktornotor
|
$wc_msg = gettext('Enabled the default check IP service.');
|
55 |
39d2f39d
|
NOYB
|
} else {
|
56 |
|
|
$config['checkipservices']['disable_factory_default'] = true;
|
57 |
9178eadc
|
doktornotor
|
$wc_msg = gettext('Disabled the default check IP service.');
|
58 |
39d2f39d
|
NOYB
|
}
|
59 |
|
|
$dirty = true;
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
if ($dirty) {
|
63 |
9178eadc
|
doktornotor
|
write_config($wc_msg);
|
64 |
39d2f39d
|
NOYB
|
|
65 |
|
|
header("Location: services_checkip.php");
|
66 |
|
|
exit;
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Check IP Services"));
|
70 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "services_dyndns.php", "@self");
|
71 |
39d2f39d
|
NOYB
|
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 |
f764f63a
|
jim-p
|
<th><?=gettext("Verify SSL/TLS Peer")?></th>
|
95 |
39d2f39d
|
NOYB
|
<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 |
c946d721
|
Steve Beaver
|
<a class="fa fa-ban" title="<?=gettext('Disable service')?>" href="?act=toggle&id=<?=$i?>" usepost></a>
|
138 |
39d2f39d
|
NOYB
|
<?php } else {
|
139 |
|
|
?>
|
140 |
c946d721
|
Steve Beaver
|
<a class="fa fa-check-square-o" title="<?=gettext('Enable service')?>" href="?act=toggle&id=<?=$i?>" usepost></a>
|
141 |
39d2f39d
|
NOYB
|
<?php }
|
142 |
|
|
?>
|
143 |
c946d721
|
Steve Beaver
|
<a class="fa fa-trash <?=$visibility?>" title="<?=gettext('Delete service')?>" href="services_checkip.php?act=del&id=<?=$i?>" usepost></a>
|
144 |
39d2f39d
|
NOYB
|
</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 |
6f3ac947
|
NOYB
|
<div class="infoblock">
|
165 |
186c7a6c
|
jim-p
|
<?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 |
c946d721
|
Steve Beaver
|
'The first (highest in list) enabled check ip service will be used to ' .
|
170 |
6f3ac947
|
NOYB
|
'check IP addresses for Dynamic DNS services, and ' .
|
171 |
186c7a6c
|
jim-p
|
'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 |
6f3ac947
|
NOYB
|
</div>
|
192 |
|
|
|
193 |
|
|
<?php include("foot.inc");
|