0) { $len = is_array($_POST['poe_on']) ? count($_POST['poe_on']) : 0; for ($i = 0; $i < $len; $i++) { $port_index = intval($_POST['poe_on'][$i]); $sSQL = "SELECT port from device_ports WHERE device_id=" . $id . " and snmp_index=" . $port_index; $port = get_record_sql($db_link, $sSQL); LOG_DEBUG($db_link, "Device id: " . $id . " enable poe at port " . $port['port'] . " snmp index " . $port_index); set_port_poe_state($device['vendor_id'], $port['port'], $port_index, $device['ip'], $device['rw_community'], $device['snmp_version'], 1); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST['poe_off']) and $device['snmp_version'] > 0) { $len = is_array($_POST['poe_off']) ? count($_POST['poe_off']) : 0; for ($i = 0; $i < $len; $i++) { $port_index = intval($_POST['poe_off'][$i]); $sSQL = "SELECT port from device_ports WHERE device_id=" . $id . " and snmp_index=" . $port_index; $port = get_record_sql($db_link, $sSQL); LOG_DEBUG($db_link, "Device id: " . $id . " disable poe at port " . $port['port'] . " snmp index " . $port_index); set_port_poe_state($device['vendor_id'], $port['port'], $port_index, $device['ip'], $device['rw_community'], $device['snmp_version'], 0); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST['port_on']) and $device['snmp_version'] > 0) { $len = is_array($_POST['port_on']) ? count($_POST['port_on']) : 0; for ($i = 0; $i < $len; $i++) { $port_index = intval($_POST['port_on'][$i]); LOG_DEBUG($db_link, "Device id: $id enable port with snmp index $port_index"); set_port_state($device['vendor_id'], $port_index, $device['ip'], $device['rw_community'], $device['snmp_version'], 1); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } if (isset($_POST['port_off']) and $device['snmp_version'] > 0) { $len = is_array($_POST['port_off']) ? count($_POST['port_off']) : 0; for ($i = 0; $i < $len; $i++) { $port_index = intval($_POST['port_off'][$i]); LOG_DEBUG($db_link, "Device id: $id disable port with snmp index $port_index"); set_port_state($device['vendor_id'], $port_index, $device['ip'], $device['rw_community'], $device['snmp_version'], 0); } header("Location: " . $_SERVER["REQUEST_URI"]); exit; } unset($_POST); $user_info = get_record_sql($db_link, "SELECT * FROM User_list WHERE id=" . $device['user_id']); require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php"); print_device_submenu($page_url); print_editdevice_submenu($page_url, $id, $device['device_type'], $user_info['login']); ?>
\n"; print "" . WEB_device_port_state_list . " " . $device['device_name'] . " - " . $device['ip'] . "
\n"; $snmp_ok = 0; $vlan_list = []; if (!empty($device['ip']) and $device['snmp_version'] > 0) { $snmp_ok = check_snmp_access($device['ip'], $device['community'], $device['snmp_version']); $modules_oids = NULL; if ($snmp_ok) { if ($device['snmp_version'] == 2) { $modules_oids = snmp2_real_walk($device['ip'], $device['community'], CISCO_MODULES, SNMP_timeout, SNMP_retry); } if ($device['snmp_version'] == 1) { $modules_oids = snmprealwalk($device['ip'], $device['community'], CISCO_MODULES, SNMP_timeout, SNMP_retry); } $vlan_list = get_switch_vlans($device['vendor_id'],$device['ip'], $device['community'], $device['snmp_version']); $ifmib_list = get_snmp_interfaces($device['ip'], $device['community'], $device['snmp_version']); } } else { $snmp_ok = 0; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $sSQL = "SELECT * FROM device_ports WHERE device_ports.device_id=$id ORDER BY port"; $ports = get_records_sql($db_link, $sSQL); foreach ($ports as $row) { print "\n"; $cl = "down"; $new_info = NULL; $display_vlan= $row['vlan']; if (!empty($row['untagged_vlan'])) { if ($row['untagged_vlan'] != $row['vlan']) { $display_vlan.=";U:".$row['untagged_vlan']; } } if (!empty($row['tagged_vlan'])) { $display_vlan.=";T:".$row['tagged_vlan']; } //fix empty port names if (empty($row['port_name'])) { $row['port_name'] = $row['port']; $new_info['port_name'] = $row['port']; } if ($snmp_ok) { $port_state_detail = get_port_state_detail($row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']); list($poper, $padmin, $pspeed, $perrors) = explode(';', $port_state_detail); if ($poper == 1) { $cl = "up"; } if ($poper >= 2) { if ($padmin >= 2) { $cl = "shutdown"; } else { $cl = "down"; } } } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $poe_info = "POE:None"; $ifname = $row['ifName']; if ($snmp_ok) { $sfp_status = get_sfp_status($device['vendor_id'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version'], $modules_oids); $poe_status = get_port_poe_state($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']); if (isset($poe_status)) { if ($poe_status == 1) { $port_poe_detail = get_port_poe_detail($device['vendor_id'], $row['port'], $row['snmp_index'], $device['ip'], $device['community'], $device['snmp_version']); if (empty($port_poe_detail)) { $poe_info = 'POE:on'; } else { $poe_info = $port_poe_detail; } } if ($poe_status == 2) { $poe_info = "POE:Off"; } } if (!empty($vlan_list)) { //allied telesys, huawei $vlan_by_portnum = array('8','3'); if (in_array($device['vendor_id'],$vlan_by_portnum) and !empty($vlan_list[$row['snmp_index']])) { $new_info['vlan'] = $vlan_list[$row['snmp_index']]['pvid']; $new_info['tagged_vlan']=$vlan_list[$row['snmp_index']]['tagged']; $new_info['untagged_vlan']=$vlan_list[$row['snmp_index']]['untagged']; } else { $new_info['vlan'] = $vlan_list[$row['port']]['pvid']; $new_info['tagged_vlan']=$vlan_list[$row['port']]['tagged']; $new_info['untagged_vlan']=$vlan_list[$row['port']]['untagged']; } $display_vlan = $new_info['vlan']; if (!empty($new_info['untagged_vlan'])) { if ($new_info['untagged_vlan'] != $new_info['vlan']) { $display_vlan.=";U:".$new_info['untagged_vlan']; } } if (!empty($new_info['tagged_vlan'])) { $display_vlan.=";T:".$new_info['tagged_vlan']; } } //interface name if (!empty($ifmib_list[$row['snmp_index']])) { $ifname = $ifmib_list[$row['snmp_index']]; } if (!isset($row['ifName']) or $row['ifName'] !== $ifname) { $new_info['ifName'] = $ifname; } } //fix port information if (!empty($new_info)) { update_record($db_link, "device_ports", "id=" . $row['id'], $new_info); } $ifname = compact_port_name($ifname); $f_cacti_url = get_cacti_graph($device['ip'], $row['snmp_index']); if (empty(get_const('torrus_url')) and (empty($f_cacti_url))) { $snmp_url = $ifname; } else { if (isset($f_cacti_url)) { $snmp_url = "" . $ifname . ""; } if (!empty(get_const('torrus_url'))) { $normed_ifname = str_replace("/", "_", $ifname); $normed_ifname = str_replace(".", "_", $normed_ifname); $normed_ifname = trim(str_replace(" ", "_", $normed_ifname)); $t_url = str_replace("HOST_IP", $device['ip'], get_const('torrus_url')); $t_url = str_replace("IF_NAME", $normed_ifname, $t_url); $snmp_url = "" . $ifname . ""; } } print "\n"; print "\n"; $speed = "0"; $cl_speed = $cl; if ($pspeed == 0) { $speed = ""; } if ($pspeed == 10000000) { $speed = "10M"; $cl_speed = "speed10M"; } if ($pspeed == 100000000) { $speed = "100M"; $cl_speed = "speed100M"; } if ($pspeed == 1000000000) { $speed = "1G"; $cl_speed = "speed1G"; } if ($pspeed == 10000000000) { $speed = "10G"; $cl_speed = "speed10G"; } if ($pspeed == 4294967295) { $speed = "10G"; $cl_speed = "speed10G"; } if ($pspeed == 10) { $speed = "10G"; $cl_speed = "speed10G"; } print "\n"; $cl_error = $cl; if ($perrors > 0) { $cl_error = "crc"; } print "\n"; print "\n"; print "\n"; if (isset($poe_status) and !$row['skip'] and !$device['is_router']) { print "\n"; } else { print "\n"; } if (isset($padmin) and !$row['uplink'] and !$row['skip'] and !$device['is_router']) { print "\n"; } print ""; } print "\n"; print "
id" . WEB_device_port_number . "" . WEB_device_port_name . "" . WEB_device_port_snmp_index . "" . WEB_device_connected_endpoint . "" . WEB_cell_comment . "" . WEB_device_port_uplink . "" . WEB_nagios . "" . WEB_cell_skip . "" . WEB_cell_vlan . "" . WEB_device_snmp_port_oid_name . "" . WEB_device_port_speed . "" . WEB_device_port_errors . "" . WEB_cell_mac_count . "" . WEB_msg_additional . "" . WEB_device_poe_control . "" . WEB_device_port_control . "
" . $row['port'] . "" . $row['port_name'] . "" . $row['snmp_index'] . ""; if (isset($row['target_port_id']) and $row['target_port_id'] > 0) { print_device_port($db_link, $row['target_port_id']); } else { print_auth_port($db_link, $row['id']); } print "" . $row['comment'] . "" . get_qa($row['uplink']) . "" . get_qa($row['nagios']) . "" . get_qa($row['skip']) . "" . $display_vlan . "" . $snmp_url . "" . $speed . "" . $perrors . "" . $sfp_status . " " . $poe_info . ""; if ($device['vendor_id'] != 9) { if ($poe_status == 2) { print ""; } if ($poe_status == 1) { print ""; } } else { print WEB_msg_unsupported; } print "" . WEB_msg_unsupported . ""; if ($device['vendor_id'] != 9) { if ($padmin >= 2) { print ""; } if ($padmin == 1) { print ""; } } else { print WEB_msg_unsupported; } print "
\n"; ?>
 
\n"; print "" . WEB_port_status . "\n"; print "" . WEB_port_oper_down . ""; print "" . WEB_port_oper_up . ""; print "" . WEB_port_admin_shutdown . "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
" . WEB_port_speed . "
" . WEB_port_speed_10 . "" . WEB_port_speed_100 . "" . WEB_port_speed_1G . "" . WEB_port_speed_10G . "
\n"; print "
"; require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/footer.small.php"); ?>