Subversion Repositories ALCASAR

Rev

Rev 1484 | Rev 1548 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
838 richard 1
<?php
2
/* written by steweb57 & Rexy */ 
3
# Choice of language
4
$Language = 'en';
5
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
6
	$Langue		= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
7
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
8
if($Language == 'fr'){
9
	$l_services_title	= "Configuration des services";
1157 stephane 10
	$l_main_services	= "Services principaux";
1476 richard 11
	$l_filter_services	= "Services de filtrage";
1157 stephane 12
	$l_opt_services		= "Services optionnels";
838 richard 13
	$l_service_title 	= "Nom du service";
14
	$l_service_start 	= "D&eacute;marrer";
15
	$l_service_stop 	= "Arr&ecirc;ter";
16
	$l_service_restart 	= "Red&eacute;marrer";
17
	$l_service_status 	= "Status";
1006 richard 18
	$l_service_status_img_ok= "Démarré";
19
	$l_service_status_img_ko= "Arrété";
838 richard 20
	$l_service_action 	= "Actions";
21
	$l_radiusd		= "Serveur d'authentification et d'autorisation";
22
	$l_chilli		= "Passerelle d'interception";
23
	$l_dansguardian		= "Filtre d'URL et de contenu WEB";
1476 richard 24
	$l_mysqld		= "Serveur de la base des usagers";
25
	$l_httpd		= "Serveur WEB (Alcasar Control Center)";
26
	$l_sshd			= "Accès sécurisée distant";
838 richard 27
	$l_freshclam		= "Mise à jour de l'antivirus toutes les 2 heures";
28
	$l_ntpd			= "Service de mise à l'heure réseau";
1396 richard 29
	$l_havp			= "Proxy Antivirus 1";
1508 richard 30
	$l_tinyproxy		= "Proxy HTTP léger";
1476 richard 31
	$l_dnsmasq		= "Serveur DNS et DHCP";
32
	$l_dnsmasq_blacklist	= "Serveur DNS pour la Blacklist";
33
	$l_dnsmasq_whitelist	= "Serveur DNS pour la Whitelist";
34
	$l_dnsmasq_blackhole	= "Serveur DNS 'trou noir'";
1484 richard 35
	$l_ulogd_ssh		= "journalisation des accès par SSH";
1476 richard 36
	$l_ulogd_ext_access	= "journalisation des tentatives d'accès externes";
37
	$l_ulogd_traceability	= "journalisation des connexions WEB filtrés";
838 richard 38
} else {
39
	$l_services_title	= "Services configuration";
1157 stephane 40
	$l_main_services	= "Main services";
1476 richard 41
	$l_filter_services	= "Filtering services";
1157 stephane 42
	$l_opt_services		= "Optional services";
838 richard 43
	$l_service_title 	= "Service name";
44
	$l_service_start 	= "Start";
45
	$l_service_stop 	= "Stop";
46
	$l_service_restart 	= "Restart";
47
	$l_service_status 	= "Status";
1006 richard 48
	$l_service_status_img_ok= "Running";
49
	$l_service_status_img_ko= "Stopped";
838 richard 50
	$l_service_action 	= "Actions";
51
	$l_radiusd		= "Authentication and authorisation serveur";
52
	$l_chilli		= "Interception gateway";
53
	$l_dansguardian		= "URL and WEB content filter";
54
	$l_mysqld		= "User database server";
55
	$l_httpd		= "WEB server (ALCASAR Control Center)";
56
	$l_sshd			= "Secure remote access";
57
	$l_freshclam		= "WEB antivirus update (every 2 hours)";
58
	$l_ntpd			= "Network time";
1396 richard 59
	$l_havp			= "Antivirus Proxy 1";
1508 richard 60
	$l_tinyproxy		= "Light HTTP Proxy";
1476 richard 61
	$l_dnsmasq		= "DNS and DHCP server";
62
	$l_dnsmasq_blacklist	= "DNS server for the Blacklist";
63
	$l_dnsmasq_whitelist	= "DNS server for the Whitelist";
64
	$l_dnsmasq_blackhole	= "DNS server (blackhole)";
65
	$l_ulogd_ssh		= "SSH access logging process";
66
	$l_ulogd_ext_access	= "Extern access attempts logging processs";
67
	$l_ulogd_traceability	= "Filtering WEB access logging process";
838 richard 68
}
69
 
70
/****************************************************************
71
*	CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION	*
72
*****************************************************************/
73
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
74
 
75
/********************************************************
76
*	TEST DU FICHIERS DE CONFIGURATION		*
77
*********************************************************/
78
//Test de présence et des droits en lecture des fichiers de configuration.
79
if (!file_exists(CONF_FILE)){
80
	exit("Fichier de configuration ".CONF_FILE." non présent");
81
}
82
if (!is_readable(CONF_FILE)){
83
	exit("Vous n'avez pas les droits de lecture sur le fichier ".CONF_FILE);
84
}
85
 
86
//fonction pour faire une action (start,stop,restart) sur un service
87
function serviceExec($service, $action){
88
	if (($action == "start")||($action == "stop")||($action == "restart")){
89
		exec("sudo /sbin/service $service $action",$retval, $retstatus);
90
		if ($service == "sshd"){
91
			if ($action == "start"){ 
1041 richard 92
				exec("sudo /bin/systemctl enable $service.service");
838 richard 93
				file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
94
				exec ("sudo /usr/local/bin/alcasar-iptables.sh");
95
				}
96
			if ($action == "stop"){
1055 richard 97
			       	exec("sudo /sbin/systemctl disable $service.service");
838 richard 98
				file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
99
				exec ("sudo /usr/local/bin/alcasar-iptables.sh");
100
				}
101
			}
102
		return $retstatus;
103
	} else {
104
		return false;
105
	}
106
}
107
//fonction définissant le status d'un service 
108
//(en fonction de la présence d'un mot clé dans la valeur de status)
1006 richard 109
function checkServiceStatus($service){
838 richard 110
	$response = false;
1006 richard 111
	exec("/bin/systemctl is-active $service.service",$retval);
838 richard 112
	foreach( $retval as $val ) {
1006 richard 113
		if ($val == "active"){
838 richard 114
			$response = true;
115
			break;
116
		}
117
	}
118
	return $response;
119
}
120
 
121
//-------------------------------
122
// Les actions sur un service
123
//-------------------------------
124
//sécurité sur les actions à réaliser
1508 richard 125
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","httpd","sshd","freshclam","ntpd","havp","tinyproxy","dnsmasq","dnsmasq-blacklist","dnsmasq-whitelist","dnsmasq-blackhole");
838 richard 126
$autorizeAction = array("start","stop","restart");
127
 
128
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
129
    if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
130
    	$execStatus = serviceExec($_GET['service'], $_GET['action']);
131
		// execStatus non exploité
132
	}
133
}
134
//-------------------------------
135
//recherche du status des services
136
//-------------------------------
137
$MainServiceStatus = array();
1006 richard 138
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd");
139
$MainServiceStatus['chilli'] = checkServiceStatus("chilli");
140
$MainServiceStatus['mysqld'] = checkServiceStatus("mysqld");
141
$MainServiceStatus['httpd'] = checkServiceStatus("httpd");
1396 richard 142
$MainServiceStatus['dnsmasq'] = checkServiceStatus("dnsmasq");
1478 richard 143
$MainServiceStatus['ulogd_ssh'] = checkServiceStatus("ulogd-ssh");
144
$MainServiceStatus['ulogd_ext_access'] = checkServiceStatus("ulogd-ext-access");
145
$MainServiceStatus['ulogd_traceability'] = checkServiceStatus("ulogd-traceability");
838 richard 146
 
1476 richard 147
$FilterServiceStatus = array();
148
$FilterServiceStatus['dnsmasq_blacklist'] = checkServiceStatus("dnsmasq-blacklist");
149
$FilterServiceStatus['dnsmasq_whitelist'] = checkServiceStatus("dnsmasq-whitelist");
150
$FilterServiceStatus['dnsmasq_blackhole'] = checkServiceStatus("dnsmasq-blackhole");
151
$filterServiceStatus['dansguardian'] = checkServiceStatus("dansguardian");
152
$FilterServiceStatus['havp'] = checkServiceStatus("havp");
1508 richard 153
$FilterServiceStatus['tinyproxy'] = checkServiceStatus("tinyproxy");
1476 richard 154
$FilterServiceStatus['freshclam'] = checkServiceStatus("freshclam");
155
 
156
 
838 richard 157
$OptServiceStatus = array();
1006 richard 158
$OptServiceStatus['sshd'] = checkServiceStatus("sshd");
159
$OptServiceStatus['ntpd'] = checkServiceStatus("ntpd");
838 richard 160
 
161
/****************
162
*	MAIN	*
163
*****************/
164
 
165
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
166
<html><!-- written by steweb57 / rexy -->
167
<head>
168
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
169
<title><?php echo $l_services_title; ?></title>
170
<link rel="stylesheet" href="/css/style.css" type="text/css">
171
</head>
172
<body>
173
<table width="100%" border="0" cellspacing="0" cellpadding="0">
174
	<tr><th><?php echo $l_main_services; ?></th></tr>
175
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
176
</table>
177
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
178
	<tr align="center"><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>
179
	<TR align="center">
180
<?php foreach( $MainServiceStatus as $serviceName => $statusOK ) { ?>
181
<tr>
182
	<?php if ($statusOK) { ?>
183
    <td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
184
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
185
    <td width="80" align="center">---</td>
1476 richard 186
    <td width="80" align="center"><?php if ($serviceName != "chilli") { echo "<a href=".$_SERVER['PHP_SELF']."?action=stop&service=$serviceName\"> $l_service_stop</a>"; } else echo "---";?></td>
838 richard 187
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
188
	<?php } else { ?>
189
    <td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
190
    <td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
191
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=$serviceName\"> $l_service_start";?></a></td>
192
    <td width="80" align="center">---</td>
193
    <td width="80" align="center">---</td>
194
    <?php } ?>
195
</tr>
196
<?php } ?>
197
</td></tr>
198
</table>
199
<table width="100%" border="0" cellspacing="0" cellpadding="0">
1476 richard 200
	<tr><th><?php echo $l_filter_services; ?></th></tr>
201
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
202
</table>
203
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
204
	<tr align="center"><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>
205
	<TR align="center">
206
<?php foreach( $FilterServiceStatus as $serviceName => $statusOK ) { ?>
207
<tr>
208
	<?php if ($statusOK) { ?>
209
    <td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
210
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
211
    <td width="80" align="center">---</td>
212
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=$serviceName\"> $l_service_stop";?></a></td>
213
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
214
	<?php } else { ?>
215
    <td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
216
    <td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
217
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=$serviceName\"> $l_service_start";?></a></td>
218
    <td width="80" align="center">---</td>
219
    <td width="80" align="center">---</td>
220
    <?php } ?>
221
</tr>
222
<?php } ?>
223
</td></tr>
224
</table>
225
<table width="100%" border="0" cellspacing="0" cellpadding="0">
838 richard 226
	<tr><th><?php echo $l_opt_services; ?></th></tr>
227
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
228
</table>
229
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
230
	<tr align="center"><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>
231
	<TR align="center">
232
<?php foreach( $OptServiceStatus as $serviceName => $statusOK ) { ?>
233
<tr>
234
	<?php if ($statusOK) { ?>
235
    <td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
236
	<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
237
    <td width="80" align="center">---</td>
238
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=$serviceName\"> $l_service_stop";?></a></td>
239
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
240
	<?php } else { ?>
241
    <td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
242
    <td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
243
    <td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=start&service=$serviceName\"> $l_service_start";?></a></td>
244
    <td width="80" align="center">---</td>
245
    <td width="80" align="center">---</td>
246
    <?php } ?>
247
</tr>
248
<?php } ?>
249
</td></tr>
250
</table>
251
</body>
252
</html>