diff --git a/resources/switch.php b/resources/switch.php index 4fd332b9f2..c0d30965b5 100644 --- a/resources/switch.php +++ b/resources/switch.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-2016 + Portions created by the Initial Developer are Copyright (C) 2008-2018 the Initial Developer. All Rights Reserved. Contributor(s): @@ -399,33 +399,33 @@ function save_var_xml() { //build the xml $sql = "select * from v_vars "; $sql .= "where var_enabled = 'true' "; - $sql .= "order by var_cat, var_order asc "; + $sql .= "order by var_category, var_order asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $prev_var_cat = ''; - $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $variables = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $prev_var_category = ''; $xml = ''; - foreach ($result as &$row) { + foreach ($variables as &$row) { if ($row['var_cat'] != 'Provision') { if ($prev_var_cat != $row['var_cat']) { - $xml .= "\n\n"; + $xml .= "\n\n"; if (strlen($row["var_description"]) > 0) { $xml .= "\n"; } } - - if ($row['var_cat'] == 'Exec-Set') { $var_cmd = 'exec-set'; } else { $var_cmd = 'set'; } + if (strlen($row['var_command']) == 0) { $row['var_command'] = 'set'; } + if ($row['var_category'] == 'Exec-Set') { $row['var_command'] = 'exec-set'; } if (strlen($row['var_hostname']) == 0) { - $xml .= "\n"; + $xml .= "\n"; } elseif ($row['var_hostname'] == $hostname) { - $xml .= "\n"; + $xml .= "\n"; } } - $prev_var_cat = $row['var_cat']; + $prev_var_category = $row['var_category']; } $xml .= "\n"; fwrite($fout, $xml); - unset($xml); + unset($prep_statement, $variables, $xml); fclose($fout); //apply settings