Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1573 → Rev 1574

/web/acc/admin/services.php
35,6 → 35,10
$l_ulogd_ssh = "journalisation des accès par SSH";
$l_ulogd_ext_access = "journalisation des tentatives d'accès externes";
$l_ulogd_traceability = "journalisation des connexions WEB filtrés";
$l_execute = "Exécuter";
$l_stop_restart = "Arret et redémarrage du système";
$l_halt = "Arréter le système";
$l_reboot = "Relancer le système";
} else {
$l_services_title = "Services configuration";
$l_main_services = "Main services";
65,6 → 69,10
$l_ulogd_ssh = "SSH access logging process";
$l_ulogd_ext_access = "Extern access attempts logging process";
$l_ulogd_traceability = "Filtering WEB access logging process";
$l_execute = "Execute";
$l_stop_restart = "Halt and restart the system";
$l_halt = "Halt le system";
$l_reboot = "Restart the system";
}
 
/****************************************************************
86,15 → 94,15
//fonction pour faire une action (start,stop,restart) sur un service
function serviceExec($service, $action){
if (($action == "start")||($action == "stop")||($action == "restart")){
exec("sudo /bin/systemctl $action $service",$retval, $retstatus);
exec("sudo /usr/bin/systemctl $action $service",$retval, $retstatus);
if ($service == "sshd"){
if ($action == "start"){
exec("sudo /bin/systemctl enable $service");
exec("sudo /usr/bin/systemctl enable $service");
file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
}
if ($action == "stop"){
exec("sudo /sbin/systemctl disable $service");
exec("sudo /usr/bin/systemctl disable $service");
file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
}
108,7 → 116,7
//(en fonction de la présence d'un mot clé dans la valeur de status)
function checkServiceStatus($service){
$response = false;
exec("/bin/systemctl is-active $service.service",$retval);
exec("/usr/bin/systemctl is-active $service.service",$retval);
foreach( $retval as $val ) {
if ($val == "active"){
$response = true;
119,7 → 127,7
}
 
//-------------------------------
// Les actions sur un service
// Actions on services
//-------------------------------
//sécurité sur les actions à réaliser
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","httpd","sshd","freshclam","ntpd","havp","tinyproxy","dnsmasq","dnsmasq-blacklist","dnsmasq-whitelist","dnsmasq-blackhole");
132,6 → 140,23
}
}
//-------------------------------
// Actions on system
//-------------------------------
if (isset($_POST['choix'])){
switch ($_POST['choix']){
case 'reboot' :
exec ("sudo /usr/local/sbin/alcasar-logout.sh all");
exec ("sudo /usr/bin/systemctl reboot");
break;
case 'halt' :
exec ("sudo /usr/local/sbin/alcasar-logout.sh all");
exec ("sudo /usr/bin/systemctl halt");
break;
}
}
 
 
//-------------------------------
//recherche du status des services
//-------------------------------
$MainServiceStatus = array();
183,7 → 208,7
<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
<td align="center"><?php $comment="l_$serviceName"; echo "<b>$serviceName</b></td><td>${$comment}" ;?> </td>
<td width="80" align="center">---</td>
<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>
<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>
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=restart&service=$serviceName\"> $l_service_restart";?></a></td>
<?php } else { ?>
<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko ?>"></td>
247,6 → 272,20
</tr>
<?php } ?>
</td></tr>
</table>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><th><? echo $l_stop_restart;?></th></tr>
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
</TABLE>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
<tr><td valign="middle" align="left">
<FORM action="services.php" method=POST><b>
<select name='choix'></b>
<option selected value="reboot"><?echo "$l_reboot";?>
<option value="halt"><?echo "$l_halt";?>
</select>
<input type=submit value="<?echo "$l_execute";?>">
</FORM>
</td></tr>
</TABLE>
</body>
</html>