From 91b6e4e194b4044b89007f17611162dbbedff21b Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Wed, 22 Oct 2014 08:15:20 +0000 Subject: [PATCH] Menu -> Status -> Services change 'pid file' to 'pid', and add 'file'. --- app/services/service_edit.php | 20 ++++++++----- app/services/services.php | 53 +++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 25 deletions(-) diff --git a/app/services/service_edit.php b/app/services/service_edit.php index 9a02ba04cd..c61d64efcf 100644 --- a/app/services/service_edit.php +++ b/app/services/service_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -212,17 +212,23 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo " \n"; echo "
\n"; diff --git a/app/services/services.php b/app/services/services.php index 2a4b747db4..429d322ab3 100644 --- a/app/services/services.php +++ b/app/services/services.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -43,11 +43,11 @@ else { require_once "resources/header.php"; require_once "resources/paging.php"; -$order_by = $_GET["order_by"]; -$order = $_GET["order"]; +$order_by = check_str($_GET["order_by"]); +$order = check_str($_GET["order"]); if (strlen($_GET["a"]) > 0) { - $service_uuid = $_GET["id"]; + $service_uuid = check_str($_GET["id"]); $sql = "select * from v_services "; $sql .= "where service_uuid = '$service_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); @@ -61,7 +61,6 @@ if (strlen($_GET["a"]) > 0) { $service_cmd_start = $row["service_cmd_start"]; $service_cmd_stop = $row["service_cmd_stop"]; $service_description = $row["service_description"]; - break; //limit to 1 row } unset ($prep_statement); @@ -148,10 +147,7 @@ if (strlen($_GET["a"]) > 0) { echo "\n"; echo "\n"; - if ($result_count == 0) { - //no results - } - else { //received results + if ($result_count > 0) { foreach($result as $row) { $tr_link = (permission_exists('service_edit')) ? "href='service_edit.php?id=".$row[service_uuid]."'" : null; echo "\n"; @@ -164,20 +160,41 @@ if (strlen($_GET["a"]) > 0) { } echo " \n"; echo " \n"; - $pid = file_get_contents($row[service_data]); - if (is_process_running($pid)) { - echo "Running"; + if ($row[service_type] == "pid" || $row[service_type] == "pid_file") { + $pid = file_get_contents($row[service_data]); + if (is_process_running($pid)) { + echo "Running"; + } + else { + echo "Stopped"; + } } - else { - echo "Stopped"; + if ($row[service_type] == "file") { + $service_data = $row[service_data]; + if (file_exists($service_data)) { + echo "Running"; + } + else { + echo "Stopped"; + } } echo "\n"; echo " \n"; - if (is_process_running($pid)) { - echo " Stop"; + if ($row[service_type] == "pid" || $row[service_type] == "pid_file") { + if (is_process_running($pid)) { + echo " Stop"; + } + else { + echo " Start"; + } } - else { - echo " Start"; + if ($row[service_type] == "file") { + if (file_exists($service_data)) { + echo " Stop"; + } + else { + echo " Start"; + } } echo "\n"; echo " ".$row[service_description]." \n";