0 ORDER BY id"); if (!empty($first_auth) and !empty($first_auth['mac'])) { add_auth_rule($db_link, $first_auth['mac'], 2, $id); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST["delMacRule"])) { run_sql($db_link, "DELETE FROM auth_rules WHERE user_id=" . $id . " AND type=2"); LOG_INFO($db_link, "All autorules removed for id: $id login: " . $user_info["login"] . " by mac"); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST["addIPRule"])) { unset($new); $first_auth = get_record_sql($db_link, "SELECT ip FROM User_auth WHERE user_id=" . $id . " AND deleted=0 AND LENGTH(ip)>0 ORDER BY id"); if (!empty($first_auth) and !empty($first_auth['ip'])) { add_auth_rule($db_link, $first_auth['ip'], 1, $id); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST["delIPRule"])) { run_sql($db_link, "DELETE FROM auth_rules WHERE user_id=" . $id . " AND type=1"); LOG_INFO($db_link, "Removed all auto rules for id: $id login: " . $user_info["login"] . " by ip"); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST["showDevice"])) { $device = get_record_sql($db_link, "SELECT * FROM devices WHERE user_id=" . $id); $auth = get_record_sql($db_link, "SELECT * FROM User_auth WHERE user_id=" . $id); if (empty($device) and !empty($auth)) { $new['user_id'] = $id; $new['device_name'] = $user_info['login']; $new['device_type'] = 5; $new['ip'] = $auth['ip']; $new['ip_int'] = $auth['ip_int']; $new['community'] = get_const('snmp_default_community'); $new['snmp_version'] = get_const('snmp_default_version'); $new['login'] = get_option($db_link, 28); $new['password'] = get_option($db_link, 29); //default ssh $new['protocol'] = 0; $new['control_port'] = get_option($db_link, 30); $new_id = insert_record($db_link, "devices", $new); unset($_POST); if (!empty($new_id)) { LOG_INFO($db_link, "Created device with id: $new_id for auth_id: $id"); header("Location: /admin/devices/editdevice.php?id={$new_id}"); exit; } else { header("Location: " . $_SERVER["REQUEST_URI"]); exit; } } header("Location: /admin/devices/editdevice.php?id=" . $device['id']); exit; } if (isset($_POST["addauth"])) { $fip = substr(trim($_POST["newip"]), 0, 18); $fmac = NULL; if (isset($_POST["newmac"])) { $fmac = mac_dotted(substr(trim($_POST["newmac"]), 0, 17)); } if ($fip) { if (checkValidIp($fip)) { $ip_aton = ip2long($fip); $f_dhcp = 1; //search mac if (!empty($fmac) and !empty($fip)) { $mac_exists = find_mac_in_subnet($db_link, $fip, $fmac); if (!empty($mac_exists) and $mac_exists['count'] >= 1 and !in_array($id, $mac_exists['users_id'])) { $dup_sql = "SELECT * FROM User_list WHERE id=" . $mac_exists['users_id']['0']; $dup_info = get_record_sql($db_link, $dup_sql); $msg_error = "Mac already exists at another user in this subnet! Skip creating $fip [$fmac].
Old user id: " . $dup_info['id'] . " login: " . $dup_info['login']; $_SESSION[$page_url]['msg'] = $msg_error; LOG_ERROR($db_link, $msg_error); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } //disable dhcp for secondary ip if (empty($mac_exists)) { $f_dhcp = 1; } else { if (in_array($id, $mac_exists['users_id'])) { $f_dhcp = 0; } } } //search ip $dup_ip_record = get_record_sql($db_link, "SELECT * FROM User_auth WHERE `ip_int`=$ip_aton AND user_id<>" . $id . " AND deleted=0"); if (!empty($dup_ip_record)) { $dup_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $dup_ip_record['user_id']); $msg_error = "$fip already exists. Skip creating $fip [$fmac].
Old user id: " . $dup_info['id'] . " login: " . $dup_info['login']; $_SESSION[$page_url]['msg'] = $msg_error; LOG_ERROR($db_link, $msg_error); header("Location: " . $_SERVER["REQUEST_URI"]); exit; } $fid = new_auth($db_link, $fip, $fmac, $id); if (!empty($fid)) { $new['dhcp'] = $f_dhcp; $new['created_by'] = 'manual'; update_record($db_link, "User_auth", "id=" . $fid, $new); LOG_WARNING($db_link, "Add ip for login: " . $user_info["login"] . ": ip => $fip, mac => $fmac", $fid); header("Location: /admin/users/editauth.php?id=" . $fid); exit; } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } else { $msg_error = "$msg_ip_error xxx.xxx.xxx.xxx"; $_SESSION[$page_url]['msg'] = $msg_error; } } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST["removeauth"])) { $auth_id = $_POST["f_auth_id"]; foreach ($auth_id as $key => $val) { if ($val) { delete_user_auth($db_link, $val); } } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST["new_user"])) { $auth_id = $_POST["f_auth_id"]; $save_traf = get_option($db_link, 23) * 1; foreach ($auth_id as $key => $val) { if ($val) { $auth_info = get_record_sql($db_link, "SELECT ip, mac, comments, dns_name, dhcp_hostname FROM User_auth WHERE id=$val"); $ou_id = $user_info["ou_id"]; $login = NULL; if (!empty($auth_info["dns_name"])) { $login = $auth_info["dns_name"]; } if (empty($login) and !empty($auth_info["comments"])) { $login = transliterate($auth_info["comments"]); } if (empty($login) and !empty($auth_info["dhcp_hostname"])) { $login = $auth_info["dhcp_hostname"]; } if (empty($login) and !empty($auth_info["mac"])) { $login = $auth_info["mac"]; } if (empty($login)) { $login = $auth_info["ip"]; } $new_user = get_record_sql($db_link, "SELECT * FROM User_list WHERE LCase(login)=LCase('$login') and deleted=0"); if (!empty($new_user)) { // move auth $auth["user_id"] = $new_user["id"]; $auth["ou_id"] = $new_user["ou_id"]; $auth["save_traf"] = $save_traf; $auth = apply_auth_rule($db_link, $auth, $l_id); update_record($db_link, "User_auth", "id='" . $val . "'", $auth); LOG_WARNING($db_link, "ip from id: $val moved to another user user_id: " . $new_user["id"], $val); } else { $new["login"] = $login; $new["ou_id"] = $ou_id; $l_id = insert_record($db_link, "User_list", $new); $auth["user_id"] = $l_id; $auth["save_traf"] = $save_traf; update_record($db_link, "User_auth", "id='" . $val . "'", $auth); LOG_WARNING($db_link, "Create user from ip: login => $login. ip-record auth_id: $val moved to this user.", $val); } } } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } unset($_POST); require_once($_SERVER["DOCUMENT_ROOT"] . "/inc/header.php"); ?>
' . $_SESSION[$page_url]['msg'] . '
'; unset($_SESSION[$page_url]['msg']); } ?>
> "; print_url(WEB_user_rule_list, "/admin/users/edit_rules.php?id=$id"); print ""; $rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id); print ""; $first_auth = get_record_sql($db_link, "SELECT id FROM User_auth WHERE user_id=" . $id . " AND deleted=0 ORDER BY id"); if (!empty($first_auth)) { //mac $mac_rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id . " AND type=2"); if (!empty($mac_rule_count)) { print ""; } else { print ""; } //ip $ip_rule_count = get_count_records($db_link, "auth_rules", "user_id=" . $id . " AND type=1"); if (!empty($ip_rule_count)) { print ""; } else { print ""; } } else { print ""; } ?> "; print_url(WEB_report_by_day, "/admin/reports/userday.php?id=$id"); ?>
" size=25> " size=25>
" size=5> " size=5>
:
Count: " . $rule_count . "
> >
$msg_error
\n"; } $sort_table = 'User_auth'; $sort_url = "

"; print ""; print ""; print ""; if (isset($row["dhcp_hostname"]) and strlen($row["dhcp_hostname"]) > 0) { print ""; } else { print ""; } print ""; $ip_status = 1; if ($row["blocked"] or !$row["enabled"]) { $ip_status = 0; } print_td_qa($ip_status); $cl = "data_green"; if (!$row["dhcp"]) { $cl = "data_red"; } print ""; print ""; print ""; print ""; if ($row['dynamic']) { $cl = "data_red"; } else { $cl = "data_green"; } print ""; print ""; print ""; } } ?>
" . WEB_cell_ip . ""; ?> " . WEB_cell_mac . ""; ?> " . WEB_cell_dns_name . ""; ?> " . WEB_cell_permonth . ", Mb"; ?> "; ?>
" . $row["ip"] . ""; if (!empty($row["arp_found"])) { print "

".FormatDateStr('Y.m.d H:i', $row["arp_found"])."

"; } print "
" . expand_mac($db_link, $row["mac"]); if (!empty($row["last_found"])) { print "

".FormatDateStr('Y.m.d H:i', $row["last_found"])."

"; } print "
" . $row["comments"] . " [" . $row["dhcp_hostname"] . "]" . $row["comments"] . "" . $row["dns_name"] . "" . get_qa($row["dhcp"]); if (!empty($dhcp_str)) { print "

".$dhcp_str. "

"; } print "
" . get_group($db_link, $row["filter_group_id"]) . "" . get_queue($db_link, $row["queue_id"]) . "" . $row["day_quota"] . "/" . $row["month_quota"] . "". get_qa($row['dynamic']); if ($row['dynamic'] and !empty($row["eof"])) { print "

".FormatDateStr('Y.m.d H:i', $row["eof"])."

"; } else { print " "; } print "
"; if (!empty($row["created_by"])) { print $row["created_by"]; } else { print " "; } print "