Line 151... |
Line 151... |
151 |
$wifi4eu_code = $conf['WIFI4EU_CODE'];
|
151 |
$wifi4eu_code = $conf['WIFI4EU_CODE'];
|
152 |
|
152 |
|
153 |
// Doing an action on a service (start,stop or restart)
|
153 |
// Doing an action on a service (start,stop or restart)
|
154 |
function serviceExec($service, $action){
|
154 |
function serviceExec($service, $action){
|
155 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
155 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
156 |
if ($service != "wifi4eu") { exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus); }
|
156 |
exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus);
|
157 |
if ($service == "wifi4eu"){
|
- |
|
158 |
if ($action == "stop"){ // see POST fonction (below) to start this service
|
- |
|
159 |
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
|
- |
|
160 |
}
|
- |
|
161 |
}
|
- |
|
162 |
if ($service == "sshd"){
|
157 |
if ($service == "sshd"){
|
163 |
if ($action == "start"){
|
158 |
if ($action == "start"){
|
164 |
//exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service));
|
159 |
//exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service));
|
165 |
file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE))); // in order to keep that conf for SSH at next reboot
|
160 |
file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE))); // in order to keep that conf for SSH at next reboot
|
166 |
exec("sudo /usr/local/bin/alcasar-iptables.sh");
|
161 |
exec("sudo /usr/local/bin/alcasar-iptables.sh");
|
Line 189... |
Line 184... |
189 |
}
|
184 |
}
|
190 |
return $response;
|
185 |
return $response;
|
191 |
}
|
186 |
}
|
192 |
|
187 |
|
193 |
//-------------------------------
|
188 |
//-------------------------------
|
194 |
// Actions on services
|
- |
|
195 |
//-------------------------------
|
- |
|
196 |
$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");
|
- |
|
197 |
$autorizeAction = array("start","stop","restart");
|
- |
|
198 |
|
- |
|
199 |
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
|
- |
|
200 |
if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
|
- |
|
201 |
$execStatus = serviceExec($_GET['service'], $_GET['action']);
|
- |
|
202 |
// execStatus non exploité
|
- |
|
203 |
}
|
- |
|
204 |
}
|
- |
|
205 |
//-------------------------------
|
- |
|
206 |
// WIFI4EU
|
189 |
// WIFI4EU
|
207 |
//-------------------------------
|
190 |
//-------------------------------
|
208 |
if (isset($_POST['wifi4eu'])){
|
191 |
if (isset($_POST['wifi4eu'])){
|
- |
|
192 |
switch ($_POST['wifi4eu']){
|
- |
|
193 |
case 'on' :
|
209 |
//file_put_contents(CONF_FILE, preg_replace('/^WIFI4EU_CODE=*/', 'WIFI4EU_CODE='.$_POST['wifi4eu'], file_get_contents(CONF_FILE)));
|
194 |
file_put_contents(CONF_FILE, preg_replace('/WIFI4EU_CODE=.*/', 'WIFI4EU_CODE='.trim($_POST['wifi4eu_code']), file_get_contents(CONF_FILE)));
|
210 |
file_put_contents(CONF_FILE, preg_replace('/^WIFI4EU_CODE=.*/', 'WIFI4EU_CODE=REXY', file_get_contents(CONF_FILE)));
|
195 |
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
|
- |
|
196 |
break;
|
- |
|
197 |
case 'off' :
|
211 |
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
|
198 |
exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
|
- |
|
199 |
break;
|
- |
|
200 |
}
|
- |
|
201 |
header('Location: '.$_SERVER['PHP_SELF']);
|
212 |
}
|
202 |
}
|
- |
|
203 |
|
213 |
//-------------------------------
|
204 |
//-------------------------------
|
214 |
// Actions on system
|
205 |
// Stop/restart system
|
215 |
//-------------------------------
|
206 |
//-------------------------------
|
216 |
if (isset($_POST['choix'])){
|
207 |
if (isset($_POST['system'])){
|
217 |
switch ($_POST['choix']){
|
208 |
switch ($_POST['system']){
|
218 |
case 'reboot' :
|
209 |
case 'reboot' :
|
219 |
exec ("sudo /usr/local/bin/alcasar-logout.sh all");
|
210 |
exec ("sudo /usr/local/bin/alcasar-logout.sh all");
|
220 |
exec ("sudo /usr/sbin/shutdown -r now");
|
211 |
exec ("sudo /usr/sbin/shutdown -r now");
|
221 |
break;
|
212 |
break;
|
222 |
case 'halt' :
|
213 |
case 'halt' :
|
Line 225... |
Line 216... |
225 |
break;
|
216 |
break;
|
226 |
}
|
217 |
}
|
227 |
}
|
218 |
}
|
228 |
|
219 |
|
229 |
//-------------------------------
|
220 |
//-------------------------------
|
- |
|
221 |
// Actions on services
|
- |
|
222 |
//-------------------------------
|
- |
|
223 |
$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");
|
- |
|
224 |
$autorizeAction = array("start","stop","restart");
|
- |
|
225 |
|
- |
|
226 |
if (isset($_GET['service'])&&(in_array($_GET['service'], $autorizeService))) {
|
- |
|
227 |
if (isset($_GET['action'])&&(in_array($_GET['action'], $autorizeAction))) {
|
- |
|
228 |
$execStatus = serviceExec($_GET['service'], $_GET['action']);
|
- |
|
229 |
// execStatus non exploité
|
- |
|
230 |
}
|
- |
|
231 |
}
|
- |
|
232 |
|
- |
|
233 |
//-------------------------------
|
230 |
// Check services status
|
234 |
// Check services status
|
231 |
//-------------------------------
|
235 |
//-------------------------------
|
232 |
$MainServiceStatus = array();
|
236 |
$MainServiceStatus = array();
|
233 |
$MainServiceStatus['chilli'] = checkServiceStatus("chilli");
|
237 |
$MainServiceStatus['chilli'] = checkServiceStatus("chilli");
|
234 |
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd");
|
238 |
$MainServiceStatus['radiusd'] = checkServiceStatus("radiusd");
|
Line 325... |
Line 329... |
325 |
<tr>
|
329 |
<tr>
|
326 |
<?php if ($wifi4eu == "on") { ?>
|
330 |
<?php if ($wifi4eu == "on") { ?>
|
327 |
<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
331 |
<td align="center"><img src="/images/state_ok.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ok; ?>"></td>
|
328 |
<td align="center"><b>WIFI4EU</b></td><td><?php echo "network ID : $wifi4eu_code"; ?></td>
|
332 |
<td align="center"><b>WIFI4EU</b></td><td><?php echo "network ID : $wifi4eu_code"; ?></td>
|
329 |
<td width="80" align="center">---</td>
|
333 |
<td width="80" align="center">---</td>
|
330 |
<td width="80" align="center"><a href="<?php echo $_SERVER['PHP_SELF']."?action=stop&service=wifi4eu\"> $l_service_stop";?></a></td>
|
334 |
<td width="80" align="center"><input type=submit value="<?echo $l_service_stop;?>"><input type=hidden name="wifi4eu" value="off"></td>
|
331 |
<td width="80" align="center">---</td>
|
335 |
<td width="80" align="center">---</td>
|
332 |
<?php } else { ?>
|
336 |
<?php } else { ?>
|
333 |
<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko; ?>"></td>
|
337 |
<td align="center"><img src="/images/state_error.gif" width="15" height="15" alt="<?php echo $l_service_status_img_ko; ?>"></td>
|
334 |
<td align="center">WIFI4EU</td><td><?php echo $l_wifi4eu_id; ?> : <input type ="text" name="wifi4eu" value="<?php echo $wifi4eu_code; ?>" size="40"></td>
|
338 |
<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>
|
335 |
<td width="80" align="center"><input type=submit value="<?echo $l_service_start;?>"></td>
|
339 |
<td width="80" align="center"><input type=submit value="<?echo $l_service_start;?>"><input type=hidden name="wifi4eu" value="on"></td>
|
336 |
<td width="80" align="center">---</td>
|
340 |
<td width="80" align="center">---</td>
|
337 |
<td width="80" align="center">---</td>
|
341 |
<td width="80" align="center">---</td>
|
338 |
<?php } ?>
|
342 |
<?php } ?>
|
339 |
</tr>
|
343 |
</tr>
|
340 |
</table>
|
344 |
</table>
|
Line 345... |
Line 349... |
345 |
<div class="panel-header"><?= $l_stop_restart ?></div>
|
349 |
<div class="panel-header"><?= $l_stop_restart ?></div>
|
346 |
<div class="panel-row">
|
350 |
<div class="panel-row">
|
347 |
<table width="100%" border=0 cellspacing=0 cellpadding=1>
|
351 |
<table width="100%" border=0 cellspacing=0 cellpadding=1>
|
348 |
<tr><td valign="middle" align="left">
|
352 |
<tr><td valign="middle" align="left">
|
349 |
<form action="<?php echo $_SERVER['PHP_SELF']?>" method=POST>
|
353 |
<form action="<?php echo $_SERVER['PHP_SELF']?>" method=POST>
|
350 |
<select name='choix'>
|
354 |
<select name='system'>
|
351 |
<option selected value="reboot"><?echo "$l_reboot";?>
|
355 |
<option selected value="reboot"><?echo "$l_reboot";?>
|
352 |
<option value="halt"><?echo "$l_halt";?>
|
356 |
<option value="halt"><?echo "$l_halt";?>
|
353 |
</select>
|
357 |
</select>
|
354 |
<input type=submit value="<?echo "$l_execute";?>">
|
358 |
<input type=submit value="<?echo "$l_execute";?>">
|
355 |
</form>
|
359 |
</form>
|