Update var_edit.php

This commit is contained in:
FusionPBX 2018-03-25 10:26:50 -06:00 committed by GitHub
parent b481d0d7ba
commit 2287d39940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 52 additions and 20 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-2018
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -52,10 +52,11 @@
}
//set http values as php variables
if (count($_POST)>0) {
if (is_array($_POST)) {
$var_command = check_str($_POST["var_command"]);
$var_name = check_str($_POST["var_name"]);
$var_hostname = check_str($_POST["var_hostname"]);
$var_value = check_str($_POST["var_value"]);
$var_hostname = check_str($_POST["var_hostname"]);
$var_category = check_str($_POST["var_category"]);
if (strlen($_POST["var_cat_other"]) > 0) {
$var_cat = check_str($_POST["var_cat_other"]);
@ -67,7 +68,7 @@
}
//process the post
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (is_array($_POST) && strlen($_POST["persistformvar"]) == 0) {
//get the uuid
if ($action == "update") {
@ -76,6 +77,7 @@
//check for all required data
$msg = '';
//if (strlen($var_command) == 0) { $msg .= $text['message-required'].$text['label-command']."<br>\n"; }
if (strlen($var_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
//if (strlen($var_value) == 0) { $msg .= $text['message-required'].$text['label-value']."<br>\n"; }
//if (strlen($var_category) == 0) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
@ -102,9 +104,10 @@
$sql = "insert into v_vars ";
$sql .= "(";
$sql .= "var_uuid, ";
$sql .= "var_command, ";
$sql .= "var_name, ";
$sql .= "var_hostname, ";
$sql .= "var_value, ";
$sql .= "var_hostname, ";
$sql .= "var_category, ";
$sql .= "var_enabled, ";
$sql .= "var_order, ";
@ -113,14 +116,16 @@
$sql .= "values ";
$sql .= "(";
$sql .= "'$var_uuid', ";
$sql .= "'$var_command', ";
$sql .= "'$var_name', ";
$sql .= "'$var_value', ";
if (strlen($var_hostname) > 0) {
$sql .= "'$var_hostname', ";
}
else {
$sql .= "null, ";
}
$sql .= "'$var_value', ";
$sql .= "'$var_category', ";
$sql .= "'$var_enabled', ";
$sql .= "'$var_order', ";
@ -144,14 +149,15 @@
if ($action == "update" && permission_exists('var_edit')) {
//update the variables
$sql = "update v_vars set ";
$sql .= "var_command = '$var_command', ";
$sql .= "var_name = '$var_name', ";
$sql .= "var_value = '$var_value', ";
if (strlen($var_hostname) > 0) {
$sql .= "var_hostname = '$var_hostname', ";
}
else {
$sql .= "var_hostname = null, ";
}
$sql .= "var_value = '$var_value', ";
$sql .= "var_category = '$var_category', ";
$sql .= "var_enabled = '$var_enabled', ";
$sql .= "var_order = '$var_order', ";
@ -175,7 +181,7 @@
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$var_uuid = $_GET["id"];
$sql = "select * from v_vars ";
$sql .= "where var_uuid = '$var_uuid' ";
@ -183,9 +189,10 @@
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$var_command = $row["var_command"];
$var_name = $row["var_name"];
$var_hostname = $row["var_hostname"];
$var_value = $row["var_value"];
$var_hostname = $row["var_hostname"];
$var_category = $row["var_category"];
$var_enabled = $row["var_enabled"];
$var_order = $row["var_order"];
@ -221,7 +228,31 @@
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-command']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='var_command'>\n";
if ($var_enabled == "set") {
echo " <option value='set' selected='selected'>".$text['option-set']."</option>\n";
}
else {
echo " <option value='set'>".$text['option-set']."</option>\n";
}
if ($var_enabled == "exec-set") {
echo " <option value='exec-set' selected='selected'>".$text['option-exec-set']."</option>\n";
}
else {
echo " <option value='exec-set'>".$text['option-exec-set']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-command']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
@ -232,7 +263,7 @@
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-value']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
@ -254,7 +285,7 @@
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-category']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
@ -266,38 +297,38 @@
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='var_enabled'>\n";
if ($var_enabled == "true") {
echo " <option value='true' SELECTED >".$text['option-true']."</option>\n";
echo " <option value='true' selected='selected'>".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($var_enabled == "false") {
echo " <option value='false' SELECTED >".$text['option-false']."</option>\n";
echo " <option value='false' selected='selected'>".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "\n";
echo $text['description-enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-order']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='var_order' class='formfld'>\n";
$i=0;
while($i<=999) {
$selected = ($var_order == $i) ? "selected" : null;
$selected = ($var_order == $i) ? "selected='selected'" : null;
if (strlen($i) == 1) {
echo " <option value='00$i' ".$selected.">00$i</option>\n";
}
@ -311,17 +342,18 @@
}
echo " </select>\n";
echo " <br />\n";
echo $text['description-order']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <textarea class='formfld' name='var_description' rows='17'>$var_description</textarea>\n";
echo "<br />\n";
echo "\n";
echo $text['description-description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";