Files
shopdb/printerlookup.asp
cproudlock 0d263fccdb Fix printerlookup.asp: Add Dim objConn,rs for Option Explicit
Option Explicit requires all variables to be declared. objConn and rs
are created in sql.asp but need to be pre-declared in the calling page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 10:03:33 -05:00

42 lines
1.1 KiB
Plaintext

<%@ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
Dim objConn, rs
%>
<!--#include file="includes/sql.asp"-->
<%
' Lookup printer by IP address or FQDN and redirect to displayprinter.asp
' Used by Zabbix to link directly to printer details
Dim ip, fqdn, lookupValue, cmd
ip = Trim(Request.QueryString("ip") & "")
fqdn = Trim(Request.QueryString("fqdn") & "")
If ip <> "" Then
lookupValue = ip
ElseIf fqdn <> "" Then
lookupValue = fqdn
Else
Response.Write "No IP or FQDN provided. Usage: printerlookup.asp?ip=x.x.x.x or printerlookup.asp?fqdn=hostname"
Response.End
End If
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = objConn
cmd.CommandText = "SELECT printerid FROM printers WHERE address = ? AND isactive = 1"
cmd.Parameters.Append cmd.CreateParameter("@addr", 200, 1, 100, lookupValue)
Set rs = cmd.Execute()
If Not rs.EOF Then
Response.Redirect "displayprinter.asp?printerid=" & rs("printerid")
Else
Response.Write "Printer not found: " & Server.HTMLEncode(lookupValue)
End If
rs.Close
Set rs = Nothing
Set cmd = Nothing
objConn.Close
%>