diff --git a/user_admin.php b/user_admin.php index 6c1f02b90..509b63d1c 100644 --- a/user_admin.php +++ b/user_admin.php @@ -22,22 +22,22 @@ +-------------------------------------------------------------------------+ */ -include("./include/auth.php"); +include('./include/auth.php'); -define("MAX_DISPLAY_PAGES", 21); +define('MAX_DISPLAY_PAGES', 21); $user_actions = array( - 1 => "Delete", - 2 => "Copy", - 3 => "Enable", - 4 => "Disable", - 5 => "Batch Copy" + 1 => 'Delete', + 2 => 'Copy', + 3 => 'Enable', + 4 => 'Disable', + 5 => 'Batch Copy' ); if (isset($_POST['update_policy'])) { update_policies(); }else{ - switch (get_request_var_request("action")) { + switch (get_request_var_request('action')) { case 'actions': form_actions(); break; @@ -57,7 +57,7 @@ if (isset($_POST['update_policy'])) { break; default: - if (!api_plugin_hook_function('user_admin_action', get_request_var_request("action"))) { + if (!api_plugin_hook_function('user_admin_action', get_request_var_request('action'))) { top_header(); user(); bottom_footer(); @@ -73,16 +73,16 @@ if (isset($_POST['update_policy'])) { function update_policies() { $set = ''; - $set .= isset($_POST["policy_graphs"]) ? "policy_graphs=" . get_request_var_post("policy_graphs"):""; - $set .= isset($_POST["policy_trees"]) ? (strlen($set) ? ",":"") . "policy_trees=" . get_request_var_post("policy_trees"):""; - $set .= isset($_POST["policy_hosts"]) ? (strlen($set) ? ",":"") . "policy_hosts=" . get_request_var_post("policy_hosts"):""; - $set .= isset($_POST["policy_graph_templates"]) ? (strlen($set) ? ",":"") . "policy_graph_templates=" . get_request_var_post("policy_graph_templates"):""; + $set .= isset($_POST['policy_graphs']) ? 'policy_graphs=' . get_request_var_post('policy_graphs'):''; + $set .= isset($_POST['policy_trees']) ? (strlen($set) ? ',':'') . 'policy_trees=' . get_request_var_post('policy_trees'):''; + $set .= isset($_POST['policy_hosts']) ? (strlen($set) ? ',':'') . 'policy_hosts=' . get_request_var_post('policy_hosts'):''; + $set .= isset($_POST['policy_graph_templates']) ? (strlen($set) ? ',':'') . 'policy_graph_templates=' . get_request_var_post('policy_graph_templates'):''; if (strlen($set)) { - db_execute("UPDATE user_auth SET $set WHERE id = " . get_request_var_post("id")); + db_execute_prepared("UPDATE user_auth SET $set WHERE id = ?", array(get_request_var_post('id'))); } - header("Location: user_admin.php?action=user_edit&tab=" . get_request_var_post("tab") . "&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=' . get_request_var_post('tab') . '&id=' . get_request_var_post('id')); exit; } @@ -90,97 +90,97 @@ function form_actions() { global $user_actions, $auth_realms; /* if we are to save this form, instead of display it */ - if (isset($_POST["associate_host"])) { + if (isset($_POST['associate_host'])) { while (list($var,$val) = each($_POST)) { - if (ereg("^chk_([0-9]+)$", $var, $matches)) { + if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ - if (get_request_var_post("drp_action") == "1") { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . $matches[1] . ",3)"); + if (get_request_var_post('drp_action') == '1') { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 3)', array(get_request_var_post('id'), $matches[1])); }else{ - db_execute("DELETE FROM user_auth_perms WHERE user_id=" . get_request_var_post("id") . " AND item_id=" . $matches[1] . " AND type=3"); + db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 3', array(get_request_var_post('id'), $matches[1])); } } } - header("Location: user_admin.php?action=user_edit&tab=permsd&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_post('id')); exit; - }elseif (isset($_POST["associate_graph"])) { + }elseif (isset($_POST['associate_graph'])) { while (list($var,$val) = each($_POST)) { - if (ereg("^chk_([0-9]+)$", $var, $matches)) { + if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ - if (get_request_var_post("drp_action") == "1") { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . $matches[1] . ",1)"); + if (get_request_var_post('drp_action') == '1') { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 1)', array(get_request_var_post('id'), $matches[1])); }else{ - db_execute("DELETE FROM user_auth_perms WHERE user_id=" . get_request_var_post("id") . " AND item_id=" . $matches[1] . " AND type=1"); + db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 1', array(get_request_var_post('id'), $matches[1])); } } } - header("Location: user_admin.php?action=user_edit&tab=permsg&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=permsg&id=' . get_request_var_post('id')); exit; - }elseif (isset($_POST["associate_template"])) { + }elseif (isset($_POST['associate_template'])) { while (list($var,$val) = each($_POST)) { - if (ereg("^chk_([0-9]+)$", $var, $matches)) { + if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ - if (get_request_var_post("drp_action") == "1") { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . $matches[1] . ",4)"); + if (get_request_var_post('drp_action') == '1') { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 4)', array(get_request_var_post('id'), $matches[1])); }else{ - db_execute("DELETE FROM user_auth_perms WHERE user_id=" . get_request_var_post("id") . " AND item_id=" . $matches[1] . " AND type=4"); + db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 4', array(get_request_var_post('id'), $matches[1])); } } } - header("Location: user_admin.php?action=user_edit&tab=permste&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=permste&id=' . get_request_var_post('id')); exit; - }elseif (isset($_POST["associate_groups"])) { + }elseif (isset($_POST['associate_groups'])) { while (list($var,$val) = each($_POST)) { - if (ereg("^chk_([0-9]+)$", $var, $matches)) { + if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ - if (get_request_var_post("drp_action") == "1") { - db_execute("REPLACE INTO user_auth_group_members (user_id, group_id) VALUES (" . get_request_var_post("id") . "," . $matches[1] . ")"); + if (get_request_var_post('drp_action') == '1') { + db_execute_prepared('REPLACE INTO user_auth_group_members (user_id, group_id) VALUES (?, ?)', array(get_request_var_post('id'), $matches[1])); }else{ - db_execute("DELETE FROM user_auth_group_members WHERE user_id=" . get_request_var_post("id") . " AND group_id=" . $matches[1]); + db_execute_prepared('DELETE FROM user_auth_group_members WHERE user_id = ? AND group_id = ?', array(get_request_var_post('id'), $matches[1])); } } } - header("Location: user_admin.php?action=user_edit&tab=permsgr&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=permsgr&id=' . get_request_var_post('id')); exit; - }elseif (isset($_POST["associate_tree"])) { + }elseif (isset($_POST['associate_tree'])) { while (list($var,$val) = each($_POST)) { - if (ereg("^chk_([0-9]+)$", $var, $matches)) { + if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ - if (get_request_var_post("drp_action") == "1") { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . $matches[1] . ",2)"); + if (get_request_var_post('drp_action') == '1') { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 2)', array(get_request_var_post('id'), $matches[1]));; }else{ - db_execute("DELETE FROM user_auth_perms WHERE user_id=" . get_request_var_post("id") . " AND item_id=" . $matches[1] . " AND type=2"); + db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 2', array(get_request_var_post('id'), $matches[1]));; } } } - header("Location: user_admin.php?action=user_edit&tab=permstr&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=permstr&id=' . get_request_var_post('id')); exit; - }elseif (isset($_POST["selected_items"])) { - if (get_request_var_post("drp_action") != "2") { - $selected_items = unserialize(stripslashes(get_request_var_post("selected_items"))); + }elseif (isset($_POST['selected_items'])) { + if (get_request_var_post('drp_action') != '2') { + $selected_items = unserialize(stripslashes(get_request_var_post('selected_items'))); } - if (get_request_var_post("drp_action") == "1") { /* delete */ + if (get_request_var_post('drp_action') == '1') { /* delete */ for ($i=0;($i get_request_var_post("new_fullname") ); + $new_username = get_request_var_post('new_username'); + $new_realm = get_request_var_post('new_realm', 0); + $template_user = db_fetch_row_prepared('SELECT username, realm FROM user_auth WHERE id = ?', array(get_request_var_post('selected_items'))); + $overwrite = array( 'full_name' => get_request_var_post('new_fullname') ); if (strlen($new_username)) { - if (sizeof(db_fetch_assoc("SELECT username FROM user_auth WHERE username='" . $new_username . "' AND realm=" . $new_realm))) { + if (sizeof(db_fetch_assoc_prepared('SELECT username FROM user_auth WHERE username = ? AND realm = ?', array($new_username, $new_realm)))) { raise_message(19); } else { - if (user_copy($template_user["username"], $new_username, $template_user["realm"], $new_realm, false, $overwrite) === false) { + if (user_copy($template_user['username'], $new_username, $template_user['realm'], $new_realm, false, $overwrite) === false) { raise_message(2); } else { raise_message(1); @@ -216,7 +216,7 @@ function form_actions() { } } - if (get_request_var_post("drp_action") == "3") { /* enable */ + if (get_request_var_post('drp_action') == '3') { /* enable */ for ($i=0;($i"; + if (get_request_var_post('drp_action') != '2') { + $user_list .= '
  • ' . db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($matches[1])) . '
  • '; } $user_array[$i] = $matches[1]; @@ -286,23 +286,23 @@ function form_actions() { } /* Check for deleting of Graph Export User */ - if ((get_request_var_post("drp_action") == "1") && isset($user_array) && sizeof($user_array)) { /* delete */ + if ((get_request_var_post('drp_action') == '1') && isset($user_array) && sizeof($user_array)) { /* delete */ $exportuser = read_config_option('export_user_id'); if (in_array($exportuser, $user_array)) { raise_message(22); - header("Location: user_admin.php"); + header('Location: user_admin.php'); exit; } } top_header(); - html_start_box("" . $user_actions[get_request_var_post("drp_action")] . "", "40%", "", "3", "center", ""); + html_start_box('' . $user_actions[get_request_var_post('drp_action')] . '', '40%', '', '3', 'center', ''); print "
    \n"; if (isset($user_array) && sizeof($user_array)) { - if ((get_request_var_post("drp_action") == "1") && (sizeof($user_array))) { /* delete */ + if ((get_request_var_post('drp_action') == '1') && (sizeof($user_array))) { /* delete */ print " @@ -312,11 +312,11 @@ function form_actions() { \n"; $save_html = " "; } - $user_id = ""; + $user_id = ''; - if ((get_request_var_post("drp_action") == "2") && (sizeof($user_array))) { /* copy */ + if ((get_request_var_post('drp_action') == '2') && (sizeof($user_array))) { /* copy */ $user_id = $user_array[0]; - $user_realm = db_fetch_cell("SELECT realm FROM user_auth WHERE id = " . $user_id); + $user_realm = db_fetch_cell_prepared('SELECT realm FROM user_auth WHERE id = ?', array($user_id)); print " @@ -326,25 +326,25 @@ function form_actions() { - Template Username: " . db_fetch_cell("SELECT username FROM user_auth WHERE id=" . $user_id) . " + Template Username: " . db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($user_id)) . " Username: "; - print form_text_box("new_username", "", "", 25); + print form_text_box('new_username', '', '', 25); print " Full Name: "; - print form_text_box("new_fullname", "", "", 35); + print form_text_box('new_fullname', '', '', 35); print " Realm: \n"; - print form_dropdown("new_realm", $auth_realms, "", "", $user_realm, "", 0); + print form_dropdown('new_realm', $auth_realms, '', '', $user_realm, '', 0); print " \n"; @@ -352,7 +352,7 @@ function form_actions() { $save_html = " "; } - if ((get_request_var_post("drp_action") == "3") && (sizeof($user_array))) { /* enable */ + if ((get_request_var_post('drp_action') == '3') && (sizeof($user_array))) { /* enable */ print " @@ -364,7 +364,7 @@ function form_actions() { $save_html = " "; } - if ((get_request_var_post("drp_action") == "4") && (sizeof($user_array))) { /* disable */ + if ((get_request_var_post('drp_action') == '4') && (sizeof($user_array))) { /* disable */ print " @@ -376,8 +376,8 @@ function form_actions() { $save_html = " "; } - if ((get_request_var_post("drp_action") == "5") && (sizeof($user_array))) { /* batch copy */ - $usernames = db_fetch_assoc('SELECT id,username FROM user_auth WHERE realm = 0 ORDER BY username'); + if ((get_request_var_post('drp_action') == '5') && (sizeof($user_array))) { /* batch copy */ + $usernames = db_fetch_assoc('SELECT id, username FROM user_auth WHERE realm = 0 ORDER BY username'); print " @@ -385,7 +385,7 @@ function form_actions() { Template User: \n"; - print form_dropdown("template_user", $usernames, "username", "id", "", "", 0); + print form_dropdown('template_user', $usernames, 'username', 'id', '', '', 0); print " @@ -405,13 +405,13 @@ function form_actions() { print " "; - if (get_request_var_post("drp_action") == "2") { /* copy */ + if (get_request_var_post('drp_action') == '2') { /* copy */ print " \n"; }else{ print " \n"; } - print " + print " $save_html @@ -430,64 +430,64 @@ function form_save() { global $settings_graphs; /* graph permissions */ - if ((isset($_POST["save_component_graph_perms"])) && (!is_error_message())) { + if ((isset($_POST['save_component_graph_perms'])) && (!is_error_message())) { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_post("id")); - input_validate_input_number(get_request_var_post("perm_graphs")); - input_validate_input_number(get_request_var_post("perm_trees")); - input_validate_input_number(get_request_var_post("perm_hosts")); - input_validate_input_number(get_request_var_post("perm_graph_templates")); - input_validate_input_number(get_request_var_post("policy_graphs")); - input_validate_input_number(get_request_var_post("policy_trees")); - input_validate_input_number(get_request_var_post("policy_hosts")); - input_validate_input_number(get_request_var_post("policy_graph_templates")); + input_validate_input_number(get_request_var_post('id')); + input_validate_input_number(get_request_var_post('perm_graphs')); + input_validate_input_number(get_request_var_post('perm_trees')); + input_validate_input_number(get_request_var_post('perm_hosts')); + input_validate_input_number(get_request_var_post('perm_graph_templates')); + input_validate_input_number(get_request_var_post('policy_graphs')); + input_validate_input_number(get_request_var_post('policy_trees')); + input_validate_input_number(get_request_var_post('policy_hosts')); + input_validate_input_number(get_request_var_post('policy_graph_templates')); /* ==================================================== */ $add_button_clicked = false; - if (isset($_POST["add_graph_x"])) { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_graphs") . ",1)"); + if (isset($_POST['add_graph_x'])) { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (?, ?, 1)', array(get_request_var_post('id'), get_request_var_post('perm_graphs'))); $add_button_clicked = true; - }elseif (isset($_POST["add_tree_x"])) { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_trees") . ",2)"); + }elseif (isset($_POST['add_tree_x'])) { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (?, ?, 2)', array(get_request_var_post('id'), get_request_var_post('perm_trees'))); $add_button_clicked = true; - }elseif (isset($_POST["add_host_x"])) { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_hosts") . ",3)"); + }elseif (isset($_POST['add_host_x'])) { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (?, ?, 3)', array(get_request_var_post('id'), get_request_var_post('perm_hosts'))); $add_button_clicked = true; - }elseif (isset($_POST["add_graph_template_x"])) { - db_execute("REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (" . get_request_var_post("id") . "," . get_request_var_post("perm_graph_templates") . ",4)"); + }elseif (isset($_POST['add_graph_template_x'])) { + db_execute_prepared('REPLACE INTO user_auth_perms (user_id,item_id,type) VALUES (?, ?, 4)', array(get_request_var_post('id'), get_request_var_post('perm_graph_templates'))); $add_button_clicked = true; } if ($add_button_clicked == true) { - header("Location: user_admin.php?action=user_edit&tab=graph_perms_edit&id=" . get_request_var_post("id")); + header('Location: user_admin.php?action=user_edit&tab=graph_perms_edit&id=' . get_request_var_post('id')); exit; } } /* user management save */ - if (isset($_POST["save_component_user"])) { + if (isset($_POST['save_component_user'])) { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_post("id")); - input_validate_input_number(get_request_var_post("realm")); + input_validate_input_number(get_request_var_post('id')); + input_validate_input_number(get_request_var_post('realm')); /* ==================================================== */ - if ((get_request_var_post("password") == "") && (get_request_var_post("password_confirm") == "")) { - $password = db_fetch_cell("SELECT password FROM user_auth WHERE id = " . get_request_var_post("id")); + if ((get_request_var_post('password') == '') && (get_request_var_post('password_confirm') == '')) { + $password = db_fetch_cell_prepared('SELECT password FROM user_auth WHERE id = ?', array(get_request_var_post('id'))); }else{ - $password = md5(get_request_var_post("password")); + $password = md5(get_request_var_post('password')); } /* check duplicate username */ - if (sizeof(db_fetch_row("SELECT * FROM user_auth WHERE realm=" . get_request_var_post("realm") . " AND username='" . get_request_var_post("username") . "' AND id != " . get_request_var_post("id")))) { + if (sizeof(db_fetch_row_prepared('SELECT * FROM user_auth WHERE realm = ? AND username = ? AND id != ?', array(get_request_var_post('realm'), get_request_var_post('username'), get_request_var_post('id'))))) { raise_message(12); } /* check for guest or template user */ - $username = db_fetch_cell("SELECT username FROM user_auth WHERE id=" . get_request_var_post("id")); - if ($username != '' && $username != get_request_var_post("username")) { - $template_user = read_config_option("user_template"); - $guest_user = read_config_option("guest_user"); + $username = db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array(get_request_var_post('id'))); + if ($username != '' && $username != get_request_var_post('username')) { + $template_user = read_config_option('user_template'); + $guest_user = read_config_option('guest_user'); if ($username == $template_user) { raise_message(20); @@ -499,29 +499,29 @@ function form_save() { } /* check to make sure the passwords match; if not error */ - if (get_request_var_post("password") != get_request_var_post("password_confirm")) { + if (get_request_var_post('password') != get_request_var_post('password_confirm')) { raise_message(4); } - form_input_validate(get_request_var_post("password"), "password", "" . preg_quote(get_request_var_post("password_confirm")) . "", true, 4); - form_input_validate(get_request_var_post("password_confirm"), "password_confirm", "" . preg_quote(get_request_var_post("password")) . "", true, 4); + form_input_validate(get_request_var_post('password'), 'password', '' . preg_quote(get_request_var_post('password_confirm')) . '', true, 4); + form_input_validate(get_request_var_post('password_confirm'), 'password_confirm', '' . preg_quote(get_request_var_post('password')) . '', true, 4); - $save["id"] = get_request_var_post("id"); - $save["username"] = form_input_validate(get_request_var_post("username"), "username", "^[A-Za-z0-9\._\\\@\ -]+$", false, 3); - $save["full_name"] = form_input_validate(get_request_var_post("full_name"), "full_name", "", true, 3); - $save["password"] = $password; - $save["must_change_password"] = form_input_validate(get_request_var_post("must_change_password", ""), "must_change_password", "", true, 3); - $save["show_tree"] = form_input_validate(get_request_var_post("show_tree", ""), "show_tree", "", true, 3); - $save["show_list"] = form_input_validate(get_request_var_post("show_list", ""), "show_list", "", true, 3); - $save["show_preview"] = form_input_validate(get_request_var_post("show_preview", ""), "show_preview", "", true, 3); - $save["graph_settings"] = form_input_validate(get_request_var_post("graph_settings", ""), "graph_settings", "", true, 3); - $save["login_opts"] = form_input_validate(get_request_var_post("login_opts"), "login_opts", "", true, 3); - $save["realm"] = get_request_var_post("realm", 0); - $save["enabled"] = form_input_validate(get_request_var_post("enabled", ""), "enabled", "", true, 3); + $save['id'] = get_request_var_post('id'); + $save['username'] = form_input_validate(get_request_var_post('username'), 'username', "^[A-Za-z0-9\._\\\@\ -]+$", false, 3); + $save['full_name'] = form_input_validate(get_request_var_post('full_name'), 'full_name', '', true, 3); + $save['password'] = $password; + $save['must_change_password'] = form_input_validate(get_request_var_post('must_change_password', ''), 'must_change_password', '', true, 3); + $save['show_tree'] = form_input_validate(get_request_var_post('show_tree', ''), 'show_tree', '', true, 3); + $save['show_list'] = form_input_validate(get_request_var_post('show_list', ''), 'show_list', '', true, 3); + $save['show_preview'] = form_input_validate(get_request_var_post('show_preview', ''), 'show_preview', '', true, 3); + $save['graph_settings'] = form_input_validate(get_request_var_post('graph_settings', ''), 'graph_settings', '', true, 3); + $save['login_opts'] = form_input_validate(get_request_var_post('login_opts'), 'login_opts', '', true, 3); + $save['realm'] = get_request_var_post('realm', 0); + $save['enabled'] = form_input_validate(get_request_var_post('enabled', ''), 'enabled', '', true, 3); $save = api_plugin_hook_function('user_admin_setup_sql_save', $save); if (!is_error_message()) { - $user_id = sql_save($save, "user_auth"); + $user_id = sql_save($save, 'user_auth'); if ($user_id) { raise_message(1); @@ -529,48 +529,44 @@ function form_save() { raise_message(2); } } - }elseif (isset($_POST["save_component_realm_perms"])) { - db_execute("DELETE FROM user_auth_realm WHERE user_id = " . get_request_var_post("id")); + }elseif (isset($_POST['save_component_realm_perms'])) { + db_execute_prepared('DELETE FROM user_auth_realm WHERE user_id = ?', array(get_request_var_post('id'))); while (list($var, $val) = each($_POST)) { - if (preg_match("/^[section]/i", $var)) { - if (substr($var, 0, 7) == "section") { - db_execute("REPLACE INTO user_auth_realm (user_id,realm_id) VALUES (" . get_request_var_post("id") . "," . substr($var, 7) . ")"); + if (preg_match('/^[section]/i', $var)) { + if (substr($var, 0, 7) == 'section') { + db_execute_prepared('REPLACE INTO user_auth_realm (user_id, realm_id) VALUES (?, ?)', array(get_request_var_post('id'), substr($var, 7))); } } } raise_message(1); - }elseif (isset($_POST["save_component_graph_settings"])) { + }elseif (isset($_POST['save_component_graph_settings'])) { while (list($tab_short_name, $tab_fields) = each($settings_graphs)) { while (list($field_name, $field_array) = each($tab_fields)) { - if ((isset($field_array["items"])) && (is_array($field_array["items"]))) { - while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) { - db_execute("REPLACE INTO settings_graphs (user_id,name,value) VALUES (" . (!empty($user_id) ? $user_id : get_request_var_post("id")) . ",'$sub_field_name', '" . get_request_var_post($sub_field_name, "") . "')"); + if ((isset($field_array['items'])) && (is_array($field_array['items']))) { + while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) { + db_execute_prepared('REPLACE INTO settings_graphs (user_id, name, value) VALUES (?, ?, ?)', array((!empty($user_id) ? $user_id : get_request_var_post('id')), $sub_field_name, get_request_var_post($sub_field_name, ''))); } }else{ - db_execute("REPLACE INTO settings_graphs (user_id,name,value) VALUES (" . (!empty($user_id) ? $user_id : $_POST["id"]) . ",'$field_name', '" . get_request_var_post($field_name) . "')"); + db_execute_prepared('REPLACE INTO settings_graphs (user_id, name, value) VALUES (?, ?, ?)', array((!empty($user_id) ? $user_id : $_POST['id']), $field_name, get_request_var_post($field_name))); } } } /* reset local settings cache so the user sees the new settings */ - kill_session_var("sess_graph_config_array"); + kill_session_var('sess_graph_config_array'); raise_message(1); - }elseif (isset($_POST["save_component_graph_perms"])) { - db_execute("UPDATE user_auth SET - policy_graphs = " . get_request_var_post("policy_graphs") . ", - policy_trees = " . get_request_var_post("policy_trees") . ", - policy_hosts = " . get_request_var_post("policy_hosts") . ", - policy_graph_templates = " . get_request_var_post("policy_graph_templates") . " - WHERE id = " . get_request_var_post("id")); + }elseif (isset($_POST['save_component_graph_perms'])) { + db_execute_prepared('UPDATE user_auth SET policy_graphs = ?, policy_trees = ?, policy_hosts = ?, policy_graph_templates = ? WHERE id = ?', + array(get_request_var_post('policy_graphs'), get_request_var_post('policy_trees'), get_request_var_post('policy_hosts'), get_request_var_post('policy_graph_templates'), get_request_var_post('id'))); } else { api_plugin_hook('user_admin_user_save'); } /* redirect to the appropriate page */ - header("Location: user_admin.php?action=user_edit&id=" . (empty($user_id) ? $_POST["id"] : $user_id)); + header('Location: user_admin.php?action=user_edit&id=' . (empty($user_id) ? $_POST['id'] : $user_id)); } /* -------------------------- @@ -579,28 +575,28 @@ function form_save() { function perm_remove() { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("id")); - input_validate_input_number(get_request_var_request("user_id")); + input_validate_input_number(get_request_var_request('id')); + input_validate_input_number(get_request_var_request('user_id')); /* ==================================================== */ - if (get_request_var_request("type") == "graph") { - db_execute("DELETE FROM user_auth_perms WHERE type = 1 AND user_id = " . get_request_var_request("user_id") . " AND item_id = " . get_request_var_request("id")); - }elseif (get_request_var_request("type") == "tree") { - db_execute("DELETE FROM user_auth_perms WHERE type = 2 AND user_id = " . get_request_var_request("user_id") . " AND item_id = " . get_request_var_request("id")); - }elseif (get_request_var_request("type") == "host") { - db_execute("DELETE FROM user_auth_perms WHERE type = 3 AND user_id = " . get_request_var_request("user_id") . " AND item_id = " . get_request_var_request("id")); - }elseif (get_request_var_request("type") == "graph_template") { - db_execute("DELETE FROM user_auth_perms WHERE type = 4 AND user_id=" . get_request_var_request("user_id") . " and item_id = " . get_request_var_request("id")); + if (get_request_var_request('type') == 'graph') { + db_execute_prepared('DELETE FROM user_auth_perms WHERE type = 1 AND user_id = ? AND item_id = ?', array(get_request_var_request('user_id'), get_request_var_request('id'))); + }elseif (get_request_var_request('type') == 'tree') { + db_execute_prepared('DELETE FROM user_auth_perms WHERE type = 2 AND user_id = ? AND item_id = ?', array(get_request_var_request('user_id'), get_request_var_request('id'))); + }elseif (get_request_var_request('type') == 'host') { + db_execute_prepared('DELETE FROM user_auth_perms WHERE type = 3 AND user_id = ? AND item_id = ?', array(get_request_var_request('user_id'), get_request_var_request('id'))); + }elseif (get_request_var_request('type') == 'graph_template') { + db_execute_prepared('DELETE FROM user_auth_perms WHERE type = 4 AND user_id = ? AND item_id = ?', array(get_request_var_request('user_id'), get_request_var_request('id'))); } - header("Location: user_admin.php?action=user_edit&tab=graph_perms_edit&id=" . get_request_var_request("user_id")); + header('Location: user_admin.php?action=user_edit&tab=graph_perms_edit&id=' . get_request_var_request('user_id')); } function get_permission_string(&$graph, &$policies) { $grantStr = ''; $rejectStr = ''; - if (read_config_option("graph_auth_method") == 1) { + if (read_config_option('graph_auth_method') == 1) { $method = 'loose'; }else{ $method = 'strong'; @@ -610,16 +606,16 @@ function get_permission_string(&$graph, &$policies) { foreach($policies as $p) { if ($p['policy_graphs'] == 1) { if ($graph["user$i"] == '') { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }else{ - $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); } }elseif ($graph["user$i"] != '') { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }elseif ($method == 'loose') { $reject++; }else{ - $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Graph:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); } $i++; @@ -628,16 +624,16 @@ function get_permission_string(&$graph, &$policies) { if ($p['policy_hosts'] == 1) { if ($graph["user$i"] == '') { if ($method == 'loose') { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Host:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Host:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }else{ $allowed++; } }else{ - $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Host:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Host:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); } }elseif ($graph["user$i"] != '') { if ($method == 'loose') { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Host:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Host:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }else{ $allowed++; } @@ -650,16 +646,16 @@ function get_permission_string(&$graph, &$policies) { if ($p['policy_graph_templates'] == 1) { if ($graph["user$i"] == '') { if ($method == 'loose') { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }else{ $allowed++; } }else{ - $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); } }elseif ($graph["user$i"] != '') { if ($method == 'loose') { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }else{ $allowed++; } @@ -670,25 +666,25 @@ function get_permission_string(&$graph, &$policies) { if ($method != 'loose') { if ($allowed == 2) { - $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Host+Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $grantStr = $grantStr . (strlen($grantStr) ? ', ':'') . 'Host+Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); }else{ - $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Host+Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Host+Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); } }elseif ($reject == 3) { - $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Graph+Host+Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? "/" . $p['name'] . ')':')'); + $rejectStr = $rejectStr . (strlen($rejectStr) ? ', ':'') . 'Graph+Host+Template:(' . ucfirst($p['type']) . ($p['type'] != 'user' ? '/' . $p['name'] . ')':')'); } } $permStr = ''; if (strlen($grantStr)) { - $permStr = "Granted: " . trim($grantStr,',') . ""; + $permStr = "Granted: " . trim($grantStr,',') . ''; } if (strlen($rejectStr)) { if ($grantStr == '') { - $permStr = "Restricted: " . trim($rejectStr,',') . ""; + $permStr = "Restricted: " . trim($rejectStr,',') . ''; }else{ - $permStr .= ", " . trim($rejectStr,',') . ""; + $permStr .= ", " . trim($rejectStr,',') . ''; } } @@ -697,7 +693,7 @@ function get_permission_string(&$graph, &$policies) { function graph_perms_edit($tab, $header_label) { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("id")); + input_validate_input_number(get_request_var_request('id')); /* ==================================================== */ $sql_where = ''; @@ -706,13 +702,13 @@ function graph_perms_edit($tab, $header_label) { $sql_having = ''; $policy_array = array( - 1 => "Allow", - 2 => "Deny"); + 1 => 'Allow', + 2 => 'Deny'); - if (!empty($_REQUEST["id"])) { - $policy = db_fetch_row("SELECT policy_graphs,policy_trees,policy_hosts,policy_graph_templates + if (!empty($_REQUEST['id'])) { + $policy = db_fetch_row_prepared('SELECT policy_graphs, policy_trees, policy_hosts, policy_graph_templates FROM user_auth - WHERE id=" . get_request_var_request("id")); + WHERE id = ?', array(get_request_var_request('id'))); } else { $policy = array( 'policy_graphs' => '1', @@ -732,19 +728,19 @@ function graph_perms_edit($tab, $header_label) { print "\n"; /* box: device permissions */ - html_start_box("Default Graph Policy", "100%", "", "3", "center", ""); + html_start_box('Default Graph Policy', '100%', '', '3', 'center', ''); ?>
    Default Graph Policy for this User - + - "> +
    @@ -755,45 +751,43 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* if the number of rows is -1, set it to the default */ - if ($_REQUEST["rows"] == -1) { - $rows = read_config_option("num_rows_table"); + if ($_REQUEST['rows'] == -1) { + $rows = read_config_option('num_rows_table'); }else{ - $rows = $_REQUEST["rows"]; + $rows = $_REQUEST['rows']; } /* print checkbox form for validation */ - print "
    \n"; + print "\n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); $user = $_SESSION['sess_user_id']; - if (read_config_option("graph_auth_method") == 1) { - $sql_operator = "OR"; + if (read_config_option('graph_auth_method') == 1) { + $sql_operator = 'OR'; }else{ - $sql_operator = "AND"; + $sql_operator = 'AND'; } - $limit = "LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows; + $limit = 'LIMIT ' . ($rows*(get_request_var_request('page')-1)) . ',' . $rows; /* get policies for all groups and user */ - $policies = db_fetch_assoc("SELECT uag.id, 'group' AS type, uag.name, + $policies = db_fetch_assoc_prepared("SELECT uag.id, 'group' AS type, uag.name, policy_graphs, policy_hosts, policy_graph_templates FROM user_auth_group AS uag INNER JOIN user_auth_group_members AS uagm - ON uag.id=uagm.group_id - WHERE uag.enabled='on' AND uagm.user_id=$user"); - $policies[] = db_fetch_row("SELECT id, 'user' AS type, 'user' AS name, + ON uag.id = uagm.group_id + WHERE uag.enabled = 'on' AND uagm.user_id = ?", array($user)); + $policies[] = db_fetch_row_prepared("SELECT id, 'user' AS type, 'user' AS name, policy_graphs, policy_hosts, policy_graph_templates - FROM user_auth WHERE id=$user"); - - //print "
    ";print_r($policies);print "
    ";exit; + FROM user_auth WHERE id = ?", array($user)); /* form the 'where' clause for our main sql query */ - if (strlen(get_request_var_request("filter"))) { - $sql_where = "WHERE (gtg.title_cache LIKE '%%" . get_request_var_request('filter') . "%%' AND gtg.local_graph_id>0)"; + if (strlen(get_request_var_request('filter'))) { + $sql_where = "WHERE (gtg.title_cache LIKE '%%" . get_request_var_request('filter') . "%%' AND gtg.local_graph_id > 0)"; } else { - $sql_where = "WHERE (gtg.local_graph_id>0)"; + $sql_where = 'WHERE (gtg.local_graph_id > 0)'; } if (get_request_var_request('graph_template_id') == '-1') { @@ -837,7 +831,7 @@ function graph_perms_edit($tab, $header_label) { if ($policy['policy_graph_templates'] == 1) { $sql_having .= " $sql_operator user$i IS NULL))"; }else{ - $sql_having .= " $sql_operator user$i=" . $policy['id'] . "))"; + $sql_having .= " $sql_operator user$i=" . $policy['id'] . '))'; } } $sql_join .= 'LEFT JOIN user_auth_' . ($policy['type'] == 'user' ? '':'group_') . "perms AS uap$i ON (gl.graph_template_id=uap$i.item_id AND uap$i.type=4) "; @@ -854,11 +848,11 @@ function graph_perms_edit($tab, $header_label) { $sql_select FROM graph_templates_graph AS gtg INNER JOIN graph_local AS gl - ON gl.id=gtg.local_graph_id + ON gl.id = gtg.local_graph_id LEFT JOIN graph_templates AS gt - ON gt.id=gl.graph_template_id + ON gt.id = gl.graph_template_id LEFT JOIN host AS h - ON h.id=gl.host_id + ON h.id = gl.host_id $sql_join $sql_where $sql_having @@ -870,64 +864,64 @@ function graph_perms_edit($tab, $header_label) { SELECT $sql_select FROM graph_templates_graph AS gtg INNER JOIN graph_local AS gl - ON gl.id=gtg.local_graph_id + ON gl.id = gtg.local_graph_id LEFT JOIN graph_templates AS gt - ON gt.id=gl.graph_template_id + ON gt.id = gl.graph_template_id LEFT JOIN host AS h - ON h.id=gl.host_id + ON h.id = gl.host_id $sql_join $sql_where $sql_having ) AS rows"); - //print "
    ";print_r($graphs);print "
    "; + //print '
    ';print_r($graphs);print '
    '; - $nav = html_nav_bar("user_admin.php?action=user_edit&tab=permsg&id=" . get_request_var_request("id"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 11, "Graphs", 'page', 'main'); + $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsg&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Graphs', 'page', 'main'); print $nav; - $display_text = array("Graph Title", "ID", "Effective Policy"); + $display_text = array('Graph Title', 'ID', 'Effective Policy'); html_header_checkbox($display_text, false); if (sizeof($graphs)) { foreach ($graphs as $g) { - form_alternate_row('line' . $g["local_graph_id"], true); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($g["title_cache"])) : htmlspecialchars($g["title_cache"])), $g["local_graph_id"]); - form_selectable_cell($g["local_graph_id"], $g["local_graph_id"]); + form_alternate_row('line' . $g['local_graph_id'], true); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($g['title_cache'])) : htmlspecialchars($g['title_cache'])), $g['local_graph_id']); + form_selectable_cell($g['local_graph_id'], $g['local_graph_id']); form_selectable_cell(get_permission_string($g, $policies), $g['local_graph_id']); - form_checkbox_cell($g["title_cache"], $g["local_graph_id"]); + form_checkbox_cell($g['title_cache'], $g['local_graph_id']); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; } else { - print "No Matching Graphs Found"; + print 'No Matching Graphs Found'; } html_end_box(false); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("tab",$tab,""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("associate_graph", "1", ""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('tab',$tab,''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('associate_graph', '1', ''); if ($policy['policy_graphs'] == 1) { $assoc_actions = array( - 1 => "Revoke Access", - 2 => "Grant Access" + 1 => 'Revoke Access', + 2 => 'Grant Access' ); }else{ $assoc_actions = array( - 1 => "Grant Access", - 2 => "Revoke Access" + 1 => 'Grant Access', + 2 => 'Revoke Access' ); } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($assoc_actions); - print "
    "; + print ''; break; case 'permsgr': @@ -936,90 +930,90 @@ function graph_perms_edit($tab, $header_label) { group_filter($header_label); /* if the number of rows is -1, set it to the default */ - if ($_REQUEST["rows"] == -1) { - $rows = read_config_option("num_rows_table"); + if ($_REQUEST['rows'] == -1) { + $rows = read_config_option('num_rows_table'); }else{ - $rows = $_REQUEST["rows"]; + $rows = $_REQUEST['rows']; } /* form the 'where' clause for our main sql query */ /* form the 'where' clause for our main sql query */ - if (strlen(get_request_var_request("filter"))) { - $sql_where = "WHERE ((uag.name LIKE '%" . get_request_var_request("filter") . "%') OR (uag.description LIKE '%" . get_request_var_request("filter") . "%'))"; + if (strlen(get_request_var_request('filter'))) { + $sql_where = "WHERE ((uag.name LIKE '%" . get_request_var_request('filter') . "%') OR (uag.description LIKE '%" . get_request_var_request('filter') . "%'))"; } else { - $sql_where = ""; + $sql_where = ''; } - if (get_request_var_request("associated") != "false") { + if (get_request_var_request('associated') != 'false') { /* Show all items */ } else { - $sql_where .= (strlen($sql_where) ? " AND ":"WHERE ") . " uagm.user_id=" . get_request_var_request("id", 0); + $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' uagm.user_id=' . get_request_var_request('id', 0); } /* print checkbox form for validation */ - print "
    \n"; + print "\n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT COUNT(uag.id) FROM user_auth_group AS uag LEFT JOIN user_auth_group_members AS uagm - ON uag.id=uagm.group_id + ON uag.id = uagm.group_id $sql_where"); $sql_query = "SELECT uag.*, uagm.user_id FROM user_auth_group AS uag LEFT JOIN user_auth_group_members AS uagm - ON uag.id=uagm.group_id + ON uag.id = uagm.group_id $sql_where ORDER BY name - LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows; + LIMIT " . ($rows*(get_request_var_request('page')-1)) . ',' . $rows; $groups = db_fetch_assoc($sql_query); - $nav = html_nav_bar("user_admin.php?action=user_edit&tab=permsgr&id=" . get_request_var_request("id"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 11, "Hosts", 'page', 'main'); + $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsgr&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Hosts', 'page', 'main'); print $nav; - $display_text = array("Name", "Description", "Member", "ID", "Policies (Graph/Host/Template)", "Enabled"); + $display_text = array('Name', 'Description', 'Member', 'ID', 'Policies (Graph/Host/Template)', 'Enabled'); html_header_checkbox($display_text, false); if (sizeof($groups)) { foreach ($groups as $g) { - form_alternate_row('line' . $g["id"], true); - form_selectable_cell("" . (strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($g["name"])) : htmlspecialchars($g["name"])) . "", $g["id"]); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($g["description"])) : htmlspecialchars($g["description"])), $g["id"]); - form_selectable_cell($g["user_id"] > 0 ? 'Member':'Non Member', $g["id"]); - form_selectable_cell(($g["id"]), $g["id"]); - form_selectable_cell(($g['policy_graphs'] == 1 ? 'ALLOW':'DENY') . '/' . ($g['policy_hosts'] == 1 ? 'ALLOW':'DENY') . '/' . ($g['policy_graph_templates'] == 1 ? 'ALLOW':'DENY'), $g["id"]); + form_alternate_row('line' . $g['id'], true); + form_selectable_cell("" . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($g['name'])) : htmlspecialchars($g['name'])) . '', $g['id']); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($g['description'])) : htmlspecialchars($g['description'])), $g['id']); + form_selectable_cell($g['user_id'] > 0 ? 'Member':'Non Member', $g['id']); + form_selectable_cell(($g['id']), $g['id']); + form_selectable_cell(($g['policy_graphs'] == 1 ? 'ALLOW':'DENY') . '/' . ($g['policy_hosts'] == 1 ? 'ALLOW':'DENY') . '/' . ($g['policy_graph_templates'] == 1 ? 'ALLOW':'DENY'), $g['id']); form_selectable_cell($g['enabled'] == 'on' ? 'Enabled':'Disabled', $g['id']); - form_checkbox_cell($g["name"], $g["id"]); + form_checkbox_cell($g['name'], $g['id']); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; } else { - print "No Matching User Groups Found"; + print 'No Matching User Groups Found'; } html_end_box(false); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("tab",$tab,""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("associate_groups", "1", ""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('tab',$tab,''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('associate_groups', '1', ''); $assoc_actions = array( - 1 => "Assign Membership", - 2 => "Remove Membership" + 1 => 'Assign Membership', + 2 => 'Remove Membership' ); /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($assoc_actions); - print "
    "; + print ''; break; case 'permsd': @@ -1031,19 +1025,19 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* box: device permissions */ - html_start_box("Default Device Policy", "100%", "", "3", "center", ""); + html_start_box('Default Device Policy', '100%', '', '3', 'center', ''); ?>
    Default Device Policy for this User - + - "> +
    @@ -1054,72 +1048,72 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* if the number of rows is -1, set it to the default */ - if ($_REQUEST["rows"] == -1) { - $rows = read_config_option("num_rows_table"); + if ($_REQUEST['rows'] == -1) { + $rows = read_config_option('num_rows_table'); }else{ - $rows = $_REQUEST["rows"]; + $rows = $_REQUEST['rows']; } /* form the 'where' clause for our main sql query */ /* form the 'where' clause for our main sql query */ - if (strlen(get_request_var_request("filter"))) { - $sql_where = "WHERE (host.hostname LIKE '%%" . get_request_var_request("filter") . "%%' OR host.description LIKE '%%" . get_request_var_request("filter") . "%%')"; + if (strlen(get_request_var_request('filter'))) { + $sql_where = "WHERE (host.hostname LIKE '%%" . get_request_var_request('filter') . "%%' OR host.description LIKE '%%" . get_request_var_request('filter') . "%%')"; } else { - $sql_where = ""; + $sql_where = ''; } - if (get_request_var_request("host_template_id") == "-1") { + if (get_request_var_request('host_template_id') == '-1') { /* Show all items */ - }elseif (get_request_var_request("host_template_id") == "0") { - $sql_where .= (strlen($sql_where) ? " AND ":"WHERE ") . " host.host_template_id=0"; - }elseif (!empty($_REQUEST["host_template_id"])) { - $sql_where .= (strlen($sql_where) ? " AND ":"WHERE ") . " host.host_template_id=" . get_request_var_request("host_template_id"); + }elseif (get_request_var_request('host_template_id') == '0') { + $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' host.host_template_id=0'; + }elseif (!empty($_REQUEST['host_template_id'])) { + $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' host.host_template_id=' . get_request_var_request('host_template_id'); } - if (get_request_var_request("associated") == "false") { + if (get_request_var_request('associated') == 'false') { /* Show all items */ } else { - $sql_where .= (strlen($sql_where) ? " AND ":"WHERE ") . " user_auth_perms.user_id=" . get_request_var_request("id", 0); + $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' user_auth_perms.user_id=' . get_request_var_request('id', 0); } /* print checkbox form for validation */ - print "
    \n"; + print "\n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); - $total_rows = db_fetch_cell("select + $total_rows = db_fetch_cell("SELECT COUNT(host.id) FROM host LEFT JOIN user_auth_perms - ON (host.id=user_auth_perms.item_id AND user_auth_perms.type = 3) + ON (host.id = user_auth_perms.item_id AND user_auth_perms.type = 3) $sql_where"); - $host_graphs = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id"), "host_id", "graphs"); - $host_data_sources = array_rekey(db_fetch_assoc("SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id"), "host_id", "data_sources"); + $host_graphs = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as graphs FROM graph_local GROUP BY host_id'), 'host_id', 'graphs'); + $host_data_sources = array_rekey(db_fetch_assoc('SELECT host_id, count(*) as data_sources FROM data_local GROUP BY host_id'), 'host_id', 'data_sources'); $sql_query = "SELECT host.*, user_auth_perms.user_id FROM host LEFT JOIN user_auth_perms - ON (host.id=user_auth_perms.item_id AND user_auth_perms.type=3) + ON (host.id = user_auth_perms.item_id AND user_auth_perms.type = 3) $sql_where ORDER BY description - LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows; + LIMIT " . ($rows*(get_request_var_request('page')-1)) . ',' . $rows; $hosts = db_fetch_assoc($sql_query); - $nav = html_nav_bar("user_admin.php?action=user_edit&tab=permsd&id=" . get_request_var_request("id"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 11, "Hosts", 'page', 'main'); + $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Hosts', 'page', 'main'); print $nav; - $display_text = array("Description", "ID", "Effective Policy", "Graphs", "Data Sources", "Status", "Hostname"); + $display_text = array('Description', 'ID', 'Effective Policy', 'Graphs', 'Data Sources', 'Status', 'Hostname'); html_header_checkbox($display_text, false); if (sizeof($hosts)) { foreach ($hosts as $host) { - form_alternate_row('line' . $host["id"], true); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($host["description"])) : htmlspecialchars($host["description"])), $host["id"]); - form_selectable_cell(round(($host["id"]), 2), $host["id"]); + form_alternate_row('line' . $host['id'], true); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($host['description'])) : htmlspecialchars($host['description'])), $host['id']); + form_selectable_cell(round(($host['id']), 2), $host['id']); if (empty($host['user_id']) || $host['user_id'] == NULL) { if ($policy['policy_hosts'] == 1) { form_selectable_cell('Access Granted', $host['id']); @@ -1133,42 +1127,42 @@ function graph_perms_edit($tab, $header_label) { form_selectable_cell('Access Granted', $host['id']); } } - form_selectable_cell((isset($host_graphs[$host["id"]]) ? $host_graphs[$host["id"]] : 0), $host["id"]); - form_selectable_cell((isset($host_data_sources[$host["id"]]) ? $host_data_sources[$host["id"]] : 0), $host["id"]); - form_selectable_cell(get_colored_device_status(($host["disabled"] == "on" ? true : false), $host["status"]), $host["id"]); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($host["hostname"])) : htmlspecialchars($host["hostname"])), $host["id"]); - form_checkbox_cell($host["description"], $host["id"]); + form_selectable_cell((isset($host_graphs[$host['id']]) ? $host_graphs[$host['id']] : 0), $host['id']); + form_selectable_cell((isset($host_data_sources[$host['id']]) ? $host_data_sources[$host['id']] : 0), $host['id']); + form_selectable_cell(get_colored_device_status(($host['disabled'] == 'on' ? true : false), $host['status']), $host['id']); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname'])), $host['id']); + form_checkbox_cell($host['description'], $host['id']); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; } else { - print "No Matching Devices Found"; + print 'No Matching Devices Found'; } html_end_box(false); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("tab",$tab,""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("associate_host", "1", ""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('tab',$tab,''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('associate_host', '1', ''); if ($policy['policy_hosts'] == 1) { $assoc_actions = array( - 1 => "Revoke Access", - 2 => "Grant Access" + 1 => 'Revoke Access', + 2 => 'Grant Access' ); }else{ $assoc_actions = array( - 1 => "Grant Access", - 2 => "Revoke Access" + 1 => 'Grant Access', + 2 => 'Revoke Access' ); } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($assoc_actions); - print "
    "; + print ''; break; case 'permste': @@ -1180,19 +1174,19 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* box: device permissions */ - html_start_box("Default Graph Template Policy", "100%", "", "3", "center", ""); + html_start_box('Default Graph Template Policy', '100%', '', '3', 'center', ''); ?>
    Default Graph Template Policy for this User - + - "> +
    @@ -1203,66 +1197,66 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* if the number of rows is -1, set it to the default */ - if ($_REQUEST["rows"] == -1) { - $rows = read_config_option("num_rows_table"); + if ($_REQUEST['rows'] == -1) { + $rows = read_config_option('num_rows_table'); }else{ - $rows = $_REQUEST["rows"]; + $rows = $_REQUEST['rows']; } /* form the 'where' clause for our main sql query */ - if (strlen(get_request_var_request("filter"))) { - $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request("filter") . "%%')"; + if (strlen(get_request_var_request('filter'))) { + $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request('filter') . "%%')"; } else { - $sql_where = ""; + $sql_where = ''; } - if (get_request_var_request("associated") == "false") { + if (get_request_var_request('associated') == 'false') { /* Show all items */ } else { - $sql_where .= (strlen($sql_where) ? " AND ":"WHERE ") . " (user_auth_perms.type=4 AND user_auth_perms.user_id=" . get_request_var_request("id", 0) . ")"; + $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' (user_auth_perms.type=4 AND user_auth_perms.user_id=' . get_request_var_request('id', 0) . ')'; } /* print checkbox form for validation */ - print "
    \n"; + print "\n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT COUNT(gt.id) FROM graph_templates AS gt INNER JOIN graph_local AS gl - ON gt.id=gl.graph_template_id + ON gt.id = gl.graph_template_id LEFT JOIN user_auth_perms - ON (gt.id=user_auth_perms.item_id AND user_auth_perms.type=4) + ON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 4) $sql_where GROUP BY gl.graph_template_id"); $sql_query = "SELECT gt.id, gt.name, count(*) AS totals, user_auth_perms.user_id FROM graph_templates AS gt INNER JOIN graph_local AS gl - ON gt.id=gl.graph_template_id + ON gt.id = gl.graph_template_id LEFT JOIN user_auth_perms - ON (gt.id=user_auth_perms.item_id AND user_auth_perms.type=4) + ON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 4) $sql_where GROUP BY gl.graph_template_id ORDER BY name - LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows; + LIMIT " . ($rows*(get_request_var_request('page')-1)) . ',' . $rows; $graphs = db_fetch_assoc($sql_query); - $nav = html_nav_bar("user_admin.php?action=user_edit&tab=permste&id=" . get_request_var_request("id"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 11, "Graph Templates", 'page', 'main'); + $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permste&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Graph Templates', 'page', 'main'); print $nav; - $display_text = array("Template Name", "ID", "Effective Policy", "Total Graphs"); + $display_text = array('Template Name', 'ID', 'Effective Policy', 'Total Graphs'); html_header_checkbox($display_text, false); if (sizeof($graphs)) { foreach ($graphs as $g) { - form_alternate_row('line' . $g["id"], true); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($g["name"])) : htmlspecialchars($g["name"])), $g["id"]); - form_selectable_cell($g["id"], $g["id"]); + form_alternate_row('line' . $g['id'], true); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($g['name'])) : htmlspecialchars($g['name'])), $g['id']); + form_selectable_cell($g['id'], $g['id']); if (empty($g['user_id']) || $g['user_id'] == NULL) { if ($policy['policy_graph_templates'] == 1) { form_selectable_cell('Access Granted', $g['id']); @@ -1276,39 +1270,39 @@ function graph_perms_edit($tab, $header_label) { form_selectable_cell('Access Granted', $g['id']); } } - form_selectable_cell($g["totals"], $g["id"]); - form_checkbox_cell($g["name"], $g["id"]); + form_selectable_cell($g['totals'], $g['id']); + form_checkbox_cell($g['name'], $g['id']); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; } else { - print "No Matching Graph Templates Found"; + print 'No Matching Graph Templates Found'; } html_end_box(false); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("tab",$tab,""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("associate_template", "1", ""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('tab',$tab,''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('associate_template', '1', ''); if ($policy['policy_graph_templates'] == 1) { $assoc_actions = array( - 1 => "Revoke Access", - 2 => "Grant Access" + 1 => 'Revoke Access', + 2 => 'Grant Access' ); }else{ $assoc_actions = array( - 1 => "Grant Access", - 2 => "Revoke Access" + 1 => 'Grant Access', + 2 => 'Revoke Access' ); } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($assoc_actions); - print "
    "; + print ''; break; case 'permstr': @@ -1320,19 +1314,19 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* box: device permissions */ - html_start_box("Default Tree Policy", "100%", "", "3", "center", ""); + html_start_box('Default Tree Policy', '100%', '', '3', 'center', ''); ?>
    Default Tree Policy for this User - + - "> +
    @@ -1343,60 +1337,60 @@ function graph_perms_edit($tab, $header_label) { print "
    \n"; /* if the number of rows is -1, set it to the default */ - if ($_REQUEST["rows"] == -1) { - $rows = read_config_option("num_rows_table"); + if ($_REQUEST['rows'] == -1) { + $rows = read_config_option('num_rows_table'); }else{ - $rows = $_REQUEST["rows"]; + $rows = $_REQUEST['rows']; } /* form the 'where' clause for our main sql query */ - if (strlen(get_request_var_request("filter"))) { - $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request("filter") . "%%')"; + if (strlen(get_request_var_request('filter'))) { + $sql_where = "WHERE (gt.name LIKE '%%" . get_request_var_request('filter') . "%%')"; } else { - $sql_where = ""; + $sql_where = ''; } - if (get_request_var_request("associated") == "false") { + if (get_request_var_request('associated') == 'false') { /* showing all rows */ } else { - $sql_where .= (strlen($sql_where) ? " AND ":"WHERE ") . " (user_auth_perms.type=2 AND user_auth_perms.user_id=" . get_request_var_request("id", 0) . ")"; + $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' (user_auth_perms.type=2 AND user_auth_perms.user_id=' . get_request_var_request('id', 0) . ')'; } /* print checkbox form for validation */ - print "
    \n"; + print "\n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT COUNT(gt.id) FROM graph_tree AS gt LEFT JOIN user_auth_perms - ON (gt.id=user_auth_perms.item_id AND user_auth_perms.type=2) + ON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 2) $sql_where"); $sql_query = "SELECT gt.id, gt.name, user_auth_perms.user_id FROM graph_tree AS gt LEFT JOIN user_auth_perms - ON (gt.id=user_auth_perms.item_id AND user_auth_perms.type=2) + ON (gt.id = user_auth_perms.item_id AND user_auth_perms.type = 2) $sql_where ORDER BY name - LIMIT " . ($rows*(get_request_var_request("page")-1)) . "," . $rows; + LIMIT " . ($rows*(get_request_var_request('page')-1)) . ',' . $rows; $trees = db_fetch_assoc($sql_query); - $nav = html_nav_bar("user_admin.php?action=user_edit&tab=permstr&id=" . get_request_var_request("id"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 11, "Trees", 'page', 'main'); + $nav = html_nav_bar('user_admin.php?action=user_edit&tab=permstr&id=' . get_request_var_request('id'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 11, 'Trees', 'page', 'main'); print $nav; - $display_text = array("Tree Name", "ID", "Effective Policy"); + $display_text = array('Tree Name', 'ID', 'Effective Policy'); html_header_checkbox($display_text, false); if (sizeof($trees)) { foreach ($trees as $t) { - form_alternate_row('line' . $t["id"], true); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($t["name"])) : htmlspecialchars($t["name"])), $t["id"]); - form_selectable_cell($t["id"], $t["id"]); + form_alternate_row('line' . $t['id'], true); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($t['name'])) : htmlspecialchars($t['name'])), $t['id']); + form_selectable_cell($t['id'], $t['id']); if (empty($t['user_id']) || $t['user_id'] == NULL) { if ($policy['policy_graphs'] == 1) { form_selectable_cell('Access Granted', $t['id']); @@ -1410,38 +1404,38 @@ function graph_perms_edit($tab, $header_label) { form_selectable_cell('Access Granted', $t['id']); } } - form_checkbox_cell($t["name"], $t["id"]); + form_checkbox_cell($t['name'], $t['id']); form_end_row(); } /* put the nav bar on the bottom as well */ print $nav; } else { - print "No Matching Trees Found"; + print 'No Matching Trees Found'; } html_end_box(false); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("tab",$tab,""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("associate_tree", "1", ""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('tab',$tab,''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('associate_tree', '1', ''); if ($policy['policy_graph_templates'] == 1) { $assoc_actions = array( - 1 => "Revoke Access", - 2 => "Grant Access" + 1 => 'Revoke Access', + 2 => 'Grant Access' ); }else{ $assoc_actions = array( - 1 => "Grant Access", - 2 => "Revoke Access" + 1 => 'Grant Access', + 2 => 'Revoke Access' ); } /* draw the dropdown containing a list of available actions for this form */ draw_actions_dropdown($assoc_actions); - print "
    "; + print ''; break; } @@ -1451,12 +1445,12 @@ function user_realms_edit($header_label) { global $user_auth_realms; /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("id")); + input_validate_input_number(get_request_var_request('id')); /* ==================================================== */ print "
    \n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); $all_realms = $user_auth_realms; @@ -1473,10 +1467,10 @@ function user_realms_edit($header_label) { $base = array(7,8,15,1,2,3,4,5,6,9,10,11,12,13,14,16,17,101); foreach($base as $realm) { if (isset($user_auth_realms[$realm])) { - if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id=" . get_request_var_request("id", 0) . " AND realm_id=" . $realm)) > 0) { - $old_value = "on"; + if (sizeof(db_fetch_assoc_prepared('SELECT realm_id FROM user_auth_realm WHERE user_id = ? AND realm_id = ?', array(get_request_var_request('id', 0), $realm))) > 0) { + $old_value = 'on'; }else{ - $old_value = ""; + $old_value = ''; } unset($all_realms[$realm]); @@ -1486,7 +1480,7 @@ function user_realms_edit($header_label) { $j = 1; } - form_checkbox("section" . $realm, $old_value, $user_auth_realms[$realm], "", "", "", (!empty($_REQUEST["id"]) ? 1 : 0)); print "
    "; + form_checkbox('section' . $realm, $old_value, $user_auth_realms[$realm], '', '', '', (!empty($_REQUEST['id']) ? 1 : 0)); print '
    '; $j++; } @@ -1494,54 +1488,54 @@ function user_realms_edit($header_label) { print "\n"; /* do plugin realms */ - $realms = db_fetch_assoc("SELECT pc.name, pr.id AS realm_id, pr.display + $realms = db_fetch_assoc('SELECT pc.name, pr.id AS realm_id, pr.display FROM plugin_config AS pc INNER JOIN plugin_realms AS pr - ON pc.directory=pr.plugin - ORDER BY pc.name, pr.display"); + ON pc.directory = pr.plugin + ORDER BY pc.name, pr.display'); print "Plugin Permissions\n"; print " @@ -2383,18 +2377,18 @@ function graph_filter($header_label) { @@ -2494,7 +2488,7 @@ function group_filter($header_label) { Search: @@ -2586,14 +2580,14 @@ function device_filter($header_label) { @@ -2693,7 +2687,7 @@ function template_filter($header_label) { Search: @@ -2783,7 +2777,7 @@ function tree_filter($header_label) { Search: @@ -2873,7 +2867,7 @@ function member_filter($header_label) { Search:
    \n"; if (sizeof($realms)) { - $last_plugin = "none"; + $last_plugin = 'none'; $i = 1; $j = 1; $level = floor(sizeof($all_realms) / 4); $break = false; foreach($realms as $r) { - if ($last_plugin != $r["name"]) { + if ($last_plugin != $r['name']) { if ($break) { print "\n"; $break = false; $j = 1; } - print "" . $r["name"] . "
    \n"; - $last_plugin = $r["name"]; + print '' . $r['name'] . "
    \n"; + $last_plugin = $r['name']; }elseif ($break) { print "
    \n"; $break = false; $j = 1; - print "" . $r["name"] . " (cont)
    \n"; + print '' . $r['name'] . " (cont)
    \n"; } if ($j == 6) { $break = true;; } - $realm = $r["realm_id"] + 100; + $realm = $r['realm_id'] + 100; - if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id=" . get_request_var_request("id", 0) . " AND realm_id=" . $realm)) > 0) { - $old_value = "on"; + if (sizeof(db_fetch_assoc_prepared('SELECT realm_id FROM user_auth_realm WHERE user_id =? AND realm_id = ?', array(get_request_var_request('id', 0), $realm))) > 0) { + $old_value = 'on'; }else{ - $old_value = ""; + $old_value = ''; } unset($all_realms[$realm]); - $pos = (strpos($user_auth_realms[$realm], "->") !== false ? strpos($user_auth_realms[$realm], "->")+2:0); + $pos = (strpos($user_auth_realms[$realm], '->') !== false ? strpos($user_auth_realms[$realm], '->')+2:0); - form_checkbox("section" . $realm, $old_value, substr($user_auth_realms[$realm], $pos), "", "", "", (!empty($_REQUEST["id"]) ? 1 : 0)); print "
    "; + form_checkbox('section' . $realm, $old_value, substr($user_auth_realms[$realm], $pos), '', '', '', (!empty($_REQUEST['id']) ? 1 : 0)); print '
    '; $j++; } @@ -1554,15 +1548,15 @@ function user_realms_edit($header_label) { } print "Legacy 1.x Plugins
    \n"; foreach($all_realms as $realm => $name) { - if (sizeof(db_fetch_assoc("SELECT realm_id FROM user_auth_realm WHERE user_id=" . get_request_var_request("id", 0) . " AND realm_id=" . $realm)) > 0) { - $old_value = "on"; + if (sizeof(db_fetch_assoc_prepared('SELECT realm_id FROM user_auth_realm WHERE user_id = ? AND realm_id = ?', array(get_request_var_request('id', 0), $realm))) > 0) { + $old_value = 'on'; }else{ - $old_value = ""; + $old_value = ''; } - $pos = (strpos($user_auth_realms[$realm], "->") !== false ? strpos($user_auth_realms[$realm], "->")+2:0); + $pos = (strpos($user_auth_realms[$realm], '->') !== false ? strpos($user_auth_realms[$realm], '->')+2:0); - form_checkbox("section" . $realm, $old_value, substr($user_auth_realms[$realm], $pos), "", "", "", (!empty($_REQUEST["id"]) ? 1 : 0)); print "
    "; + form_checkbox('section' . $realm, $old_value, substr($user_auth_realms[$realm], $pos), '', '', '', (!empty($_REQUEST['id']) ? 1 : 0)); print '
    '; } @@ -1573,24 +1567,24 @@ function user_realms_edit($header_label) { html_end_box(); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("tab", "realms", ""); - form_hidden_box("save_component_realm_perms", "1", ""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('tab', 'realms', ''); + form_hidden_box('save_component_realm_perms', '1', ''); - form_save_button("user_admin.php", "return"); + form_save_button('user_admin.php', 'return'); } function graph_settings_edit($header_label) { global $settings_graphs, $tabs_graphs, $graph_views; /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("id")); + input_validate_input_number(get_request_var_request('id')); /* ==================================================== */ print "\n"; - html_start_box("Graph Settings $header_label", "100%", "", "3", "center", ""); + html_start_box("Graph Settings $header_label", '100%', '', '3', 'center', ''); while (list($tab_short_name, $tab_fields) = each($settings_graphs)) { ?> @@ -1606,41 +1600,41 @@ function graph_settings_edit($header_label) { while (list($field_name, $field_array) = each($tab_fields)) { $form_array += array($field_name => $tab_fields[$field_name]); - if ((isset($field_array["items"])) && (is_array($field_array["items"]))) { - while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) { - if (graph_config_value_exists($sub_field_name, $_REQUEST["id"])) { - $form_array[$field_name]["items"][$sub_field_name]["form_id"] = 1; + if ((isset($field_array['items'])) && (is_array($field_array['items']))) { + while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) { + if (graph_config_value_exists($sub_field_name, $_REQUEST['id'])) { + $form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1; } - $form_array[$field_name]["items"][$sub_field_name]["value"] = db_fetch_cell("SELECT value FROM settings_graphs WHERE name = '" . $sub_field_name . "' AND user_id = " . get_request_var_request("id")); + $form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, get_request_var_request('id'))); } }else{ - if (graph_config_value_exists($field_name, $_REQUEST["id"])) { - $form_array[$field_name]["form_id"] = 1; + if (graph_config_value_exists($field_name, $_REQUEST['id'])) { + $form_array[$field_name]['form_id'] = 1; } - $form_array[$field_name]["value"] = db_fetch_cell("select value from settings_graphs where name='$field_name' and user_id=" . $_REQUEST["id"]); + $form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? and user_id = ?', array($field_name, $_REQUEST['id'])); } } draw_edit_form( array( - "config" => array( - "no_form_tag" => true + 'config' => array( + 'no_form_tag' => true ), - "fields" => $form_array + 'fields' => $form_array ) ); } html_end_box(); - form_hidden_box("action", "user_edit", ""); - form_hidden_box("id", get_request_var_request("id"), ""); - form_hidden_box("tab", "settings", ""); - form_hidden_box("save_component_graph_settings","1",""); + form_hidden_box('action', 'user_edit', ''); + form_hidden_box('id', get_request_var_request('id'), ''); + form_hidden_box('tab', 'settings', ''); + form_hidden_box('save_component_graph_settings','1',''); - form_save_button("user_admin.php", "return"); + form_save_button('user_admin.php', 'return'); ?> User Management", "100%", "", "3", "center", "user_admin.php?tab=general&action=user_edit"); + html_start_box('User Management', '100%', '', '3', 'center', 'user_admin.php?tab=general&action=user_edit'); - if ($_REQUEST["rows"] == '-1') { - $rows = read_config_option("num_rows_table"); + if ($_REQUEST['rows'] == '-1') { + $rows = read_config_option('num_rows_table'); }else{ - $rows = $_REQUEST["rows"]; + $rows = $_REQUEST['rows']; } ?> @@ -1905,7 +1899,7 @@ function user() { Search:
    - "> + Users: @@ -1915,7 +1909,7 @@ function user() { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -1938,16 +1932,16 @@ function user() { html_end_box(); /* form the 'where' clause for our main sql query */ - if (strlen(get_request_var_request("filter"))) { - $sql_where = "WHERE (user_auth.username LIKE '%" . get_request_var_request("filter") . "%' OR user_auth.full_name LIKE '%" . get_request_var_request("filter") . "%')"; + if (strlen(get_request_var_request('filter'))) { + $sql_where = "WHERE (user_auth.username LIKE '%" . get_request_var_request('filter') . "%' OR user_auth.full_name LIKE '%" . get_request_var_request('filter') . "%')"; }else{ - $sql_where = ""; + $sql_where = ''; } /* print checkbox form for validation */ print "\n"; - html_start_box("", "100%", "", "3", "center", ""); + html_start_box('', '100%', '', '3', 'center', ''); $total_rows = db_fetch_cell("SELECT COUNT(user_auth.id) @@ -1961,43 +1955,43 @@ function user() { LEFT JOIN user_log ON (user_auth.id = user_log.user_id) $sql_where GROUP BY id - ORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . - " LIMIT " . ($rows * (get_request_var_request("page") - 1)) . "," . $rows); + ORDER BY " . get_request_var_request('sort_column') . ' ' . get_request_var_request('sort_direction') . + ' LIMIT ' . ($rows * (get_request_var_request('page') - 1)) . ',' . $rows); - $nav = html_nav_bar("user_admin.php?filter=" . get_request_var_request("filter"), MAX_DISPLAY_PAGES, get_request_var_request("page"), $rows, $total_rows, 9, "Users", 'page', 'main'); + $nav = html_nav_bar('user_admin.php?filter=' . get_request_var_request('filter'), MAX_DISPLAY_PAGES, get_request_var_request('page'), $rows, $total_rows, 9, 'Users', 'page', 'main'); print $nav; $display_text = array( - "username" => array("User Name", "ASC"), - "full_name" => array("Full Name", "ASC"), - "enabled" => array("Enabled", "ASC"), - "realm" => array("Realm", "ASC"), - "policy_graphs" => array("Graph Policy", "ASC"), - "policy_hosts" => array("Device Policy", "ASC"), - "policy_graph_templates" => array("Template Policy", "ASC"), - "dtime" => array("Last Login", "DESC")); + 'username' => array('User Name', 'ASC'), + 'full_name' => array('Full Name', 'ASC'), + 'enabled' => array('Enabled', 'ASC'), + 'realm' => array('Realm', 'ASC'), + 'policy_graphs' => array('Graph Policy', 'ASC'), + 'policy_hosts' => array('Device Policy', 'ASC'), + 'policy_graph_templates' => array('Template Policy', 'ASC'), + 'dtime' => array('Last Login', 'DESC')); - html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), false); + html_header_sort_checkbox($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), false); if (sizeof($user_list) > 0) { foreach ($user_list as $user) { - if (empty($user["dtime"]) || ($user["dtime"] == "12/31/1969")) { - $last_login = "N/A"; + if (empty($user['dtime']) || ($user['dtime'] == '12/31/1969')) { + $last_login = 'N/A'; }else{ - $last_login = strftime("%A, %B %d, %Y %H:%M:%S ", strtotime($user["dtime"]));; + $last_login = strftime('%A, %B %d, %Y %H:%M:%S ', strtotime($user['dtime']));; } - if ($user["enabled"] == "on") { - $enabled = "Yes"; + if ($user['enabled'] == 'on') { + $enabled = 'Yes'; }else{ - $enabled = "No"; + $enabled = 'No'; } - form_alternate_row('line' . $user["id"], true); - form_selectable_cell("" . - (strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($user["username"])) : htmlspecialchars($user["username"])) - , $user["id"]); - form_selectable_cell((strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter")) . ")/i", "\\1", htmlspecialchars($user["full_name"])) : htmlspecialchars($user["full_name"])), $user["id"]); + form_alternate_row('line' . $user['id'], true); + form_selectable_cell("" . + (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($user['username'])) : htmlspecialchars($user['username'])) + , $user['id']); + form_selectable_cell((strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter')) . ')/i', "\\1", htmlspecialchars($user['full_name'])) : htmlspecialchars($user['full_name'])), $user['id']); form_selectable_cell($enabled, $user['id']); form_selectable_cell($auth_realms[$user['realm']], $user['id']); form_selectable_cell(($user['policy_graphs'] == 1 ? 'ALLOW':'DENY'), $user['id']); @@ -2020,14 +2014,14 @@ function user() { function process_graph_request_vars() { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("graph_template_id")); - input_validate_input_number(get_request_var_request("rows")); - input_validate_input_number(get_request_var_request("page")); + input_validate_input_number(get_request_var_request('graph_template_id')); + input_validate_input_number(get_request_var_request('rows')); + input_validate_input_number(get_request_var_request('page')); /* ==================================================== */ /* clean up search string */ - if (isset($_REQUEST["filter"])) { - $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter")); + if (isset($_REQUEST['filter'])) { + $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } /* clean up sort solumn */ @@ -2046,22 +2040,22 @@ function process_graph_request_vars() { } /* if the user pushed the 'clear' button */ - if (isset($_REQUEST["clearf"])) { - kill_session_var("sess_uag_page"); - kill_session_var("sess_default_rows"); - kill_session_var("sess_uag_filter"); - kill_session_var("sess_uag_graph_template_id"); - kill_session_var("sess_uag_associated"); - kill_session_var("sess_uag_sort_column"); - kill_session_var("sess_uag_sort_direction"); + if (isset($_REQUEST['clearf'])) { + kill_session_var('sess_uag_page'); + kill_session_var('sess_default_rows'); + kill_session_var('sess_uag_filter'); + kill_session_var('sess_uag_graph_template_id'); + kill_session_var('sess_uag_associated'); + kill_session_var('sess_uag_sort_column'); + kill_session_var('sess_uag_sort_direction'); - unset($_REQUEST["page"]); - unset($_REQUEST["rows"]); - unset($_REQUEST["filter"]); - unset($_REQUEST["graph_template_id"]); - unset($_REQUEST["associated"]); - unset($_REQUEST["sort_column"]); - unset($_REQUEST["sort_direction"]); + unset($_REQUEST['page']); + unset($_REQUEST['rows']); + unset($_REQUEST['filter']); + unset($_REQUEST['graph_template_id']); + unset($_REQUEST['associated']); + unset($_REQUEST['sort_column']); + unset($_REQUEST['sort_direction']); }else{ $changed = 0; $changed += check_changed('rows', 'sess_default_rows'); @@ -2076,22 +2070,22 @@ function process_graph_request_vars() { } /* remember these search fields in session vars so we don't have to keep passing them around */ - load_current_session_value("page", "sess_uag_page", "1"); - load_current_session_value("filter", "sess_uag_filter", ""); - load_current_session_value("associated", "sess_uag_associated", "true"); - load_current_session_value("graph_template_id", "sess_uag_graph_template_id", "-1"); - load_current_session_value("rows", "sess_default_rows", read_config_option('num_rows_table')); + load_current_session_value('page', 'sess_uag_page', '1'); + load_current_session_value('filter', 'sess_uag_filter', ''); + load_current_session_value('associated', 'sess_uag_associated', 'true'); + load_current_session_value('graph_template_id', 'sess_uag_graph_template_id', '-1'); + load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); } function process_group_request_vars() { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("rows")); - input_validate_input_number(get_request_var_request("page")); + input_validate_input_number(get_request_var_request('rows')); + input_validate_input_number(get_request_var_request('page')); /* ==================================================== */ /* clean up search string */ - if (isset($_REQUEST["filter"])) { - $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter")); + if (isset($_REQUEST['filter'])) { + $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } /* clean up sort solumn */ @@ -2110,20 +2104,20 @@ function process_group_request_vars() { } /* if the user pushed the 'clear' button */ - if (isset($_REQUEST["clearf"])) { - kill_session_var("sess_uagr_page"); - kill_session_var("sess_default_rows"); - kill_session_var("sess_uagr_filter"); - kill_session_var("sess_uagr_associated"); - kill_session_var("sess_uagr_sort_column"); - kill_session_var("sess_uagr_sort_direction"); + if (isset($_REQUEST['clearf'])) { + kill_session_var('sess_uagr_page'); + kill_session_var('sess_default_rows'); + kill_session_var('sess_uagr_filter'); + kill_session_var('sess_uagr_associated'); + kill_session_var('sess_uagr_sort_column'); + kill_session_var('sess_uagr_sort_direction'); - unset($_REQUEST["page"]); - unset($_REQUEST["rows"]); - unset($_REQUEST["filter"]); - unset($_REQUEST["associated"]); - unset($_REQUEST["sort_column"]); - unset($_REQUEST["sort_direction"]); + unset($_REQUEST['page']); + unset($_REQUEST['rows']); + unset($_REQUEST['filter']); + unset($_REQUEST['associated']); + unset($_REQUEST['sort_column']); + unset($_REQUEST['sort_direction']); }else{ $changed = 0; $changed += check_changed('rows', 'sess_default_rows'); @@ -2137,22 +2131,22 @@ function process_group_request_vars() { } /* remember these search fields in session vars so we don't have to keep passing them around */ - load_current_session_value("page", "sess_uagr_page", "1"); - load_current_session_value("filter", "sess_uagr_filter", ""); - load_current_session_value("associated", "sess_uagr_associated", "true"); - load_current_session_value("rows", "sess_default_rows", read_config_option('num_rows_table')); + load_current_session_value('page', 'sess_uagr_page', '1'); + load_current_session_value('filter', 'sess_uagr_filter', ''); + load_current_session_value('associated', 'sess_uagr_associated', 'true'); + load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); } function process_device_request_vars() { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("host_template_id")); - input_validate_input_number(get_request_var_request("rows")); - input_validate_input_number(get_request_var_request("page")); + input_validate_input_number(get_request_var_request('host_template_id')); + input_validate_input_number(get_request_var_request('rows')); + input_validate_input_number(get_request_var_request('page')); /* ==================================================== */ /* clean up search string */ - if (isset($_REQUEST["filter"])) { - $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter")); + if (isset($_REQUEST['filter'])) { + $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } /* clean up sort solumn */ @@ -2171,22 +2165,22 @@ function process_device_request_vars() { } /* if the user pushed the 'clear' button */ - if (isset($_REQUEST["clearf"])) { - kill_session_var("sess_uad_page"); - kill_session_var("sess_default_rows"); - kill_session_var("sess_uad_filter"); - kill_session_var("sess_uad_host_template_id"); - kill_session_var("sess_uad_associated"); - kill_session_var("sess_uad_sort_column"); - kill_session_var("sess_uad_sort_direction"); + if (isset($_REQUEST['clearf'])) { + kill_session_var('sess_uad_page'); + kill_session_var('sess_default_rows'); + kill_session_var('sess_uad_filter'); + kill_session_var('sess_uad_host_template_id'); + kill_session_var('sess_uad_associated'); + kill_session_var('sess_uad_sort_column'); + kill_session_var('sess_uad_sort_direction'); - unset($_REQUEST["page"]); - unset($_REQUEST["rows"]); - unset($_REQUEST["filter"]); - unset($_REQUEST["host_template_id"]); - unset($_REQUEST["associated"]); - unset($_REQUEST["sort_column"]); - unset($_REQUEST["sort_direction"]); + unset($_REQUEST['page']); + unset($_REQUEST['rows']); + unset($_REQUEST['filter']); + unset($_REQUEST['host_template_id']); + unset($_REQUEST['associated']); + unset($_REQUEST['sort_column']); + unset($_REQUEST['sort_direction']); }else{ $changed = 0; $changed += check_changed('rows', 'sess_default_rows'); @@ -2201,22 +2195,22 @@ function process_device_request_vars() { } /* remember these search fields in session vars so we don't have to keep passing them around */ - load_current_session_value("page", "sess_uad_page", "1"); - load_current_session_value("filter", "sess_uad_filter", ""); - load_current_session_value("associated", "sess_uad_associated", "true"); - load_current_session_value("host_template_id", "sess_uad_host_template_id", "-1"); - load_current_session_value("rows", "sess_default_rows", read_config_option('num_rows_table')); + load_current_session_value('page', 'sess_uad_page', '1'); + load_current_session_value('filter', 'sess_uad_filter', ''); + load_current_session_value('associated', 'sess_uad_associated', 'true'); + load_current_session_value('host_template_id', 'sess_uad_host_template_id', '-1'); + load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); } function process_template_request_vars() { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("rows")); - input_validate_input_number(get_request_var_request("page")); + input_validate_input_number(get_request_var_request('rows')); + input_validate_input_number(get_request_var_request('page')); /* ==================================================== */ /* clean up search string */ - if (isset($_REQUEST["filter"])) { - $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter")); + if (isset($_REQUEST['filter'])) { + $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } /* clean up sort solumn */ @@ -2235,20 +2229,20 @@ function process_template_request_vars() { } /* if the user pushed the 'clear' button */ - if (isset($_REQUEST["clearf"])) { - kill_session_var("sess_uate_page"); - kill_session_var("sess_default_rows"); - kill_session_var("sess_uate_filter"); - kill_session_var("sess_uate_associated"); - kill_session_var("sess_uate_sort_column"); - kill_session_var("sess_uate_sort_direction"); + if (isset($_REQUEST['clearf'])) { + kill_session_var('sess_uate_page'); + kill_session_var('sess_default_rows'); + kill_session_var('sess_uate_filter'); + kill_session_var('sess_uate_associated'); + kill_session_var('sess_uate_sort_column'); + kill_session_var('sess_uate_sort_direction'); - unset($_REQUEST["page"]); - unset($_REQUEST["rows"]); - unset($_REQUEST["filter"]); - unset($_REQUEST["associated"]); - unset($_REQUEST["sort_column"]); - unset($_REQUEST["sort_direction"]); + unset($_REQUEST['page']); + unset($_REQUEST['rows']); + unset($_REQUEST['filter']); + unset($_REQUEST['associated']); + unset($_REQUEST['sort_column']); + unset($_REQUEST['sort_direction']); }else{ $changed = 0; $changed += check_changed('rows', 'sess_default_rows'); @@ -2262,21 +2256,21 @@ function process_template_request_vars() { } /* remember these search fields in session vars so we don't have to keep passing them around */ - load_current_session_value("page", "sess_uate_page", "1"); - load_current_session_value("filter", "sess_uate_filter", ""); - load_current_session_value("associated", "sess_uate_associated", "true"); - load_current_session_value("rows", "sess_default_rows", read_config_option('num_rows_table')); + load_current_session_value('page', 'sess_uate_page', '1'); + load_current_session_value('filter', 'sess_uate_filter', ''); + load_current_session_value('associated', 'sess_uate_associated', 'true'); + load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); } function process_tree_request_vars() { /* ================= input validation ================= */ - input_validate_input_number(get_request_var_request("rows")); - input_validate_input_number(get_request_var_request("page")); + input_validate_input_number(get_request_var_request('rows')); + input_validate_input_number(get_request_var_request('page')); /* ==================================================== */ /* clean up search string */ - if (isset($_REQUEST["filter"])) { - $_REQUEST["filter"] = sanitize_search_string(get_request_var_request("filter")); + if (isset($_REQUEST['filter'])) { + $_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter')); } /* clean up sort solumn */ @@ -2295,20 +2289,20 @@ function process_tree_request_vars() { } /* if the user pushed the 'clear' button */ - if (isset($_REQUEST["clearf"])) { - kill_session_var("sess_uatr_page"); - kill_session_var("sess_default_rows"); - kill_session_var("sess_uatr_filter"); - kill_session_var("sess_uatr_associated"); - kill_session_var("sess_uatr_sort_column"); - kill_session_var("sess_uatr_sort_direction"); + if (isset($_REQUEST['clearf'])) { + kill_session_var('sess_uatr_page'); + kill_session_var('sess_default_rows'); + kill_session_var('sess_uatr_filter'); + kill_session_var('sess_uatr_associated'); + kill_session_var('sess_uatr_sort_column'); + kill_session_var('sess_uatr_sort_direction'); - unset($_REQUEST["page"]); - unset($_REQUEST["rows"]); - unset($_REQUEST["filter"]); - unset($_REQUEST["associated"]); - unset($_REQUEST["sort_column"]); - unset($_REQUEST["sort_direction"]); + unset($_REQUEST['page']); + unset($_REQUEST['rows']); + unset($_REQUEST['filter']); + unset($_REQUEST['associated']); + unset($_REQUEST['sort_column']); + unset($_REQUEST['sort_direction']); }else{ $changed = 0; $changed += check_changed('rows', 'sess_default_rows'); @@ -2324,10 +2318,10 @@ function process_tree_request_vars() { } /* remember these search fields in session vars so we don't have to keep passing them around */ - load_current_session_value("page", "sess_uatr_page", "1"); - load_current_session_value("filter", "sess_uatr_filter", ""); - load_current_session_value("associated", "sess_uatr_associated", "true"); - load_current_session_value("rows", "sess_default_rows", read_config_option('num_rows_table')); + load_current_session_value('page', 'sess_uatr_page', '1'); + load_current_session_value('filter', 'sess_uatr_filter', ''); + load_current_session_value('associated', 'sess_uatr_associated', 'true'); + load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table')); } function graph_filter($header_label) { @@ -2370,7 +2364,7 @@ function graph_filter($header_label) { Graph Permissions " . htmlspecialchars($header_label), "100%", "", "3", "center", ""); + html_start_box('Graph Permissions ' . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?>
    - " onChange="applyFilter()"> + Graphs: @@ -2414,7 +2408,7 @@ function graph_filter($header_label) { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -2482,7 +2476,7 @@ function group_filter($header_label) { Group Membership " . htmlspecialchars($header_label), "100%", "", "3", "center", ""); + html_start_box('Group Membership ' . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?>
    - " onChange="applyFilter()"> + Groups: @@ -2504,7 +2498,7 @@ function group_filter($header_label) { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -2573,7 +2567,7 @@ function device_filter($header_label) { Devices Permission " . htmlspecialchars($header_label), "100%", "", "3", "center", ""); + html_start_box('Devices Permission ' . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?>
    - " onChange="applyFilter()"> + Devices: @@ -2613,7 +2607,7 @@ function device_filter($header_label) { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -2681,7 +2675,7 @@ function template_filter($header_label) { Template Permission " . htmlspecialchars($header_label), "100%", "", "3", "center", ""); + html_start_box('Template Permission ' . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?>
    - " onChange="applyFilter()"> + Templates: @@ -2703,7 +2697,7 @@ function template_filter($header_label) { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -2771,7 +2765,7 @@ function tree_filter($header_label) { Tree Permission " . htmlspecialchars($header_label), "100%", "", "3", "center", ""); + html_start_box('Tree Permission ' . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?>
    - " onChange="applyFilter()"> + Trees: @@ -2793,7 +2787,7 @@ function tree_filter($header_label) { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -2861,7 +2855,7 @@ function member_filter($header_label) { Tree Permission " . htmlspecialchars($header_label), "100%", "", "3", "center", ""); + html_start_box('Tree Permission ' . htmlspecialchars($header_label), '100%', '', '3', 'center', ''); ?>
    - " onChange="applyFilter()"> + Rows: @@ -2883,7 +2877,7 @@ function member_filter($header_label) { 0) { foreach ($item_rows as $key => $value) { - print "\n"; + print "\n"; } } ?> @@ -2915,4 +2909,3 @@ function member_filter($header_label) { html_end_box(); } -?>