1
|
<?php
|
2
|
/*
|
3
|
* status_services.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-2022 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-status-services
|
26
|
##|*NAME=Status: Services
|
27
|
##|*DESCR=Allow access to the 'Status: Services' page.
|
28
|
##|*MATCH=status_services.php*
|
29
|
##|-PRIV
|
30
|
|
31
|
require_once("guiconfig.inc");
|
32
|
require_once("service-utils.inc");
|
33
|
require_once("shortcuts.inc");
|
34
|
|
35
|
if ($_POST['ajax']) {
|
36
|
if (isset($_POST['service'])) {
|
37
|
$service_name = htmlspecialchars($_REQUEST['service']);
|
38
|
}
|
39
|
|
40
|
if (!empty($service_name)) {
|
41
|
switch ($_POST['mode']) {
|
42
|
case "restartservice":
|
43
|
$savemsg = service_control_restart($service_name, $_REQUEST);
|
44
|
break;
|
45
|
case "startservice":
|
46
|
$savemsg = service_control_start($service_name, $_REQUEST);
|
47
|
break;
|
48
|
case "stopservice":
|
49
|
$savemsg = service_control_stop($service_name, $_REQUEST);
|
50
|
break;
|
51
|
}
|
52
|
sleep(5);
|
53
|
}
|
54
|
|
55
|
exit;
|
56
|
}
|
57
|
|
58
|
$pgtitle = array(gettext("Status"), gettext("Services"));
|
59
|
include("head.inc");
|
60
|
|
61
|
if ($savemsg) {
|
62
|
print_info_box($savemsg, 'success');
|
63
|
}
|
64
|
|
65
|
$services = get_services();
|
66
|
|
67
|
// $debugsvcs = array('name' => 'captiveportal', 'description' => 'Captive Portal', 'zone' => '14');
|
68
|
// array_push($services, $debugsvcs);
|
69
|
|
70
|
if (count($services) > 0) {
|
71
|
?>
|
72
|
<form action="status_services.php" method="post">
|
73
|
<input id="mode" type="hidden" name="mode" value=""/>
|
74
|
<input id="vpnmode" type="hidden" name="vpnmode" value=""/>
|
75
|
<input id="service" type="hidden" name="service" value=""/>
|
76
|
<input id="id" type="hidden" name="id" value=""/>
|
77
|
<input id="zone" type="hidden" name="zone" value=""/>
|
78
|
|
79
|
<div class="panel panel-default">
|
80
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Services')?></h2></div>
|
81
|
<div class="panel-body">
|
82
|
|
83
|
<div class="panel-body panel-default">
|
84
|
<div class="table-responsive">
|
85
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
86
|
<thead>
|
87
|
<tr>
|
88
|
<th><?=gettext("Service")?></th>
|
89
|
<th><?=gettext("Description")?></th>
|
90
|
<th><?=gettext("Status")?></th>
|
91
|
<th><?=gettext("Actions")?></th>
|
92
|
</tr>
|
93
|
</thead>
|
94
|
<tbody>
|
95
|
<?php
|
96
|
|
97
|
uasort($services, "service_name_compare");
|
98
|
|
99
|
foreach ($services as $service) {
|
100
|
if (empty($service['name'])) {
|
101
|
continue;
|
102
|
}
|
103
|
|
104
|
if (empty($service['description'])) {
|
105
|
$service['description'] = get_pkg_descr($service['name']);
|
106
|
}
|
107
|
?>
|
108
|
<tr>
|
109
|
<td>
|
110
|
<?=$service['name']?>
|
111
|
</td>
|
112
|
<td>
|
113
|
<?=$service['description']?>
|
114
|
</td>
|
115
|
<td>
|
116
|
<?= get_service_status_icon($service, false, true, false, "state"); ?>
|
117
|
</td>
|
118
|
<td>
|
119
|
<?=get_service_control_links($service)?>
|
120
|
|
121
|
<?php
|
122
|
$scut = get_shortcut_by_service_name($service['name']);
|
123
|
|
124
|
if (!empty($scut)) {
|
125
|
echo get_shortcut_main_link($scut, true, $service);
|
126
|
echo get_shortcut_status_link($scut, true, $service);
|
127
|
echo get_shortcut_log_link($scut, true);
|
128
|
}
|
129
|
?>
|
130
|
</td>
|
131
|
</tr>
|
132
|
<?php
|
133
|
}
|
134
|
?>
|
135
|
</tbody>
|
136
|
</table>
|
137
|
</div>
|
138
|
</div>
|
139
|
|
140
|
</div>
|
141
|
</div>
|
142
|
|
143
|
</form>
|
144
|
<?php
|
145
|
} else {
|
146
|
print_info_box(gettext("No services found."), 'danger');
|
147
|
}
|
148
|
|
149
|
include("foot.inc");
|