Project

General

Profile

Download (4.09 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
if (!empty($service_name)) {
50
	switch ($_GET['mode']) {
51
		case "restartservice":
52
			$savemsg = service_control_restart($service_name, $_GET);
53
			break;
54
		case "startservice":
55
			$savemsg = service_control_start($service_name, $_GET);
56
			break;
57
		case "stopservice":
58
			$savemsg = service_control_stop($service_name, $_GET);
59
			break;
60
	}
61
	sleep(5);
62
}
63

    
64
/* batch mode, allow other scripts to call this script */
65
if($_GET['batch'])
66
	exit;
67

    
68
$pgtitle = array(gettext("Status"),gettext("Services"));
69
include("head.inc");
70

    
71
?>
72

    
73
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
74
<?php
75
include("fbegin.inc");
76
?>
77
<form action="status_services.php" method="post">
78
<?php if ($savemsg) print_info_box($savemsg); ?>
79

    
80
<div id="boxarea">
81
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="status services">
82
	<thead>
83
	<tr>
84
		<td class="listhdrr" align="center"><?=gettext("Service");?></td>
85
		<td class="listhdrr" align="center"><?=gettext("Description");?></td>
86
		<td class="listhdrr" align="center"><?=gettext("Status");?></td>
87
	</tr>
88
	</thead>
89
	<tbody>
90
<?php
91

    
92
$services = get_services();
93

    
94
if (count($services) > 0) {
95
	uasort($services, "service_name_compare");
96
	foreach($services as $service) {
97
		if (empty($service['name']))
98
			continue;
99
		if (empty($service['description']))
100
			$service['description'] = get_pkg_descr($service['name']);
101
		echo "<tr><td class=\"listlr\" width=\"20%\">" . $service['name'] . "</td>\n";
102
		echo "<td class=\"listr\" width=\"55%\">" . $service['description'] . "</td>\n";
103
		// if service is running then listr else listbg
104
		$bgclass = null;
105
		if (get_service_status($service))
106
			$bgclass = "listr";
107
		else
108
			$bgclass = "listbg";
109
		echo "<td class=\"" . $bgclass . "\" align=\"center\">" . get_service_status_icon($service, true, true) . "</td>\n";
110
		echo "<td valign=\"middle\" class=\"list nowrap\">" . get_service_control_links($service);
111
		$scut = get_shortcut_by_service_name($service['name']);
112
		if (!empty($scut)) {
113
			echo get_shortcut_main_link($scut, true, $service);
114
			echo get_shortcut_status_link($scut, true, $service);
115
			echo get_shortcut_log_link($scut, true);
116
		}
117
		echo "</td></tr>\n";
118
	}
119
} else {
120
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . " . </td></tr>\n";
121
}
122

    
123
?>
124
</tbody>
125
</table>
126
</div>
127
</form>
128
<?php include("fend.inc"); ?>
129
</body>
130
</html>
(201-201/256)