1
|
<?php
|
2
|
/*
|
3
|
* status_services.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* Redistribution and use in source and binary forms, with or without
|
10
|
* modification, are permitted provided that the following conditions are met:
|
11
|
*
|
12
|
* 1. Redistributions of source code must retain the above copyright notice,
|
13
|
* this list of conditions and the following disclaimer.
|
14
|
*
|
15
|
* 2. Redistributions in binary form must reproduce the above copyright
|
16
|
* notice, this list of conditions and the following disclaimer in
|
17
|
* the documentation and/or other materials provided with the
|
18
|
* distribution.
|
19
|
*
|
20
|
* 3. All advertising materials mentioning features or use of this software
|
21
|
* must display the following acknowledgment:
|
22
|
* "This product includes software developed by the pfSense Project
|
23
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
24
|
*
|
25
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
26
|
* endorse or promote products derived from this software without
|
27
|
* prior written permission. For written permission, please contact
|
28
|
* coreteam@pfsense.org.
|
29
|
*
|
30
|
* 5. Products derived from this software may not be called "pfSense"
|
31
|
* nor may "pfSense" appear in their names without prior written
|
32
|
* permission of the Electric Sheep Fencing, LLC.
|
33
|
*
|
34
|
* 6. Redistributions of any form whatsoever must retain the following
|
35
|
* acknowledgment:
|
36
|
*
|
37
|
* "This product includes software developed by the pfSense Project
|
38
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
39
|
*
|
40
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
41
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
42
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
43
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
44
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
45
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
46
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
47
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
48
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
49
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
50
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
51
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
52
|
*/
|
53
|
|
54
|
##|+PRIV
|
55
|
##|*IDENT=page-status-services
|
56
|
##|*NAME=Status: Services
|
57
|
##|*DESCR=Allow access to the 'Status: Services' page.
|
58
|
##|*MATCH=status_services.php*
|
59
|
##|-PRIV
|
60
|
|
61
|
require_once("guiconfig.inc");
|
62
|
require_once("service-utils.inc");
|
63
|
require_once("shortcuts.inc");
|
64
|
|
65
|
if ($_REQUEST['ajax']) {
|
66
|
if (isset($_REQUEST['service'])) {
|
67
|
$service_name = htmlspecialchars($_REQUEST['service']);
|
68
|
}
|
69
|
|
70
|
if (!empty($service_name)) {
|
71
|
switch ($_REQUEST['mode']) {
|
72
|
case "restartservice":
|
73
|
$savemsg = service_control_restart($service_name, $_REQUEST);
|
74
|
break;
|
75
|
case "startservice":
|
76
|
$savemsg = service_control_start($service_name, $_REQUEST);
|
77
|
break;
|
78
|
case "stopservice":
|
79
|
$savemsg = service_control_stop($service_name, $_REQUEST);
|
80
|
break;
|
81
|
}
|
82
|
sleep(5);
|
83
|
}
|
84
|
|
85
|
exit;
|
86
|
}
|
87
|
|
88
|
$pgtitle = array(gettext("Status"), gettext("Services"));
|
89
|
include("head.inc");
|
90
|
|
91
|
if ($savemsg) {
|
92
|
print_info_box($savemsg, 'success');
|
93
|
}
|
94
|
|
95
|
$services = get_services();
|
96
|
|
97
|
// $debugsvcs = array('name' => 'captiveportal', 'description' => 'Captive Portal', 'zone' => '14');
|
98
|
// array_push($services, $debugsvcs);
|
99
|
|
100
|
if (count($services) > 0) {
|
101
|
?>
|
102
|
<form action="status_services.php" method="post">
|
103
|
<input id="mode" type="hidden" name="mode" value=""/>
|
104
|
<input id="vpnmode" type="hidden" name="vpnmode" value=""/>
|
105
|
<input id="service" type="hidden" name="service" value=""/>
|
106
|
<input id="id" type="hidden" name="id" value=""/>
|
107
|
<input id="zone" type="hidden" name="zone" value=""/>
|
108
|
|
109
|
<div class="panel panel-default">
|
110
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Services')?></h2></div>
|
111
|
<div class="panel-body">
|
112
|
|
113
|
<div class="panel-body panel-default">
|
114
|
<div class="table-responsive">
|
115
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
116
|
<thead>
|
117
|
<tr>
|
118
|
<th><?=gettext("Service")?></th>
|
119
|
<th><?=gettext("Description")?></th>
|
120
|
<th><?=gettext("Status")?></th>
|
121
|
<th><?=gettext("Actions")?></th>
|
122
|
</tr>
|
123
|
</thead>
|
124
|
<tbody>
|
125
|
<?php
|
126
|
|
127
|
uasort($services, "service_name_compare");
|
128
|
|
129
|
foreach ($services as $service) {
|
130
|
if (empty($service['name'])) {
|
131
|
continue;
|
132
|
}
|
133
|
|
134
|
if (empty($service['description'])) {
|
135
|
$service['description'] = get_pkg_descr($service['name']);
|
136
|
}
|
137
|
?>
|
138
|
<tr>
|
139
|
<td>
|
140
|
<?=$service['name']?>
|
141
|
</td>
|
142
|
|
143
|
<td>
|
144
|
<?=$service['description']?>
|
145
|
</td>
|
146
|
<?php
|
147
|
// if service is running then listr else listbg
|
148
|
$bgclass = null;
|
149
|
$running = false;
|
150
|
|
151
|
if (get_service_status($service)) {
|
152
|
$running = true;
|
153
|
}
|
154
|
?>
|
155
|
<td>
|
156
|
<?=$running ? '<span class="text-success">' . gettext("Running") . '</span>':'<span class="text-danger">' . gettext("Stopped") . '</span>'?>
|
157
|
</td>
|
158
|
<td>
|
159
|
<?=get_service_control_links($service)?>
|
160
|
|
161
|
<?php
|
162
|
$scut = get_shortcut_by_service_name($service['name']);
|
163
|
|
164
|
if (!empty($scut)) {
|
165
|
echo get_shortcut_main_link($scut, true, $service);
|
166
|
echo get_shortcut_status_link($scut, true, $service);
|
167
|
echo get_shortcut_log_link($scut, true);
|
168
|
}
|
169
|
?>
|
170
|
</td>
|
171
|
</tr>
|
172
|
<?php
|
173
|
}
|
174
|
?>
|
175
|
</tbody>
|
176
|
</table>
|
177
|
</div>
|
178
|
</div>
|
179
|
|
180
|
</div>
|
181
|
</div>
|
182
|
|
183
|
</form>
|
184
|
<?php
|
185
|
} else {
|
186
|
print_info_box(gettext("No services found."), 'danger');
|
187
|
}
|
188
|
|
189
|
include("foot.inc");
|