Project

General

Profile

Download (5.57 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_services.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *	Redistribution and use in source and binary forms, with or without modification,
9
 *	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
16
 *		the documentation and/or other materials provided with the
17
 *		distribution.
18
 *
19
 *	3. All advertising materials mentioning features or use of this software
20
 *		must display the following acknowledgment:
21
 *		"This product includes software developed by the pfSense Project
22
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
23
 *
24
 *	4. The names "pfSense" and "pfSense Project" must not be used to
25
 *		 endorse or promote products derived from this software without
26
 *		 prior written permission. For written permission, please contact
27
 *		 coreteam@pfsense.org.
28
 *
29
 *	5. Products derived from this software may not be called "pfSense"
30
 *		nor may "pfSense" appear in their names without prior written
31
 *		permission of the Electric Sheep Fencing, LLC.
32
 *
33
 *	6. Redistributions of any form whatsoever must retain the following
34
 *		acknowledgment:
35
 *
36
 *	"This product includes software developed by the pfSense Project
37
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
38
 *
39
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
40
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
43
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
51
 *
52
 *	====================================================================
53
 *
54
 */
55

    
56
##|+PRIV
57
##|*IDENT=page-status-services
58
##|*NAME=Status: Services
59
##|*DESCR=Allow access to the 'Status: Services' page.
60
##|*MATCH=status_services.php*
61
##|-PRIV
62

    
63
require_once("guiconfig.inc");
64
require_once("service-utils.inc");
65
require_once("shortcuts.inc");
66

    
67
if ($_REQUEST['ajax']) {
68
	if (isset($_REQUEST['service'])) {
69
		$service_name = htmlspecialchars($_REQUEST['service']);
70
	}
71

    
72
	if (!empty($service_name)) {
73
		switch ($_REQUEST['mode']) {
74
			case "restartservice":
75
				$savemsg = service_control_restart($service_name, $_REQUEST);
76
				break;
77
			case "startservice":
78
				$savemsg = service_control_start($service_name, $_REQUEST);
79
				break;
80
			case "stopservice":
81
				$savemsg = service_control_stop($service_name, $_REQUEST);
82
				break;
83
		}
84
		sleep(5);
85
	}
86

    
87
	exit;
88
}
89

    
90
$pgtitle = array(gettext("Status"), gettext("Services"));
91
include("head.inc");
92

    
93
if ($savemsg) {
94
	print_info_box($savemsg, 'success');
95
}
96

    
97
$services = get_services();
98

    
99
// $debugsvcs = array('name' => 'captiveportal', 'description' => 'Captive Portal', 'zone' => '14');
100
// array_push($services, $debugsvcs);
101

    
102
if (count($services) > 0) {
103
?>
104
<form action="status_services.php" method="post">
105
	<input id="mode" type="hidden" name="mode" value=""/>
106
	<input id="vpnmode" type="hidden" name="vpnmode" value=""/>
107
	<input id="service" type="hidden" name="service" value=""/>
108
	<input id="id" type="hidden" name="id" value=""/>
109
	<input id="zone" type="hidden" name="zone" value=""/>
110

    
111
<div class="panel panel-default">
112
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Services')?></h2></div>
113
	<div class="panel-body">
114

    
115
	<div class="panel-body panel-default">
116
		<div class="table-responsive">
117
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
118
				<thead>
119
					<tr>
120
						<th><?=gettext("Service")?></th>
121
						<th><?=gettext("Description")?></th>
122
						<th><?=gettext("Status")?></th>
123
						<th><?=gettext("Actions")?></th>
124
					</tr>
125
				</thead>
126
				<tbody>
127
<?php
128

    
129
	uasort($services, "service_name_compare");
130

    
131
	foreach ($services as $service) {
132
		if (empty($service['name'])) {
133
			continue;
134
		}
135

    
136
		if (empty($service['description'])) {
137
			$service['description'] = get_pkg_descr($service['name']);
138
		}
139
?>
140
					<tr>
141
						<td>
142
							<?=$service['name']?>
143
						</td>
144

    
145
						<td>
146
							<?=$service['description']?>
147
						</td>
148
<?php
149
		// if service is running then listr else listbg
150
		$bgclass = null;
151
		$running = false;
152

    
153
		if (get_service_status($service)) {
154
			$running = true;
155
		}
156
?>
157
						<td>
158
							<?=$running ? '<span class="text-success">' . gettext("Running") . '</span>':'<span class="text-danger">' . gettext("Stopped") . '</span>'?>
159
						</td>
160
						<td>
161
							<?=get_service_control_links($service)?>
162

    
163
<?php
164
		$scut = get_shortcut_by_service_name($service['name']);
165

    
166
		if (!empty($scut)) {
167
			echo get_shortcut_main_link($scut, true, $service);
168
			echo get_shortcut_status_link($scut, true, $service);
169
			echo get_shortcut_log_link($scut, true);
170
		}
171
?>
172
						</td>
173
					</tr>
174
<?php
175
	}
176
?>
177
				</tbody>
178
			</table>
179
		</div>
180
	</div>
181

    
182
	</div>
183
</div>
184

    
185
</form>
186
<?php
187
} else {
188
	print_info_box(gettext("No services found."), 'danger');
189
}
190

    
191
include("foot.inc");
(182-182/225)