Project

General

Profile

Download (5.97 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-2016 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * 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
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * 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
 */
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
if (!is_array($config['checkipservices']['checkipservice'])) {
32
	$config['checkipservices']['checkipservice'] = array();
33
}
34

    
35
$a_checkipservice = &$config['checkipservices']['checkipservice'];
36

    
37
$dirty = false;
38
if ($_GET['act'] == "del") {
39
	unset($a_checkipservice[$_GET['id']]);
40
	$dirty = true;
41
} else if ($_GET['act'] == "toggle") {
42
	if ($a_checkipservice[$_GET['id']]) {
43
		if (isset($a_checkipservice[$_GET['id']]['enable'])) {
44
			unset($a_checkipservice[$_GET['id']]['enable']);
45
		} else {
46
			$a_checkipservice[$_GET['id']]['enable'] = true;
47
		}
48
		$dirty = true;
49
	} else if ($_GET['id'] == count($a_checkipservice)) {
50
		if (isset($config['checkipservices']['disable_factory_default'])) {
51
			unset($config['checkipservices']['disable_factory_default']);
52
		} else {
53
			$config['checkipservices']['disable_factory_default'] = true;
54
		}
55
		$dirty = true;
56
	}
57
}
58
if ($dirty) {
59
	write_config();
60

    
61
	header("Location: services_checkip.php");
62
	exit;
63
}
64

    
65
$pgtitle = array(gettext("Services"), gettext("Dynamic DNS"), gettext("Check IP Services"));
66
$pglinks = array("", "services_dyndns.php", "@self");
67
include("head.inc");
68

    
69
$tab_array = array();
70
$tab_array[] = array(gettext("Dynamic DNS Clients"), false, "services_dyndns.php");
71
$tab_array[] = array(gettext("RFC 2136 Clients"), false, "services_rfc2136.php");
72
$tab_array[] = array(gettext("Check IP Services"), true, "services_checkip.php");
73
display_top_tabs($tab_array);
74

    
75
if ($input_errors) {
76
	print_input_errors($input_errors);
77
}
78
?>
79

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

    
102
// Append the factory default check IP service to the list.
103
$a_checkipservice[] = $factory_default_checkipservice;
104
$factory_default = count($a_checkipservice) - 1;
105

    
106
$i = 0;
107
foreach ($a_checkipservice as $checkipservice):
108

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

    
146
					</tbody>
147
				</table>
148
			</div>
149
		</div>
150
	</div>
151
</form>
152

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

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

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

    
189
<?php include("foot.inc");
(113-113/223)