Project

General

Profile

Download (3.89 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_services.php
4
	Copyright (C) 2004, 2005 Scott Ullrich
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, 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 the
16
	   documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
/*
30
	pfSense_BUILDER_BINARIES:	/usr/local/sbin/openvpn	/usr/bin/killall	/bin/ps
31
	pfSense_MODULE:	services
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-status-services
36
##|*NAME=Status: Services page
37
##|*DESCR=Allow access to the 'Status: Services' page.
38
##|*MATCH=status_services.php*
39
##|-PRIV
40

    
41
require_once("guiconfig.inc");
42
require_once("service-utils.inc");
43
require_once("shortcuts.inc");
44

    
45
$service_name = '';
46
if (isset($_GET['service'])) {
47
	$service_name = htmlspecialchars($_GET['service']);
48
}
49

    
50
if (!empty($service_name)) {
51
	switch ($_GET['mode']) {
52
		case "restartservice":
53
			$savemsg = service_control_restart($service_name, $_GET);
54
			break;
55
		case "startservice":
56
			$savemsg = service_control_start($service_name, $_GET);
57
			break;
58
		case "stopservice":
59
			$savemsg = service_control_stop($service_name, $_GET);
60
			break;
61
	}
62

    
63
	sleep(5);
64
}
65

    
66
/* batch mode, allow other scripts to call this script */
67
if ($_GET['batch']) {
68
	exit;
69
}
70

    
71
$pgtitle = array(gettext("Status"), gettext("Services"));
72
include("head.inc");
73

    
74
if ($savemsg)
75
	print_info_box($savemsg, 'success');
76

    
77
$services = get_services();
78

    
79
if (count($services) > 0) {
80
?>
81
<form action="status_services.php" method="post">
82
	<div class="panel-body panel-default">
83
		<div class="table-responsive">
84
			<table class="table table-striped table-hover table-condensed">
85
				<thead>
86
					<tr>
87
						<th><?=gettext("Service")?></th>
88
						<th><?=gettext("Description")?></th>
89
						<th><?=gettext("Status")?></th>
90
						<th><?=gettext("Actions")?></th>
91
					</tr>
92
				</thead>
93
				<tbody>
94
<?php
95

    
96
	uasort($services, "service_name_compare");
97

    
98
	foreach($services as $service) {
99
		if (empty($service['name']))
100
			continue;
101

    
102
		if (empty($service['description']))
103
			$service['description'] = get_pkg_descr($service['name']);
104
?>
105
					<tr>
106
						<td>
107
							<?=$service['name']?>
108
						</td>
109

    
110
						<td>
111
							<?=$service['description']?>
112
						</td>
113
<?php
114
		// if service is running then listr else listbg
115
		$bgclass = null;
116
		$running = false;
117

    
118
		if (get_service_status($service))
119
			$running = true;
120
?>
121
						<td>
122
							<?=$running ? '<font color="green">Running</font>':'<font color="red">Stopped</font>'?>
123
						</td>
124
						<td>
125
							<?=get_service_control_links($service)?>
126

    
127
<?php
128
		$scut = get_shortcut_by_service_name($service['name']);
129

    
130
		if (!empty($scut)) {
131
			echo get_shortcut_main_link($scut, true, $service);
132
			echo get_shortcut_status_link($scut, true, $service);
133
			echo get_shortcut_log_link($scut, true);
134
		}
135
?>
136
						</td>
137
					</tr>
138
<?php
139
	}
140
?>
141
				</tbody>
142
			</table>
143
		</div>
144
	</div>
145
</form>
146
<?php
147
} else {
148
	print_info_box(gettext("No services found"), 'danger');
149
}
150

    
151
include("foot.inc");
(184-184/235)