Portions created by the Initial Developer are Copyright (C) 2008-2018 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (permission_exists('var_view')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //toggle enabled state if (is_uuid($_REQUEST['id']) && (strtolower($_REQUEST['enabled']) == 'true' || strtolower($_REQUEST['enabled']) == 'false')) { //build array $array['vars'][0]['var_uuid'] = $_REQUEST['id']; $array['vars'][0]['var_enabled'] = strtolower($_REQUEST['enabled']); //grant temporary permissions $p = new permissions; $p->add('var_edit', 'temp'); //execute update $database = new database; $database->app_name = 'vars'; $database->app_uuid = '54e08402-c1b8-0a9d-a30a-f569fc174dd8'; $database->save($array); unset($array); //revoke temporary permissions $p->delete('var_edit', 'temp'); //unset the user defined variables $_SESSION["user_defined_variables"] = ""; //synchronize the configuration save_var_xml(); //set message message::add($text['message-update']); //redirect header("Location: vars.php?id=".$_REQUEST['id']); exit; } //include the header require_once "resources/header.php"; $document['title'] = $text['title-variables']; //set http values as php variables $order_by = $_GET["order_by"]; $order = $_GET["order"]; //show the content echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "
".$text['header-variables']."
\n"; echo " ".$text['description-variables']."\n"; echo "
\n"; $sql = "select * from v_vars "; $sql .= $order_by != '' ? order_by($order_by, $order) : "order by var_category, var_order asc "; $database = new database; $result = $database->select($sql, null, 'all'); unset($sql); $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; echo "\n"; $tmp_var_header = "\n"; $tmp_var_header .= th_order_by('var_name', $text['label-name'], $order_by, $order); $tmp_var_header .= th_order_by('var_value', $text['label-value'], $order_by, $order); $tmp_var_header .= th_order_by('var_hostname', $text['label-hostname'], $order_by, $order); $tmp_var_header .= th_order_by('var_enabled', $text['label-enabled'], $order_by, $order); $tmp_var_header .= "\n"; $tmp_var_header .= "\n"; $tmp_var_header .= "\n"; if (is_array($result) && @sizeof($result) != 0) { $prev_var_category = ''; foreach($result as $row) { $var_value = $row['var_value']; $var_value = substr($var_value, 0, 50); if ($prev_var_category != $row['var_category']) { $c=0; if (strlen($prev_var_category) > 0) { echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo $tmp_var_header; } $tr_link = (permission_exists('var_edit')) ? "href='var_edit.php?id=".$row['var_uuid']."'" : null; echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; $var_description = str_replace("\n", "
", trim(substr(base64_decode($row['var_description']),0,40))); $var_description = str_replace(" ", "       ", $var_description); echo " \n"; echo " \n"; echo "\n"; $prev_var_category = $row['var_category']; $c = $c ? 0 : 1; } } unset($result, $row); echo "\n"; echo "\n"; echo "\n"; echo "
".$text['label-description'].""; if (permission_exists('var_add')) { $tmp_var_header .= "$v_link_label_add"; } $tmp_var_header .= "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
  "; if (permission_exists('var_add')) { echo "$v_link_label_add"; } echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " ".$row['var_category']." 
"; if (permission_exists('var_edit')) { echo "".substr($row['var_name'],0,32).""; } else { echo substr($row['var_name'],0,32); } echo " ".substr($var_value,0,30)."".$row['var_hostname']." "; echo " ".(($row['var_enabled'] == 'true') ? $text['option-true'] : $text['option-false']).""; echo " ".$var_description." "; if (permission_exists('var_edit')) { echo "$v_link_label_edit"; } if (permission_exists('var_delete')) { echo "$v_link_label_delete"; } echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 $paging_controls"; if (permission_exists('var_add')) { echo "$v_link_label_add"; } echo "
\n"; echo "
"; echo "

"; //include the footer require_once "resources/footer.php"; ?>