0 ORDER BY id"); if (!empty($first_auth) and !empty($first_auth['mac'])) { $new['user_id']=$id; $new['type']=2; $new['rule']=$first_auth['mac']; insert_record($db_link,"auth_rules",$new); LOG_INFO($db_link,"Create auto rule at id: ".$id." login: ".$user_info["login"]." for mac ".$first_auth['mac']); } 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'])) { $new['user_id']=$id; $new['type']=1; $new['rule']=$first_auth['ip']; insert_record($db_link,"auth_rules",$new); LOG_INFO($db_link,"Create auto rule id: ".$id." login: ".$user_info["login"]." for ip ".$first_auth['IP']); } 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['community'] = get_const('snmp_default_community'); $new['snmp_version'] = get_const('snmp_default_version'); $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); if (isset($_POST["newmac"])) { $fmac = mac_dotted(substr(trim($_POST["newmac"]), 0, 17)); } if ($fip) { if (checkValidIp($fip)) { $ip_aton = ip2long($fip); //search mac $mac_exists=find_mac_in_subnet($db_link,$fip,$fmac); if (isset($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 $f_dhcp = 1; 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; update_record($db_link,"User_auth","id=".$fid,$new); apply_auth_rule($db_link,$fid,$id); 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) { run_sql($db_link, 'DELETE FROM connections WHERE auth_id='.$val); run_sql($db_link, 'DELETE FROM User_auth_alias WHERE auth_id='.$val); $auth["deleted"] = 1; $changes = get_diff_rec($db_link,"User_auth","id='$val'", '', 0); if (!empty($changes)) { LOG_WARNING($db_link,"Removed ip from login: ".$user_info["login"].": \r\n $changes",$val); } update_record($db_link, "User_auth", "id=" . $val, $auth); } } 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; update_record($db_link, "User_auth", "id='" . $val . "'", $auth); apply_auth_rule($db_link,$val,$l_id); 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 = "

\n"; print "\n"; print "\n"; print "\n"; if (isset($row["dhcp_hostname"]) and strlen($row["dhcp_hostname"]) > 0) { print "\n"; } else { print "\n"; } print "\n"; $ip_status = 1; if ($row["blocked"] or !$row["enabled"]) { $ip_status = 0; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; } } ?>
" . WEB_cell_ip . ""; ?> " . WEB_cell_mac . ""; ?> " . WEB_cell_dns_name . ""; ?> ".WEB_cell_permonth.", Mb"; ?> ".WEB_cell_created.""; ?> Last DHCP/ARP Event ".WEB_cell_last_found.""; ?> "; ?>
" . $row["ip"] . "" . expand_mac($db_link,$row["mac"]) . "".$row["comments"]." [" . $row["dhcp_hostname"] . "]".$row["comments"]."".$row["dns_name"]."" . get_qa($ip_status). "" . get_qa($row["dhcp"]). "" . get_group($db_link, $row["filter_group_id"]) . "" . get_queue($db_link, $row["queue_id"]) . "".$row["day_quota"]."/".$row["month_quota"]."" . get_connection($db_link, $row["id"]) . "" . FormatDateStr('Y.m.d',$row["timestamp"]) . "" . $dhcp_str . "" . FormatDateStr('Y.m.d H:i',$row["last_found"]) . "