Project

General

Profile

Download (3.69 KB) Statistics
| Branch: | Tag: | Revision:
1 a0e4cea2 Scott Ullrich
<?php
2
/*
3 c5d81585 Renato Botelho
 * status_services.php
4
 *
5
 * 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 0284d79e jim-p
 * Copyright (c) 2014-2020 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * All rights reserved.
10
 *
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 c5d81585 Renato Botelho
 *
15 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
16 c5d81585 Renato Botelho
 *
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 74b0f23e Stephen Beaver
 */
23 a0e4cea2 Scott Ullrich
24 6b07c15a Matthew Grooms
##|+PRIV
25
##|*IDENT=page-status-services
26 5230f468 jim-p
##|*NAME=Status: Services
27 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Status: Services' page.
28
##|*MATCH=status_services.php*
29
##|-PRIV
30
31 e3c88b77 Ermal
require_once("guiconfig.inc");
32 44173def Ermal Lu?i
require_once("service-utils.inc");
33 a517a108 jmkizer
require_once("shortcuts.inc");
34 a0e4cea2 Scott Ullrich
35 c7027903 Steve Beaver
if ($_POST['ajax']) {
36
	if (isset($_POST['service'])) {
37 29fda3d3 Stephen Beaver
		$service_name = htmlspecialchars($_REQUEST['service']);
38 8b88ac79 jim-p
	}
39 517d3109 sbeaver
40 29fda3d3 Stephen Beaver
	if (!empty($service_name)) {
41 c7027903 Steve Beaver
		switch ($_POST['mode']) {
42 29fda3d3 Stephen Beaver
			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 74b0f23e Stephen Beaver
55 246a887a Ermal
	exit;
56 42b0c921 Phil Davis
}
57 b9eadc0c Colin Smith
58 6c07db48 Phil Davis
$pgtitle = array(gettext("Status"), gettext("Services"));
59 4df96eff Scott Ullrich
include("head.inc");
60
61 abe98adb Phil Davis
if ($savemsg) {
62 517d3109 sbeaver
	print_info_box($savemsg, 'success');
63 abe98adb Phil Davis
}
64 a0e4cea2 Scott Ullrich
65 517d3109 sbeaver
$services = get_services();
66
67 74b0f23e Stephen Beaver
// $debugsvcs = array('name' => 'captiveportal', 'description' => 'Captive Portal', 'zone' => '14');
68
// array_push($services, $debugsvcs);
69
70 517d3109 sbeaver
if (count($services) > 0) {
71 a0e4cea2 Scott Ullrich
?>
72
<form action="status_services.php" method="post">
73 74b0f23e Stephen Beaver
	<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 ac950976 Colin Fleming
<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 517d3109 sbeaver
	<div class="panel-body panel-default">
84
		<div class="table-responsive">
85 10fe1eb5 Stephen Beaver
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
86 517d3109 sbeaver
				<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 a0e4cea2 Scott Ullrich
<?php
96
97 b2254c7f jim-p
	uasort($services, "service_name_compare");
98 517d3109 sbeaver
99 ab7e04c7 Colin Fleming
	foreach ($services as $service) {
100
		if (empty($service['name'])) {
101 246a887a Ermal
			continue;
102 ab7e04c7 Colin Fleming
		}
103 517d3109 sbeaver
104 74b0f23e Stephen Beaver
		if (empty($service['description'])) {
105 246a887a Ermal
			$service['description'] = get_pkg_descr($service['name']);
106 74b0f23e Stephen Beaver
		}
107 517d3109 sbeaver
?>
108
					<tr>
109
						<td>
110
							<?=$service['name']?>
111
						</td>
112
						<td>
113
							<?=$service['description']?>
114
						</td>
115
						<td>
116 0adf0d88 NOYB
							<?= get_service_status_icon($service, false, true, false, "state"); ?>
117 517d3109 sbeaver
						</td>
118
						<td>
119
							<?=get_service_control_links($service)?>
120
121
<?php
122 391abfcf jim-p
		$scut = get_shortcut_by_service_name($service['name']);
123 517d3109 sbeaver
124 391abfcf jim-p
		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 517d3109 sbeaver
?>
130
						</td>
131
					</tr>
132
<?php
133 a0e4cea2 Scott Ullrich
	}
134 517d3109 sbeaver
?>
135
				</tbody>
136
			</table>
137
		</div>
138
	</div>
139 ac950976 Colin Fleming
140
	</div>
141
</div>
142
143 517d3109 sbeaver
</form>
144
<?php
145 b9eadc0c Colin Smith
} else {
146 8545adde k-paulius
	print_info_box(gettext("No services found."), 'danger');
147 b9eadc0c Colin Smith
}
148 74b0f23e Stephen Beaver
149
include("foot.inc");