Menu -> Status -> Services change 'pid file' to 'pid', and add 'file'.

This commit is contained in:
Mark Crane
2014-10-22 08:15:20 +00:00
parent 50dcfc3fae
commit 91b6e4e194
2 changed files with 48 additions and 25 deletions

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
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 "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='service_type'>\n";
echo " <option value=''></option>\n";
if ($service_type == "pid_file") {
echo " <option value='pid_file' SELECTED >pid file</option>\n";
if ($service_type == "pid" || $service_type == "pid_file") {
echo " <option value='pid' selected='selected'>pid</option>\n";
}
else {
echo " <option value='pid_file'>pid file</option>\n";
echo " <option value='pid'>pid</option>\n";
}
if ($service_type == "php") {
echo " <option value='php' SELECTED >php</option>\n";
//if ($service_type == "php") {
// echo " <option value='php' selected='selected'>php</option>\n";
//}
//else {
// echo " <option value='php'>php</option>\n";
//}
if ($service_type == "file") {
echo " <option value='file' selected='selected'>file</option>\n";
}
else {
echo " <option value='php'>php</option>\n";
echo " <option value='file'>file</option>\n";
}
echo " </select>\n";
echo "<br />\n";

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
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 "</td>\n";
echo "</tr>\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 "<tr ".$tr_link.">\n";
@@ -164,20 +160,41 @@ if (strlen($_GET["a"]) > 0) {
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>\n";
$pid = file_get_contents($row[service_data]);
if (is_process_running($pid)) {
echo "<strong>Running</strong>";
if ($row[service_type] == "pid" || $row[service_type] == "pid_file") {
$pid = file_get_contents($row[service_data]);
if (is_process_running($pid)) {
echo "<strong>Running</strong>";
}
else {
echo "<strong>Stopped</strong>";
}
}
else {
echo "<strong>Stopped</strong>";
if ($row[service_type] == "file") {
$service_data = $row[service_data];
if (file_exists($service_data)) {
echo "<strong>Running</strong>";
}
else {
echo "<strong>Stopped</strong>";
}
}
echo "</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>\n";
if (is_process_running($pid)) {
echo " <a href='services.php?id=".$row[service_uuid]."&a=stop' alt='stop'>Stop</a>";
if ($row[service_type] == "pid" || $row[service_type] == "pid_file") {
if (is_process_running($pid)) {
echo " <a href='services.php?id=".$row[service_uuid]."&a=stop' alt='stop'>Stop</a>";
}
else {
echo " <a href='services.php?id=".$row[service_uuid]."&a=start' alt='start'>Start</a>";
}
}
else {
echo " <a href='services.php?id=".$row[service_uuid]."&a=start' alt='start'>Start</a>";
if ($row[service_type] == "file") {
if (file_exists($service_data)) {
echo " <a href='services.php?id=".$row[service_uuid]."&a=stop' alt='stop'>Stop</a>";
}
else {
echo " <a href='services.php?id=".$row[service_uuid]."&a=start' alt='start'>Start</a>";
}
}
echo "</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row[service_description]."&nbsp;</td>\n";