Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2933 → Rev 2934

/web/acc/admin/services.php
153,12 → 153,7
// Doing an action on a service (start,stop or restart)
function serviceExec($service, $action){
if (($action == "start")||($action == "stop")||($action == "restart")){
if ($service != "wifi4eu") { exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus); }
if ($service == "wifi4eu"){
if ($action == "stop"){ // see POST fonction (below) to start this service
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
}
}
exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus);
if ($service == "sshd"){
if ($action == "start"){
//exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service));
191,30 → 186,26
}
 
//-------------------------------
// Actions on services
//-------------------------------
$autorizeService = array("radiusd","chilli","mysqld","lighttpd","unbound-forward","ulogd-ssh","ulogd-ext-access","ulogd-traceability","unbound-blacklist","unbound-whitelist","dnsmasq-whitelist","unbound-blackhole","e2guardian","clamav-daemon","clamav-freshclam","sshd","ntpd","fail2ban","nfcapd","vnstat");
$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é
}
}
//-------------------------------
// WIFI4EU
//-------------------------------
if (isset($_POST['wifi4eu'])){
//file_put_contents(CONF_FILE, preg_replace('/^WIFI4EU_CODE=*/', 'WIFI4EU_CODE='.$_POST['wifi4eu'], file_get_contents(CONF_FILE)));
file_put_contents(CONF_FILE, preg_replace('/^WIFI4EU_CODE=.*/', 'WIFI4EU_CODE=REXY', file_get_contents(CONF_FILE)));
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
switch ($_POST['wifi4eu']){
case 'on' :
file_put_contents(CONF_FILE, preg_replace('/WIFI4EU_CODE=.*/', 'WIFI4EU_CODE='.trim($_POST['wifi4eu_code']), file_get_contents(CONF_FILE)));
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
break;
case 'off' :
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
break;
}
header('Location: '.$_SERVER['PHP_SELF']);
}
 
//-------------------------------
// Actions on system
// Stop/restart system
//-------------------------------
if (isset($_POST['choix'])){
switch ($_POST['choix']){
if (isset($_POST['system'])){
switch ($_POST['system']){
case 'reboot' :
exec ("sudo /usr/local/bin/alcasar-logout.sh all");
exec ("sudo /usr/sbin/shutdown -r now");
227,6 → 218,19
}
 
//-------------------------------
// Actions on services
//-------------------------------
$autorizeService = array("radiusd","chilli","mysqld","lighttpd","unbound-forward","ulogd-ssh","ulogd-ext-access","ulogd-traceability","unbound-blacklist","unbound-whitelist","dnsmasq-whitelist","unbound-blackhole","e2guardian","clamav-daemon","clamav-freshclam","sshd","ntpd","fail2ban","nfcapd","vnstat");
$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é
}
}
 
//-------------------------------
// Check services status
//-------------------------------
$MainServiceStatus = array();
327,12 → 331,12
<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"><b>WIFI4EU</b></td><td><?php echo "network ID : $wifi4eu_code"; ?></td>
<td width="80" align="center">---</td>
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=wifi4eu\"> $l_service_stop";?></a></td>
<td width="80" align="center"><input type=submit value="<?echo $l_service_stop;?>"><input type=hidden name="wifi4eu" value="off"></td>
<td width="80" align="center">---</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">WIFI4EU</td><td><?php echo $l_wifi4eu_id; ?> : <input type ="text" name="wifi4eu" value="<?php echo $wifi4eu_code; ?>" size="40"></td>
<td width="80" align="center"><input type=submit value="<?echo $l_service_start;?>"></td>
<td align="center">WIFI4EU</td><td><?php echo $l_wifi4eu_id; ?> : <input type ="text" name="wifi4eu_code" value="<?php echo $wifi4eu_code; ?>" size="40"></td>
<td width="80" align="center"><input type=submit value="<?echo $l_service_start;?>"><input type=hidden name="wifi4eu" value="on"></td>
<td width="80" align="center">---</td>
<td width="80" align="center">---</td>
<?php } ?>
347,7 → 351,7
<table width="100%" border=0 cellspacing=0 cellpadding=1>
<tr><td valign="middle" align="left">
<form action="<?php echo $_SERVER['PHP_SELF']?>" method=POST>
<select name='choix'>
<select name='system'>
<option selected value="reboot"><?echo "$l_reboot";?>
<option value="halt"><?echo "$l_halt";?>
</select>