Projet

Général

Profil

Télécharger (4,16 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / widgets / widgets / services_status.widget.php @ 2b641a08

1
<?php
2
/*
3
    services_status.widget.php
4
    Copyright (C) 2004, 2005 Scott Ullrich
5
    All rights reserved.
6

    
7
    services_status.widget.php
8
    Copyright (C) 2007 Sam Wenham
9

    
10
    Redistribution and use in source and binary forms, with or without
11
    modification, are permitted provided that the following conditions are met:
12

    
13
    1. Redistributions of source code must retain the above copyright notice,
14
       this list of conditions and the following disclaimer.
15

    
16
    2. Redistributions in binary form must reproduce the above copyright
17
       notice, this list of conditions and the following disclaimer in the
18
       documentation and/or other materials provided with the distribution.
19

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

    
32
$nocsrf = true;
33

    
34
require_once("guiconfig.inc");
35
require_once("captiveportal.inc");
36
require_once("service-utils.inc");
37
require_once("ipsec.inc");
38
require_once("vpn.inc");
39
require_once("/usr/local/www/widgets/include/services_status.inc");
40

    
41
$services = get_services();
42

    
43
if(isset($_POST['servicestatusfilter'])) {
44
	$config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401);
45
	write_config("Saved Service Status Filter via Dashboard");
46
	header("Location: ../../index.php");
47
}
48
?>
49
<input type="hidden" id="services_status-config" name="services_status-config" value="" />
50
<div id="services_status-settings" class="widgetconfigdiv" style="display:none;">
51
	<form action="/widgets/widgets/services_status.widget.php" method="post" name="iformd">
52
		Comma separated list of services to NOT display in the widget<br />
53
		<input type="text" size="30" name="servicestatusfilter" class="formfld unknown" id="servicestatusfilter" value="<?= $config['widgets']['servicestatusfilter'] ?>" />
54
		<input id="submitd" name="submitd" type="submit" class="formbtn" value="Save" />
55
    </form>
56
</div>
57

    
58
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="services">
59
	<tr>
60
	  <td class="widgetsubheader" align="center"><b>Service</b></td>
61
	  <td class="widgetsubheader" align="center"><b>Description</b></td>
62
	  <td class="widgetsubheader" align="center"><b>Status</b></td>
63
	  <td class="widgetsubheader">&nbsp;</td>
64
	</tr>
65
<?php
66
$skipservices = explode(",", $config['widgets']['servicestatusfilter']);
67

    
68
if (count($services) > 0) {
69
	uasort($services, "service_name_compare");
70
	foreach($services as $service) {
71
		if((!$service['name']) || (in_array($service['name'], $skipservices)) || (!is_service_enabled($service['name'])))
72
			continue;
73
		if (empty($service['description']))
74
			$service['description'] = get_pkg_descr($service['name']);
75
		$service_desc = explode(".",$service['description']);
76
		echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n";
77
		echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n";
78
		// if service is running then listr else listbg
79
		$bgclass = null;
80
		if (get_service_status($service))
81
			$bgclass = "listr";
82
		else
83
			$bgclass = "listbg";
84
		echo "<td class=\"" . $bgclass . "\" align=\"center\">" . get_service_status_icon($service, true, true) . "</td>\n";
85
		echo "<td valign=\"middle\" class=\"list nowrap\">" . get_service_control_links($service) . "</td></tr>\n";
86
	}
87
} else {
88
	echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . " . </td></tr>\n";
89
}
90
?>
91
</table>
92

    
93
<!-- needed to display the widget settings menu -->
94
<script type="text/javascript">
95
//<![CDATA[
96
	selectIntLink = "services_status-configure";
97
	textlink = document.getElementById(selectIntLink);
98
	textlink.style.display = "inline";
99
//]]>
100
</script>
(16-16/21)