Subversion Repositories ALCASAR

Rev

Rev 596 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 596 Rev 703
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
/* written by steweb57 */
2
/*
3
/*
3
 
4
 
4
 
5
 
5
*/
6
*/
6
require_once('includes/defines.inc.php');
7
require_once('includes/defines.inc.php');
7
require_once(ALCASAR_ADMIN_PATH_INC.'/session.inc.php');
8
require_once(ALCASAR_ADMIN_PATH_INC.'/session.inc.php');
-
 
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&eacute;marrer";
-
 
23
	$l_service_stop 	= "Arr&ecirc;ter";
-
 
24
	$l_service_restart 	= "Red&eacute;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
 
8
?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
124
?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
9
<html>
125
<html>
10
<head>
126
<head>
11
<title>Services page</title>
127
<title>Services page</title>
-
 
128
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
12
<!-- include default CSS -->
129
<!-- include default CSS -->
13
<link rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/default.css" type="text/css">
130
<link rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/default.css" type="text/css">
14
<!-- include JQUERY UI CSS -->
131
<!-- include JQUERY UI CSS -->
15
<link type="text/css"  rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/ui-lightness/jquery-ui-1.8.10.custom.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">
16
<!-- include custom page CSS -->
133
<!-- include custom page CSS -->
Line 25... Line 142...
25
<script type="text/javascript">
142
<script type="text/javascript">
26
 
143
 
27
</script>
144
</script>
28
</head>
145
</head>
29
<body>
146
<body>
-
 
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>
30
<h1>SERVICES PAGE</h1>
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>
31
</body>
202
</body>
32
</html>
203
</html>
33
 
204