1 |
a0e4cea2
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
ce77a9c4
|
Phil Davis
|
status_services.php
|
4 |
a0e4cea2
|
Scott Ullrich
|
*/
|
5 |
74b0f23e
|
Stephen Beaver
|
/* ====================================================================
|
6 |
|
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. 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 |
a0e4cea2
|
Scott Ullrich
|
|
56 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
57 |
|
|
##|*IDENT=page-status-services
|
58 |
5230f468
|
jim-p
|
##|*NAME=Status: Services
|
59 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: Services' page.
|
60 |
|
|
##|*MATCH=status_services.php*
|
61 |
|
|
##|-PRIV
|
62 |
|
|
|
63 |
e3c88b77
|
Ermal
|
require_once("guiconfig.inc");
|
64 |
44173def
|
Ermal Lu?i
|
require_once("service-utils.inc");
|
65 |
a517a108
|
jmkizer
|
require_once("shortcuts.inc");
|
66 |
a0e4cea2
|
Scott Ullrich
|
|
67 |
74b0f23e
|
Stephen Beaver
|
// Leave GET enabled in case any other pages use it.
|
68 |
|
|
// ToDo: Check other pages and remove GET completely
|
69 |
ab7e04c7
|
Colin Fleming
|
if (!$_GET && $_POST) {
|
70 |
74b0f23e
|
Stephen Beaver
|
$_GET = $_POST;
|
71 |
ab7e04c7
|
Colin Fleming
|
}
|
72 |
74b0f23e
|
Stephen Beaver
|
|
73 |
2f9951fe
|
Renato Botelho
|
$service_name = '';
|
74 |
42b0c921
|
Phil Davis
|
if (isset($_GET['service'])) {
|
75 |
2f9951fe
|
Renato Botelho
|
$service_name = htmlspecialchars($_GET['service']);
|
76 |
42b0c921
|
Phil Davis
|
}
|
77 |
2f9951fe
|
Renato Botelho
|
|
78 |
|
|
if (!empty($service_name)) {
|
79 |
8b88ac79
|
jim-p
|
switch ($_GET['mode']) {
|
80 |
|
|
case "restartservice":
|
81 |
2f9951fe
|
Renato Botelho
|
$savemsg = service_control_restart($service_name, $_GET);
|
82 |
8b88ac79
|
jim-p
|
break;
|
83 |
|
|
case "startservice":
|
84 |
2f9951fe
|
Renato Botelho
|
$savemsg = service_control_start($service_name, $_GET);
|
85 |
8b88ac79
|
jim-p
|
break;
|
86 |
|
|
case "stopservice":
|
87 |
2f9951fe
|
Renato Botelho
|
$savemsg = service_control_stop($service_name, $_GET);
|
88 |
8b88ac79
|
jim-p
|
break;
|
89 |
|
|
}
|
90 |
517d3109
|
sbeaver
|
|
91 |
cd72ded3
|
Timo Boettcher
|
sleep(5);
|
92 |
a0e4cea2
|
Scott Ullrich
|
}
|
93 |
|
|
|
94 |
74b0f23e
|
Stephen Beaver
|
|
95 |
a0e4cea2
|
Scott Ullrich
|
/* batch mode, allow other scripts to call this script */
|
96 |
42b0c921
|
Phil Davis
|
if ($_GET['batch']) {
|
97 |
246a887a
|
Ermal
|
exit;
|
98 |
42b0c921
|
Phil Davis
|
}
|
99 |
b9eadc0c
|
Colin Smith
|
|
100 |
6c07db48
|
Phil Davis
|
$pgtitle = array(gettext("Status"), gettext("Services"));
|
101 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
102 |
|
|
|
103 |
abe98adb
|
Phil Davis
|
if ($savemsg) {
|
104 |
517d3109
|
sbeaver
|
print_info_box($savemsg, 'success');
|
105 |
abe98adb
|
Phil Davis
|
}
|
106 |
a0e4cea2
|
Scott Ullrich
|
|
107 |
517d3109
|
sbeaver
|
$services = get_services();
|
108 |
|
|
|
109 |
74b0f23e
|
Stephen Beaver
|
// $debugsvcs = array('name' => 'captiveportal', 'description' => 'Captive Portal', 'zone' => '14');
|
110 |
|
|
// array_push($services, $debugsvcs);
|
111 |
|
|
|
112 |
517d3109
|
sbeaver
|
if (count($services) > 0) {
|
113 |
a0e4cea2
|
Scott Ullrich
|
?>
|
114 |
|
|
<form action="status_services.php" method="post">
|
115 |
74b0f23e
|
Stephen Beaver
|
<input id="mode" type="hidden" name="mode" value=""/>
|
116 |
|
|
<input id="vpnmode" type="hidden" name="vpnmode" value=""/>
|
117 |
|
|
<input id="service" type="hidden" name="service" value=""/>
|
118 |
|
|
<input id="id" type="hidden" name="id" value=""/>
|
119 |
|
|
<input id="zone" type="hidden" name="zone" value=""/>
|
120 |
|
|
|
121 |
ac950976
|
Colin Fleming
|
<div class="panel panel-default">
|
122 |
|
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Services')?></h2></div>
|
123 |
|
|
<div class="panel-body">
|
124 |
|
|
|
125 |
517d3109
|
sbeaver
|
<div class="panel-body panel-default">
|
126 |
|
|
<div class="table-responsive">
|
127 |
10fe1eb5
|
Stephen Beaver
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
128 |
517d3109
|
sbeaver
|
<thead>
|
129 |
|
|
<tr>
|
130 |
|
|
<th><?=gettext("Service")?></th>
|
131 |
|
|
<th><?=gettext("Description")?></th>
|
132 |
|
|
<th><?=gettext("Status")?></th>
|
133 |
|
|
<th><?=gettext("Actions")?></th>
|
134 |
|
|
</tr>
|
135 |
|
|
</thead>
|
136 |
|
|
<tbody>
|
137 |
a0e4cea2
|
Scott Ullrich
|
<?php
|
138 |
|
|
|
139 |
b2254c7f
|
jim-p
|
uasort($services, "service_name_compare");
|
140 |
517d3109
|
sbeaver
|
|
141 |
ab7e04c7
|
Colin Fleming
|
foreach ($services as $service) {
|
142 |
|
|
if (empty($service['name'])) {
|
143 |
246a887a
|
Ermal
|
continue;
|
144 |
ab7e04c7
|
Colin Fleming
|
}
|
145 |
517d3109
|
sbeaver
|
|
146 |
74b0f23e
|
Stephen Beaver
|
if (empty($service['description'])) {
|
147 |
246a887a
|
Ermal
|
$service['description'] = get_pkg_descr($service['name']);
|
148 |
74b0f23e
|
Stephen Beaver
|
}
|
149 |
517d3109
|
sbeaver
|
?>
|
150 |
|
|
<tr>
|
151 |
|
|
<td>
|
152 |
|
|
<?=$service['name']?>
|
153 |
|
|
</td>
|
154 |
|
|
|
155 |
|
|
<td>
|
156 |
|
|
<?=$service['description']?>
|
157 |
|
|
</td>
|
158 |
|
|
<?php
|
159 |
17b8c60a
|
Colin Fleming
|
// if service is running then listr else listbg
|
160 |
|
|
$bgclass = null;
|
161 |
517d3109
|
sbeaver
|
$running = false;
|
162 |
|
|
|
163 |
74b0f23e
|
Stephen Beaver
|
if (get_service_status($service)) {
|
164 |
517d3109
|
sbeaver
|
$running = true;
|
165 |
74b0f23e
|
Stephen Beaver
|
}
|
166 |
517d3109
|
sbeaver
|
?>
|
167 |
|
|
<td>
|
168 |
3bd74348
|
bruno
|
<?=$running ? '<span class="text-success">' . gettext("Running") . '</span>':'<span class="text-danger">' . gettext("Stopped") . '</span>'?>
|
169 |
517d3109
|
sbeaver
|
</td>
|
170 |
|
|
<td>
|
171 |
|
|
<?=get_service_control_links($service)?>
|
172 |
|
|
|
173 |
|
|
<?php
|
174 |
391abfcf
|
jim-p
|
$scut = get_shortcut_by_service_name($service['name']);
|
175 |
517d3109
|
sbeaver
|
|
176 |
391abfcf
|
jim-p
|
if (!empty($scut)) {
|
177 |
|
|
echo get_shortcut_main_link($scut, true, $service);
|
178 |
|
|
echo get_shortcut_status_link($scut, true, $service);
|
179 |
|
|
echo get_shortcut_log_link($scut, true);
|
180 |
|
|
}
|
181 |
517d3109
|
sbeaver
|
?>
|
182 |
|
|
</td>
|
183 |
|
|
</tr>
|
184 |
|
|
<?php
|
185 |
a0e4cea2
|
Scott Ullrich
|
}
|
186 |
517d3109
|
sbeaver
|
?>
|
187 |
|
|
</tbody>
|
188 |
|
|
</table>
|
189 |
|
|
</div>
|
190 |
|
|
</div>
|
191 |
ac950976
|
Colin Fleming
|
|
192 |
|
|
</div>
|
193 |
|
|
</div>
|
194 |
|
|
|
195 |
517d3109
|
sbeaver
|
</form>
|
196 |
|
|
<?php
|
197 |
b9eadc0c
|
Colin Smith
|
} else {
|
198 |
8545adde
|
k-paulius
|
print_info_box(gettext("No services found."), 'danger');
|
199 |
b9eadc0c
|
Colin Smith
|
}
|
200 |
74b0f23e
|
Stephen Beaver
|
?>
|
201 |
ab7e04c7
|
Colin Fleming
|
<script type="text/javascript">
|
202 |
74b0f23e
|
Stephen Beaver
|
//<![CDATA[
|
203 |
abe98adb
|
Phil Davis
|
events.push(function() {
|
204 |
74b0f23e
|
Stephen Beaver
|
// If a restart button is clicked, populate the hidden inputs and submit the form (via POST)
|
205 |
|
|
$('[id^=restartservice-]').click(function(event) {
|
206 |
|
|
$('#mode').val('restartservice');
|
207 |
|
|
$('#service').val(this.id.replace("restartservice-", ""));
|
208 |
|
|
$(this).parents('form').submit();
|
209 |
|
|
});
|
210 |
|
|
|
211 |
|
|
// If a stop button is clicked, populate the hidden inputs and submit the form (via POST)
|
212 |
|
|
$('[id^=stopservice-]').click(function(event) {
|
213 |
|
|
$('#mode').val('stopservice');
|
214 |
|
|
$('#service').val(this.id.replace("stopservice-", ""));
|
215 |
|
|
$(this).parents('form').submit();
|
216 |
|
|
});
|
217 |
cd72ded3
|
Timo Boettcher
|
|
218 |
74b0f23e
|
Stephen Beaver
|
// If a start button is clicked, populate the hidden inputs and submit the form (via POST)
|
219 |
|
|
$('[id^=startservice-]').click(function(event) {
|
220 |
|
|
$('#mode').val('startservice');
|
221 |
|
|
$('#service').val(this.id.replace("startservice-", ""));
|
222 |
|
|
$(this).parents('form').submit();
|
223 |
|
|
});
|
224 |
|
|
|
225 |
|
|
// If an openvpn start button is clicked, populate the hidden inputs and submit the form (via POST)
|
226 |
|
|
$('[id^=openvpn-startservice-]').click(function(event) {
|
227 |
|
|
var args = this.id.split('-');
|
228 |
|
|
$('#mode').val('startservice');
|
229 |
|
|
$('#service').val('openvpn');
|
230 |
|
|
$('#id').val(args[3]);
|
231 |
|
|
$('#vpnmode').val(args[2]);
|
232 |
|
|
$(this).parents('form').submit();
|
233 |
|
|
});
|
234 |
|
|
|
235 |
|
|
// If an openvpn restart button is clicked, populate the hidden inputs and submit the form (via POST)
|
236 |
|
|
$('[id^=openvpn-restartservice-]').click(function(event) {
|
237 |
|
|
var args = this.id.split('-');
|
238 |
|
|
$('#mode').val('restartservice');
|
239 |
|
|
$('#service').val('openvpn');
|
240 |
|
|
$('#id').val(args[3]);
|
241 |
|
|
$('#vpnmode').val(args[2]);
|
242 |
|
|
$(this).parents('form').submit();
|
243 |
|
|
});
|
244 |
|
|
|
245 |
|
|
// If an openvpn stop button is clicked, populate the hidden inputs and submit the form (via POST)
|
246 |
|
|
$('[id^=openvpn-stopservice-]').click(function(event) {
|
247 |
|
|
var args = this.id.split('-');
|
248 |
|
|
$('#mode').val('stopservice');
|
249 |
|
|
$('#service').val('openvpn');
|
250 |
|
|
$('#id').val(args[3]);
|
251 |
|
|
$('#vpnmode').val(args[2]);
|
252 |
|
|
$(this).parents('form').submit();
|
253 |
|
|
});
|
254 |
|
|
|
255 |
|
|
// If a captiveportal start button is clicked, populate the hidden inputs and submit the form (via POST)
|
256 |
|
|
$('[id^=captiveportal-startservice-]').click(function(event) {
|
257 |
|
|
var args = this.id.split('-');
|
258 |
|
|
$('#mode').val('startservice');
|
259 |
|
|
$('#service').val('captiveportal');
|
260 |
|
|
$('#zone').val(args[2]);
|
261 |
|
|
$(this).parents('form').submit();
|
262 |
|
|
});
|
263 |
|
|
|
264 |
|
|
// If a captiveportal restart button is clicked, populate the hidden inputs and submit the form (via POST)
|
265 |
|
|
$('[id^=captiveportal-restartservice-]').click(function(event) {
|
266 |
|
|
var args = this.id.split('-');
|
267 |
|
|
$('#mode').val('restartservice');
|
268 |
|
|
$('#service').val('captiveportal');
|
269 |
|
|
$('#zone').val(args[2]);
|
270 |
|
|
$(this).parents('form').submit();
|
271 |
|
|
});
|
272 |
|
|
|
273 |
|
|
// If a captiveportal stop button is clicked, populate the hidden inputs and submit the form (via POST)
|
274 |
|
|
$('[id^=captiveportal-stopservice-]').click(function(event) {
|
275 |
|
|
var args = this.id.split('-');
|
276 |
|
|
$('#mode').val('stopservice');
|
277 |
|
|
$('#service').val('captiveportal');
|
278 |
|
|
$('#zone').val(args[2]);
|
279 |
|
|
$(this).parents('form').submit();
|
280 |
|
|
});
|
281 |
|
|
});
|
282 |
|
|
//]]>
|
283 |
|
|
</script>
|
284 |
|
|
<?php
|
285 |
|
|
include("foot.inc");
|