593 |
stephane |
1 |
<?php
|
703 |
stephane |
2 |
/* written by steweb57 */
|
593 |
stephane |
3 |
/*
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
*/
|
|
|
7 |
require_once('includes/defines.inc.php');
|
|
|
8 |
require_once(ALCASAR_ADMIN_PATH_INC.'/session.inc.php');
|
703 |
stephane |
9 |
|
|
|
10 |
|
|
|
11 |
# Choice of language
|
|
|
12 |
$Language = 'en';
|
|
|
13 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
14 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
15 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
16 |
if($Language == 'fr'){
|
|
|
17 |
$l_services_title = "Configuration des services";
|
|
|
18 |
$l_main_services = "Services réseau principaux";
|
|
|
19 |
$l_opt_services = "Services réseau optionnels";
|
|
|
20 |
|
|
|
21 |
$l_service_title = "Nom du service";
|
|
|
22 |
$l_service_start = "Démarrer";
|
|
|
23 |
$l_service_stop = "Arrêter";
|
|
|
24 |
$l_service_restart = "Redémarrer";
|
|
|
25 |
$l_service_status = "Status";
|
|
|
26 |
$l_service_action = "Actions";
|
|
|
27 |
$l_enable = "actif";
|
|
|
28 |
$l_disable = "inactif";
|
|
|
29 |
$l_radiusd = "Serveur d'authentification et d'autorisation";
|
|
|
30 |
$l_chilli = "Passerelle d'interception";
|
|
|
31 |
$l_dansguardian = "Filtre d'URL et de contenu WEB";
|
|
|
32 |
$l_mysqld = "Serveur de la base de données usager";
|
|
|
33 |
$l_squid = "Serveur de cache WEB";
|
|
|
34 |
$l_dnsmasq = "Serveur DNS et filtre de domaine";
|
|
|
35 |
$l_httpd = "Serveur WEB (Centre de Gestion d'ALCASAR)";
|
|
|
36 |
$l_havp = "Filtre antivirus WEB";
|
|
|
37 |
$l_sshd = "Accàs sécurisée à distance";
|
|
|
38 |
$l_freshclam = "Mise à jour de l'antivirus toutes les 2 heures";
|
|
|
39 |
$l_ntpd = "Service de mise à l'heure réseau";
|
|
|
40 |
} else {
|
|
|
41 |
$l_services_title = "Configuration des services"; // a modifier
|
|
|
42 |
$l_main_services = "Main network services";
|
|
|
43 |
$l_opt_services = "Optional network services";
|
|
|
44 |
|
|
|
45 |
$l_service_title = "Service name";
|
|
|
46 |
$l_service_start = "Start";
|
|
|
47 |
$l_service_stop = "Stop";
|
|
|
48 |
$l_service_restart = "Restart";
|
|
|
49 |
$l_service_status = "Status";
|
|
|
50 |
$l_service_action = "Actions";
|
|
|
51 |
$l_enable = "enable";
|
|
|
52 |
$l_disable = "disable";
|
|
|
53 |
$l_radiusd = "Authentication and authorisation serveur";
|
|
|
54 |
$l_chilli = "Interception gateway";
|
|
|
55 |
$l_dansguardian = "URL and WEB content filter";
|
|
|
56 |
$l_mysqld = "User database server";
|
|
|
57 |
$l_squid = "Proxy Cache WEB";
|
|
|
58 |
$l_dnsmasq = "DNS and domain name filter";
|
|
|
59 |
$l_httpd = "WEB server (ALCASAR Control Center)";
|
|
|
60 |
$l_havp = "WEB antivirus filter";
|
|
|
61 |
$l_sshd = "Secure remote access";
|
|
|
62 |
$l_freshclam = "WEB antivirus update (every 2 hours)";
|
|
|
63 |
$l_ntpd = "Network time";
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
//fonction pour faire une action (start,stop,restart) sur un service
|
|
|
67 |
function serviceExec($service, $action){
|
|
|
68 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
|
|
69 |
exec("sudo /sbin/service $service $action",$retval, $retstatus);
|
|
|
70 |
if ($service == "sshd"){
|
|
|
71 |
if ($action == "start"){ exec("sudo /sbin/chkconfig --add $service");}
|
|
|
72 |
if ($action == "stop"){ exec("sudo /sbin/chkconfig --del $service");}
|
|
|
73 |
}
|
|
|
74 |
return $retstatus;
|
|
|
75 |
} else {
|
|
|
76 |
return false;
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
//fonction définissant le status d'un service
|
|
|
80 |
//(en fonction de la présence d'un mot clé dans la valeur de status)
|
|
|
81 |
function checkServiceStatus($service, $strMatch){
|
|
|
82 |
$response = false;
|
|
|
83 |
exec("sudo /sbin/service $service status",$retval);
|
|
|
84 |
foreach( $retval as $val ) {
|
|
|
85 |
if (strpos($val,$strMatch)){
|
|
|
86 |
$response = true;
|
|
|
87 |
break;
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
return $response;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
//-------------------------------
|
|
|
94 |
// Les actions sur un service
|
|
|
95 |
//-------------------------------
|
|
|
96 |
//sécurité sur les actions à réaliser
|
|
|
97 |
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","squid","dnsmasq","httpd","havp","sshd","freshclam","ntpd");
|
|
|
98 |
$autorizeAction = array("start","stop","restart");
|
|
|
99 |
|
|
|
100 |
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
|
|
|
101 |
if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
|
|
|
102 |
$execStatus = serviceExec($_GET['service'], $_GET['action']);
|
|
|
103 |
// execStatus non exploité
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
//-------------------------------
|
|
|
107 |
//recherche du status des services
|
|
|
108 |
//-------------------------------
|
|
|
109 |
$MainServiceStatus = array();
|
|
|
110 |
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd","pid");
|
|
|
111 |
$MainServiceStatus['chilli'] = checkServiceStatus("chilli","pid");
|
|
|
112 |
$MainServiceStatus['dansguardian'] = checkServiceStatus("dansguardian","pid");
|
|
|
113 |
$MainServiceStatus['mysqld'] = checkServiceStatus("mysqld","OK");
|
|
|
114 |
$MainServiceStatus['squid'] = checkServiceStatus("squid","pid");
|
|
|
115 |
$MainServiceStatus['dnsmasq'] = checkServiceStatus("dnsmasq","pid");
|
|
|
116 |
$MainServiceStatus['httpd'] = checkServiceStatus("httpd","pid");
|
|
|
117 |
$MainServiceStatus['havp'] = checkServiceStatus("havp","pid");
|
|
|
118 |
|
|
|
119 |
$OptServiceStatus = array();
|
|
|
120 |
$OptServiceStatus['sshd'] = checkServiceStatus("sshd","pid");
|
|
|
121 |
$OptServiceStatus['freshclam'] = checkServiceStatus("freshclam","pid");
|
|
|
122 |
$OptServiceStatus['ntpd'] = checkServiceStatus("ntpd","pid");
|
|
|
123 |
|
593 |
stephane |
124 |
?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
|
|
|
125 |
<html>
|
|
|
126 |
<head>
|
|
|
127 |
<title>Services page</title>
|
703 |
stephane |
128 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
596 |
stephane |
129 |
<!-- include default CSS -->
|
593 |
stephane |
130 |
<link rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/default.css" type="text/css">
|
596 |
stephane |
131 |
<!-- include JQUERY UI CSS -->
|
|
|
132 |
<link type="text/css" rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/ui-lightness/jquery-ui-1.8.10.custom.css">
|
|
|
133 |
<!-- include custom page CSS -->
|
|
|
134 |
<style type="text/css">
|
|
|
135 |
|
|
|
136 |
</style>
|
|
|
137 |
<!-- include JQUERY -->
|
|
|
138 |
<script type="text/javascript" src="<?php echo ALCASAR_ADMIN_PATH_JS; ?>/jquery-1.5.min.js"></script>
|
|
|
139 |
<!-- include JQUERY UI -->
|
|
|
140 |
<script type="text/javascript" src="<?php echo ALCASAR_ADMIN_PATH_JS; ?>/jquery-ui-1.8.10.all.min.js"></script>
|
|
|
141 |
<!-- include page javascript -->
|
|
|
142 |
<script type="text/javascript">
|
|
|
143 |
|
|
|
144 |
</script>
|
593 |
stephane |
145 |
</head>
|
596 |
stephane |
146 |
<body>
|
703 |
stephane |
147 |
<div class="title">
|
|
|
148 |
<h3 class="ui-widget-header ui-corner-all"><?php echo $l_services_title; ?></h3>
|
|
|
149 |
</div>
|
|
|
150 |
<br />
|
|
|
151 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
|
|
152 |
<tr><th><?php echo $l_main_services; ?></th></tr>
|
|
|
153 |
</table>
|
|
|
154 |
<table width="100%" border=0 cellspacing=0 cellpadding=0 class="ui-widget ui-widget-content">
|
|
|
155 |
<tr align="center" class="ui-widget-header"><td><?php echo $l_service_status;?></td><td colspan="2"><?php echo $l_service_title;?></td><td colspan="3"><?php echo $l_service_action;?></td></tr>
|
|
|
156 |
<tr align="center">
|
|
|
157 |
<?php foreach( $MainServiceStatus as $servicename => $statusok ) { ?>
|
|
|
158 |
<tr>
|
|
|
159 |
<?php if ($statusok) { ?>
|
|
|
160 |
<td align="center"><img src="../images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
|
|
161 |
<td align="center"><?php $comment="l_$servicename"; echo "<b>$servicename</b></td><td>${$comment}" ;?> </td>
|
|
|
162 |
<td width="80" align="center">---</td>
|
|
|
163 |
<td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=stop&service=$servicename\"> $l_service_stop";?></a></td>
|
|
|
164 |
<td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=restart&service=$servicename\"> $l_service_restart";?></a></td>
|
|
|
165 |
<?php } else { ?>
|
|
|
166 |
<td align="center"><img src="../images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
|
|
|
167 |
<td align="center"><?php $comment="l_$servicename"; echo "<b>$servicename</b></td><td>${$comment}" ;?> </td>
|
|
|
168 |
<td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=start&service=$servicename\"> $l_service_start";?></a></td>
|
|
|
169 |
<td width="80" align="center">---</td>
|
|
|
170 |
<td width="80" align="center">---</td>
|
|
|
171 |
<?php } ?>
|
|
|
172 |
</tr>
|
|
|
173 |
<?php } ?>
|
|
|
174 |
</td></tr>
|
|
|
175 |
</table>
|
|
|
176 |
<br />
|
|
|
177 |
<table width="100%" border="0" cellspacing="2" cellpadding="0">
|
|
|
178 |
<tr><th><?php echo $l_opt_services; ?></th></tr>
|
|
|
179 |
</table>
|
|
|
180 |
<table width="100%" border=0 cellspacing=0 cellpadding=0 class="ui-widget ui-widget-content">
|
|
|
181 |
<tr align="center" class="ui-widget-header"><td><?php echo $l_service_status;?></td><td colspan="2"><?php echo $l_service_title;?></td><td colspan="3"><?php echo $l_service_action;?></td></tr>
|
|
|
182 |
<tr align="center">
|
|
|
183 |
<?php foreach( $OptServiceStatus as $servicename => $statusok ) { ?>
|
|
|
184 |
<tr>
|
|
|
185 |
<?php if ($statusok) { ?>
|
|
|
186 |
<td align="center"><img src="../images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
|
|
187 |
<td align="center"><?php $comment="l_$servicename"; echo "<b>$servicename</b></td><td>${$comment}" ;?> </td>
|
|
|
188 |
<td width="80" align="center">---</td>
|
|
|
189 |
<td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=stop&service=$servicename\"> $l_service_stop";?></a></td>
|
|
|
190 |
<td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=restart&service=$servicename\"> $l_service_restart";?></a></td>
|
|
|
191 |
<?php } else { ?>
|
|
|
192 |
<td align="center"><img src="../images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
|
|
|
193 |
<td align="center"><?php $comment="l_$servicename"; echo "<b>$servicename</b></td><td>${$comment}" ;?> </td>
|
|
|
194 |
<td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=start&service=$servicename\"> $l_service_start";?></a></td>
|
|
|
195 |
<td width="80" align="center">---</td>
|
|
|
196 |
<td width="80" align="center">---</td>
|
|
|
197 |
<?php } ?>
|
|
|
198 |
</tr>
|
|
|
199 |
<?php } ?>
|
|
|
200 |
</td></tr>
|
|
|
201 |
</table>
|
593 |
stephane |
202 |
</body>
|
|
|
203 |
</html>
|