Subversion Repositories ALCASAR

Rev

Rev 596 | Go to most recent revision | Blame | Last modification | View Log

<?php
/* written by steweb57 */
/*


*/
require_once('includes/defines.inc.php');
require_once(ALCASAR_ADMIN_PATH_INC.'/session.inc.php');


# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
        $Langue         = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
        $Language       = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
        $l_services_title       = "Configuration des services";
        $l_main_services        = "Services réseau principaux";
        $l_opt_services         = "Services réseau optionnels";

        $l_service_title        = "Nom du service";
        $l_service_start        = "D&eacute;marrer";
        $l_service_stop         = "Arr&ecirc;ter";
        $l_service_restart      = "Red&eacute;marrer";
        $l_service_status       = "Status";
        $l_service_action       = "Actions";
        $l_enable               = "actif";
        $l_disable              = "inactif";
        $l_radiusd              = "Serveur d'authentification et d'autorisation";
        $l_chilli               = "Passerelle d'interception";
        $l_dansguardian         = "Filtre d'URL et de contenu WEB";
        $l_mysqld               = "Serveur de la base de données usager";
        $l_squid                = "Serveur de cache WEB";
        $l_dnsmasq              = "Serveur DNS et filtre de domaine";
        $l_httpd                = "Serveur WEB (Centre de Gestion d'ALCASAR)";
        $l_havp                 = "Filtre antivirus WEB";
        $l_sshd                 = "Accàs sécurisée à distance";
        $l_freshclam            = "Mise à jour de l'antivirus toutes les 2 heures";
        $l_ntpd                 = "Service de mise à l'heure réseau";
} else {
        $l_services_title       = "Configuration des services"; // a modifier
        $l_main_services        = "Main network services";
        $l_opt_services         = "Optional network services";

        $l_service_title        = "Service name";
        $l_service_start        = "Start";
        $l_service_stop         = "Stop";
        $l_service_restart      = "Restart";
        $l_service_status       = "Status";
        $l_service_action       = "Actions";
        $l_enable               = "enable";
        $l_disable              = "disable";
        $l_radiusd              = "Authentication and authorisation serveur";
        $l_chilli               = "Interception gateway";
        $l_dansguardian         = "URL and WEB content filter";
        $l_mysqld               = "User database server";
        $l_squid                = "Proxy Cache WEB";
        $l_dnsmasq              = "DNS and domain name filter";
        $l_httpd                = "WEB server (ALCASAR Control Center)";
        $l_havp                 = "WEB antivirus filter";
        $l_sshd                 = "Secure remote access";
        $l_freshclam            = "WEB antivirus update (every 2 hours)";
        $l_ntpd                 = "Network time";
}

//fonction pour faire une action (start,stop,restart) sur un service
function serviceExec($service, $action){
        if (($action == "start")||($action == "stop")||($action == "restart")){
                exec("sudo /sbin/service $service $action",$retval, $retstatus);
                if ($service == "sshd"){
                        if ($action == "start"){ exec("sudo /sbin/chkconfig --add $service");}
                        if ($action == "stop"){ exec("sudo /sbin/chkconfig --del $service");}
                        }
                return $retstatus;
        } else {
                return false;
        }
}
//fonction définissant le status d'un service 
//(en fonction de la présence d'un mot clé dans la valeur de status)
function checkServiceStatus($service, $strMatch){
        $response = false;
        exec("sudo /sbin/service $service status",$retval);
        foreach( $retval as $val ) {
                if (strpos($val,$strMatch)){
                        $response = true;
                        break;
                }
        }
        return $response;
}

//-------------------------------
// Les actions sur un service
//-------------------------------
//sécurité sur les actions à réaliser
$autorizeService = array("radiusd","chilli","dansguardian","mysqld","squid","dnsmasq","httpd","havp","sshd","freshclam","ntpd");
$autorizeAction = array("start","stop","restart");

if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
    if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
        $execStatus = serviceExec($_GET['service'], $_GET['action']);
                // execStatus non exploité
        }
}
//-------------------------------
//recherche du status des services
//-------------------------------
$MainServiceStatus = array();
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd","pid");
$MainServiceStatus['chilli'] = checkServiceStatus("chilli","pid");
$MainServiceStatus['dansguardian'] = checkServiceStatus("dansguardian","pid");
$MainServiceStatus['mysqld'] = checkServiceStatus("mysqld","OK");
$MainServiceStatus['squid'] = checkServiceStatus("squid","pid");
$MainServiceStatus['dnsmasq'] = checkServiceStatus("dnsmasq","pid");
$MainServiceStatus['httpd'] = checkServiceStatus("httpd","pid");
$MainServiceStatus['havp'] = checkServiceStatus("havp","pid");

$OptServiceStatus = array();
$OptServiceStatus['sshd'] = checkServiceStatus("sshd","pid");
$OptServiceStatus['freshclam'] = checkServiceStatus("freshclam","pid");
$OptServiceStatus['ntpd'] = checkServiceStatus("ntpd","pid");

?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">
<html>
<head>
<title>Services page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- include default CSS -->
<link rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/default.css" type="text/css">
<!-- include JQUERY UI CSS -->
<link type="text/css"  rel="stylesheet" href="<?php echo ALCASAR_ADMIN_PATH_CSS; ?>/default/ui-lightness/jquery-ui-1.8.10.custom.css">
<!-- include custom page CSS -->
<style type="text/css">

</style>
<!-- include JQUERY -->
<script type="text/javascript" src="<?php echo ALCASAR_ADMIN_PATH_JS; ?>/jquery-1.5.min.js"></script>
<!-- include JQUERY UI -->
<script type="text/javascript" src="<?php echo ALCASAR_ADMIN_PATH_JS; ?>/jquery-ui-1.8.10.all.min.js"></script>
<!-- include page javascript -->
<script type="text/javascript">

</script>
</head>
<body>
<div class="title">
        <h3 class="ui-widget-header ui-corner-all"><?php echo $l_services_title; ?></h3>
</div>
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr><th><?php echo $l_main_services; ?></th></tr>
</table>
<table width="100%" border=0 cellspacing=0 cellpadding=0 class="ui-widget ui-widget-content">
        <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>
        <tr align="center">
<?php foreach( $MainServiceStatus as $servicename => $statusok ) { ?>
<tr>
        <?php if ($statusok) { ?>
    <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"><a href="<?php echo $_server['php_self']."?action=stop&service=$servicename\"> $l_service_stop";?></a></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>
    <td align="center"><?php $comment="l_$servicename"; echo "<b>$servicename</b></td><td>${$comment}" ;?> </td>
    <td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=start&service=$servicename\"> $l_service_start";?></a></td>
    <td width="80" align="center">---</td>
    <td width="80" align="center">---</td>
    <?php } ?>
</tr>
<?php } ?>
</td></tr>
</table>
<br />
<table width="100%" border="0" cellspacing="2" cellpadding="0">
        <tr><th><?php echo $l_opt_services; ?></th></tr>
</table>
<table width="100%" border=0 cellspacing=0 cellpadding=0 class="ui-widget ui-widget-content">
        <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>
        <tr align="center">
<?php foreach( $OptServiceStatus as $servicename => $statusok ) { ?>
<tr>
        <?php if ($statusok) { ?>
    <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"><a href="<?php echo $_server['php_self']."?action=stop&service=$servicename\"> $l_service_stop";?></a></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>
    <td align="center"><?php $comment="l_$servicename"; echo "<b>$servicename</b></td><td>${$comment}" ;?> </td>
    <td width="80" align="center"><a href="<?php echo $_server['php_self']."?action=start&service=$servicename\"> $l_service_start";?></a></td>
    <td width="80" align="center">---</td>
    <td width="80" align="center">---</td>
    <?php } ?>
</tr>
<?php } ?>
</td></tr>
</table>
</body>
</html>

Generated by GNU Enscript 1.6.6.