Commit 4918a819 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) $_GET should be $_POST, like in the rest of our code... last one, needs a bit of polishing

parent 8336e27b
...@@ -2785,32 +2785,45 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false) ...@@ -2785,32 +2785,45 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
function get_service_control_links($service, $addname = false) function get_service_control_links($service, $addname = false)
{ {
$stitle = $addname ? $service['name'] . ' ' : ''; $stitle = $addname ? $service['name'] . ' ' : '';
$output = ''; $output = "
<script type='text/javascript'>
$( document ).ready(function() {
$('.srv_status_act').click(function(event){
event.preventDefault();
params = {};
params['action'] = $(this).data('service_action');
params['service'] = $(this).data('service');
params['id'] = $(this).data('service_id');
$.post('/status_services.php',params, function(data) {
// refresh page after service action
location.reload();
});
});
});
</script>
";
if (get_service_status($service)) { if (get_service_status($service)) {
/* restart service button */
$output .= "<a href='status_services.php?action=restart&amp;service={$service['name']}";
if (isset($service['id'])) { if (isset($service['id'])) {
$output .= "&amp;id={$service['id']}"; $service_id = $service['id'];
} else {
$service_id = "";
} }
$output .= "' class=\"btn btn-default\">"; $output .= "<span data-service_id=\"{$service_id}\" data-service_action=\"restart\" data-service=\"{$service['name']}\"";
$output .= "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title='" . sprintf(gettext("Restart %sService"),$stitle) . "' class=\"glyphicon glyphicon-refresh\"></span></a>\n"; $output .= " data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"";
$output .= sprintf(gettext("Restart %sService"),$stitle) ;
$output .= "\" class=\"btn btn-default srv_status_act glyphicon glyphicon-refresh\"></span></i>\n";
/* stop service button */ $output .= "<span data-service_id=\"{$service_id}\" data-service_action=\"stop\" data-service=\"{$service['name']}\"";
$output .= "<a href='status_services.php?action=stop&amp;service={$service['name']}"; $output .= " data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"";
if (isset($service['id'])) { $output .= sprintf(gettext("Stop %sService"),$stitle) ;
$output .= "&amp;id={$service['id']}"; $output .= "\" class=\"btn btn-default srv_status_act glyphicon glyphicon-stop\"></span></i>\n";
}
$output .= "' class=\"btn btn-default\">";
$output .= "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title='" . sprintf(gettext("Stop %sService"),$stitle) . "' class=\"glyphicon glyphicon-stop\"></span></a>";
} else { } else {
/* start service button */ /* start service button */
$output .= "<a href='status_services.php?action=start&amp;service={$service['name']}"; $output .= "<span data-service_id=\"{$service_id}\" data-service_action=\"start\" data-service=\"{$service['name']}\"";
if (isset($service['id'])) { $output .= " data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"";
$output .= "&amp;id={$service['id']}"; $output .= sprintf(gettext("Start %sService"),$stitle) ;
} $output .= "\" class=\"btn btn-default srv_status_act glyphicon glyphicon-play\"></span></i>\n";
$output .= "' class=\"btn btn-default\">";
$output .= "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' class=\"glyphicon glyphicon-play\"/></a>\n";
} }
return $output; return $output;
......
...@@ -41,34 +41,27 @@ require_once("ipsec.inc"); ...@@ -41,34 +41,27 @@ require_once("ipsec.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("rrd.inc"); require_once("rrd.inc");
if (!empty($_GET['service'])) { if (!empty($_POST['service'])) {
$service_name = $_GET['service']; $service_name = $_POST['service'];
switch ($_GET['action']) { switch ($_POST['action']) {
case 'restart': case 'restart':
$savemsg = service_control_restart($service_name, $_GET); service_control_restart($service_name, $_POST);
break; break;
case 'start': case 'start':
$savemsg = service_control_start($service_name, $_GET); service_control_start($service_name, $_POST);
break; break;
case 'stop': case 'stop':
$savemsg = service_control_stop($service_name, $_GET); service_control_stop($service_name, $_POST);
break; break;
} }
if (isset($_SERVER['HTTP_REFERER'])) { exit;
$referer = $_SERVER['HTTP_REFERER'];
if (strpos($referer, $_SERVER['PHP_SELF']) === false) {
/* redirect only if launched from somewhere else */
header('Location: '. $referer);
exit;
}
}
} }
function service_control_start($name, $extras) function service_control_start($name, $extras)
{ {
$msg = sprintf(gettext('%s has been started.'), htmlspecialchars($name)); $msg = sprintf(gettext('%s has been started.'), htmlspecialchars($name));
if (isset($extras['id'])) { if (!empty($extras['id'])) {
$filter['id'] = $extras['id']; $filter['id'] = $extras['id'];
} }
...@@ -107,7 +100,7 @@ function service_control_stop($name, $extras) ...@@ -107,7 +100,7 @@ function service_control_stop($name, $extras)
$msg = sprintf(gettext("%s has been stopped."), htmlspecialchars($name)); $msg = sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
$filter = array(); $filter = array();
if (isset($extras['id'])) { if (!empty($extras['id'])) {
$filter['id'] = $extras['id']; $filter['id'] = $extras['id'];
} }
...@@ -142,7 +135,7 @@ function service_control_restart($name, $extras) ...@@ -142,7 +135,7 @@ function service_control_restart($name, $extras)
{ {
$msg = sprintf(gettext("%s has been restarted."), htmlspecialchars($name)); $msg = sprintf(gettext("%s has been restarted."), htmlspecialchars($name));
if (isset($extras['id'])) { if (!empty($extras['id'])) {
$filter['id'] = $extras['id']; $filter['id'] = $extras['id'];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment