<% On Error Resume Next theme = Request.Cookies("theme") If theme = "" Then theme = "bg-theme1" End If ' Get device type and ID from query string Dim deviceType, deviceId deviceType = Trim(Request.Querystring("type")) deviceId = Trim(Request.Querystring("id")) ' Validate inputs If deviceType = "" Or deviceId = "" Or Not IsNumeric(deviceId) Or CLng(deviceId) < 1 Then Response.Redirect("networkdevices.asp") Response.End End If ' Build query based on device type ' All network devices now use unified machines table with machinetypeid: ' 16 = Access Point, 17 = IDF, 18 = Camera, 19 = Switch, 20 = Server Dim strSQL, rs, tableName, idField, editUrl, listUrl, machineTypeId Select Case LCase(deviceType) Case "idf" machineTypeId = 17 editUrl = "deviceidf.asp?id=" & deviceId listUrl = "networkdevices.asp?filter=IDF" strSQL = "SELECT mac.machineid, COALESCE(mac.alias, mac.machinenumber) AS idfname, " & _ "mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, " & _ "NULL AS vendor, NULL AS modelnumber, NULL AS image, NULL AS serialnumber, NULL AS ipaddress, NULL AS macaddress, " & _ "'IDF' AS devicetype " & _ "FROM machines mac " & _ "WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 17" Case "server" machineTypeId = 20 editUrl = "deviceserver.asp?id=" & deviceId listUrl = "networkdevices.asp?filter=Server" strSQL = "SELECT mac.machineid, mac.alias AS servername, mac.machinenotes AS description, " & _ "mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, mac.logicmonitorurl, " & _ "v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _ "NULL AS idfname, 'Server' AS devicetype, " & _ "mac.alias AS devicename " & _ "FROM machines mac " & _ "LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ "WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 20" Case "switch" machineTypeId = 19 editUrl = "deviceswitch.asp?id=" & deviceId listUrl = "networkdevices.asp?filter=Switch" strSQL = "SELECT mac.machineid, mac.alias AS switchname, mac.machinenotes AS description, " & _ "mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, mac.logicmonitorurl, " & _ "v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _ "NULL AS idfname, 'Switch' AS devicetype, " & _ "mac.alias AS devicename " & _ "FROM machines mac " & _ "LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ "WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 19" Case "camera" machineTypeId = 18 editUrl = "devicecamera.asp?id=" & deviceId listUrl = "networkdevices.asp?filter=Camera" strSQL = "SELECT mac.machineid, mac.alias AS cameraname, mac.machinenotes AS description, " & _ "mac.maptop, mac.mapleft, mac.isactive, mac.serialnumber, mac.fqdn, " & _ "v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _ "idf.alias AS idfname, idf.machineid AS idfid, 'Camera' AS devicetype, " & _ "mac.alias AS devicename " & _ "FROM machines mac " & _ "LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ "LEFT JOIN machinerelationships mr ON mac.machineid = mr.machineid AND mr.isactive = 1 " & _ "LEFT JOIN machines idf ON mr.related_machineid = idf.machineid AND idf.machinetypeid = 17 " & _ "WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 18" Case "accesspoint", "access point" machineTypeId = 16 editUrl = "deviceaccesspoint.asp?id=" & deviceId listUrl = "networkdevices.asp?filter=Access Point" strSQL = "SELECT mac.machineid AS apid, mac.alias AS devicename, mac.modelnumberid AS modelid, " & _ "mac.serialnumber, mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, mac.logicmonitorurl, " & _ "v.vendor, m.modelnumber, m.image, c.address AS ipaddress, c.macaddress, " & _ "NULL AS idfname, NULL AS idfid, 'Access Point' AS devicetype " & _ "FROM machines mac " & _ "LEFT JOIN models m ON mac.modelnumberid = m.modelnumberid " & _ "LEFT JOIN vendors v ON m.vendorid = v.vendorid " & _ "LEFT JOIN communications c ON mac.machineid = c.machineid AND c.isprimary = 1 AND c.comstypeid = 1 " & _ "WHERE mac.machineid = " & CLng(deviceId) & " AND mac.machinetypeid = 16" Case Else Response.Redirect("networkdevices.asp") Response.End End Select Set rs = objConn.Execute(strSQL) ' Check if device exists If rs.EOF Then rs.Close Set rs = Nothing Response.Redirect("networkdevices.asp") Response.End End If ' Get device name based on type Dim deviceName, deviceDescription Select Case LCase(deviceType) Case "idf" deviceName = rs("idfname") Case "server" deviceName = rs("servername") Case "switch" deviceName = rs("switchname") Case "camera" deviceName = rs("cameraname") Case "accesspoint", "access point" deviceName = rs("devicename") End Select ' Store description in variable (reading rs fields twice can cause issues with ADO cursors) deviceDescription = rs("description") & "" %>
"" Then Response.Write(Server.HTMLEncode(rs("image") & "")) Else Response.Write(LCase(deviceType) & ".png") End If%>" alt="Card image cap" onerror="this.onerror=null; this.src='./images/machines/default.png'">
"" Then Response.Write(Server.HTMLEncode(rs("image") & "")) Else Response.Write(LCase(deviceType) & ".png") End If%>" alt="profile-image" class="profile" onerror="this.onerror=null; this.src='./images/machines/default.png'">
<%=Server.HTMLEncode(deviceName)%>
<%If Not IsNull(rs("vendor")) Then Response.Write(Server.HTMLEncode(rs("vendor"))) Else Response.Write(" ") End If%>
<%=Server.HTMLEncode(rs("devicetype"))%>

<%If deviceDescription <> "" Then Response.Write(Server.HTMLEncode(deviceDescription)) Else Response.Write(" ") End If%>

Configuration

Type:

Name:

<%If Not IsNull(rs("vendor")) Then%>

Vendor:

Model:

<%End If%> <%If Not IsNull(rs("serialnumber")) And rs("serialnumber") <> "" Then%>

Serial:

<%End If%> <%If Not IsNull(rs("ipaddress")) And rs("ipaddress") <> "" Then%>

IP Address:

<%End If%> <%If Not IsNull(rs("macaddress")) And rs("macaddress") <> "" Then%>

MAC Address:

<%End If%> <%If Not IsNull(rs("idfname")) Then%>

IDF:

<%End If%> <% Dim showLogicMonitor showLogicMonitor = False If LCase(deviceType) = "server" Or LCase(deviceType) = "switch" Or LCase(deviceType) = "accesspoint" Or LCase(deviceType) = "access point" Then If Not IsNull(rs("logicmonitorurl")) Then If rs("logicmonitorurl") & "" <> "" Then showLogicMonitor = True End If End If If showLogicMonitor Then%>

Logic Monitor:

<%End If%>

Location:

<%If deviceDescription <> "" Then%>

Notes:

<%End If%>

<%=Server.HTMLEncode(rs("devicetype"))%>

<%=Server.HTMLEncode(deviceName)%>

<%If Not IsNull(rs("vendor")) Then%>

<%=Server.HTMLEncode(rs("vendor"))%>

<%=Server.HTMLEncode(rs("modelnumber"))%>

<%End If%> <%If Not IsNull(rs("serialnumber")) And rs("serialnumber") <> "" Then%>

<%=Server.HTMLEncode(rs("serialnumber"))%>

<%End If%> <%If Not IsNull(rs("ipaddress")) And rs("ipaddress") <> "" Then%>

" target="_blank"><%=Server.HTMLEncode(rs("ipaddress"))%>

<%End If%> <%If Not IsNull(rs("macaddress")) And rs("macaddress") <> "" Then%>

<%=Server.HTMLEncode(rs("macaddress"))%>

<%End If%> <%If Not IsNull(rs("idfname")) Then%>

"><%=Server.HTMLEncode(rs("idfname"))%>

<%End If%> <%If showLogicMonitor Then%>

" target="_blank"> View in Logic Monitor

<%End If%>

<%If Not IsNull(rs("maptop")) And Not IsNull(rs("mapleft")) Then%> View on Map <%Else%> Not set <%End If%>

<%If deviceDescription <> "" Then%>

<%=Server.HTMLEncode(deviceDescription)%>

<%End If%>
<%If LCase(deviceType) = "server" Then ' Query installed applications for this server Dim rsApps, strAppSQL, appCount appCount = 0 strAppSQL = "SELECT ia.installedappid, a.appid, a.appname, a.appdescription, " & _ "av.version, ia.isactive " & _ "FROM installedapps ia " & _ "INNER JOIN applications a ON ia.appid = a.appid " & _ "LEFT JOIN appversions av ON ia.appversionid = av.appversionid " & _ "WHERE ia.machineid = " & CLng(deviceId) & " AND ia.isactive = 1 " & _ "ORDER BY a.appname" Set rsApps = objConn.Execute(strAppSQL) %>
<% If rsApps.EOF Then %> <% Else Do While Not rsApps.EOF appCount = appCount + 1 %> <% rsApps.MoveNext Loop End If rsApps.Close Set rsApps = Nothing %>
Application Version Description
No applications assigned to this server
"><%=Server.HTMLEncode(rsApps("appname") & "")%> <%If Not IsNull(rsApps("version")) Then Response.Write(Server.HTMLEncode(rsApps("version") & "")) Else Response.Write("-")%> <%If Not IsNull(rsApps("appdescription")) Then Response.Write(Server.HTMLEncode(rsApps("appdescription") & "")) Else Response.Write("-")%>
<%=appCount%> application(s) hosted on this server
<%End If%>
<% rs.Close Set rs = Nothing objConn.Close %>