diff --git a/addlink_direct.asp.backup-20251027 b/addlink_direct.asp.backup-20251027 deleted file mode 100644 index b510869..0000000 --- a/addlink_direct.asp.backup-20251027 +++ /dev/null @@ -1,215 +0,0 @@ - -<% -' Get form inputs for KB article -Dim linkurl, shortdescription, keywords, appid -linkurl = Trim(Request.Form("linkurl")) -shortdescription = Trim(Request.Form("shortdescription")) -keywords = Trim(Request.Form("keywords")) -appid = Trim(Request.Form("appid")) - -' Get form inputs for new topic -Dim newappname, newappdescription, newsupportteamid -Dim newapplicationnotes, newinstallpath, newdocumentationpath, newisactive -newappname = Trim(Request.Form("newappname")) -newappdescription = Trim(Request.Form("newappdescription")) -newsupportteamid = Trim(Request.Form("newsupportteamid")) -newapplicationnotes = Trim(Request.Form("newapplicationnotes")) -newinstallpath = Trim(Request.Form("newinstallpath")) -newdocumentationpath = Trim(Request.Form("newdocumentationpath")) -newisactive = Request.Form("newisactive") - -' Get form inputs for new support team -Dim newsupportteamname, newsupportteamurl, newappownerid -newsupportteamname = Trim(Request.Form("newsupportteamname")) -newsupportteamurl = Trim(Request.Form("newsupportteamurl")) -newappownerid = Trim(Request.Form("newappownerid")) - -' Get form inputs for new app owner -Dim newappownername, newappownersso -newappownername = Trim(Request.Form("newappownername")) -newappownersso = Trim(Request.Form("newappownersso")) - -' Basic validation for KB article -If Len(linkurl) = 0 Or Len(shortdescription) = 0 Or Len(appid) = 0 Then - Response.Write("Required fields missing") - objConn.Close - Response.End -End If - -If Len(linkurl) > 2000 Or Len(shortdescription) > 500 Or Len(keywords) > 500 Then - Response.Write("Field length exceeded") - objConn.Close - Response.End -End If - -' Handle new topic creation -If appid = "new" Then - If Len(newappname) = 0 Then - Response.Write("New topic name is required") - objConn.Close - Response.End - End If - - If Len(newsupportteamid) = 0 Then - Response.Write("Support team is required for new topic") - objConn.Close - Response.End - End If - - ' Validate field lengths for new topic - If Len(newappname) > 50 Or Len(newappdescription) > 255 Or Len(newapplicationnotes) > 512 Or Len(newinstallpath) > 255 Or Len(newdocumentationpath) > 512 Then - Response.Write("New topic field length exceeded") - objConn.Close - Response.End - End If - - ' Handle new support team creation (nested) - If newsupportteamid = "new" Then - If Len(newsupportteamname) = 0 Then - Response.Write("New support team name is required") - objConn.Close - Response.End - End If - - If Len(newappownerid) = 0 Then - Response.Write("App owner is required for new support team") - objConn.Close - Response.End - End If - - If Len(newsupportteamname) > 50 Or Len(newsupportteamurl) > 512 Then - Response.Write("New support team field length exceeded") - objConn.Close - Response.End - End If - - ' Handle new app owner creation (doubly nested) - If newappownerid = "new" Then - If Len(newappownername) = 0 Or Len(newappownersso) = 0 Then - Response.Write("App owner name and SSO are required") - objConn.Close - Response.End - End If - - If Len(newappownername) > 50 Or Len(newappownersso) > 255 Then - Response.Write("App owner field length exceeded") - objConn.Close - Response.End - End If - - ' Escape single quotes for new app owner - Dim escapedOwnerName, escapedOwnerSSO - escapedOwnerName = Replace(newappownername, "'", "''") - escapedOwnerSSO = Replace(newappownersso, "'", "''") - - ' Insert new app owner - Dim sqlNewOwner - sqlNewOwner = "INSERT INTO appowners (appowner, sso, isactive) " & _ - "VALUES ('" & escapedOwnerName & "', '" & escapedOwnerSSO & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewOwner - - If Err.Number <> 0 Then - Response.Write("Error creating new app owner: " & Err.Description) - objConn.Close - Response.End - End If - - ' Get the newly created app owner ID - Dim rsNewOwner - Set rsNewOwner = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newappownerid = rsNewOwner("newid") - rsNewOwner.Close - Set rsNewOwner = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for new support team - Dim escapedTeamName, escapedTeamURL - escapedTeamName = Replace(newsupportteamname, "'", "''") - escapedTeamURL = Replace(newsupportteamurl, "'", "''") - - ' Insert new support team with selected or newly created app owner - Dim sqlNewTeam - sqlNewTeam = "INSERT INTO supportteams (teamname, teamurl, appownerid, isactive) " & _ - "VALUES ('" & escapedTeamName & "', '" & escapedTeamURL & "', " & newappownerid & ", 1)" - - On Error Resume Next - objConn.Execute sqlNewTeam - - If Err.Number <> 0 Then - Response.Write("Error creating new support team: " & Err.Description) - objConn.Close - Response.End - End If - - ' Get the newly created support team ID - Dim rsNewTeam - Set rsNewTeam = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newsupportteamid = rsNewTeam("newid") - rsNewTeam.Close - Set rsNewTeam = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for new topic - Dim escapedAppName, escapedAppDesc, escapedAppNotes, escapedInstallPath, escapedDocPath - escapedAppName = Replace(newappname, "'", "''") - escapedAppDesc = Replace(newappdescription, "'", "''") - escapedAppNotes = Replace(newapplicationnotes, "'", "''") - escapedInstallPath = Replace(newinstallpath, "'", "''") - escapedDocPath = Replace(newdocumentationpath, "'", "''") - - ' Convert isactive checkbox - Dim isActiveValue - If newisactive = "1" Then - isActiveValue = 1 - Else - isActiveValue = 0 - End If - - ' Insert new application/topic - Dim sqlNewApp - sqlNewApp = "INSERT INTO applications (appname, appdescription, supportteamid, applicationnotes, installpath, documentationpath, isactive, isinstallable, ishidden, isprinter, islicenced) " & _ - "VALUES ('" & escapedAppName & "', '" & escapedAppDesc & "', " & newsupportteamid & ", '" & escapedAppNotes & "', '" & escapedInstallPath & "', '" & escapedDocPath & "', " & isActiveValue & ", 0, 0, 0, 0)" - - On Error Resume Next - objConn.Execute sqlNewApp - - If Err.Number <> 0 Then - Response.Write("Error creating new topic: " & Err.Description) - objConn.Close - Response.End - End If - - ' Get the newly created topic ID - Dim rsNewApp - Set rsNewApp = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - appid = rsNewApp("newid") - rsNewApp.Close - Set rsNewApp = Nothing - On Error Goto 0 -End If - -' Escape single quotes for KB article -linkurl = Replace(linkurl, "'", "''") -shortdescription = Replace(shortdescription, "'", "''") -keywords = Replace(keywords, "'", "''") - -' Build INSERT statement for KB article -Dim strSQL -strSQL = "INSERT INTO knowledgebase (linkurl, shortdescription, keywords, appid, isactive, clicks) " & _ - "VALUES ('" & linkurl & "', '" & shortdescription & "', '" & keywords & "', " & appid & ", 1, 0)" - -On Error Resume Next -objConn.Execute strSQL - -If Err.Number = 0 Then - objConn.Close - Response.Redirect("displayknowledgebase.asp?status=added") -Else - objConn.Close - Response.Redirect("displayknowledgebase.asp?status=error&msg=" & Server.URLEncode("Error: " & Err.Description)) -End If -%> diff --git a/addmachine.asp.backup b/addmachine.asp.backup deleted file mode 100644 index 9bf35c4..0000000 --- a/addmachine.asp.backup +++ /dev/null @@ -1,1050 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
- -
-
- -
-
-
-
-
-
- Add New Equipment -
- - Back to Machines - -
- -
- - - - - -
- - -
-
- - - Unique identifier for this machine -
- -
- -
- -
- -
-
-
- - - - -
- - - -
- -
- -
- -
- -
-
-
- - - - -
- - -
- -
- - -
- -
- - -
-
Network Communications
-

Configure network interfaces for this equipment. You can add up to 3 interfaces.

- - -
-
- Interface 1 (Primary) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
-
- Interface 2 (Optional) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
-
- Interface 3 (Optional) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- -
- - -
-
Machine Relationships
-

Define relationships between this equipment and other machines or PCs.

- -
- - - PC that controls this equipment -
- -
- - - Redundant/backup machine for this equipment -
- -
- - -
-
Compliance & Security
-

Manage compliance requirements and third-party vendor information.

- -
- - -
- -
- - - Select the vendor managing this equipment -
- -
- - - Operational Technology system classification -
- -
- - - Department of Defense asset classification -
- -
- - -
-
Physical Location
-

Set the physical location of this equipment on the shop floor map.

- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
- -
- - -
-
- - - Cancel - -
- - - -
-
-
-
- - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Select Machine Location - -
-
-
-
-
- Click on the map to select a location -
- - -
-
-
-
- - - - - -<% - objConn.Close -%> diff --git a/addmachine.asp.backup-refactor-20251027 b/addmachine.asp.backup-refactor-20251027 deleted file mode 100644 index f658be5..0000000 --- a/addmachine.asp.backup-refactor-20251027 +++ /dev/null @@ -1,815 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
- -
-
- -
-
-
-
-
-
- Add Machine -
- - Back - -
- -
-
- - - Unique identifier for this machine -
- -
- -
- -
- -
-
-
- - - - -
- -
- -
- -
-
- What this machine does (e.g., CNC, Mill, Lathe) -
- - - - -
- -
- -
- -
-
-
- - - - -
- - -
- -
- - -
- -
- - - Scan the PC serial number to auto-select from dropdown below -
- -
- - - Or manually select a PC to link to this machine -
- -
- -
Location (Optional)
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
- -
- - - Cancel - -
-
- -
-
-
-
- - - -
- - - - - -
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - -
-
-
- Select Machine Location - -
-
-
-
-
- Click on the map to select a location -
- - -
-
-
-
- - - - - -<% - objConn.Close -%> diff --git a/addsubnetbackend_direct.asp.backup-20251027 b/addsubnetbackend_direct.asp.backup-20251027 deleted file mode 100644 index 5d01860..0000000 --- a/addsubnetbackend_direct.asp.backup-20251027 +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - -
-<% - ' Get form inputs - Dim vlan, ipstart, cidr, description, subnettypeid, cidrarray, ipend - - vlan = Trim(Request.Form("vlan")) - ipstart = Trim(Request.Form("ipstart")) - cidr = Trim(Request.Form("cidr")) - description = Trim(Request.Form("description")) - subnettypeid = Trim(Request.Form("subnettypeid")) - - ' Validate required fields - If vlan = "" Or ipstart = "" Or cidr = "" Or subnettypeid = "" Then - Response.Write("
Error: Required field missing.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate VLAN is numeric - If Not IsNumeric(vlan) Then - Response.Write("
Error: VLAN must be numeric.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Basic IP address validation - If Len(ipstart) < 7 Or Len(ipstart) > 15 Then - Response.Write("
Error: Invalid IP address.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate subnet type ID - If Not IsNumeric(subnettypeid) Or CLng(subnettypeid) < 1 Then - Response.Write("
Error: Invalid subnet type.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Parse CIDR value (expected format: "cidr,ipend") - If InStr(cidr, ",") = 0 Then - Response.Write("
Error: Invalid CIDR format.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - cidrarray = Split(cidr, ",") - If UBound(cidrarray) < 1 Then - Response.Write("
Error: Invalid CIDR format.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ipend = Trim(cidrarray(1)) - cidr = Trim(cidrarray(0)) - - ' Validate CIDR is numeric - If Not IsNumeric(cidr) Or CInt(cidr) < 0 Or CInt(cidr) > 32 Then - Response.Write("
Error: CIDR must be between 0 and 32.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate ipend is numeric - If Not IsNumeric(ipend) Then - Response.Write("
Error: Invalid IP end value.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate description length - If Len(description) > 500 Then - Response.Write("
Error: Description too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape quotes - description = Replace(description, "'", "''") - ipstart = Replace(ipstart, "'", "''") - - ' Verify subnet type exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM subnettypes WHERE subnettypeid = " & subnettypeid - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck("cnt") = 0 Then - rsCheck.Close - Response.Write("
Error: Subnet type not found.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Insert - ' Note: INET_ATON requires the IP address, ipend is added to the result - Dim strSQL - strSQL = "INSERT INTO subnets (vlan, description, cidr, ipstart, ipend, subnettypeid, isactive) " & _ - "VALUES (" & vlan & ", '" & description & "', " & cidr & ", INET_ATON('" & ipstart & "'), (INET_ATON('" & ipstart & "') + " & ipend & "), " & subnettypeid & ", 1)" - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number = 0 Then - objConn.Close - Response.Redirect("./displaysubnets.asp") - Else - Response.Write("
Error: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - End If -%> diff --git a/aspJSON.asp b/aspJSON.asp deleted file mode 100644 index cffee69..0000000 --- a/aspJSON.asp +++ /dev/null @@ -1,25 +0,0 @@ - - - \ No newline at end of file diff --git a/backup/images/Thumbs.db b/backup/images/Thumbs.db deleted file mode 100644 index 215a964..0000000 Binary files a/backup/images/Thumbs.db and /dev/null differ diff --git a/backup/images/applications/Thumbs.db b/backup/images/applications/Thumbs.db deleted file mode 100644 index 619f8af..0000000 Binary files a/backup/images/applications/Thumbs.db and /dev/null differ diff --git a/backup/images/machines/Thumbs.db b/backup/images/machines/Thumbs.db deleted file mode 100644 index d40fb9e..0000000 Binary files a/backup/images/machines/Thumbs.db and /dev/null differ diff --git a/backup/leaflet/images/Thumbs.db b/backup/leaflet/images/Thumbs.db deleted file mode 100644 index 0406154..0000000 Binary files a/backup/leaflet/images/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/assets/images/Thumbs.db b/backup/v2-backup/assets/images/Thumbs.db deleted file mode 100644 index 29321d7..0000000 Binary files a/backup/v2-backup/assets/images/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/images/Thumbs.db b/backup/v2-backup/images/Thumbs.db deleted file mode 100644 index b0cc218..0000000 Binary files a/backup/v2-backup/images/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/images/applications/Thumbs.db b/backup/v2-backup/images/applications/Thumbs.db deleted file mode 100644 index bebb1e5..0000000 Binary files a/backup/v2-backup/images/applications/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/images/computers/Thumbs.db b/backup/v2-backup/images/computers/Thumbs.db deleted file mode 100644 index c447b46..0000000 Binary files a/backup/v2-backup/images/computers/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/images/machines/Thumbs.db b/backup/v2-backup/images/machines/Thumbs.db deleted file mode 100644 index 0333946..0000000 Binary files a/backup/v2-backup/images/machines/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/images/printers/Thumbs.db b/backup/v2-backup/images/printers/Thumbs.db deleted file mode 100644 index 26d24d7..0000000 Binary files a/backup/v2-backup/images/printers/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/leaflet/images/Thumbs.db b/backup/v2-backup/leaflet/images/Thumbs.db deleted file mode 100644 index 0406154..0000000 Binary files a/backup/v2-backup/leaflet/images/Thumbs.db and /dev/null differ diff --git a/backup/v2-backup/template/assets/images/bg-themes/Thumbs.db b/backup/v2-backup/template/assets/images/bg-themes/Thumbs.db deleted file mode 100644 index 1892695..0000000 Binary files a/backup/v2-backup/template/assets/images/bg-themes/Thumbs.db and /dev/null differ diff --git a/backup/v2-bakcup-10-13-25/v2/images/Thumbs.db b/backup/v2-bakcup-10-13-25/v2/images/Thumbs.db deleted file mode 100644 index 5ec0090..0000000 Binary files a/backup/v2-bakcup-10-13-25/v2/images/Thumbs.db and /dev/null differ diff --git a/backup/v2-bakcup-10-13-25/v2/images/applications/Thumbs.db b/backup/v2-bakcup-10-13-25/v2/images/applications/Thumbs.db deleted file mode 100644 index 09cf9fb..0000000 Binary files a/backup/v2-bakcup-10-13-25/v2/images/applications/Thumbs.db and /dev/null differ diff --git a/bulkupdatenotificationtypes.asp b/bulkupdatenotificationtypes.asp deleted file mode 100644 index 1f4b0a1..0000000 --- a/bulkupdatenotificationtypes.asp +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
- -
-
- -
-
-
-
-
-
- Bulk Update Notification Types -
- -
- -<% -' Check for success/error messages -Dim updated, errors -updated = Request.QueryString("updated") -errors = Request.QueryString("errors") - -If updated <> "" Then -%> - -<% End If %> - -
- - Instructions: Select the appropriate notification type for each notification below, then click "Save All Changes" at the bottom. -
- -
-
Notification Type Legend:
- TBD - Type to be determined (gray on calendar)
- Awareness - General awareness notification (green on calendar)
- Change - Scheduled change or maintenance (yellow on calendar)
- Incident - Active incident or outage (red on calendar) -
- -
-
- - - -
- -<% -' Fetch all active notifications -Dim strSQL, rs -strSQL = "SELECT n.notificationid, n.notification, n.starttime, n.endtime, n.ticketnumber, " & _ - "n.notificationtypeid, nt.typename " & _ - "FROM notifications n " & _ - "LEFT JOIN notificationtypes nt ON n.notificationtypeid = nt.notificationtypeid " & _ - "WHERE n.isactive = 1 " & _ - "ORDER BY n.starttime DESC" -Set rs = objconn.Execute(strSQL) - -Dim count -count = 0 - -If Not rs.EOF Then - Do While Not rs.EOF - count = count + 1 - - Dim currentType, currentTypeName - If IsNull(rs("notificationtypeid")) Then - currentType = 1 - currentTypeName = "TBD" - Else - currentType = rs("notificationtypeid") - currentTypeName = rs("typename") - End If -%> -
-
- <%=rs("notification")%> -
-
- Date: <%=FormatDateTime(rs("starttime"), 2)%> - <% If Not IsNull(rs("endtime")) And rs("endtime") <> "" Then %> - to <%=FormatDateTime(rs("endtime"), 2)%> - <% Else %> - ONGOING - <% End If %> - <% If Not IsNull(rs("ticketnumber")) And rs("ticketnumber") <> "" Then %> - | Ticket: <%=rs("ticketnumber")%> - <% End If %> -
-
- - <%=currentTypeName%> -
-
- - -
-
-<% - rs.MoveNext - Loop -End If - -rs.Close -Set rs = Nothing -objConn.Close -%> - - <% If count > 0 Then %> -
- -
- <% Else %> -
- No active notifications found. -
- <% End If %> - -
- -
-
-
-
- - - -
- - - - - -
-
-
-
-
-
- - -
- - - - - - - - - - - - - - - - - - diff --git a/check_all_warranties.asp.broken b/check_all_warranties.asp.broken deleted file mode 100644 index f7a16b4..0000000 --- a/check_all_warranties.asp.broken +++ /dev/null @@ -1,222 +0,0 @@ -<%@ Language=VBScript %> -<% -' ======================================================================== -' Check All Warranties - Batch Process -' This page checks all PCs without warranty information against Dell API -' ======================================================================== - -On Error Resume Next -Response.Buffer = True -Response.ContentType = "application/json" -%> - -<% -If Err.Number <> 0 Then - Response.Write "{""success"": false, ""error"": ""Database include error: " & Replace(Err.Description, """", "'") & """}" - Response.End -End If - -' Configuration -Const VENDOR_API_URL = "http://10.48.130.113/vendor-api-proxy.php" -Const BATCH_SIZE = 10 ' Process 10 at a time - -Dim strSQL -Dim serviceTags, serialNumber -Dim warrantyData, warrantyResults -Dim updated, errors, total -Dim response -Dim rsWarranties ' Create our own recordset object -' Note: objConn is declared in sql.asp include - -' Initialize counters -updated = 0 -errors = 0 - -' Find all PCs without warranty information -strSQL = "SELECT pcid, hostname, serialnumber " & _ - "FROM pc " & _ - "WHERE (warrantyenddate IS NULL OR warrantyenddate = '' OR warrantyenddate = '0000-00-00') " & _ - "AND serialnumber IS NOT NULL " & _ - "AND serialnumber <> 'N/A' " & _ - "AND serialnumber <> '' " & _ - "AND LENGTH(serialnumber) >= 5 " & _ - "AND isactive = 1" - -' Create and open recordset with cursor to support MoveFirst -Set rsWarranties = Server.CreateObject("ADODB.Recordset") -If Err.Number <> 0 Then - Response.Write "{""success"": false, ""error"": ""Failed to create recordset: " & Replace(Err.Description, """", "'") & """}" - Response.End -End If - -rsWarranties.CursorLocation = 3 ' adUseClient -rsWarranties.Open strSQL, objConn - -If Err.Number <> 0 Then - Response.Write "{""success"": false, ""error"": ""Failed to open recordset: " & Replace(Err.Description, """", "'") & """}" - Response.End -End If - -' Check if we have any records -If rsWarranties.EOF Then - ' No devices need warranty checks - Response.Write "{""success"": true, ""message"": ""No devices require warranty checks"", ""total"": 0, ""updated"": 0, ""errors"": 0}" - rsWarranties.Close - objConn.Close - Response.End -End If - -' Count total records -Dim serviceTagList() -Dim deviceInfo() -Dim count -count = 0 - -Do While Not rsWarranties.EOF - count = count + 1 - rsWarranties.MoveNext -Loop -total = count - -' Reset to beginning -rsWarranties.MoveFirst - -' Build arrays -ReDim serviceTagList(total - 1) -ReDim deviceInfo(total - 1) -count = 0 - -Do While Not rsWarranties.EOF - serialNumber = Trim(rsWarranties("serialnumber")) - serviceTagList(count) = serialNumber - Set deviceInfo(count) = CreateObject("Scripting.Dictionary") - deviceInfo(count)("pcid") = rsWarranties("pcid") - deviceInfo(count)("hostname") = rsWarranties("hostname") - deviceInfo(count)("serialnumber") = serialNumber - count = count + 1 - rsWarranties.MoveNext -Loop - -rsWarranties.Close -Set rsWarranties = Nothing - -' Process in batches -Dim i, batchStart, batchEnd, batchTags -Dim batchTagsStr, apiUrl, xmlhttp -Dim responseText, json - -For i = 0 To total - 1 Step BATCH_SIZE - batchStart = i - batchEnd = i + BATCH_SIZE - 1 - If batchEnd >= total Then - batchEnd = total - 1 - End If - - ' Build batch of service tags - batchTagsStr = "" - Dim j - For j = batchStart To batchEnd - If batchTagsStr <> "" Then - batchTagsStr = batchTagsStr & "," - End If - batchTagsStr = batchTagsStr & serviceTagList(j) - Next - - ' Call vendor API - apiUrl = VENDOR_API_URL & "?vendor=dell&action=warranty-batch&servicetags=" & Server.URLEncode(batchTagsStr) - - Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0") - xmlhttp.setTimeouts 30000, 30000, 30000, 30000 ' 30 second timeout - - On Error Resume Next - xmlhttp.Open "GET", apiUrl, False - xmlhttp.setRequestHeader "Accept", "application/json" - xmlhttp.Send - - If Err.Number <> 0 Then - errors = errors + (batchEnd - batchStart + 1) - Err.Clear - Else - responseText = xmlhttp.responseText - - ' Parse JSON response (simplified - for production use proper JSON parser) - ' For now, we'll extract warranty data using string parsing - If InStr(responseText, """success"":true") > 0 Then - ' Process each warranty in batch - For j = batchStart To batchEnd - serialNumber = serviceTagList(j) - - ' Extract warranty data for this serial (simplified extraction) - Dim warrantyEndDate, serviceLevel, warrantyStatus - warrantyEndDate = ExtractWarrantyData(responseText, serialNumber, "warrantyEndDate") - serviceLevel = ExtractWarrantyData(responseText, serialNumber, "serviceLevel") - warrantyStatus = ExtractWarrantyData(responseText, serialNumber, "warrantyStatus") - - If warrantyEndDate <> "" Then - ' Update database - strSQL = "UPDATE pc SET " & _ - "warrantyenddate = '" & Replace(warrantyEndDate, "'", "''") & "', " & _ - "warrantystatus = '" & Replace(warrantyStatus, "'", "''") & "', " & _ - "warrantylevel = '" & Replace(Left(serviceLevel, 100), "'", "''") & "' " & _ - "WHERE pcid = " & deviceInfo(j)("pcid") - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number = 0 Then - updated = updated + 1 - Else - errors = errors + 1 - Err.Clear - End If - On Error Goto 0 - Else - errors = errors + 1 - End If - Next - Else - errors = errors + (batchEnd - batchStart + 1) - End If - End If - On Error Goto 0 - - Set xmlhttp = Nothing - - ' Small delay between batches - ASP doesn't support WScript.Sleep - ' Instead, we'll just continue without delay since batches are small - ' If batchEnd < total - 1 Then - ' ' No sleep available in ASP - ' End If -Next - -' Return response -Response.Write "{""success"": true, ""total"": " & total & ", ""updated"": " & updated & ", ""errors"": " & errors & ", ""message"": ""Updated " & updated & " of " & total & " warranty records""}" - -objConn.Close - -' Helper function to extract warranty data from JSON -Function ExtractWarrantyData(jsonText, serviceTag, fieldName) - Dim pattern, startPos, endPos, value - pattern = """serviceTag"":""" & serviceTag & """" - startPos = InStr(jsonText, pattern) - - If startPos > 0 Then - ' Find the field within this warranty object - Dim fieldPattern - fieldPattern = """" & fieldName & """:""" - startPos = InStr(startPos, jsonText, fieldPattern) - - If startPos > 0 Then - startPos = startPos + Len(fieldPattern) - endPos = InStr(startPos, jsonText, """") - If endPos > startPos Then - value = Mid(jsonText, startPos, endPos - startPos) - ExtractWarrantyData = value - Exit Function - End If - End If - End If - - ExtractWarrantyData = "" -End Function -%> diff --git a/checkduplicateprinters.asp b/checkduplicateprinters.asp deleted file mode 100644 index 3b205e9..0000000 --- a/checkduplicateprinters.asp +++ /dev/null @@ -1,58 +0,0 @@ - -<% -Response.Write("

Check for Duplicate Printer Machines

") - -Dim strSQL, rs - -' Find duplicates by machinenumber -strSQL = "SELECT machinenumber, COUNT(*) as cnt " &_ - "FROM machines " &_ - "WHERE machinenumber LIKE '%-PRINTER' " &_ - "GROUP BY machinenumber " &_ - "HAVING COUNT(*) > 1 " &_ - "ORDER BY cnt DESC, machinenumber" -set rs = objConn.Execute(strSQL) - -Response.Write("

Duplicate Machine Numbers:

") -Response.Write("") -Response.Write("") -Dim hasDuplicates -hasDuplicates = False -While Not rs.EOF - hasDuplicates = True - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs.MoveNext -Wend -Response.Write("
Machine NumberCount
" & Server.HTMLEncode(rs("machinenumber") & "") & "" & rs("cnt") & "
") - -If Not hasDuplicates Then - Response.Write("

No duplicates found!

") -End If -rs.Close - -' Show all printer machines grouped -Response.Write("

All Printer Machines (grouped by name):

") -strSQL = "SELECT machinenumber, COUNT(*) as cnt, GROUP_CONCAT(machineid) as ids " &_ - "FROM machines " &_ - "WHERE machinetypeid = 15 " &_ - "GROUP BY machinenumber " &_ - "ORDER BY machinenumber" -set rs = objConn.Execute(strSQL) -Response.Write("") -Response.Write("") -While Not rs.EOF - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs.MoveNext -Wend -Response.Write("
Machine NumberCountMachine IDs
" & Server.HTMLEncode(rs("machinenumber") & "") & "" & rs("cnt") & "" & Server.HTMLEncode(rs("ids") & "") & "
") -rs.Close - -objConn.Close -%> diff --git a/checkprintermachinescount.asp b/checkprintermachinescount.asp deleted file mode 100644 index e9cb875..0000000 --- a/checkprintermachinescount.asp +++ /dev/null @@ -1,42 +0,0 @@ - -<% -Response.Write("

Production Printer Machines Count

") - -Dim strSQL, rs - -' Count printer machines -strSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinetypeid = 15" -set rs = objConn.Execute(strSQL) -Response.Write("

Machines with Printer type (machinetypeid=15): " & rs("cnt") & "

") -rs.Close - -' Count machines with -PRINTER suffix -strSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinenumber LIKE '%-PRINTER'" -set rs = objConn.Execute(strSQL) -Response.Write("

Machines with '-PRINTER' suffix: " & rs("cnt") & "

") -rs.Close - -' Show sample -Response.Write("

Sample Printer Machines:

") -strSQL = "SELECT m.machineid, m.machinenumber, m.alias, c.address as ipaddress " &_ - "FROM machines m " &_ - "LEFT JOIN communications c ON m.machineid = c.machineid AND c.comstypeid = 1 " &_ - "WHERE m.machinetypeid = 15 " &_ - "ORDER BY m.machineid DESC LIMIT 10" -set rs = objConn.Execute(strSQL) -Response.Write("") -Response.Write("") -While Not rs.EOF - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs.MoveNext -Wend -Response.Write("
IDMachine NumberAliasIP
" & rs("machineid") & "" & Server.HTMLEncode(rs("machinenumber") & "") & "" & Server.HTMLEncode(rs("alias") & "") & "" & Server.HTMLEncode(rs("ipaddress") & "") & "
") -rs.Close - -objConn.Close -%> diff --git a/cleanupduplicateprintersexecute.asp b/cleanupduplicateprintersexecute.asp deleted file mode 100644 index 21ea354..0000000 --- a/cleanupduplicateprintersexecute.asp +++ /dev/null @@ -1,98 +0,0 @@ - -<% -Response.Write("

Cleanup Duplicate Printer Machines

") - -' First, show what will be deleted -Response.Write("

Records that will be DELETED:

") -Dim strSQL, rs -strSQL = "SELECT m1.machineid, m1.machinenumber, m1.alias, c.address as ipaddress " &_ - "FROM machines m1 " &_ - "LEFT JOIN communications c ON m1.machineid = c.machineid AND c.comstypeid = 1 " &_ - "WHERE m1.machinetypeid = 15 " &_ - "AND m1.machineid NOT IN ( " &_ - " SELECT MIN(m2.machineid) " &_ - " FROM machines m2 " &_ - " WHERE m2.machinetypeid = 15 " &_ - " GROUP BY m2.machinenumber " &_ - ") " &_ - "ORDER BY m1.machinenumber, m1.machineid" -set rs = objConn.Execute(strSQL) - -Response.Write("") -Response.Write("") -Dim deleteCount -deleteCount = 0 -While Not rs.EOF - deleteCount = deleteCount + 1 - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs.MoveNext -Wend -Response.Write("
Machine IDMachine NumberAliasIP
" & rs("machineid") & "" & Server.HTMLEncode(rs("machinenumber") & "") & "" & Server.HTMLEncode(rs("alias") & "") & "" & Server.HTMLEncode(rs("ipaddress") & "") & "
") -rs.Close - -Response.Write("

Total records to delete: " & deleteCount & "

") - -' Now execute the DELETE -Response.Write("

Executing DELETE...

") -On Error Resume Next -strSQL = "DELETE m1 " &_ - "FROM machines m1 " &_ - "WHERE m1.machinetypeid = 15 " &_ - "AND m1.machineid NOT IN ( " &_ - " SELECT * FROM ( " &_ - " SELECT MIN(m2.machineid) " &_ - " FROM machines m2 " &_ - " WHERE m2.machinetypeid = 15 " &_ - " GROUP BY m2.machinenumber " &_ - " ) AS keep_ids " &_ - ")" -objConn.Execute(strSQL) - -If Err.Number <> 0 Then - Response.Write("

ERROR:

") - Response.Write("

Error Number: " & Err.Number & "

") - Response.Write("

Error Description: " & Server.HTMLEncode(Err.Description) & "

") - Err.Clear -Else - Response.Write("

DELETE completed successfully!

") -End If -On Error Goto 0 - -' Verify no duplicates remain -Response.Write("

Verification - Remaining Duplicates:

") -strSQL = "SELECT machinenumber, COUNT(*) as cnt " &_ - "FROM machines " &_ - "WHERE machinetypeid = 15 " &_ - "GROUP BY machinenumber " &_ - "HAVING COUNT(*) > 1" -set rs = objConn.Execute(strSQL) -If rs.EOF Then - Response.Write("

No duplicates remaining! ✓

") -Else - Response.Write("

WARNING: Duplicates still exist!

") - Response.Write("") - Response.Write("") - While Not rs.EOF - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs.MoveNext - Wend - Response.Write("
Machine NumberCount
" & Server.HTMLEncode(rs("machinenumber") & "") & "" & rs("cnt") & "
") -End If -rs.Close - -' Show final count -strSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinetypeid = 15" -set rs = objConn.Execute(strSQL) -Response.Write("

Final printer machine count: " & rs("cnt") & "

") -rs.Close - -objConn.Close -%> diff --git a/deviceswitch.asp.backup b/deviceswitch.asp.backup deleted file mode 100644 index c1b650d..0000000 --- a/deviceswitch.asp.backup +++ /dev/null @@ -1,473 +0,0 @@ - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - Dim serverid, isNewRecord - serverid = Request.QueryString("id") - If serverid = "" Or serverid = "0" Then - isNewRecord = True - serverid = 0 - Else - isNewRecord = False - End If - - ' If editing, fetch existing data - Dim rs, servername, modelid, serialnumber, ipaddress, description, maptop, mapleft, isactive - Dim vendorname, modelnumber - If Not isNewRecord Then - Dim strSQL - strSQL = "SELECT mac.machineid, mac.alias AS servername, mac.modelnumberid AS modelid, " & _ - "mac.serialnumber, mac.machinenotes AS description, mac.maptop, mac.mapleft, mac.isactive, " & _ - "m.modelnumber, v.vendor, c.address AS ipaddress " & _ - "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 = " & serverid & " AND mac.machinetypeid = 30" - Set rs = objConn.Execute(strSQL) - - If rs.EOF Then - Response.Write("Server not found") - Response.End - End If - - If Not IsNull(rs("servername")) Then servername = rs("servername") Else servername = "" - If Not IsNull(rs("modelid")) Then modelid = rs("modelid") Else modelid = "" - If Not IsNull(rs("serialnumber")) Then serialnumber = rs("serialnumber") Else serialnumber = "" - If Not IsNull(rs("ipaddress")) Then ipaddress = rs("ipaddress") Else ipaddress = "" - If Not IsNull(rs("description")) Then description = rs("description") Else description = "" - If Not IsNull(rs("maptop")) Then maptop = rs("maptop") Else maptop = "" - If Not IsNull(rs("mapleft")) Then mapleft = rs("mapleft") Else mapleft = "" - If Not IsNull(rs("isactive")) Then isactive = rs("isactive") Else isactive = 1 - If Not IsNull(rs("vendor")) Then vendorname = rs("vendor") Else vendorname = "" - If Not IsNull(rs("modelnumber")) Then modelnumber = rs("modelnumber") Else modelnumber = "" - - rs.Close - Set rs = Nothing - Else - ' New record defaults - servername = "" - modelid = "" - serialnumber = "" - ipaddress = "" - description = "" - maptop = "" - mapleft = "" - isactive = 1 ' Active by default for new records - vendorname = "" - modelnumber = "" - End If -%> - - - - -
- - -
- - - - -
- -
-
- - -
-
- -
-
- -
-
-
-
-
- - <%If isNewRecord Then Response.Write("Add Server") Else Response.Write("Edit Server: " & Server.HTMLEncode(servername))%> -
-
- -
- - - -
- -
- - - Short name to identify this server - -
-
- -
- -
-
- -
- -
-
- - Select a model or click "New" to add one - -
-
- - - - -
- -
- -
-
- -
- -
- - - IPv4 or IPv6 address - -
-
- -
- -
- - - Optional: Purpose, rack location, or other notes - -
-
- -
- -
-
- > - -
- - Inactive devices are hidden from most lists and the network map - -
-
- - - - - -
- -
- -
- <%If maptop <> "" And mapleft <> "" Then - Response.Write("Current position: X=" & mapleft & ", Y=" & maptop) - Else - Response.Write("No position set - click button to select") - End If%> -
- - Click to select this server's position on the network map - -
-
- -
- -
-
- - - Cancel - - <%If Not isNewRecord Then%> - - <%End If%> -
-
- -
- -
-
-
-
- -
- -
- - - - - -
-
- - -
- - - - - - - - - - - - - - - - - - -<% - objConn.Close -%> diff --git a/displaymachine.asp.backup-20251027 b/displaymachine.asp.backup-20251027 deleted file mode 100644 index 315b77a..0000000 --- a/displaymachine.asp.backup-20251027 +++ /dev/null @@ -1,1192 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - If theme = "" Then - theme = "bg-theme1" - End If - - ' Get and validate machineid parameter - Dim machineid - machineid = Trim(Request.Querystring("machineid")) - - ' Validate machine ID - If Not IsNumeric(machineid) Or CLng(machineid) < 1 Then - Response.Redirect("default.asp") - Response.End - End If - - ' Use LEFT JOINs so query returns data even if printer/PC not associated - strSQL = "SELECT machines.*, machinetypes.*, models.*, businessunits.*, vendors.*, functionalaccounts.*, " & _ - "printers.ipaddress AS printerip, printers.printerid, printers.printercsfname, printers.printerwindowsname, " & _ - "pc.pcid, pc.hostname, pc.loggedinuser AS LoggedInUser, pc_network_interfaces.IPAddress AS pcip " & _ - "FROM machines " & _ - "INNER JOIN machinetypes ON machines.machinetypeid = machinetypes.machinetypeid " & _ - "INNER JOIN models ON machines.modelnumberid = models.modelnumberid " & _ - "INNER JOIN businessunits ON machines.businessunitid = businessunits.businessunitid " & _ - "INNER JOIN functionalaccounts ON machinetypes.functionalaccountid = functionalaccounts.functionalaccountid " & _ - "INNER JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "LEFT JOIN printers ON machines.printerid = printers.printerid " & _ - "LEFT JOIN pc ON pc.machinenumber = machines.machinenumber " & _ - "LEFT JOIN pc_network_interfaces ON pc_network_interfaces.pcid = pc.pcid AND pc_network_interfaces.DefaultGateway IS NOT NULL " & _ - "WHERE machines.machineid = " & CLng(machineid) - - Set rs = objConn.Execute(strSQL) - - ' Check if machine exists - If rs.EOF Then - rs.Close - Set rs = Nothing - Response.Redirect("default.asp") - Response.End - End If -%> - - - - -
- - -
- - - - -
- -
-
- -
-
-
-
- " alt="Card image cap"> -
-
- " alt="profile-image" class="profile"> -
<%If Not IsNull(rs("machinenumber")) Then Response.Write(Server.HTMLEncode(rs("machinenumber"))) End If%>
-
<%If Not IsNull(rs("vendor")) Then Response.Write(Server.HTMLEncode(rs("vendor"))) End If%>
-
<%If Not IsNull(rs("machinetype")) Then Response.Write(Server.HTMLEncode(rs("machinetype"))) End If%>
-

<%If Not IsNull(rs("machinedescription")) Then Response.Write(Server.HTMLEncode(rs("machinedescription"))) End If%>

-
- -
-
- -
-
-
- -
-
-
Configuration
-
-
-

Location:

-

Vendor:

-

Model:

-

Function:

-

BU:

-

PC:

-

IP:

-

User:

-

Printer:

-

- -

-
-
-

- - <%Response.Write(rs("machinenumber"))%> - -

-

<%Response.Write(rs("vendor"))%>

-

<%Response.Write(rs("modelnumber"))%>

-

<%Response.Write(rs("machinetype"))%>

-

<%Response.Write(rs("businessunit"))%>

-<% -' PC data - check if exists (LEFT JOIN may return NULL) -If Not IsNull(rs("pcip")) And rs("pcip") <> "" Then - Response.Write("

" & rs("hostname") & "

") - Response.Write("

" & rs("pcip") & "

") - If Not IsNull(rs("LoggedInUser")) Then - Response.Write("

" & rs("LoggedInUser") & "

") - Else - Response.Write("

 

") - End If -Else - Response.Write("

No PC assigned

") - Response.Write("

 

") - Response.Write("

 

") -End If - -' Printer data - check if exists (LEFT JOIN may return NULL) -If Not IsNull(rs("printerid")) And rs("printerid") <> "" Then - Response.Write("

" & rs("printerwindowsname") & "

") -Else - Response.Write("

No printer assigned

") -End If -%> -
-
-
-
-
-
- -
-
-
- - -<% - strSQL2 = "SELECT * FROM installedapps, applications WHERE installedapps.appid = applications.appid AND installedapps.isactive = 1 AND installedapps.machineid = " & CLng(machineid) & " ORDER BY appname ASC" - Set rs2 = objConn.Execute(strSQL2) - Do While Not rs2.EOF - Response.Write("") - rs2.MoveNext - Loop - rs2.Close - Set rs2 = Nothing -%> - -
" & Server.HTMLEncode(rs2("appname")) & "
-
-
-
-
-
- -
- -
-
-
- -
-
- -
- -
-
- - - -
-
-
- -
-
- -
- -
-
- - - -
-
-
- -
-
- -
- -
-
- - - -
-
-
- -
- -
-
- - "> - "> - -
- -
- -
- Current position: X=<%Response.Write(rs("mapleft"))%>, Y=<%Response.Write(rs("maptop"))%> -
-
-
-
- -
-
- -
-
-
- -
-
-
-
-
- -
- - -
- - -
- -
- - - - - -
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Select Machine Location - -
-
-
-
-
- Click on the map to select a location -
- - -
-
-
-
- - - - - -<% - objConn.Close -%> \ No newline at end of file diff --git a/displaymachine.asp.backup2 b/displaymachine.asp.backup2 deleted file mode 100644 index 8e6e917..0000000 --- a/displaymachine.asp.backup2 +++ /dev/null @@ -1,1674 +0,0 @@ -<% -'============================================================================= -' FILE: displaymachine.asp -' PURPOSE: Display detailed machine information with edit capability -' SECURITY: Parameterized queries, HTML encoding, input validation -' UPDATED: 2025-10-27 - Migrated to secure patterns -'============================================================================= -%> - - - - - - - - - - -<% - theme = Request.Cookies("theme") - If theme = "" Then - theme = "bg-theme1" - End If - - '============================================================================= - ' SECURITY: Validate machineid or machinenumber parameter - ' NOTE: This handles both database ID and machine number for flexibility - '============================================================================= - Dim machineid, machinenumber, paramValue - machineid = GetSafeInteger("QS", "machineid", 0, 1, 999999) - - ' If machineid not provided, try machinenumber parameter - IF machineid = 0 THEN - machinenumber = Request.QueryString("machinenumber") - IF machinenumber <> "" THEN - ' Look up machineid by machinenumber - Dim rsLookup, strLookupSQL - strLookupSQL = "SELECT machineid FROM machines WHERE machinenumber = ? AND isactive = 1" - Set rsLookup = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(machinenumber)) - IF NOT rsLookup.EOF THEN - machineid = rsLookup("machineid") - END IF - rsLookup.Close - Set rsLookup = Nothing - END IF - ELSE - ' We have a machineid, but it might actually be a machine number - ' Try to look it up as a machineid first - Dim rsCheck - strLookupSQL = "SELECT machineid FROM machines WHERE machineid = ? AND isactive = 1" - Set rsCheck = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(machineid)) - - ' If no machine found with that machineid, try treating it as a machine number - IF rsCheck.EOF THEN - rsCheck.Close - strLookupSQL = "SELECT machineid FROM machines WHERE machinenumber = ? AND isactive = 1" - Set rsCheck = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(CStr(machineid))) - IF NOT rsCheck.EOF THEN - machineid = rsCheck("machineid") - ELSE - machineid = 0 ' Not found - END IF - END IF - rsCheck.Close - Set rsCheck = Nothing - END IF - - IF machineid = 0 THEN - objConn.Close - Response.Redirect("default.asp") - Response.End - END IF - - '============================================================================= - ' SECURITY: Use parameterized query to prevent SQL injection - '============================================================================= - strSQL = "SELECT machines.*, machinetypes.*, models.*, businessunits.*, vendors.*, functionalaccounts.*, " & _ - "printers.ipaddress AS printerip, printers.printerid, printers.printercsfname, printers.printerwindowsname, " & _ - "pc.pcid, pc.hostname, pc.loggedinuser AS LoggedInUser, pc_network_interfaces.IPAddress AS pcip " & _ - "FROM machines " & _ - "INNER JOIN models ON machines.modelnumberid = models.modelnumberid " & _ - "LEFT JOIN machinetypes ON models.machinetypeid = machinetypes.machinetypeid " & _ - "INNER JOIN businessunits ON machines.businessunitid = businessunits.businessunitid " & _ - "LEFT JOIN functionalaccounts ON machinetypes.functionalaccountid = functionalaccounts.functionalaccountid " & _ - "INNER JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "LEFT JOIN printers ON machines.printerid = printers.printerid " & _ - "LEFT JOIN pc ON pc.machinenumber = machines.machinenumber " & _ - "LEFT JOIN pc_network_interfaces ON pc_network_interfaces.pcid = pc.pcid AND pc_network_interfaces.DefaultGateway IS NOT NULL " & _ - "WHERE machines.machineid = ?" - - Set rs = ExecuteParameterizedQuery(objConn, strSQL, Array(machineid)) - - ' Check if machine exists - If rs.EOF Then - rs.Close - Set rs = Nothing - objConn.Close - Response.Redirect("default.asp") - Response.End - End If -%> - - - - -
- - -
- - - - -
- -
-
- -
-
-
-
- " alt="Card image cap"> -
-
- " alt="profile-image" class="profile"> -
<%=Server.HTMLEncode(rs("machinenumber") & "")%>
-
<%=Server.HTMLEncode(rs("vendor") & "")%>
-
<%=Server.HTMLEncode(rs("machinetype") & "")%>
-

<%=Server.HTMLEncode(rs("machinedescription") & "")%>

-
- -
-
- -
-
-
- -
-
-
Configuration
-
-
-

Location:

-

Vendor:

-

Model:

-

Function:

-

BU:

-

IP Address:

-

MAC Address:

-

Controlling PC:

-

Printer:

-

- -

-
-
-<% -Dim machineNumVal, vendorValM, modelValM, machineTypeVal, buVal - -' Get values and default to N/A if empty -machineNumVal = rs("machinenumber") & "" -If machineNumVal = "" Then machineNumVal = "N/A" - -vendorValM = rs("vendor") & "" -If vendorValM = "" Then vendorValM = "N/A" - -modelValM = rs("modelnumber") & "" -If modelValM = "" Then modelValM = "N/A" - -machineTypeVal = rs("machinetype") & "" -If machineTypeVal = "" Then machineTypeVal = "N/A" - -buVal = rs("businessunit") & "" -If buVal = "" Then buVal = "N/A" -%> -

-<% -If machineNumVal <> "N/A" Then -%> - - <%=Server.HTMLEncode(machineNumVal)%> - -<% -Else - Response.Write("N/A") -End If -%> -

-

<%=Server.HTMLEncode(vendorValM)%>

-

<%=Server.HTMLEncode(modelValM)%>

-

<%=Server.HTMLEncode(machineTypeVal)%>

-

<%=Server.HTMLEncode(buVal)%>

-<% -' Get primary communication (IP and MAC) from communications table -Dim rsPrimaryCom, strPrimaryComSQL, primaryIP, primaryMAC -strPrimaryComSQL = "SELECT address, macaddress FROM communications WHERE machineid = ? AND isprimary = 1 AND isactive = 1 LIMIT 1" -Set rsPrimaryCom = ExecuteParameterizedQuery(objConn, strPrimaryComSQL, Array(machineid)) - -If Not rsPrimaryCom.EOF Then - primaryIP = rsPrimaryCom("address") & "" - primaryMAC = rsPrimaryCom("macaddress") & "" -Else - ' Try to get first active communication if no primary set - rsPrimaryCom.Close - strPrimaryComSQL = "SELECT address, macaddress FROM communications WHERE machineid = ? AND isactive = 1 ORDER BY comid LIMIT 1" - Set rsPrimaryCom = ExecuteParameterizedQuery(objConn, strPrimaryComSQL, Array(machineid)) - If Not rsPrimaryCom.EOF Then - primaryIP = rsPrimaryCom("address") & "" - primaryMAC = rsPrimaryCom("macaddress") & "" - Else - primaryIP = "" - primaryMAC = "" - End If -End If -rsPrimaryCom.Close -Set rsPrimaryCom = Nothing - -' Display IP Address -If primaryIP <> "" Then - Response.Write("

" & Server.HTMLEncode(primaryIP) & "

") -Else - Response.Write("

N/A

") -End If - -' Display MAC Address -If primaryMAC <> "" Then - Response.Write("

" & Server.HTMLEncode(primaryMAC) & "

") -Else - Response.Write("

N/A

") -End If - -' Get controlling PC from relationships -Dim rsControlPC, strControlPCSQL, controlPCHostname, controlPCID -strControlPCSQL = "SELECT m.machineid, m.hostname, m.machinenumber FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.machineid = m.machineid " & _ - "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1 LIMIT 1" -Set rsControlPC = ExecuteParameterizedQuery(objConn, strControlPCSQL, Array(machineid)) - -If Not rsControlPC.EOF Then - controlPCHostname = rsControlPC("hostname") & "" - controlPCID = rsControlPC("machineid") - If controlPCHostname = "" Then controlPCHostname = rsControlPC("machinenumber") & "" - Response.Write("

" & Server.HTMLEncode(controlPCHostname) & "

") -Else - Response.Write("

N/A

") -End If -rsControlPC.Close -Set rsControlPC = Nothing - -' SECURITY: HTML encode printer data to prevent XSS -' Printer data - check if exists (LEFT JOIN may return NULL) -If Not IsNull(rs("printerid")) And rs("printerid") <> "" Then - Dim printerNameVal - printerNameVal = rs("printerwindowsname") & "" - If printerNameVal = "" Then printerNameVal = "Printer #" & rs("printerid") - - Response.Write("

" & Server.HTMLEncode(printerNameVal) & "

") -Else - Response.Write("

N/A

") -End If -%> -
-
-
-
-
-
- -
-
-
Network Communications
-
- - - - - - - - - - - - -<% - ' Query communications for this machine - strSQL2 = "SELECT c.*, ct.typename FROM communications c " & _ - "JOIN comstypes ct ON c.comstypeid = ct.comstypeid " & _ - "WHERE c.machineid = ? AND c.isactive = 1 ORDER BY c.isprimary DESC, c.comid ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim ipAddr, macAddr, ifaceName, isPrimary, statusBadge - ipAddr = rs2("address") & "" - macAddr = rs2("macaddress") & "" - ifaceName = rs2("interfacename") & "" - isPrimary = rs2("isprimary") - - If ipAddr = "" Then ipAddr = "N/A" - If macAddr = "" Then macAddr = "N/A" - If ifaceName = "" Then ifaceName = "N/A" - - If isPrimary Then - statusBadge = "Primary" - Else - statusBadge = "" - End If - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
TypeIP AddressMAC AddressInterfacePrimaryStatus
No network communications configured
" & Server.HTMLEncode(rs2("typename") & "") & "" & ipAddr & "" & macAddr & "" & ifaceName & "" & statusBadge & "Active
-
-
-
-
Machine Relationships
- - -
Controlled By PC
-
- - - - - - - - - -<% - ' Query PCs that control this machine - strSQL2 = "SELECT m.machineid, m.machinenumber, m.hostname, c.address, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.machineid = m.machineid " & _ - "LEFT JOIN communications c ON m.machineid = c.machineid AND c.isprimary = 1 " & _ - "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim pcHostname, pcIP, pcMachineID - pcHostname = rs2("hostname") & "" - pcIP = rs2("address") & "" - pcMachineID = rs2("machineid") - - If pcHostname = "" Then pcHostname = rs2("machinenumber") & "" - If pcIP = "" Then pcIP = "N/A" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
PC HostnameIP AddressRelationship
No controlling PC assigned
" & Server.HTMLEncode(pcHostname) & "" & pcIP & "" & Server.HTMLEncode(rs2("relationshiptype") & "") & "
-
- - -
Dualpath / Redundant Machines
-
- - - - - - - - - - -<% - ' Query dualpath relationships - strSQL2 = "SELECT m.machineid, m.machinenumber, mt.machinetype, mo.modelnumber, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.related_machineid = m.machineid " & _ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ - "WHERE mr.machineid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim dualMachineNum, dualType, dualModel, dualMachineID - dualMachineNum = rs2("machinenumber") & "" - dualType = rs2("machinetype") & "" - dualModel = rs2("modelnumber") & "" - dualMachineID = rs2("machineid") - - If dualType = "" Then dualType = "N/A" - If dualModel = "" Then dualModel = "N/A" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
Machine NumberTypeModelRelationship
No dualpath relationships
" & Server.HTMLEncode(dualMachineNum) & "" & dualType & "" & dualModel & "" & Server.HTMLEncode(rs2("relationshiptype") & "") & "
-
-
-
-
Compliance & Security
-<% - ' Query compliance data - strSQL2 = "SELECT * FROM compliance WHERE machineid = ?" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If Not rs2.EOF Then -%> -
-
-

Third Party Managed:

-

Third Party Manager:

-

OT Asset System:

-

DoD Asset Device Type:

-

Compliant:

-
-
-<% - Dim thirdPartyManaged, thirdPartyManager, otAssetSystem, dodAssetDeviceType, isCompliant - thirdPartyManaged = rs2("is_third_party_managed") & "" - thirdPartyManager = rs2("third_party_manager") & "" - otAssetSystem = rs2("ot_asset_system") & "" - dodAssetDeviceType = rs2("ot_asset_device_type") & "" - isCompliant = rs2("is_compliant") - - ' Third party managed badge - Dim tpmBadge - If thirdPartyManaged = "Yes" Then - tpmBadge = "Yes" - ElseIf thirdPartyManaged = "No" Then - tpmBadge = "No" - Else - tpmBadge = "N/A" - End If -%> -

<%=tpmBadge%>

-

<%=Server.HTMLEncode(thirdPartyManager)%>

-

<%=Server.HTMLEncode(otAssetSystem)%>

-

<%=Server.HTMLEncode(dodAssetDeviceType)%>

-

-<% - If Not IsNull(isCompliant) Then - If isCompliant Then - Response.Write("Yes") - Else - Response.Write("No") - End If - Else - Response.Write("Not Assessed") - End If -%> -

-
-
- -
- -
Security Scans
-
- - - - - - - - - - -<% - rs2.Close - Set rs2 = Nothing - - ' Query security scans - strSQL2 = "SELECT * FROM compliancescans WHERE machineid = ? ORDER BY scan_date DESC LIMIT 10" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim scanName, scanDate, scanResult, scanDetails, resultBadge - scanName = rs2("scan_name") & "" - scanDate = rs2("scan_date") & "" - scanResult = rs2("scan_result") & "" - scanDetails = rs2("scan_details") & "" - - If scanName = "" Then scanName = "Security Scan" - If scanDetails = "" Then scanDetails = "No details" - - ' Result badge - Select Case LCase(scanResult) - Case "pass" - resultBadge = "Pass" - Case "fail" - resultBadge = "Fail" - Case "warning" - resultBadge = "Warning" - Case Else - resultBadge = "Info" - End Select - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
Scan NameDateResultDetails
No security scans recorded
" & Server.HTMLEncode(scanName) & "" & Server.HTMLEncode(scanDate) & "" & resultBadge & "" & scanDetails & "
-
-<% - Else - Response.Write("

No compliance data available for this machine.

") - rs2.Close - Set rs2 = Nothing - End If -%> -
-
-
- - -<% - '============================================================================= - ' SECURITY: Use parameterized query for installed applications - '============================================================================= - strSQL2 = "SELECT * FROM installedapps, applications WHERE installedapps.appid = applications.appid AND installedapps.isactive = 1 AND installedapps.machineid = ? ORDER BY appname ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - Do While Not rs2.EOF - Response.Write("") - rs2.MoveNext - Loop - rs2.Close - Set rs2 = Nothing -%> - -
" & Server.HTMLEncode(rs2("appname") & "") & "
-
-
- - - -
-
-
- -
-
- -
- -
-
- - - -
-
-
- -
- -
-
- - "> - "> - -
- -
- -
- Current position: X=<%=Server.HTMLEncode(rs("mapleft") & "")%>, Y=<%=Server.HTMLEncode(rs("maptop") & "")%> -
-
-
-
- -
-
- -
-
-
- -
- --> -
-
-
-
- -
- - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Select Machine Location - -
-
-
-
-
- Click on the map to select a location -
- - -
-
-
-
- - - - - -<% -'============================================================================= -' CLEANUP -'============================================================================= -objConn.Close -%> diff --git a/displaymachine.asp.bak b/displaymachine.asp.bak deleted file mode 100644 index 682cf76..0000000 --- a/displaymachine.asp.bak +++ /dev/null @@ -1,793 +0,0 @@ -<% -'============================================================================= -' FILE: displaymachine.asp -' PURPOSE: Display detailed machine information with edit capability -' SECURITY: Parameterized queries, HTML encoding, input validation -' UPDATED: 2025-11-07 - Fixed for Phase 2 schema (machines + communications) -'============================================================================= -%> - - - - - - - - - - -<% - theme = Request.Cookies("theme") - If theme = "" Then - theme = "bg-theme1" - End If - - '============================================================================= - ' SECURITY: Validate machineid parameter - '============================================================================= - Dim machineid - machineid = GetSafeInteger("QS", "machineid", 0, 1, 999999) - - IF machineid = 0 THEN - objConn.Close - Response.Redirect("default.asp") - Response.End - END IF - - '============================================================================= - ' PHASE 2 SCHEMA: Query machines table with LEFT JOINs for optional data - ' - No more pc/pc_network_interfaces/pc_dualpath_assignments tables - ' - Use communications for network interfaces - ' - Use machinerelationships for dualpath relationships - ' - Use compliance for compliance data - '============================================================================= - strSQL = "SELECT machines.*, models.modelnumber, vendors.vendor, " & _ - "businessunits.businessunit, machinetypes.machinetype " & _ - "FROM machines " & _ - "INNER JOIN models ON machines.modelnumberid = models.modelnumberid " & _ - "INNER JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "INNER JOIN businessunits ON machines.businessunitid = businessunits.businessunitid " & _ - "LEFT JOIN machinetypes ON models.machinetypeid = machinetypes.machinetypeid " & _ - "WHERE machines.machineid = ?" - - Set rs = ExecuteParameterizedQuery(objConn, strSQL, Array(machineid)) - - ' Check if machine exists - If rs.EOF Then - rs.Close - Set rs = Nothing - objConn.Close - Response.Redirect("default.asp") - Response.End - End If - - '============================================================================= - ' Get primary network interface from communications table - '============================================================================= - Dim rsPrimaryNetwork, primaryIP, primaryMAC, primaryHostname, primaryInterface - primaryIP = "" - primaryMAC = "" - primaryHostname = "" - primaryInterface = "" - - ' Get hostname from machines table (for PCs) - If Not IsNull(rs("hostname")) And rs("hostname") & "" <> "" Then - primaryHostname = rs("hostname") & "" - End If - - ' Query for primary network interface - strSQL = "SELECT c.address, c.macaddress, c.interfacename " & _ - "FROM communications c " & _ - "INNER JOIN comstypes ct ON c.comstypeid = ct.comstypeid " & _ - "WHERE c.machineid = ? AND ct.typename = 'Network_Interface' " & _ - "AND c.isactive = 1 AND c.isprimary = 1 " & _ - "LIMIT 1" - Set rsPrimaryNetwork = ExecuteParameterizedQuery(objConn, strSQL, Array(machineid)) - - If Not rsPrimaryNetwork.EOF Then - primaryIP = rsPrimaryNetwork("address") & "" - If Not IsNull(rsPrimaryNetwork("macaddress")) Then - primaryMAC = rsPrimaryNetwork("macaddress") & "" - End If - If Not IsNull(rsPrimaryNetwork("interfacename")) Then - primaryInterface = rsPrimaryNetwork("interfacename") & "" - End If - End If - rsPrimaryNetwork.Close - Set rsPrimaryNetwork = Nothing - - ' If no primary, get the first network interface - If primaryIP = "" Then - strSQL = "SELECT c.address, c.macaddress, c.interfacename " & _ - "FROM communications c " & _ - "INNER JOIN comstypes ct ON c.comstypeid = ct.comstypeid " & _ - "WHERE c.machineid = ? AND ct.typename = 'Network_Interface' " & _ - "AND c.isactive = 1 " & _ - "ORDER BY c.comid ASC LIMIT 1" - Set rsPrimaryNetwork = ExecuteParameterizedQuery(objConn, strSQL, Array(machineid)) - - If Not rsPrimaryNetwork.EOF Then - primaryIP = rsPrimaryNetwork("address") & "" - If Not IsNull(rsPrimaryNetwork("macaddress")) Then - primaryMAC = rsPrimaryNetwork("macaddress") & "" - End If - If Not IsNull(rsPrimaryNetwork("interfacename")) Then - primaryInterface = rsPrimaryNetwork("interfacename") & "" - End If - End If - rsPrimaryNetwork.Close - Set rsPrimaryNetwork = Nothing - End If - - '============================================================================= - ' Query dualpath relationships from machinerelationships table - '============================================================================= - Dim rsDualpath, isDualpath, relatedMachineNumber, relatedMachineId - isDualpath = False - relatedMachineNumber = "" - relatedMachineId = 0 - - strSQL = "SELECT mr.related_machineid, m2.machinenumber " & _ - "FROM machinerelationships mr " & _ - "INNER JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "INNER JOIN machines m2 ON mr.related_machineid = m2.machineid " & _ - "WHERE mr.machineid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1 " & _ - "LIMIT 1" - Set rsDualpath = ExecuteParameterizedQuery(objConn, strSQL, Array(machineid)) - - If Not rsDualpath.EOF Then - isDualpath = True - relatedMachineId = rsDualpath("related_machineid") - relatedMachineNumber = rsDualpath("machinenumber") & "" - End If - rsDualpath.Close - Set rsDualpath = Nothing -%> - - - - -
- - -
- - - - -
- -
-
- -
-
-
-
- " alt="Card image cap"> -
-
- " alt="profile-image" class="profile"> -
<%=Server.HTMLEncode(rs("machinenumber") & "")%>
-
<%=Server.HTMLEncode(rs("vendor") & "")%>
-
<%=Server.HTMLEncode(rs("machinetype") & "")%>
-

<%=Server.HTMLEncode(rs("machinedescription") & "")%>

-
- -
-
- -
-
-
- -
-
-
Configuration
-
-
-

Machine #:

-

Alias:

-

Hostname:

-

Location:

-

Vendor:

-

Model:

-

Type:

-

BU:

-

Controller:

-

Serial #:

-

IP Address:

-

VLAN:

-

Criticality:

-

Printer:

-<% If isDualpath Then %> -

Dualpath:

-<% End If %> -

- -

-
-
-<% -Dim machineNumVal, aliasVal, hostnameVal, vendorValM, modelValM, machineTypeVal, buVal - -' Get values and default to N/A if empty -machineNumVal = rs("machinenumber") & "" -If machineNumVal = "" Then machineNumVal = "N/A" - -aliasVal = rs("alias") & "" -If aliasVal = "" Then aliasVal = "N/A" - -hostnameVal = primaryHostname -If hostnameVal = "" Then hostnameVal = "N/A" - -vendorValM = rs("vendor") & "" -If vendorValM = "" Then vendorValM = "N/A" - -modelValM = rs("modelnumber") & "" -If modelValM = "" Then modelValM = "N/A" - -machineTypeVal = rs("machinetype") & "" -If machineTypeVal = "" Then machineTypeVal = "N/A" - -buVal = rs("businessunit") & "" -If buVal = "" Then buVal = "N/A" -%> -

-<% -If machineNumVal <> "N/A" Then -%> - - <%=Server.HTMLEncode(machineNumVal)%> - -<% -Else - Response.Write("N/A") -End If -%> -

-

<%=Server.HTMLEncode(aliasVal)%>

-

-<% -If hostnameVal <> "N/A" And primaryIP <> "" Then -%> - <%=Server.HTMLEncode(hostnameVal)%> -<% -Else - Response.Write(Server.HTMLEncode(hostnameVal)) -End If -%> -

-

-<% -' Map location display -Dim mapLeft, mapTop -mapLeft = rs("mapleft") & "" -mapTop = rs("maptop") & "" -If mapLeft <> "" And mapTop <> "" Then - Response.Write(" Shop Floor (" & Server.HTMLEncode(mapLeft) & ", " & Server.HTMLEncode(mapTop) & ")") -Else - Response.Write("N/A") -End If -%> -

-

<%=Server.HTMLEncode(vendorValM)%>

-

<%=Server.HTMLEncode(modelValM)%>

-

<%=Server.HTMLEncode(machineTypeVal)%>

-

<%=Server.HTMLEncode(buVal)%>

-<% -' Controller information -' Controller info commented out - not in simplified query -' If Not IsNull(rs("controller_vendor")) And rs("controller_vendor") & "" <> "" Then -' Dim controllerDisplay -' controllerDisplay = rs("controller_vendor") & "" -' If Not IsNull(rs("controller_model")) And rs("controller_model") & "" <> "" Then -' controllerDisplay = controllerDisplay & " " & rs("controller_model") & "" -' End If -' Response.Write("

" & Server.HTMLEncode(controllerDisplay) & "

") -' Else - Response.Write("

N/A

") -' End If - -' Serial number -If Not IsNull(rs("serialnumber")) And rs("serialnumber") & "" <> "" Then - Response.Write("

" & Server.HTMLEncode(rs("serialnumber") & "") & "

") -Else - Response.Write("

N/A

") -End If - -' IP Address -If primaryIP <> "" Then - Response.Write("

" & Server.HTMLEncode(primaryIP) & "

") -Else - Response.Write("

N/A

") -End If - -' VLAN -If Not IsNull(rs("vlan")) And rs("vlan") & "" <> "" Then - Response.Write("

VLAN " & Server.HTMLEncode(rs("vlan") & "") & "

") -Else - Response.Write("

N/A

") -End If - -' Asset Criticality -If Not IsNull(rs("asset_criticality")) And rs("asset_criticality") & "" <> "" Then - Dim criticalityBadge, criticalityVal - criticalityVal = rs("asset_criticality") & "" - Select Case UCase(criticalityVal) - Case "HIGH" - criticalityBadge = " High" - Case "MEDIUM" - criticalityBadge = "Medium" - Case "LOW" - criticalityBadge = "Low" - Case Else - criticalityBadge = Server.HTMLEncode(criticalityVal) - End Select - Response.Write("

" & criticalityBadge & "

") -Else - Response.Write("

N/A

") -End If - -' Printer data - check if exists (LEFT JOIN may return NULL) -If Not IsNull(rs("printerid")) And rs("printerid") <> "" Then - Dim printerNameVal - printerNameVal = rs("printerwindowsname") & "" - If printerNameVal = "" Then printerNameVal = "Printer #" & rs("printerid") - - Response.Write("

" & Server.HTMLEncode(printerNameVal) & "

") -Else - Response.Write("

N/A

") -End If - -' Dualpath information -If isDualpath Then - Response.Write("

" & Server.HTMLEncode(relatedMachineNumber) & "

") -End If -%> -
-
-
Notes
- -
-
- -
- -
-
Network Interfaces
-
- - - - - - - - - - - -<% - '============================================================================= - ' Query all network interfaces from communications table - '============================================================================= - strSQL2 = "SELECT c.address, c.macaddress, c.interfacename, c.isprimary, c.isdhcp " & _ - "FROM communications c " & _ - "INNER JOIN comstypes ct ON c.comstypeid = ct.comstypeid " & _ - "WHERE c.machineid = ? AND ct.typename = 'Network_Interface' AND c.isactive = 1 " & _ - "ORDER BY c.isprimary DESC, c.comid ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim interfaceNameVal, ipAddressVal, macAddressVal, isPrimaryVal, isDHCPVal - - interfaceNameVal = rs2("interfacename") & "" - If interfaceNameVal = "" Then interfaceNameVal = "Unknown" - - ipAddressVal = rs2("address") & "" - If ipAddressVal = "" Then ipAddressVal = "N/A" - - macAddressVal = rs2("macaddress") & "" - If macAddressVal = "" Then macAddressVal = "N/A" - - isPrimaryVal = rs2("isprimary") - isDHCPVal = rs2("isdhcp") - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - - If isDHCPVal = 1 Or isDHCPVal = True Then - Response.Write("") - Else - Response.Write("") - End If - - If isPrimaryVal = 1 Or isPrimaryVal = True Then - Response.Write("") - Else - Response.Write("") - End If - - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
InterfaceIP AddressMAC AddressTypePrimary
No network interfaces found
" & Server.HTMLEncode(interfaceNameVal) & "" & Server.HTMLEncode(ipAddressVal) & "" & Server.HTMLEncode(macAddressVal) & "DHCPStatic
-
- -
Other Communications
-
- - - - - - - - - - -<% - '============================================================================= - ' Query other communication types (Serial, IP, USB, etc.) - '============================================================================= - strSQL2 = "SELECT c.address, c.port, c.portname, c.description, c.baud, c.databits, c.stopbits, c.parity, ct.typename " & _ - "FROM communications c " & _ - "INNER JOIN comstypes ct ON c.comstypeid = ct.comstypeid " & _ - "WHERE c.machineid = ? AND ct.typename != 'Network_Interface' AND c.isactive = 1 " & _ - "ORDER BY ct.typename, c.comid ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim typeNameVal, addressVal, detailsVal, descriptionVal - - typeNameVal = rs2("typename") & "" - addressVal = rs2("address") & "" - - ' Build details based on type - detailsVal = "" - If typeNameVal = "Serial" Then - If Not IsNull(rs2("baud")) Then detailsVal = rs2("baud") & " baud" - If Not IsNull(rs2("databits")) And rs2("databits") & "" <> "" Then - If detailsVal <> "" Then detailsVal = detailsVal & ", " - detailsVal = detailsVal & rs2("databits") & "N" & rs2("stopbits") & "" - End If - ElseIf typeNameVal = "IP" Then - If Not IsNull(rs2("port")) Then detailsVal = "Port " & rs2("port") - End If - - descriptionVal = rs2("description") & "" - If descriptionVal = "" Then descriptionVal = "-" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
TypeAddress/PortDetailsDescription
No other communications found
" & Server.HTMLEncode(typeNameVal) & "" & Server.HTMLEncode(addressVal) & "" & Server.HTMLEncode(detailsVal) & "" & Server.HTMLEncode(descriptionVal) & "
-
-
- -
-
Machine Relationships
-
- - - - - - - - - -<% - '============================================================================= - ' Query machine relationships from machinerelationships table - '============================================================================= - strSQL2 = "SELECT mr.related_machineid, mr.relationship_notes, rt.relationshiptype, m2.machinenumber " & _ - "FROM machinerelationships mr " & _ - "INNER JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "INNER JOIN machines m2 ON mr.related_machineid = m2.machineid " & _ - "WHERE mr.machineid = ? AND mr.isactive = 1 " & _ - "ORDER BY rt.relationshiptype, m2.machinenumber" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim relationshipTypeVal, relatedMachineVal, notesVal - - relationshipTypeVal = rs2("relationshiptype") & "" - relatedMachineVal = rs2("machinenumber") & "" - notesVal = rs2("relationship_notes") & "" - If notesVal = "" Then notesVal = "-" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
Relationship TypeRelated MachineNotes
No relationships found
" & Server.HTMLEncode(relationshipTypeVal) & "" & Server.HTMLEncode(relatedMachineVal) & "" & Server.HTMLEncode(notesVal) & "
-
-
- -
-
Compliance & Security
-
-
-
Management & Access
-

Third Party Managed:

-

-<% -If Not IsNull(rs("is_third_party_managed")) And rs("is_third_party_managed") & "" <> "" Then - Dim thirdPartyVal - thirdPartyVal = rs("is_third_party_managed") & "" - If UCase(thirdPartyVal) = "YES" Or thirdPartyVal = "Yes" Then - Response.Write("Yes") - ElseIf UCase(thirdPartyVal) = "NO" Or thirdPartyVal = "No" Then - Response.Write("No") - Else - Response.Write(Server.HTMLEncode(thirdPartyVal)) - End If -Else - Response.Write("Not Specified") -End If -%> -

- -

Managed By:

-

-<% -If Not IsNull(rs("third_party_manager")) And rs("third_party_manager") & "" <> "" Then - Response.Write(" " & Server.HTMLEncode(rs("third_party_manager") & "") & "") -Else - Response.Write("Not Specified") -End If -%> -

- -

Last Scan:

-

-<% -If Not IsNull(rs("scan_date")) And rs("scan_date") & "" <> "" Then - Response.Write(Server.HTMLEncode(rs("scan_date") & "")) -Else - Response.Write("Never Scanned") -End If -%> -

- -

Scan Result:

-

-<% -If Not IsNull(rs("scan")) And rs("scan") & "" <> "" Then - Response.Write(Server.HTMLEncode(rs("scan") & "")) -Else - Response.Write("N/A") -End If -%> -

-
- -
-
OT Asset Information
- -

OT Asset System:

-

-<% -If Not IsNull(rs("ot_asset_system")) And rs("ot_asset_system") & "" <> "" Then - Response.Write(Server.HTMLEncode(rs("ot_asset_system") & "")) -Else - Response.Write("Not Specified") -End If -%> -

- -

OT Device Type:

-

-<% -If Not IsNull(rs("ot_asset_device_type")) And rs("ot_asset_device_type") & "" <> "" Then - Response.Write(Server.HTMLEncode(rs("ot_asset_device_type") & "")) -Else - Response.Write("Not Specified") -End If -%> -

- -

MFT:

-

-<% -If Not IsNull(rs("mft")) And rs("mft") & "" <> "" Then - Response.Write(Server.HTMLEncode(rs("mft") & "")) -Else - Response.Write("Not Specified") -End If -%> -

- -

Deployment Notes:

-

-<% -' TEXT fields in MySQL require special handling in classic ASP -Dim deploymentNotesValue -On Error Resume Next -deploymentNotesValue = "" -If Not IsNull(rs("deployment_notes")) Then - deploymentNotesValue = rs("deployment_notes").Value -End If -On Error Goto 0 - -If deploymentNotesValue <> "" And Not IsNull(deploymentNotesValue) Then - Response.Write("" & Server.HTMLEncode(deploymentNotesValue) & "") -Else - Response.Write("No deployment notes") -End If -%> -

-
-
-
- -
-
- - - - - - - - -<% - '============================================================================= - ' SECURITY: Use parameterized query for installed applications - '============================================================================= - strSQL2 = "SELECT app.appname, ia.version " & _ - "FROM installedapps ia " & _ - "INNER JOIN applications app ON ia.appid = app.appid " & _ - "WHERE ia.machineid = ? AND ia.isactive = 1 " & _ - "ORDER BY app.appname ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(machineid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim appNameVal, versionVal - appNameVal = rs2("appname") & "" - versionVal = rs2("version") & "" - If versionVal = "" Then versionVal = "N/A" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
Application NameVersion
No applications installed
" & Server.HTMLEncode(appNameVal) & "" & Server.HTMLEncode(versionVal) & "
-
-
-
-
-
-
- -
- - -
- - -
- - -
- - - - - - - - - - - - -
- -<% -' Clean up -rs.Close -Set rs = Nothing -objConn.Close -Set objConn = Nothing -%> - - - - - - - - - - - - - - - - - - diff --git a/displaypc.asp.backup-20251027 b/displaypc.asp.backup-20251027 deleted file mode 100644 index b2a1174..0000000 --- a/displaypc.asp.backup-20251027 +++ /dev/null @@ -1,837 +0,0 @@ - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - pcid = Request.Querystring("pcid") - - strSQL = "SELECT pc.*,vendors.*,models.*,pc_network_interfaces.*,machines.machineid,machines.machinenumber as machine_number,machines.alias,machines.machinetypeid,machinetypes.machinetype,machines.businessunitid,businessunits.businessunit,machines.printerid,printers.printerwindowsname,pctype.typename,functionalaccounts.functionalaccount,functionalaccounts.description as functionalaccount_description " & _ - "FROM pc " & _ - "LEFT JOIN models ON pc.modelnumberid=models.modelnumberid " & _ - "LEFT JOIN vendors ON models.vendorid=vendors.vendorid " & _ - "LEFT JOIN pc_network_interfaces ON pc_network_interfaces.pcid=pc.pcid " & _ - "LEFT JOIN machines ON pc.machinenumber = machines.machinenumber " & _ - "LEFT JOIN machinetypes ON machines.machinetypeid = machinetypes.machinetypeid " & _ - "LEFT JOIN businessunits ON machines.businessunitid = businessunits.businessunitid " & _ - "LEFT JOIN printers ON machines.printerid = printers.printerid " & _ - "LEFT JOIN pctype ON pc.pctypeid = pctype.pctypeid " & _ - "LEFT JOIN functionalaccounts ON pctype.functionalaccountid = functionalaccounts.functionalaccountid " & _ - "WHERE pc.isactive=1 AND pc.pcid="&pcid - - 'response.write (strSQL) - 'response.end - set rs = objconn.Execute(strSQL) - - ' Check if PC exists - IF rs.EOF THEN - objConn.Close - Response.Redirect("displaypcs.asp") - Response.End - END IF - - ' Get machine ID if it exists - IF NOT rs.EOF THEN - IF NOT IsNull(rs("machineid")) THEN - machineid = rs("machineid") - ELSE - machineid = 0 - END IF - END IF -%> - - - - -
- - -
- - - - -
- -
-
- -
-
-
-
- " alt="Card image cap"> -
-
- " alt="profile-image" class="profile"> -
<%Response.Write(rs("vendor"))%>
-
- -
-
- -
-
-
- -
-
-
Configuration
-
-
-

Vendor:

-

Model:

-

Serial:

-

Hostname:

-

Location:

-

IP:

-

Functional Account:

-
-
-

<%Response.Write(rs("vendor"))%>

-

<%Response.Write(rs("modelnumber"))%>

-

<%Response.Write(rs("serialnumber"))%>

-

:5900" title="VNC To Desktop"><%Response.Write(rs("hostname"))%>

-

-<% - IF machineid > 0 THEN - Dim locationDisplay - ' Use alias if available, otherwise machine_number - IF NOT IsNull(rs("alias")) AND rs("alias") <> "" THEN - locationDisplay = rs("alias") - ELSE - locationDisplay = rs("machine_number") - END IF - Response.Write("" & locationDisplay & "") - ELSE - Response.Write("Not assigned") - END IF -%> -

-

-<% - IF NOT IsNull(rs("ipaddress")) AND rs("ipaddress") <> "" THEN - Response.Write(rs("ipaddress")) - ELSE - Response.Write("N/A") - END IF -%> -

-

-<% - IF NOT IsNull(rs("functionalaccount")) AND rs("functionalaccount") <> "" THEN - Dim accountDisplay, descDisplay, extractedAccount - Dim pcTypeName - pcTypeName = "" - IF NOT IsNull(rs("typename")) THEN - pcTypeName = UCase(Trim(rs("typename") & "")) - END IF - - ' Check if loggedinuser exists and should be used - Dim useLoggedInUser - useLoggedInUser = False - IF NOT IsNull(rs("LoggedInUser")) AND rs("LoggedInUser") <> "" THEN - ' Use loggedinuser for Standard, Engineer, or TBD types - IF pcTypeName = "STANDARD" OR pcTypeName = "ENGINEER" OR rs("functionalaccount") = "TBD" OR rs("functionalaccount") = "1" THEN - useLoggedInUser = True - END IF - END IF - - IF useLoggedInUser THEN - accountDisplay = rs("LoggedInUser") - - ' Try to extract the account number from loggedinuser (format: lg[account]sd) - Dim loggedUser - loggedUser = rs("LoggedInUser") - IF Left(loggedUser, 2) = "lg" AND Right(loggedUser, 2) = "sd" AND Len(loggedUser) > 4 THEN - extractedAccount = Mid(loggedUser, 3, Len(loggedUser) - 4) - ELSE - extractedAccount = "" - END IF - ELSE - accountDisplay = "lg" & rs("functionalaccount") & "sd" - extractedAccount = "" - END IF - - ' Determine what description to show - Dim descField - descField = "" - - ' If showing plain SSO (not lg[account]sd format), label it as "SSO" - IF useLoggedInUser AND extractedAccount = "" THEN - descField = "SSO" - ' If we extracted an account from loggedinuser, look up its description - ELSEIF extractedAccount <> "" THEN - Dim rsDesc, sqlDesc - sqlDesc = "SELECT description FROM functionalaccounts WHERE functionalaccount = '" & Replace(extractedAccount, "'", "''") & "' AND isactive = 1" - Set rsDesc = objConn.Execute(sqlDesc) - IF NOT rsDesc.EOF THEN - IF NOT IsNull(rsDesc("description")) AND rsDesc("description") <> "" THEN - descField = rsDesc("description") & "" - END IF - END IF - rsDesc.Close - Set rsDesc = Nothing - ' Otherwise use functional account description from the query - ELSE - On Error Resume Next - descField = rs("functionalaccount_description") & "" - If descField = "" Then - descField = rs("description") & "" - End If - On Error Goto 0 - END IF - - IF descField <> "" AND NOT IsNull(descField) THEN - descDisplay = " - " & descField - ELSE - descDisplay = "" - END IF - - Response.Write(accountDisplay & descDisplay) - ELSE - Response.Write("N/A") - END IF -%> -

-
-
- -
- -
Warranty Information
-
-
-

Status:

-

End Date:

-

Days Remaining:

-

Service Level:

-

Last Checked:

-
-
-<% -Dim warrantyStatus, warrantyEndDate, warrantyDaysRemaining, warrantyServiceLevel, warrantyLastChecked -Dim warrantyStatusClass, warrantyBadge - -warrantyStatus = rs("warrantystatus") -warrantyEndDate = rs("warrantyenddate") -warrantyDaysRemaining = rs("warrantydaysremaining") -warrantyServiceLevel = rs("warrantyservicelevel") -warrantyLastChecked = rs("warrantylastchecked") - -' Determine warranty status badge -If IsNull(warrantyStatus) Or warrantyStatus = "" Then - warrantyBadge = "Unknown" -ElseIf LCase(warrantyStatus) = "active" Then - If Not IsNull(warrantyDaysRemaining) And IsNumeric(warrantyDaysRemaining) Then - If warrantyDaysRemaining < 30 Then - warrantyBadge = "Expiring Soon" - Else - warrantyBadge = "Active" - End If - Else - warrantyBadge = "Active" - End If -ElseIf LCase(warrantyStatus) = "expired" Then - warrantyBadge = "Expired" -Else - warrantyBadge = "" & warrantyStatus & "" -End If -%> -

<%Response.Write(warrantyBadge)%>

-

-<% -If Not IsNull(warrantyEndDate) And warrantyEndDate <> "" And warrantyEndDate <> "0000-00-00" Then - Response.Write(warrantyEndDate) -Else - Response.Write("Not available") -End If -%> -

-

-<% -If Not IsNull(warrantyDaysRemaining) And IsNumeric(warrantyDaysRemaining) Then - If warrantyDaysRemaining < 0 Then - Response.Write("" & Abs(warrantyDaysRemaining) & " days overdue") - ElseIf warrantyDaysRemaining < 30 Then - Response.Write("" & warrantyDaysRemaining & " days") - Else - Response.Write(warrantyDaysRemaining & " days") - End If -Else - Response.Write("Not available") -End If -%> -

-

-<% -If Not IsNull(warrantyServiceLevel) And warrantyServiceLevel <> "" Then - Response.Write(warrantyServiceLevel) -Else - Response.Write("Not available") -End If -%> -

-

-<% -If Not IsNull(warrantyLastChecked) And warrantyLastChecked <> "" Then - Response.Write(warrantyLastChecked) -Else - Response.Write("Never checked") -End If -%> -

-
-
-
-
-
- - -<% - - IF machineid > 0 THEN - strSQL2 = "SELECT * FROM installedapps,applications WHERE installedapps.appid=applications.appid AND installedapps.isactive=1 AND " &_ - "installedapps.machineid=" & machineid & " ORDER BY appname ASC" - set rs2 = objconn.Execute(strSQL2) - while not rs2.eof - Response.Write("") - rs2.movenext - wend - ELSE - Response.Write("") - END IF - -%> - -
"&rs2("appname")&"
No machine assigned - cannot display installed applications
-
-
-
-
- -
- -
-
- -
- -
-
-
-
- - - -
- -
-
- -
- -
-
-
-
- - - -
- -
- -
-
- - -
- -
- - -
-
-
-
-
-
-
-
- -
- - -
- - -
- -
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -<% objConn.Close %> \ No newline at end of file diff --git a/displaypc.asp.broken b/displaypc.asp.broken deleted file mode 100644 index 4fe8167..0000000 --- a/displaypc.asp.broken +++ /dev/null @@ -1,1372 +0,0 @@ -<% -'============================================================================= -' FILE: displaypc.asp -' PURPOSE: Display detailed PC information with edit capability -' SECURITY: Parameterized queries, HTML encoding, input validation -' UPDATED: 2025-11-07 - Phase 2 migration (mirrors displaymachine.asp) -' NOTE: Uses machines table WHERE pctypeid IS NOT NULL to identify PCs -'============================================================================= -%> - - - - - - - - - - -<% - theme = Request.Cookies("theme") - If theme = "" Then - theme = "bg-theme1" - End If - - '============================================================================= - ' SECURITY: Validate pcid or hostname parameter - ' NOTE: This handles both database ID (pcid maps to pcid) and hostname - '============================================================================= - Dim pcid, hostname, paramValue - pcid = GetSafeInteger("QS", "pcid", 0, 1, 999999) - - ' If pcid not provided, try hostname parameter - IF pcid = 0 THEN - hostname = Request.QueryString("hostname") - IF hostname <> "" THEN - ' Look up pcid (pcid) by hostname - Dim rsLookup, strLookupSQL - strLookupSQL = "SELECT pcid FROM machines WHERE hostname = ? AND isactive = 1 AND pctypeid IS NOT NULL" - Set rsLookup = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(hostname)) - IF NOT rsLookup.EOF THEN - pcid = rsLookup("pcid") - END IF - rsLookup.Close - Set rsLookup = Nothing - END IF - ELSE - ' We have a pcid, verify it exists and is a PC - Dim rsCheck - strLookupSQL = "SELECT pcid FROM machines WHERE pcid = ? AND isactive = 1 AND pctypeid IS NOT NULL" - Set rsCheck = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(pcid)) - - ' If no PC found with that ID, try treating it as a hostname - IF rsCheck.EOF THEN - rsCheck.Close - strLookupSQL = "SELECT pcid FROM machines WHERE hostname = ? AND isactive = 1 AND pctypeid IS NOT NULL" - Set rsCheck = ExecuteParameterizedQuery(objConn, strLookupSQL, Array(CStr(pcid))) - IF NOT rsCheck.EOF THEN - pcid = rsCheck("pcid") - ELSE - pcid = 0 ' Not found - END IF - END IF - rsCheck.Close - Set rsCheck = Nothing - END IF - - IF pcid = 0 THEN - objConn.Close - Response.Redirect("displaypcs.asp") - Response.End - END IF - - '============================================================================= - ' SECURITY: Use parameterized query to prevent SQL injection - ' PHASE 2: Query machines table WHERE pctypeid IS NOT NULL (identifies PCs) - ' NOTE: Use explicit column names to avoid wildcard conflicts between tables - '============================================================================= - ' Phase 2: Query PCs from machines table - strSQL = "SELECT machines.pcid, machines.machinenumber, machines.alias, machines.hostname, " & _ - "machines.serialnumber, machines.machinenotes, machines.mapleft, machines.maptop, " & _ - "machines.modelnumberid, machines.businessunitid, machines.printerid, machines.pctypeid, " & _ - "machines.loggedinuser, machines.osid, machines.machinestatusid, " & _ - "machines.lastupdated, machines.dateadded, " & _ - "pctypes.pctype, pctypes.pctypeid, " & _ - "models.modelnumber, models.image, models.modelnumberid, " & _ - "businessunits.businessunit, businessunits.businessunitid, " & _ - "vendors.vendor, vendors.vendorid, " & _ - "operatingsystems.osname, operatingsystems.osversion, " & _ - "printers.ipaddress AS printerip, printers.printerid AS printer_id, " & _ - "printers.printercsfname, printers.printerwindowsname " & _ - "FROM machines " & _ - "INNER JOIN models ON machines.modelnumberid = models.modelnumberid " & _ - "LEFT JOIN pctypes ON machines.pctypeid = pctypes.pctypeid " & _ - "INNER JOIN businessunits ON machines.businessunitid = businessunits.businessunitid " & _ - "INNER JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "LEFT JOIN operatingsystems ON machines.osid = operatingsystems.osid " & _ - "LEFT JOIN printers ON machines.printerid = printers.printerid " & _ - "WHERE machines.pcid = " & CLng(pcid) & " AND machines.pctypeid IS NOT NULL" - - Set rs = objConn.Execute(strSQL) - - ' Check if PC exists - If rs.EOF Then - rs.Close - Set rs = Nothing - objConn.Close - Response.Redirect("displaypcs.asp") - Response.End - End If -%> - - - - -
- - -
- - - - -
- -
-
- -
-
-
-
- " alt="Card image cap"> -
-
- " alt="profile-image" class="profile"> -
<%=Server.HTMLEncode(rs("hostname") & "")%>
-
<%=Server.HTMLEncode(rs("vendor") & "")%>
-
<%=Server.HTMLEncode(rs("pctype") & "")%>
-

<%=Server.HTMLEncode(rs("machinenotes") & "")%>

-
- -
-
- -
-
-
- -
-
-
Configuration
-
-
-

Location:

-

Vendor:

-

Model:

-

Function:

-

BU:

-

IP Address:

-

MAC Address:

-

Controlling PC:

-

Printer:

-

- -

-
-
-<% -Dim machineNumVal, vendorValM, modelValM, machineTypeVal, buVal - -' Get values and default to N/A if empty -machineNumVal = rs("machinenumber") & "" -If machineNumVal = "" Then machineNumVal = "N/A" - -vendorValM = rs("vendor") & "" -If vendorValM = "" Then vendorValM = "N/A" - -modelValM = rs("modelnumber") & "" -If modelValM = "" Then modelValM = "N/A" - -machineTypeVal = rs("machinetype") & "" -If machineTypeVal = "" Then machineTypeVal = "N/A" - -buVal = rs("businessunit") & "" -If buVal = "" Then buVal = "N/A" -%> -

-<% -If machineNumVal <> "N/A" Then -%> - - <%=Server.HTMLEncode(machineNumVal)%> - -<% -Else - Response.Write("N/A") -End If -%> -

-

<%=Server.HTMLEncode(vendorValM)%>

-

<%=Server.HTMLEncode(modelValM)%>

-

<%=Server.HTMLEncode(machineTypeVal)%>

-

<%=Server.HTMLEncode(buVal)%>

-<% -' Get primary communication (IP and MAC) from communications table -Dim rsPrimaryCom, strPrimaryComSQL, primaryIP, primaryMAC -strPrimaryComSQL = "SELECT address, macaddress FROM communications WHERE pcid = ? AND isprimary = 1 AND isactive = 1 LIMIT 1" -Set rsPrimaryCom = ExecuteParameterizedQuery(objConn, strPrimaryComSQL, Array(pcid)) - -If Not rsPrimaryCom.EOF Then - primaryIP = rsPrimaryCom("address") & "" - primaryMAC = rsPrimaryCom("macaddress") & "" -Else - ' Try to get first active communication if no primary set - rsPrimaryCom.Close - strPrimaryComSQL = "SELECT address, macaddress FROM communications WHERE pcid = ? AND isactive = 1 ORDER BY comid LIMIT 1" - Set rsPrimaryCom = ExecuteParameterizedQuery(objConn, strPrimaryComSQL, Array(pcid)) - If Not rsPrimaryCom.EOF Then - primaryIP = rsPrimaryCom("address") & "" - primaryMAC = rsPrimaryCom("macaddress") & "" - Else - primaryIP = "" - primaryMAC = "" - End If -End If -rsPrimaryCom.Close -Set rsPrimaryCom = Nothing - -' Display IP Address -If primaryIP <> "" Then - Response.Write("

" & Server.HTMLEncode(primaryIP) & "

") -Else - Response.Write("

N/A

") -End If - -' Display MAC Address -If primaryMAC <> "" Then - Response.Write("

" & Server.HTMLEncode(primaryMAC) & "

") -Else - Response.Write("

N/A

") -End If - -' Get controlling PC from relationships -Dim rsControlPC, strControlPCSQL, controlPCHostname, controlPCID -strControlPCSQL = "SELECT m.pcid, m.hostname, m.machinenumber FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.pcid = m.pcid " & _ - "WHERE mr.related_pcid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1 LIMIT 1" -Set rsControlPC = ExecuteParameterizedQuery(objConn, strControlPCSQL, Array(pcid)) - -If Not rsControlPC.EOF Then - controlPCHostname = rsControlPC("hostname") & "" - controlPCID = rsControlPC("pcid") - If controlPCHostname = "" Then controlPCHostname = rsControlPC("machinenumber") & "" - Response.Write("

" & Server.HTMLEncode(controlPCHostname) & "

") -Else - Response.Write("

N/A

") -End If -rsControlPC.Close -Set rsControlPC = Nothing - -' SECURITY: HTML encode printer data to prevent XSS -' Printer data - check if exists (LEFT JOIN may return NULL) -If Not IsNull(rs("printerid")) And rs("printerid") <> "" Then - Dim printerNameVal - printerNameVal = rs("printerwindowsname") & "" - If printerNameVal = "" Then printerNameVal = "Printer #" & rs("printerid") - - Response.Write("

" & Server.HTMLEncode(printerNameVal) & "

") -Else - Response.Write("

N/A

") -End If -%> -
-
-
-
-
-
- -
-
-
Network Communications
-
- - - - - - - - - - - - -<% - ' Query communications for this machine - strSQL2 = "SELECT c.*, ct.typename FROM communications c " & _ - "JOIN comstypes ct ON c.comstypeid = ct.comstypeid " & _ - "WHERE c.pcid = ? AND c.isactive = 1 ORDER BY c.isprimary DESC, c.comid ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(pcid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim ipAddr, macAddr, ifaceName, isPrimary, statusBadge - ipAddr = rs2("address") & "" - macAddr = rs2("macaddress") & "" - ifaceName = rs2("interfacename") & "" - isPrimary = rs2("isprimary") - - If ipAddr = "" Then ipAddr = "N/A" - If macAddr = "" Then macAddr = "N/A" - If ifaceName = "" Then ifaceName = "N/A" - - If isPrimary Then - statusBadge = "Primary" - Else - statusBadge = "" - End If - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
TypeIP AddressMAC AddressInterfacePrimaryStatus
No network communications configured
" & Server.HTMLEncode(rs2("typename") & "") & "" & ipAddr & "" & macAddr & "" & ifaceName & "" & statusBadge & "Active
-
-
-
-
Machine Relationships
- - -
Controlled By PC
-
- - - - - - - - - -<% - ' Query PCs that control this machine - strSQL2 = "SELECT m.pcid, m.machinenumber, m.hostname, c.address, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.pcid = m.pcid " & _ - "LEFT JOIN communications c ON m.pcid = c.pcid AND c.isprimary = 1 " & _ - "WHERE mr.related_pcid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(pcid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim pcHostname, pcIP, pcMachineID - pcHostname = rs2("hostname") & "" - pcIP = rs2("address") & "" - pcMachineID = rs2("pcid") - - If pcHostname = "" Then pcHostname = rs2("machinenumber") & "" - If pcIP = "" Then pcIP = "N/A" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
PC HostnameIP AddressRelationship
No controlling PC assigned
" & Server.HTMLEncode(pcHostname) & "" & pcIP & "" & Server.HTMLEncode(rs2("relationshiptype") & "") & "
-
- - -
Dualpath / Redundant Machines
-
- - - - - - - - - - -<% - ' Query dualpath relationships - strSQL2 = "SELECT m.pcid, m.machinenumber, mt.machinetype, mo.modelnumber, rt.relationshiptype " & _ - "FROM machinerelationships mr " & _ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " & _ - "JOIN machines m ON mr.related_pcid = m.pcid " & _ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " & _ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " & _ - "WHERE mr.pcid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(pcid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim dualMachineNum, dualType, dualModel, dualMachineID - dualMachineNum = rs2("machinenumber") & "" - dualType = rs2("machinetype") & "" - dualModel = rs2("modelnumber") & "" - dualMachineID = rs2("pcid") - - If dualType = "" Then dualType = "N/A" - If dualModel = "" Then dualModel = "N/A" - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
Machine NumberTypeModelRelationship
No dualpath relationships
" & Server.HTMLEncode(dualMachineNum) & "" & dualType & "" & dualModel & "" & Server.HTMLEncode(rs2("relationshiptype") & "") & "
-
-
-
-
Compliance & Security
-<% - ' Query compliance data - strSQL2 = "SELECT * FROM compliance WHERE pcid = ?" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(pcid)) - - If Not rs2.EOF Then -%> -
-
-

Third Party Managed:

-

Third Party Manager:

-

OT Asset System:

-

DoD Asset Device Type:

-

Compliant:

-
-
-<% - Dim thirdPartyManaged, thirdPartyManager, otAssetSystem, dodAssetDeviceType, isCompliant - thirdPartyManaged = rs2("is_third_party_managed") & "" - thirdPartyManager = rs2("third_party_manager") & "" - otAssetSystem = rs2("ot_asset_system") & "" - dodAssetDeviceType = rs2("ot_asset_device_type") & "" - isCompliant = rs2("is_compliant") - - ' Third party managed badge - Dim tpmBadge - If thirdPartyManaged = "Yes" Then - tpmBadge = "Yes" - ElseIf thirdPartyManaged = "No" Then - tpmBadge = "No" - Else - tpmBadge = "N/A" - End If -%> -

<%=tpmBadge%>

-

<%=Server.HTMLEncode(thirdPartyManager)%>

-

<%=Server.HTMLEncode(otAssetSystem)%>

-

<%=Server.HTMLEncode(dodAssetDeviceType)%>

-

-<% - If Not IsNull(isCompliant) Then - If isCompliant Then - Response.Write("Yes") - Else - Response.Write("No") - End If - Else - Response.Write("Not Assessed") - End If -%> -

-
-
- -
- -
Security Scans
-
- - - - - - - - - - -<% - rs2.Close - Set rs2 = Nothing - - ' Query security scans - strSQL2 = "SELECT * FROM compliancescans WHERE pcid = ? ORDER BY scan_date DESC LIMIT 10" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(pcid)) - - If rs2.EOF Then - Response.Write("") - Else - Do While Not rs2.EOF - Dim scanName, scanDate, scanResult, scanDetails, resultBadge - scanName = rs2("scan_name") & "" - scanDate = rs2("scan_date") & "" - scanResult = rs2("scan_result") & "" - scanDetails = rs2("scan_details") & "" - - If scanName = "" Then scanName = "Security Scan" - If scanDetails = "" Then scanDetails = "No details" - - ' Result badge - Select Case LCase(scanResult) - Case "pass" - resultBadge = "Pass" - Case "fail" - resultBadge = "Fail" - Case "warning" - resultBadge = "Warning" - Case Else - resultBadge = "Info" - End Select - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - rs2.MoveNext - Loop - End If - rs2.Close - Set rs2 = Nothing -%> - -
Scan NameDateResultDetails
No security scans recorded
" & Server.HTMLEncode(scanName) & "" & Server.HTMLEncode(scanDate) & "" & resultBadge & "" & scanDetails & "
-
-<% - Else - Response.Write("

No compliance data available for this machine.

") - rs2.Close - Set rs2 = Nothing - End If -%> -
-
-
- - -<% - '============================================================================= - ' SECURITY: Use parameterized query for installed applications - '============================================================================= - strSQL2 = "SELECT * FROM installedapps, applications WHERE installedapps.appid = applications.appid AND installedapps.isactive = 1 AND installedapps.pcid = ? ORDER BY appname ASC" - Set rs2 = ExecuteParameterizedQuery(objConn, strSQL2, Array(pcid)) - Do While Not rs2.EOF - Response.Write("") - rs2.MoveNext - Loop - rs2.Close - Set rs2 = Nothing -%> - -
" & Server.HTMLEncode(rs2("appname") & "") & "
-
-
-
-
- -
- - -
- - -
- -
- - - - - -
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Select Machine Location - -
-
-
-
-
- Click on the map to select a location -
- - -
-
-
-
- - - - - -<% -'============================================================================= -' CLEANUP -'============================================================================= -objConn.Close -%> diff --git a/displayprinter.asp.backup-20251027 b/displayprinter.asp.backup-20251027 deleted file mode 100644 index 896cf49..0000000 --- a/displayprinter.asp.backup-20251027 +++ /dev/null @@ -1,1127 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - printerid = Request.Querystring("printerid") - - strSQL = "SELECT * FROM machines,models,vendors,printers WHERE " &_ - "printers.machineid=machines.machineid AND "&_ - "printers.modelid=models.modelnumberid AND "&_ - "models.vendorid=vendors.vendorid AND "&_ - "printers.printerid="&printerid - set rs = objconn.Execute(strSQL) - machineid = rs("machineid") -%> - - - - -
- - -
- - - - -
- -
-
- -
-
-
-
- " alt="Card image cap"> -
-
- " alt="profile-image" class="profile"> -
<%Response.Write(rs("vendor"))%>
-

" title="Click to Access Support Docs" target="_blank"><%Response.Write(rs("modelnumber"))%>

-
-
-
-
-
-
- -
-
-
Configuration
-
-
-

Vendor:

-

Model:

-

Serial:

-

Location:

-

IP:

-

FQDN:

-

PIN:

-

Driver:

-

CSF Name:

-

Windows Name:

-
-
-

<%Response.Write(rs("vendor"))%>

-

" title="Click to Access Support Docs" target="_blank"><%Response.Write(rs("modelnumber"))%>

-

<%Response.Write(rs("serialnumber"))%>

-

- - <%Response.Write(rs("machinenumber"))%> - -

-

" title="Click to Access Printer Admin Page" target="_blank"><%Response.Write(rs("ipaddress"))%>

-

<%Response.Write(rs("fqdn"))%>

-<% - IF rs("printerpin") <> "" THEN - response.write ("

"&rs("printerpin")&"

") - ELSE - response.write ("

 

") - END IF - IF rs("installpath") <> "" THEN - response.write ("

Download Specific Installer

") - ELSE - response.write ("

Download Universal Driver Installer

") - END IF - IF rs("printercsfname") <> "" THEN - Response.Write ("

"&rs("printercsfname")&"

") - ELSE - response.write ("

 

") - END IF -%> - -

<%Response.Write(rs("printerwindowsname"))%>

-
-
-<% -' Get Zabbix data for this printer (cached) - now includes all supplies -Dim printerIP, cachedData, zabbixConnected, pingStatus, suppliesJSON -Dim statusBadge, statusIcon, statusColor - -printerIP = rs("ipaddress") - -' Get all supplies data (toner, ink, drums, maintenance kits, etc.) -' Returns array: [zabbixConnected, pingStatus, suppliesJSON] -cachedData = GetAllPrinterSuppliesCached(printerIP) - -' Extract data from array -zabbixConnected = cachedData(0) -pingStatus = cachedData(1) -suppliesJSON = cachedData(2) -%> -
- Supply Status -<% -' Display printer online/offline status badge -If pingStatus = "1" Then - Response.Write(" Online") -ElseIf pingStatus = "0" Then - Response.Write(" Offline") -Else - Response.Write(" Unknown") -End If -%> -
-
-<% -If zabbixConnected <> "1" Then - ' Show error details - If zabbixConnected = "" Then - Response.Write("
Unable to connect to Zabbix monitoring server (empty response)
") - Else - Response.Write("
Zabbix Connection Error:
" & Server.HTMLEncode(zabbixConnected) & "
") - End If -ElseIf suppliesJSON = "" Or IsNull(suppliesJSON) Then - Response.Write("
No supply data available for this printer in Zabbix (IP: " & printerIP & ")
") -Else - ' Parse the JSON data for all supply items - Dim itemStart, itemEnd, itemBlock, itemName, itemValue - Dim namePos, nameStart, nameEnd, valuePos, valueStart, valueEnd - Dim currentPos, hasData - - hasData = False - - ' Find all items with "Level" in the name (toner, ink, drums, maintenance kits, etc.) - currentPos = 1 - Do While currentPos > 0 - itemStart = InStr(currentPos, suppliesJSON, "{""itemid""") - If itemStart = 0 Then Exit Do - - itemEnd = InStr(itemStart + 1, suppliesJSON, "},") - If itemEnd = 0 Then - itemEnd = InStr(itemStart + 1, suppliesJSON, "}]") - End If - If itemEnd = 0 Then Exit Do - - itemBlock = Mid(suppliesJSON, itemStart, itemEnd - itemStart + 1) - - ' Extract name - namePos = InStr(itemBlock, """name"":""") - If namePos > 0 Then - nameStart = namePos + 8 - nameEnd = InStr(nameStart, itemBlock, """") - itemName = Mid(itemBlock, nameStart, nameEnd - nameStart) - Else - itemName = "" - End If - - ' Only process items with "Level" in the name - If InStr(1, itemName, "Level", 1) > 0 Then - ' Extract value (lastvalue) - valuePos = InStr(itemBlock, """lastvalue"":""") - If valuePos > 0 Then - valueStart = valuePos + 13 - valueEnd = InStr(valueStart, itemBlock, """") - itemValue = Mid(itemBlock, valueStart, valueEnd - valueStart) - - ' Try to convert to numeric - On Error Resume Next - Dim numericValue, progressClass - numericValue = CDbl(itemValue) - If Err.Number = 0 Then - ' Determine progress bar color based on level - If numericValue < 10 Then - progressClass = "bg-danger" ' Red for critical (< 10%) - ElseIf numericValue < 25 Then - progressClass = "bg-warning" ' Yellow for low (< 25%) - Else - progressClass = "bg-success" ' Green for good (>= 25%) - End If - - ' Display supply level with progress bar - Response.Write("
") - Response.Write("
") - Response.Write("" & Server.HTMLEncode(itemName) & "") - Response.Write("" & Round(numericValue, 1) & "%") - Response.Write("
") - Response.Write("
") - Response.Write("
" & Round(numericValue, 1) & "%
") - Response.Write("
") - Response.Write("
") - - hasData = True - End If - Err.Clear - On Error Goto 0 - End If - End If - - currentPos = itemEnd + 1 - Loop - - If Not hasData Then - Response.Write("
No supply level data available for this printer in Zabbix (IP: " & printerIP & ")
") - End If -End If -%> -
-
-
- -
-
-
-
- -
- -
-
-
- -
-
- -
- -
-
- - - -
-
-
- -
- " placeholder="<%Response.Write(rs("serialnumber"))%>"> -
-
-
- -
- " placeholder="<%Response.Write(rs("serialnumber"))%>"> -
-
-
- -
- " placeholder="<%Response.Write(rs("fqdn"))%>"> -
-
-
- -
- " placeholder="<%Response.Write(rs("printercsfname"))%>"> -
-
-
- -
- " placeholder="<%Response.Write(rs("printerwindowsname"))%>"> -
-
-
- -
- -
-
-<% - Dim currentMapTop, currentMapLeft - If IsNull(rs("maptop")) Or rs("maptop") = "" Then - currentMapTop = "50" - Else - currentMapTop = rs("maptop") - End If - If IsNull(rs("mapleft")) Or rs("mapleft") = "" Then - currentMapLeft = "50" - Else - currentMapLeft = rs("mapleft") - End If -%> - - - - -
- -
- -
- Current position: X=<%Response.Write(currentMapLeft)%>, Y=<%Response.Write(currentMapTop)%> -
-
-
-
- -
-
- -
-
-
- -
-
-
-
-
- -
- - -
- - -
- -
- - - - - -
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- Select Printer Location - -
-
-
-
-
- Click on the map to select a location -
- - -
-
-
-
- - - - - -<% objConn.Close %> \ No newline at end of file diff --git a/displayprofile.asp.broken b/displayprofile.asp.broken deleted file mode 100644 index 9bd2fb9..0000000 --- a/displayprofile.asp.broken +++ /dev/null @@ -1,195 +0,0 @@ -<% -' Easter Eggs for special SSOs -Dim showEasterEgg, easterEggType -showEasterEgg = False -easterEggType = "" - -On Error Resume Next -IF IsNumeric(sso) THEN - IF CLng(sso) = 570005354 THEN - showEasterEgg = True - easterEggType = "developer" - ELSEIF CLng(sso) = 503432774 THEN - showEasterEgg = True - easterEggType = "documentation" - END IF -END IF -On Error Goto 0 - -IF showEasterEgg AND easterEggType = "developer" THEN -%> -
-
-
ACHIEVEMENT UNLOCKED
- Secret Developer Stats -
-
-
-
-
-

Caffeine Consumption147%

-
-
-
-
-
-
-
-
-
-
-
-

Bug Fixing Speed95%

-
-
-
-
-
-
-
-
-
-
-
-

Google-Fu99%

-
-
-
-
-
-
-
-
-
-
-
-

Database Tinkering88%

-
-
-
-
-
-
-
-
-
-
-
-

Debugging100%

-
-
-
-
-
-
-
-
-
-
-
-

Production Deployment Courage73%

-
-
-
-
-
-
-
-
- Legacy Code Archaeologist - Documentation Writer (Rare!) -
-
-<% -ELSEIF showEasterEgg AND easterEggType = "documentation" THEN -%> -
-
-
LEGEND STATUS UNLOCKED
- The Foundation Builder -
-
-
-
-
-

Documentation Mastery100%

-
-
-
-
-
-
-
-
-
-
-
-

Playbook Creation100%

-
-
-
-
-
-
-
-
-
-
-
-

Shopfloor Support100%

-
-
-
-
-
-
-
-
-
-
-
-

CNC Procedure Expertise100%

-
-
-
-
-
-
-
-
-
-
-
-

Reliability100%

-
-
-
-
-
-
-
-
-
-
-
-

Work Ethic100%

-
-
-
-
-
-
-
-
- Knowledge Architect - Procedure Master - Shopfloor Hero -
-
-

"The procedures you built will keep this place running long after you're gone."

- Thank you for the heavy lifting. You built the foundation we all stand on. -
-
-<% -ELSE -%> diff --git a/editapplication.asp.backup-20251027 b/editapplication.asp.backup-20251027 deleted file mode 100644 index 4105a04..0000000 --- a/editapplication.asp.backup-20251027 +++ /dev/null @@ -1,187 +0,0 @@ -<%@ Language=VBScript %> -<% -Option Explicit -%> - - - - - -<% -'============================================================================= -' FILE: editapplication.asp -' PURPOSE: Update an existing application record -' -' PARAMETERS: -' appid (Form, Required) - Integer ID of application to update -' appname (Form, Required) - Application name (1-50 chars) -' appdescription (Form, Optional) - Description (max 255 chars) -' supportteamid (Form, Required) - Support team ID -' applicationnotes (Form, Optional) - Notes (max 512 chars) -' installpath (Form, Optional) - Installation path/URL (max 255 chars) -' documentationpath (Form, Optional) - Documentation path/URL (max 512 chars) -' image (Form, Optional) - Image filename (max 255 chars) -' isinstallable, isactive, ishidden, isprinter, islicenced (Form, Optional) - Checkboxes (0/1) -' -' SECURITY: -' - Uses parameterized queries -' - Validates all inputs -' - HTML encodes outputs -' -' AUTHOR: Claude Code -' CREATED: 2025-10-12 -'============================================================================= - -'----------------------------------------------------------------------------- -' INITIALIZATION -'----------------------------------------------------------------------------- -Call InitializeErrorHandling("editapplication.asp") - -' Get and validate required inputs -Dim appid, appname, appdescription, supportteamid -Dim applicationnotes, installpath, documentationpath, image -Dim isinstallable, isactive, ishidden, isprinter, islicenced - -appid = Trim(Request.Form("appid")) -appname = Trim(Request.Form("appname")) -appdescription = Trim(Request.Form("appdescription")) -supportteamid = Trim(Request.Form("supportteamid")) -applicationnotes = Trim(Request.Form("applicationnotes")) -installpath = Trim(Request.Form("installpath")) -documentationpath = Trim(Request.Form("documentationpath")) -image = Trim(Request.Form("image")) - -' Checkboxes - convert to bit values -If Request.Form("isinstallable") = "1" Then - isinstallable = 1 -Else - isinstallable = 0 -End If - -If Request.Form("isactive") = "1" Then - isactive = 1 -Else - isactive = 0 -End If - -If Request.Form("ishidden") = "1" Then - ishidden = 1 -Else - ishidden = 0 -End If - -If Request.Form("isprinter") = "1" Then - isprinter = 1 -Else - isprinter = 0 -End If - -If Request.Form("islicenced") = "1" Then - islicenced = 1 -Else - islicenced = 0 -End If - -'----------------------------------------------------------------------------- -' VALIDATE INPUTS -'----------------------------------------------------------------------------- - -' Validate appid -If Not ValidateID(appid) Then - Call HandleValidationError("displayapplications.asp", "INVALID_ID") -End If - -' Verify the application exists - DISABLED DUE TO CACHING ISSUE -' If Not RecordExists(objConn, "applications", "appid", appid) Then -' Call HandleValidationError("displayapplications.asp", "NOT_FOUND") -' End If - -' Validate appname (required, 1-50 chars) -If Len(appname) < 1 Or Len(appname) > 50 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -' Validate supportteamid -If Not ValidateID(supportteamid) Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_ID") -End If - -' Verify support team exists - DISABLED DUE TO CACHING ISSUE -' If Not RecordExists(objConn, "supportteams", "supporteamid", supportteamid) Then -' Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -' End If - -' Validate field lengths -If Len(appdescription) > 255 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -If Len(applicationnotes) > 512 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -If Len(installpath) > 255 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -If Len(documentationpath) > 512 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -If Len(image) > 255 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -'----------------------------------------------------------------------------- -' DATABASE UPDATE -'----------------------------------------------------------------------------- - -Dim strSQL -strSQL = "UPDATE applications SET " & _ - "appname = ?, " & _ - "appdescription = ?, " & _ - "supportteamid = ?, " & _ - "applicationnotes = ?, " & _ - "installpath = ?, " & _ - "documentationpath = ?, " & _ - "image = ?, " & _ - "isinstallable = ?, " & _ - "isactive = ?, " & _ - "ishidden = ?, " & _ - "isprinter = ?, " & _ - "islicenced = ? " & _ - "WHERE appid = ?" - -Dim recordsAffected -recordsAffected = ExecuteParameterizedUpdate(objConn, strSQL, Array( _ - appname, _ - appdescription, _ - supportteamid, _ - applicationnotes, _ - installpath, _ - documentationpath, _ - image, _ - isinstallable, _ - isactive, _ - ishidden, _ - isprinter, _ - islicenced, _ - appid _ -)) - -Call CheckForErrors() - -'----------------------------------------------------------------------------- -' CLEANUP AND REDIRECT -'----------------------------------------------------------------------------- -Call CleanupResources() - -If recordsAffected > 0 Then - Response.Redirect("displayapplication.asp?appid=" & Server.URLEncode(appid)) -Else - Response.Write("") - Response.Write("

Error: No records were updated.

") - Response.Write("

Go Back

") - Response.Write("") -End If -%> diff --git a/editapplication_direct.asp.backup-20251027 b/editapplication_direct.asp.backup-20251027 deleted file mode 100644 index 4740611..0000000 --- a/editapplication_direct.asp.backup-20251027 +++ /dev/null @@ -1,221 +0,0 @@ - -<% -' Get all form data -Dim appid, appname, appdescription, supportteamid -Dim applicationnotes, installpath, applicationlink, documentationpath, image -Dim isinstallable, isactive, ishidden, isprinter, islicenced -Dim newsupportteamname, newsupportteamurl, newappownerid - -appid = Request.Form("appid") -appname = Trim(Request.Form("appname")) -appdescription = Trim(Request.Form("appdescription")) -supportteamid = Trim(Request.Form("supportteamid")) -applicationnotes = Trim(Request.Form("applicationnotes")) -installpath = Trim(Request.Form("installpath")) -applicationlink = Trim(Request.Form("applicationlink")) -documentationpath = Trim(Request.Form("documentationpath")) -image = Trim(Request.Form("image")) - -' New support team fields -newsupportteamname = Trim(Request.Form("newsupportteamname")) -newsupportteamurl = Trim(Request.Form("newsupportteamurl")) -newappownerid = Trim(Request.Form("newappownerid")) - -' Checkboxes -If Request.Form("isinstallable") = "1" Then isinstallable = 1 Else isinstallable = 0 -If Request.Form("isactive") = "1" Then isactive = 1 Else isactive = 0 -If Request.Form("ishidden") = "1" Then ishidden = 1 Else ishidden = 0 -If Request.Form("isprinter") = "1" Then isprinter = 1 Else isprinter = 0 -If Request.Form("islicenced") = "1" Then islicenced = 1 Else islicenced = 0 - -' Check if we need to create a new support team first -If supportteamid = "new" Then - If newsupportteamname = "" Then - Response.Write("
Error: Support team name is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newsupportteamname) > 50 Then - Response.Write("
Error: Support team name too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape quotes for support team name and URL - Dim escapedTeamName, escapedTeamUrl - escapedTeamName = Replace(newsupportteamname, "'", "''") - escapedTeamUrl = Replace(newsupportteamurl, "'", "''") - - ' Check if support team already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM supportteams WHERE LOWER(teamname) = LOWER('" & escapedTeamName & "')" - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck.EOF Then - rsCheck.Close - Response.Write("
Error: Database query failed.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Response.Write("
Error: Support team '" & Server.HTMLEncode(newsupportteamname) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Check if we need to create a new app owner first (nested creation) - If newappownerid = "new" Then - Dim newappownername, newappownersso - newappownername = Trim(Request.Form("newappownername")) - newappownersso = Trim(Request.Form("newappownersso")) - - If newappownername = "" Or newappownersso = "" Then - Response.Write("
Error: App owner name and SSO are required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newappownername) > 50 Or Len(newappownersso) > 50 Then - Response.Write("
Error: App owner name or SSO too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape quotes - Dim escapedOwnerName, escapedSSO - escapedOwnerName = Replace(newappownername, "'", "''") - escapedSSO = Replace(newappownersso, "'", "''") - - ' Check if app owner already exists - checkSQL = "SELECT COUNT(*) as cnt FROM appowners WHERE LOWER(appowner) = LOWER('" & escapedOwnerName & "') OR LOWER(sso) = LOWER('" & escapedSSO & "')" - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck.EOF Then - rsCheck.Close - Response.Write("
Error: Database query failed (app owner check).
") - Response.Write("Go back") - objConn.Close - Response.End - End If - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Response.Write("
Error: App owner with this name or SSO already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Insert new app owner - Dim ownerSQL - ownerSQL = "INSERT INTO appowners (appowner, sso, isactive) VALUES ('" & escapedOwnerName & "', '" & escapedSSO & "', 1)" - - On Error Resume Next - objConn.Execute ownerSQL - - If Err.Number <> 0 Then - Response.Write("
Error creating app owner: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new app owner ID - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newappownerid = rsCheck("newid") - rsCheck.Close - Else - ' Validate existing app owner ID (only if not empty and not "new") - If newappownerid <> "" And newappownerid <> "new" Then - If Not IsNumeric(newappownerid) Or CLng(newappownerid) < 1 Then - Response.Write("
Error: Invalid app owner.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If - End If - - ' Insert new support team - Dim teamSQL - teamSQL = "INSERT INTO supportteams (teamname, teamurl, appownerid, isactive) VALUES ('" & escapedTeamName & "', '" & escapedTeamUrl & "', " & newappownerid & ", 1)" - - On Error Resume Next - objConn.Execute teamSQL - - If Err.Number <> 0 Then - Response.Write("
Error creating support team: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new support team ID - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - supportteamid = rsCheck("newid") - rsCheck.Close -Else - ' Validate existing support team ID (only if not empty and not "new") - If supportteamid <> "" And supportteamid <> "new" Then - If Not IsNumeric(supportteamid) Or CLng(supportteamid) < 1 Then - Response.Write("
Error: Invalid support team ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If -End If - -' Escape backslashes and single quotes for SQL -' Must escape backslashes FIRST, then quotes -appname = Replace(appname, "\", "\\") -appname = Replace(appname, "'", "''") -appdescription = Replace(appdescription, "\", "\\") -appdescription = Replace(appdescription, "'", "''") -applicationnotes = Replace(applicationnotes, "\", "\\") -applicationnotes = Replace(applicationnotes, "'", "''") -installpath = Replace(installpath, "\", "\\") -installpath = Replace(installpath, "'", "''") -applicationlink = Replace(applicationlink, "\", "\\") -applicationlink = Replace(applicationlink, "'", "''") -documentationpath = Replace(documentationpath, "\", "\\") -documentationpath = Replace(documentationpath, "'", "''") -image = Replace(image, "\", "\\") -image = Replace(image, "'", "''") - -' Build UPDATE statement -Dim strSQL -strSQL = "UPDATE applications SET " & _ - "appname = '" & appname & "', " & _ - "appdescription = '" & appdescription & "', " & _ - "supportteamid = " & supportteamid & ", " & _ - "applicationnotes = '" & applicationnotes & "', " & _ - "installpath = '" & installpath & "', " & _ - "applicationlink = '" & applicationlink & "', " & _ - "documentationpath = '" & documentationpath & "', " & _ - "image = '" & image & "', " & _ - "isinstallable = " & isinstallable & ", " & _ - "isactive = " & isactive & ", " & _ - "ishidden = " & ishidden & ", " & _ - "isprinter = " & isprinter & ", " & _ - "islicenced = " & islicenced & " " & _ - "WHERE appid = " & appid - -On Error Resume Next -objConn.Execute strSQL - -If Err.Number = 0 Then - objConn.Close - Response.Redirect("displayapplication.asp?appid=" & appid) -Else - Response.Write("Error: " & Err.Description) - objConn.Close -End If -%> diff --git a/editapplication_v2.asp.backup-20251027 b/editapplication_v2.asp.backup-20251027 deleted file mode 100644 index d0a6920..0000000 --- a/editapplication_v2.asp.backup-20251027 +++ /dev/null @@ -1,96 +0,0 @@ -<%@ Language=VBScript %> -<% -Option Explicit -%> - - - - - -<% -'============================================================================= -' FILE: editapplication_v2.asp (TEST VERSION) -' PURPOSE: Update an existing application record -'============================================================================= - -Call InitializeErrorHandling("editapplication_v2.asp") - -' Get and validate inputs -Dim appid, appname, appdescription, supportteamid -Dim applicationnotes, installpath, documentationpath, image -Dim isinstallable, isactive, ishidden, isprinter, islicenced - -appid = Trim(Request.Form("appid")) -appname = Trim(Request.Form("appname")) -appdescription = Trim(Request.Form("appdescription")) -supportteamid = Trim(Request.Form("supportteamid")) -applicationnotes = Trim(Request.Form("applicationnotes")) -installpath = Trim(Request.Form("installpath")) -documentationpath = Trim(Request.Form("documentationpath")) -image = Trim(Request.Form("image")) - -' Checkboxes -If Request.Form("isinstallable") = "1" Then isinstallable = 1 Else isinstallable = 0 -If Request.Form("isactive") = "1" Then isactive = 1 Else isactive = 0 -If Request.Form("ishidden") = "1" Then ishidden = 1 Else ishidden = 0 -If Request.Form("isprinter") = "1" Then isprinter = 1 Else isprinter = 0 -If Request.Form("islicenced") = "1" Then islicenced = 1 Else islicenced = 0 - -' Validate appid -If Not ValidateID(appid) Then - Call HandleValidationError("displayapplications.asp", "INVALID_ID") -End If - -' Validate appname (required, 1-50 chars) -If Len(appname) < 1 Or Len(appname) > 50 Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -End If - -' Validate supportteamid -If Not ValidateID(supportteamid) Then - Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_ID") -End If - -' Validate field lengths -If Len(appdescription) > 255 Then Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -If Len(applicationnotes) > 512 Then Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -If Len(installpath) > 255 Then Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -If Len(documentationpath) > 512 Then Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") -If Len(image) > 255 Then Call HandleValidationError("displayapplication.asp?appid=" & appid, "INVALID_INPUT") - -' DATABASE UPDATE -Dim strSQL -strSQL = "UPDATE applications SET " & _ - "appname = ?, " & _ - "appdescription = ?, " & _ - "supportteamid = ?, " & _ - "applicationnotes = ?, " & _ - "installpath = ?, " & _ - "documentationpath = ?, " & _ - "image = ?, " & _ - "isinstallable = ?, " & _ - "isactive = ?, " & _ - "ishidden = ?, " & _ - "isprinter = ?, " & _ - "islicenced = ? " & _ - "WHERE appid = ?" - -Dim recordsAffected -recordsAffected = ExecuteParameterizedUpdate(objConn, strSQL, Array( _ - appname, appdescription, supportteamid, applicationnotes, _ - installpath, documentationpath, image, _ - isinstallable, isactive, ishidden, isprinter, islicenced, appid _ -)) - -Call CheckForErrors() -Call CleanupResources() - -If recordsAffected > 0 Then - Response.Redirect("displayapplication.asp?appid=" & Server.URLEncode(appid)) -Else - Response.Write("") - Response.Write("

Error: No records were updated.

") - Response.Write("

Go Back

") - Response.Write("") -End If -%> diff --git a/editdevice.asp.backup-20251114 b/editdevice.asp.backup-20251114 deleted file mode 100644 index adde201..0000000 --- a/editdevice.asp.backup-20251114 +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - Dim machineid, isScanned - machineid = Request.QueryString("pcid") ' Parameter named pcid for backwards compatibility - If machineid = "" Then machineid = Request.QueryString("machineid") - isScanned = Request.QueryString("scanned") - - ' Validate machineid - If Not IsNumeric(machineid) Or CLng(machineid) < 1 Then - Response.Write("Invalid device ID") - Response.End - End If - - ' Get PC data using parameterized query - PHASE 2: Use machines table - Dim strSQL, rs - strSQL = "SELECT machines.*, machinestatus.machinestatus, pctype.typename " & _ - "FROM machines " & _ - "LEFT JOIN machinestatus ON machines.machinestatusid = machinestatus.machinestatusid " & _ - "LEFT JOIN pctype ON machines.pctypeid = pctype.pctypeid " & _ - "WHERE machines.machineid = ? AND machines.pctypeid IS NOT NULL" - - Set rs = ExecuteParameterizedQuery(objconn, strSQL, Array(CLng(machineid))) - - If rs.EOF Then - Response.Write("Device not found") - Response.End - End If -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-
- Edit Device - <%=Server.HTMLEncode(rs("serialnumber"))%> -
- - Back to Scan - -
- -<% -Dim errorType, errorMsg -errorType = Request.QueryString("error") -errorMsg = Request.QueryString("msg") - -If isScanned = "1" Then -%> -
- Device already exists! Update the details below. -
-<% -ElseIf errorType = "required" Then -%> -
- Error! Status is required. -
-<% -ElseIf errorType = "db" Then -%> -
- Database Error: <%=Server.HTMLEncode(errorMsg)%> -
-<% -End If -%> - -
- - -
- - " readonly> -
- -
- - -
- -
- - -
- -
- - " - placeholder="e.g., DESKTOP-ABC123"> -
- -
- -
- -
- -
-
-
- - - - -
- - " - placeholder="e.g., 101"> -
- -
-
- > - -
- Default: Active (checked) -
- -
- -
-
- -
-
-
-
-
- -
- - - - - - -
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - -<% -rs.Close -objConn.Close -%> diff --git a/editmachine.asp.broken b/editmachine.asp.broken deleted file mode 100644 index 6d0aaf7..0000000 --- a/editmachine.asp.broken +++ /dev/null @@ -1,1136 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - ' Get and validate machineid parameter - Dim machineid, machineData, strSQL - machineid = Request.QueryString("machineid") - - ' Security validation - ensure machineid is numeric - If NOT IsNumeric(machineid) OR machineid = "" Then - Response.Redirect("./displaymachines.asp") - Response.End - End If - - ' Load machine data - strSQL = "SELECT m.*, " &_ - "mo.modelnumber, mo.vendorid AS modelvendorid, mo.machinetypeid, mo.image AS modelimage, " &_ - "v.vendor, " &_ - "bu.businessunit, " &_ - "mt.machinetype " &_ - "FROM machines m " &_ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " &_ - "LEFT JOIN vendors v ON mo.vendorid = v.vendorid " &_ - "LEFT JOIN businessunits bu ON m.businessunitid = bu.businessunitid " &_ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " &_ - "WHERE m.machineid = ?" - - Dim cmd, rsMachine - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Set rsMachine = cmd.Execute - - If rsMachine.EOF Then - rsMachine.Close - Set rsMachine = Nothing - Set cmd = Nothing - objConn.Close - Response.Redirect("./displaymachines.asp") - Response.End - End If - - ' Store machine data - Dim machinenumber, modelid, businessunitid, alias, machinenotes, mapleft, maptop - machinenumber = "" : If NOT IsNull(rsMachine("machinenumber")) Then machinenumber = rsMachine("machinenumber") - modelid = "" : If NOT IsNull(rsMachine("modelnumberid")) Then modelid = rsMachine("modelnumberid") - businessunitid = "" : If NOT IsNull(rsMachine("businessunitid")) Then businessunitid = rsMachine("businessunitid") - alias = "" : If NOT IsNull(rsMachine("alias")) Then alias = rsMachine("alias") - machinenotes = "" : If NOT IsNull(rsMachine("machinenotes")) Then machinenotes = rsMachine("machinenotes") - mapleft = "" : If NOT IsNull(rsMachine("mapleft")) Then mapleft = rsMachine("mapleft") - maptop = "" : If NOT IsNull(rsMachine("maptop")) Then maptop = rsMachine("maptop") - - rsMachine.Close - Set rsMachine = Nothing - Set cmd = Nothing - - ' Load network interfaces from communications table - Dim ip1, mac1, ip2, mac2, ip3, mac3 - ip1 = "" : mac1 = "" : ip2 = "" : mac2 = "" : ip3 = "" : mac3 = "" - - strSQL = "SELECT address, macaddress FROM communications WHERE machineid = ? AND isactive = 1 ORDER BY isprimary DESC" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsComms - Set rsComms = cmd.Execute - - Dim interfaceCount - interfaceCount = 0 - While NOT rsComms.EOF AND interfaceCount < 3 - interfaceCount = interfaceCount + 1 - If interfaceCount = 1 Then - If NOT IsNull(rsComms("address")) Then ip1 = rsComms("address") - If NOT IsNull(rsComms("macaddress")) Then mac1 = rsComms("macaddress") - ElseIf interfaceCount = 2 Then - If NOT IsNull(rsComms("address")) Then ip2 = rsComms("address") - If NOT IsNull(rsComms("macaddress")) Then mac2 = rsComms("macaddress") - ElseIf interfaceCount = 3 Then - If NOT IsNull(rsComms("address")) Then ip3 = rsComms("address") - If NOT IsNull(rsComms("macaddress")) Then mac3 = rsComms("macaddress") - End If - rsComms.MoveNext - Wend - rsComms.Close - Set rsComms = Nothing - Set cmd = Nothing - - ' Load controlling PC from machinerelationships - ' Note: Controls relationship is PC → Equipment, so we need machineid (PC) where related_machineid is this equipment - Dim controllingpcid - controllingpcid = "" - strSQL = "SELECT mr.machineid AS controlpcid FROM machinerelationships mr " &_ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ - "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsControlPC - Set rsControlPC = cmd.Execute - If NOT rsControlPC.EOF Then - If NOT IsNull(rsControlPC("controlpcid")) Then controllingpcid = rsControlPC("controlpcid") - End If - rsControlPC.Close - Set rsControlPC = Nothing - Set cmd = Nothing - - ' Load dualpath from machinerelationships - Dim dualpathid - dualpathid = "" - strSQL = "SELECT related_machineid FROM machinerelationships mr " &_ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ - "WHERE mr.machineid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsDualpath - Set rsDualpath = cmd.Execute - If NOT rsDualpath.EOF Then - If NOT IsNull(rsDualpath("related_machineid")) Then dualpathid = rsDualpath("related_machineid") - End If - rsDualpath.Close - Set rsDualpath = Nothing - Set cmd = Nothing - - ' Load compliance data - Dim thirdpartymanaged, thirdpartymanager, otassetsystem, dodassettype - thirdpartymanaged = "NA" : thirdpartymanager = "" : otassetsystem = "" : dodassettype = "" - - strSQL = "SELECT * FROM compliance WHERE machineid = ?" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsCompliance - Set rsCompliance = cmd.Execute - If NOT rsCompliance.EOF Then - If NOT IsNull(rsCompliance("is_third_party_managed")) Then thirdpartymanaged = rsCompliance("is_third_party_managed") - If NOT IsNull(rsCompliance("third_party_manager")) Then thirdpartymanager = rsCompliance("third_party_manager") - If NOT IsNull(rsCompliance("ot_asset_system")) Then otassetsystem = rsCompliance("ot_asset_system") - If NOT IsNull(rsCompliance("ot_asset_device_type")) Then dodassettype = rsCompliance("ot_asset_device_type") - End If - rsCompliance.Close - Set rsCompliance = Nothing - Set cmd = Nothing -%> - - - -
- - -
- - - - -
- -
-
- -
-
-
-
-
-
- Edit Equipment -
- - Back to Machines - -
- -
- - - - - - -
- - - - -
- -
- - - Machine number cannot be changed -
- -
- -
- -
- -
-
-
- - - - -
- -
- -
- -
-
-
- - - - -
- - -
- -
- - -
- -
- - - - -
-
Network Communications
-

Configure network interfaces for this equipment. You can add up to 3 interfaces.

- - -
-
- Interface 1 (Primary) -
-
-
-
-
- - - Example: 192.168.1.100 -
-
-
-
- - - Example: 00:1A:2B:3C:4D:5E -
-
-
-
-
- - -
-
- Interface 2 (Optional) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
-
- Interface 3 (Optional) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- -
- - - - -
-
Machine Relationships
-

Define relationships between this equipment and other machines or PCs.

- -
- - - Select a PC that controls this equipment -
- -
- - - Select a backup/redundant machine (creates bidirectional relationship) -
- -
- - - - -
-
Compliance & Security
-

Track compliance and security information for this equipment.

- -
- - - Is this equipment managed by a third party? -
- -
- -
- -
- -
-
- Select the vendor managing this equipment -
- - - - -
- - - Operational Technology asset classification -
- -
- - - Department of Defense asset classification -
- -
- - - - -
-
Location
-

Set the physical location of this equipment on the shop floor map.

- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- - -
-
- - - Cancel - -
- -
- -
-
-
-
- - -
- -
- - - - - - -
-
-
-
-
-
- -
- - - - - - - - - - - - - - - - - - -
-
-
-
Select Location on Map
- -
-
-
-
-
-
No location selected
-
- - -
-
-
-
- - - - - -<% - objConn.Close -%> diff --git a/editmacine.asp.backup-20251027 b/editmacine.asp.backup-20251027 deleted file mode 100644 index 18d210a..0000000 --- a/editmacine.asp.backup-20251027 +++ /dev/null @@ -1,346 +0,0 @@ - - - - - - - -
-<% - ' Get and validate all inputs - Dim machineid, modelid, machinetypeid, businessunitid, printerid, mapleft, maptop - machineid = Trim(Request.Querystring("machineid")) - modelid = Trim(Request.Form("modelid")) - machinetypeid = Trim(Request.Form("machinetypeid")) - businessunitid = Trim(Request.Form("businessunitid")) - printerid = Trim(Request.Form("printerid")) - mapleft = Trim(Request.Form("mapleft")) - maptop = Trim(Request.Form("maptop")) - - ' Get form inputs for new business unit - Dim newbusinessunit - newbusinessunit = Trim(Request.Form("newbusinessunit")) - - ' Get form inputs for new machine type - Dim newmachinetype, newmachinedescription, newfunctionalaccountid - newmachinetype = Trim(Request.Form("newmachinetype")) - newmachinedescription = Trim(Request.Form("newmachinedescription")) - newfunctionalaccountid = Trim(Request.Form("newfunctionalaccountid")) - - ' Get form inputs for new functional account - Dim newfunctionalaccount - newfunctionalaccount = Trim(Request.Form("newfunctionalaccount")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid, newmodelimage - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - newmodelimage = Trim(Request.Form("newmodelimage")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields - If Not IsNumeric(machineid) Or CLng(machineid) < 1 Then - Response.Write("
Error: Invalid machine ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If modelid <> "new" And (Not IsNumeric(modelid)) Then - Response.Write("
Error: Invalid model ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If machinetypeid <> "new" And (Not IsNumeric(machinetypeid)) Then - Response.Write("
Error: Invalid machine type ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If businessunitid <> "new" And (Not IsNumeric(businessunitid)) Then - Response.Write("
Error: Invalid business unit ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new business unit creation - If businessunitid = "new" Then - If Len(newbusinessunit) = 0 Then - Response.Write("
New business unit name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newbusinessunit) > 50 Then - Response.Write("
Business unit name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedBUName - escapedBUName = Replace(newbusinessunit, "'", "''") - - ' Insert new business unit - Dim sqlNewBU - sqlNewBU = "INSERT INTO businessunits (businessunit, isactive) VALUES ('" & escapedBUName & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewBU - - If Err.Number <> 0 Then - Response.Write("
Error creating new business unit: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created business unit ID - Dim rsNewBU - Set rsNewBU = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - businessunitid = CLng(rsNewBU("newid")) - rsNewBU.Close - Set rsNewBU = Nothing - On Error Goto 0 - End If - - ' Handle new machine type creation - If machinetypeid = "new" Then - If Len(newmachinetype) = 0 Then - Response.Write("
New machine type name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccountid) = 0 Then - Response.Write("
Functional account is required for new machine type
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmachinetype) > 50 Or Len(newmachinedescription) > 255 Then - Response.Write("
Machine type field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new functional account creation (nested) - If newfunctionalaccountid = "new" Then - If Len(newfunctionalaccount) = 0 Then - Response.Write("
New functional account name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccount) > 50 Then - Response.Write("
Functional account name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedFAName - escapedFAName = Replace(newfunctionalaccount, "'", "''") - - ' Insert new functional account - Dim sqlNewFA - sqlNewFA = "INSERT INTO functionalaccounts (functionalaccount, isactive) VALUES ('" & escapedFAName & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewFA - - If Err.Number <> 0 Then - Response.Write("
Error creating new functional account: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created functional account ID - Dim rsNewFA - Set rsNewFA = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newfunctionalaccountid = CLng(rsNewFA("newid")) - rsNewFA.Close - Set rsNewFA = Nothing - On Error Goto 0 - End If - - ' Escape single quotes - Dim escapedMTName, escapedMTDesc - escapedMTName = Replace(newmachinetype, "'", "''") - escapedMTDesc = Replace(newmachinedescription, "'", "''") - - ' Insert new machine type - Dim sqlNewMT - sqlNewMT = "INSERT INTO machinetypes (machinetype, machinedescription, functionalaccountid, isactive) " & _ - "VALUES ('" & escapedMTName & "', '" & escapedMTDesc & "', " & newfunctionalaccountid & ", 1)" - - On Error Resume Next - objConn.Execute sqlNewMT - - If Err.Number <> 0 Then - Response.Write("
Error creating new machine type: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created machine type ID - Dim rsNewMT - Set rsNewMT = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - machinetypeid = CLng(rsNewMT("newid")) - rsNewMT.Close - Set rsNewMT = Nothing - On Error Goto 0 - End If - - ' Handle new model creation - If modelid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Write("
New model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Write("
Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 50 Or Len(newmodelimage) > 100 Then - Response.Write("
Model field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Write("
New vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Write("
Vendor name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedVendorName - escapedVendorName = Replace(newvendorname, "'", "''") - - ' Insert new vendor (with ismachine=1) - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) " & _ - "VALUES ('" & escapedVendorName & "', 1, 0, 0, 1)" - - On Error Resume Next - objConn.Execute sqlNewVendor - - If Err.Number <> 0 Then - Response.Write("
Error creating new vendor: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for model - Dim escapedModelNumber, escapedModelImage - escapedModelNumber = Replace(newmodelnumber, "'", "''") - escapedModelImage = Replace(newmodelimage, "'", "''") - - ' Set default image if not specified - If escapedModelImage = "" Then - escapedModelImage = "default.png" - End If - - ' Insert new model - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, image, isactive) " & _ - "VALUES ('" & escapedModelNumber & "', " & newvendorid & ", '" & escapedModelImage & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - - If Err.Number <> 0 Then - Response.Write("
Error creating new model: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - End If - - ' Build UPDATE statement - Dim strSQL - strSQL = "UPDATE machines SET " & _ - "modelnumberid = " & modelid & ", " & _ - "machinetypeid = " & machinetypeid & ", " & _ - "businessunitid = " & businessunitid - - ' Add optional printerid - If printerid <> "" And IsNumeric(printerid) Then - strSQL = strSQL & ", printerid = " & printerid - End If - - ' Add optional map coordinates - If mapleft <> "" And maptop <> "" And IsNumeric(mapleft) And IsNumeric(maptop) Then - strSQL = strSQL & ", mapleft = " & mapleft & ", maptop = " & maptop - End If - - strSQL = strSQL & " WHERE machineid = " & machineid - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number <> 0 Then - Response.Write("
Error: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - objConn.Close -%> - -
- - diff --git a/editmacine.asp.backup-refactor-20251027 b/editmacine.asp.backup-refactor-20251027 deleted file mode 100644 index d7a71a1..0000000 --- a/editmacine.asp.backup-refactor-20251027 +++ /dev/null @@ -1,410 +0,0 @@ -<% -'============================================================================= -' FILE: editmacine.asp -' PURPOSE: Edit machine information with nested entity creation -' SECURITY: Parameterized queries, HTML encoding, input validation -' UPDATED: 2025-10-27 - Migrated to secure patterns -' NOTE: File has typo in name (macine vs machine) - preserved for compatibility -'============================================================================= -%> - - - - - - - - -
-<% - '============================================================================= - ' SECURITY: Validate machineid from querystring - '============================================================================= - Dim machineid - machineid = GetSafeInteger("QS", "machineid", 0, 1, 999999) - - If machineid = 0 Then - Response.Write("
Error: Invalid machine ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - '============================================================================= - ' SECURITY: Get and validate all form inputs - '============================================================================= - Dim modelid, machinetypeid, businessunitid, printerid, mapleft, maptop - modelid = GetSafeString("FORM", "modelid", "", 1, 50, "") - machinetypeid = GetSafeString("FORM", "machinetypeid", "", 1, 50, "") - businessunitid = GetSafeString("FORM", "businessunitid", "", 1, 50, "") - printerid = GetSafeInteger("FORM", "printerid", 0, 0, 999999) - mapleft = GetSafeInteger("FORM", "mapleft", 0, 0, 9999) - maptop = GetSafeInteger("FORM", "maptop", 0, 0, 9999) - - ' Get form inputs for new business unit - Dim newbusinessunit - newbusinessunit = GetSafeString("FORM", "newbusinessunitname", "", 0, 50, "") - - ' Get form inputs for new machine type - Dim newmachinetype, newmachinedescription, newfunctionalaccountid - newmachinetype = GetSafeString("FORM", "newmachinetypename", "", 0, 50, "") - newmachinedescription = GetSafeString("FORM", "newmachinetypedescription", "", 0, 255, "") - newfunctionalaccountid = GetSafeString("FORM", "newfunctionalaccountid", "", 0, 50, "") - - ' Get form inputs for new functional account - Dim newfunctionalaccount - newfunctionalaccount = GetSafeString("FORM", "newfunctionalaccountname", "", 0, 50, "") - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid, newmodelimage - newmodelnumber = GetSafeString("FORM", "newmodelnumber", "", 0, 255, "") - newvendorid = GetSafeString("FORM", "newvendorid", "", 0, 50, "") - newmodelimage = GetSafeString("FORM", "newmodelimage", "", 0, 255, "") - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = GetSafeString("FORM", "newvendorname", "", 0, 50, "") - - '============================================================================= - ' Validate required fields - '============================================================================= - If modelid <> "new" And (Not IsNumeric(modelid)) Then - Response.Write("
Error: Invalid model ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If machinetypeid <> "new" And (Not IsNumeric(machinetypeid)) Then - Response.Write("
Error: Invalid machine type ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If businessunitid <> "new" And (Not IsNumeric(businessunitid)) Then - Response.Write("
Error: Invalid business unit ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - '============================================================================= - ' SECURITY: Handle new business unit creation with parameterized query - '============================================================================= - If businessunitid = "new" Then - If Len(newbusinessunit) = 0 Then - Response.Write("
New business unit name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Insert new business unit using parameterized query - Dim sqlNewBU - sqlNewBU = "INSERT INTO businessunits (businessunit, isactive) VALUES (?, 1)" - - On Error Resume Next - Dim cmdNewBU - Set cmdNewBU = Server.CreateObject("ADODB.Command") - cmdNewBU.ActiveConnection = objConn - cmdNewBU.CommandText = sqlNewBU - cmdNewBU.CommandType = 1 - cmdNewBU.Parameters.Append cmdNewBU.CreateParameter("@businessunit", 200, 1, 50, newbusinessunit) - cmdNewBU.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new business unit: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created business unit ID - Dim rsNewBU - Set rsNewBU = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - businessunitid = 0 - If Not rsNewBU.EOF Then - If Not IsNull(rsNewBU("newid")) Then - businessunitid = CLng(rsNewBU("newid")) - End If - End If - rsNewBU.Close - Set rsNewBU = Nothing - Set cmdNewBU = Nothing - On Error Goto 0 - End If - - '============================================================================= - ' SECURITY: Handle new machine type creation with parameterized query - '============================================================================= - If machinetypeid = "new" Then - If Len(newmachinetype) = 0 Then - Response.Write("
New machine type name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccountid) = 0 Then - Response.Write("
Functional account is required for new machine type
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new functional account creation (nested) - If newfunctionalaccountid = "new" Then - If Len(newfunctionalaccount) = 0 Then - Response.Write("
New functional account name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Insert new functional account using parameterized query - Dim sqlNewFA - sqlNewFA = "INSERT INTO functionalaccounts (functionalaccount, isactive) VALUES (?, 1)" - - On Error Resume Next - Dim cmdNewFA - Set cmdNewFA = Server.CreateObject("ADODB.Command") - cmdNewFA.ActiveConnection = objConn - cmdNewFA.CommandText = sqlNewFA - cmdNewFA.CommandType = 1 - cmdNewFA.Parameters.Append cmdNewFA.CreateParameter("@functionalaccount", 200, 1, 50, newfunctionalaccount) - cmdNewFA.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new functional account: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created functional account ID - Dim rsNewFA - Set rsNewFA = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newfunctionalaccountid = 0 - If Not rsNewFA.EOF Then - If Not IsNull(rsNewFA("newid")) Then - newfunctionalaccountid = CLng(rsNewFA("newid")) - End If - End If - rsNewFA.Close - Set rsNewFA = Nothing - Set cmdNewFA = Nothing - On Error Goto 0 - End If - - ' Insert new machine type using parameterized query - Dim sqlNewMT - sqlNewMT = "INSERT INTO machinetypes (machinetype, machinedescription, functionalaccountid, isactive) VALUES (?, ?, ?, 1)" - - On Error Resume Next - Dim cmdNewMT - Set cmdNewMT = Server.CreateObject("ADODB.Command") - cmdNewMT.ActiveConnection = objConn - cmdNewMT.CommandText = sqlNewMT - cmdNewMT.CommandType = 1 - cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@machinetype", 200, 1, 50, newmachinetype) - cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@machinedescription", 200, 1, 255, newmachinedescription) - cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@functionalaccountid", 3, 1, , CLng(newfunctionalaccountid)) - cmdNewMT.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new machine type: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created machine type ID - Dim rsNewMT - Set rsNewMT = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - machinetypeid = 0 - If Not rsNewMT.EOF Then - If Not IsNull(rsNewMT("newid")) Then - machinetypeid = CLng(rsNewMT("newid")) - End If - End If - rsNewMT.Close - Set rsNewMT = Nothing - Set cmdNewMT = Nothing - On Error Goto 0 - End If - - '============================================================================= - ' SECURITY: Handle new model creation with parameterized query - '============================================================================= - If modelid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Write("
New model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Write("
Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Write("
New vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Insert new vendor using parameterized query - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) VALUES (?, 1, 0, 0, 1)" - - On Error Resume Next - Dim cmdNewVendor - Set cmdNewVendor = Server.CreateObject("ADODB.Command") - cmdNewVendor.ActiveConnection = objConn - cmdNewVendor.CommandText = sqlNewVendor - cmdNewVendor.CommandType = 1 - cmdNewVendor.Parameters.Append cmdNewVendor.CreateParameter("@vendor", 200, 1, 50, newvendorname) - cmdNewVendor.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new vendor: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = 0 - If Not rsNewVendor.EOF Then - If Not IsNull(rsNewVendor("newid")) Then - newvendorid = CLng(rsNewVendor("newid")) - End If - End If - rsNewVendor.Close - Set rsNewVendor = Nothing - Set cmdNewVendor = Nothing - On Error Goto 0 - End If - - ' Set default image if not specified - If newmodelimage = "" Then - newmodelimage = "default.png" - End If - - ' Insert new model using parameterized query - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, image, isactive) VALUES (?, ?, ?, 1)" - - On Error Resume Next - Dim cmdNewModel - Set cmdNewModel = Server.CreateObject("ADODB.Command") - cmdNewModel.ActiveConnection = objConn - cmdNewModel.CommandText = sqlNewModel - cmdNewModel.CommandType = 1 - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@modelnumber", 200, 1, 255, newmodelnumber) - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@vendorid", 3, 1, , CLng(newvendorid)) - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@image", 200, 1, 255, newmodelimage) - cmdNewModel.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new model: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = 0 - If Not rsNewModel.EOF Then - If Not IsNull(rsNewModel("newid")) Then - modelid = CLng(rsNewModel("newid")) - End If - End If - rsNewModel.Close - Set rsNewModel = Nothing - Set cmdNewModel = Nothing - On Error Goto 0 - End If - - '============================================================================= - ' SECURITY: Update machine using parameterized query - '============================================================================= - ' Build UPDATE statement with parameterized query - Dim strSQL, paramCount - paramCount = 0 - - strSQL = "UPDATE machines SET modelnumberid = ?, machinetypeid = ?, businessunitid = ?" - paramCount = 3 - - ' Add optional printerid - If printerid > 0 Then - strSQL = strSQL & ", printerid = ?" - paramCount = paramCount + 1 - End If - - ' Add optional map coordinates - If mapleft > 0 And maptop > 0 Then - strSQL = strSQL & ", mapleft = ?, maptop = ?" - paramCount = paramCount + 2 - End If - - strSQL = strSQL & " WHERE machineid = ?" - - On Error Resume Next - Dim cmdUpdate - Set cmdUpdate = Server.CreateObject("ADODB.Command") - cmdUpdate.ActiveConnection = objConn - cmdUpdate.CommandText = strSQL - cmdUpdate.CommandType = 1 - - ' Add parameters in order - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@modelnumberid", 3, 1, , CLng(modelid)) - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@machinetypeid", 3, 1, , CLng(machinetypeid)) - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@businessunitid", 3, 1, , CLng(businessunitid)) - - If printerid > 0 Then - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@printerid", 3, 1, , CLng(printerid)) - End If - - If mapleft > 0 And maptop > 0 Then - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@mapleft", 3, 1, , CLng(mapleft)) - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@maptop", 3, 1, , CLng(maptop)) - End If - - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@machineid", 3, 1, , CLng(machineid)) - - cmdUpdate.Execute - - If Err.Number <> 0 Then - Response.Write("
Error: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdUpdate = Nothing - objConn.Close - Response.End - End If - - Set cmdUpdate = Nothing - On Error Goto 0 -%> - -<% -'============================================================================= -' CLEANUP -'============================================================================= -objConn.Close -%> -
- - diff --git a/editprinter.asp.backup-20251027 b/editprinter.asp.backup-20251027 deleted file mode 100644 index 501f49a..0000000 --- a/editprinter.asp.backup-20251027 +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - -
-<% - ' Get and validate all inputs - Dim printerid, modelid, serialnumber, ipaddress, fqdn, printercsfname, printerwindowsname, machineid, maptop, mapleft - printerid = Trim(Request.Querystring("printerid")) - modelid = Trim(Request.Form("modelid")) - serialnumber = Trim(Request.Form("serialnumber")) - ipaddress = Trim(Request.Form("ipaddress")) - fqdn = Trim(Request.Form("fqdn")) - printercsfname = Trim(Request.Form("printercsfname")) - printerwindowsname = Trim(Request.Form("printerwindowsname")) - machineid = Trim(Request.Form("machineid")) - maptop = Trim(Request.Form("maptop")) - mapleft = Trim(Request.Form("mapleft")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid, newmodelnotes, newmodeldocpath - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - newmodelnotes = Trim(Request.Form("newmodelnotes")) - newmodeldocpath = Trim(Request.Form("newmodeldocpath")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields - If Not IsNumeric(printerid) Or CLng(printerid) < 1 Then - Response.Write("
Error: Invalid printer ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If modelid <> "new" And (Not IsNumeric(modelid)) Then - Response.Write("
Error: Invalid model ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Not IsNumeric(machineid) Then - Response.Write("
Error: Invalid machine ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate field lengths - If Len(serialnumber) > 100 Or Len(fqdn) > 255 Or Len(printercsfname) > 50 Or Len(printerwindowsname) > 255 Then - Response.Write("
Error: Field length exceeded.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new model creation - If modelid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Write("
New model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Write("
Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 255 Or Len(newmodelnotes) > 255 Or Len(newmodeldocpath) > 255 Then - Response.Write("
Model field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Write("
New vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Write("
Vendor name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedVendorName - escapedVendorName = Replace(newvendorname, "'", "''") - - ' Insert new vendor (with isprinter=1) - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) " & _ - "VALUES ('" & escapedVendorName & "', 1, 1, 0, 0)" - - On Error Resume Next - objConn.Execute sqlNewVendor - - If Err.Number <> 0 Then - Response.Write("
Error creating new vendor: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for model - Dim escapedModelNumber, escapedModelNotes, escapedModelDocPath - escapedModelNumber = Replace(newmodelnumber, "'", "''") - escapedModelNotes = Replace(newmodelnotes, "'", "''") - escapedModelDocPath = Replace(newmodeldocpath, "'", "''") - - ' Insert new model - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) " & _ - "VALUES ('" & escapedModelNumber & "', " & newvendorid & ", '" & escapedModelNotes & "', '" & escapedModelDocPath & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - - If Err.Number <> 0 Then - Response.Write("
Error creating new model: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - End If - - ' Escape single quotes - serialnumber = Replace(serialnumber, "'", "''") - ipaddress = Replace(ipaddress, "'", "''") - fqdn = Replace(fqdn, "'", "''") - printercsfname = Replace(printercsfname, "'", "''") - printerwindowsname = Replace(printerwindowsname, "'", "''") - - ' Handle map coordinates - default to 50 if not provided - Dim maptopSQL, mapleftSQL - If maptop <> "" And IsNumeric(maptop) Then - maptopSQL = maptop - Else - maptopSQL = "50" - End If - - If mapleft <> "" And IsNumeric(mapleft) Then - mapleftSQL = mapleft - Else - mapleftSQL = "50" - End If - - ' Build UPDATE statement - Dim strSQL - strSQL = "UPDATE printers SET " & _ - "modelid = " & modelid & ", " & _ - "serialnumber = '" & serialnumber & "', " & _ - "ipaddress = '" & ipaddress & "', " & _ - "fqdn = '" & fqdn & "', " & _ - "printercsfname = '" & printercsfname & "', " & _ - "printerwindowsname = '" & printerwindowsname & "', " & _ - "machineid = " & machineid & ", " & _ - "maptop = " & maptopSQL & ", " & _ - "mapleft = " & mapleftSQL & " " & _ - "WHERE printerid = " & printerid - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number <> 0 Then - Response.Write("
Error: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - objConn.Close -%> - -
- - \ No newline at end of file diff --git a/includes/data_cache.asp.backup-20251113-064544 b/includes/data_cache.asp.backup-20251113-064544 deleted file mode 100644 index 4e7707b..0000000 --- a/includes/data_cache.asp.backup-20251113-064544 +++ /dev/null @@ -1,417 +0,0 @@ -<% -' Universal data caching system for frequently accessed database queries -' Uses Application-level cache with configurable TTL (Time To Live) - -' Cache durations in minutes -Const CACHE_DROPDOWN_TTL = 60 ' Dropdowns (vendors, models) - 1 hour -Const CACHE_LIST_TTL = 5 ' List pages (printers, machines) - 5 minutes -Const CACHE_STATIC_TTL = 1440 ' Static data (rarely changes) - 24 hours - -'============================================================================= -' DROPDOWN DATA CACHING (Vendors, Models, etc.) -'============================================================================= - -' Get all printer vendors (cached) -Function GetPrinterVendorsCached() - Dim cacheKey, cacheAge, cachedData - cacheKey = "dropdown_printer_vendors" - - ' Check cache - If Not IsEmpty(Application(cacheKey)) Then - cacheAge = DateDiff("n", Application(cacheKey & "_time"), Now()) - If cacheAge < CACHE_DROPDOWN_TTL Then - GetPrinterVendorsCached = Application(cacheKey) - Exit Function - End If - End If - - ' Fetch from database - Dim sql, rs_temp, resultArray(), count, i - sql = "SELECT vendorid, vendor FROM vendors WHERE isprinter=1 AND isactive=1 ORDER BY vendor ASC" - - Set rs_temp = objConn.Execute(sql) - - ' Count rows - count = 0 - While Not rs_temp.EOF - count = count + 1 - rs_temp.MoveNext - Wend - - If count = 0 Then - Set rs_temp = Nothing - GetPrinterVendorsCached = Array() - Exit Function - End If - - ' Reset to beginning - rs_temp.MoveFirst - - ' Build array - ReDim resultArray(count - 1, 1) ' vendorid, vendor - i = 0 - While Not rs_temp.EOF - resultArray(i, 0) = rs_temp("vendorid") - resultArray(i, 1) = rs_temp("vendor") - i = i + 1 - rs_temp.MoveNext - Wend - - rs_temp.Close - Set rs_temp = Nothing - - ' Cache it - Application.Lock - Application(cacheKey) = resultArray - Application(cacheKey & "_time") = Now() - Application.Unlock - - GetPrinterVendorsCached = resultArray -End Function - -' Get all printer models (cached) -Function GetPrinterModelsCached() - Dim cacheKey, cacheAge, cachedData - cacheKey = "dropdown_printer_models" - - ' Check cache - If Not IsEmpty(Application(cacheKey)) Then - cacheAge = DateDiff("n", Application(cacheKey & "_time"), Now()) - If cacheAge < CACHE_DROPDOWN_TTL Then - GetPrinterModelsCached = Application(cacheKey) - Exit Function - End If - End If - - ' Fetch from database - Dim sql, rs_temp, resultArray(), count, i - sql = "SELECT models.modelnumberid, models.modelnumber, vendors.vendor " & _ - "FROM vendors, models " & _ - "WHERE models.vendorid = vendors.vendorid " & _ - "AND vendors.isprinter=1 AND models.isactive=1 " & _ - "ORDER BY modelnumber ASC" - - Set rs_temp = objConn.Execute(sql) - - ' Count rows - count = 0 - While Not rs_temp.EOF - count = count + 1 - rs_temp.MoveNext - Wend - - If count = 0 Then - Set rs_temp = Nothing - GetPrinterModelsCached = Array() - Exit Function - End If - - ' Reset to beginning - rs_temp.MoveFirst - - ' Build array - ReDim resultArray(count - 1, 2) ' modelnumberid, modelnumber, vendor - i = 0 - While Not rs_temp.EOF - resultArray(i, 0) = rs_temp("modelnumberid") - resultArray(i, 1) = rs_temp("modelnumber") - resultArray(i, 2) = rs_temp("vendor") - i = i + 1 - rs_temp.MoveNext - Wend - - rs_temp.Close - Set rs_temp = Nothing - - ' Cache it - Application.Lock - Application(cacheKey) = resultArray - Application(cacheKey & "_time") = Now() - Application.Unlock - - GetPrinterModelsCached = resultArray -End Function - -'============================================================================= -' LIST PAGE CACHING (Printer list, Machine list, etc.) -'============================================================================= - -' Get all active printers (cached) - for displayprinters.asp -Function GetPrinterListCached() - Dim cacheKey, cacheAge - cacheKey = "list_printers" - - ' Check cache - If Not IsEmpty(Application(cacheKey)) Then - cacheAge = DateDiff("n", Application(cacheKey & "_time"), Now()) - If cacheAge < CACHE_LIST_TTL Then - GetPrinterListCached = Application(cacheKey) - Exit Function - End If - End If - - ' Fetch from database - Dim sql, rs_temp, resultArray(), count, i - sql = "SELECT printers.printerid AS printer, printers.*, vendors.*, models.*, machines.* " & _ - "FROM printers, vendors, models, machines " & _ - "WHERE printers.modelid=models.modelnumberid " & _ - "AND models.vendorid=vendors.vendorid " & _ - "AND printers.machineid=machines.machineid " & _ - "AND printers.isactive=1 " & _ - "ORDER BY machinenumber ASC" - - Set rs_temp = objConn.Execute(sql) - - ' Count rows - count = 0 - While Not rs_temp.EOF - count = count + 1 - rs_temp.MoveNext - Wend - - If count = 0 Then - Set rs_temp = Nothing - GetPrinterListCached = Array() - Exit Function - End If - - rs_temp.MoveFirst - - ' Build array with all needed fields - ReDim resultArray(count - 1, 11) ' printer, image, installpath, machinenumber, machineid, vendor, modelnumber, documentationpath, printercsfname, ipaddress, serialnumber, islocationonly - i = 0 - While Not rs_temp.EOF - resultArray(i, 0) = rs_temp("printer") - resultArray(i, 1) = rs_temp("image") - resultArray(i, 2) = rs_temp("installpath") - resultArray(i, 3) = rs_temp("machinenumber") - resultArray(i, 4) = rs_temp("machineid") - resultArray(i, 5) = rs_temp("vendor") - resultArray(i, 6) = rs_temp("modelnumber") - resultArray(i, 7) = rs_temp("documentationpath") - resultArray(i, 8) = rs_temp("printercsfname") - resultArray(i, 9) = rs_temp("ipaddress") - resultArray(i, 10) = rs_temp("serialnumber") - - ' Convert islocationonly bit to 1/0 integer (bit fields come as binary) - On Error Resume Next - If IsNull(rs_temp("islocationonly")) Then - resultArray(i, 11) = 0 - Else - ' Convert bit field to integer (0 or 1) - resultArray(i, 11) = Abs(CBool(rs_temp("islocationonly"))) - End If - On Error Goto 0 - - i = i + 1 - rs_temp.MoveNext - Wend - - rs_temp.Close - Set rs_temp = Nothing - - ' Cache it - Application.Lock - Application(cacheKey) = resultArray - Application(cacheKey & "_time") = Now() - Application.Unlock - - GetPrinterListCached = resultArray -End Function - -'============================================================================= -' HELPER FUNCTIONS -'============================================================================= - -' Render dropdown options from cached vendor data -Function RenderVendorOptions(selectedID) - Dim vendors, output, i - vendors = GetPrinterVendorsCached() - output = "" - - On Error Resume Next - If Not IsArray(vendors) Or UBound(vendors) < 0 Then - RenderVendorOptions = "" - Exit Function - End If - On Error Goto 0 - - For i = 0 To UBound(vendors) - If CLng(vendors(i, 0)) = CLng(selectedID) Then - output = output & "" - Else - output = output & "" - End If - Next - - RenderVendorOptions = output -End Function - -' Render dropdown options from cached model data -Function RenderModelOptions(selectedID) - Dim models, output, i - models = GetPrinterModelsCached() - output = "" - - On Error Resume Next - If Not IsArray(models) Or UBound(models) < 0 Then - RenderModelOptions = "" - Exit Function - End If - On Error Goto 0 - - For i = 0 To UBound(models) - If CLng(models(i, 0)) = CLng(selectedID) Then - output = output & "" - Else - output = output & "" - End If - Next - - RenderModelOptions = output -End Function - -' Get all support teams (cached) - for application dropdowns -Function GetSupportTeamsCached() - Dim cacheKey, cacheAge, cachedData - cacheKey = "dropdown_support_teams" - - ' Check cache - If Not IsEmpty(Application(cacheKey)) Then - cacheAge = DateDiff("n", Application(cacheKey & "_time"), Now()) - If cacheAge < CACHE_DROPDOWN_TTL Then - GetSupportTeamsCached = Application(cacheKey) - Exit Function - End If - End If - - ' Fetch from database - Dim sql, rs_temp, resultArray(), count, i - sql = "SELECT supporteamid, teamname FROM supportteams WHERE isactive=1 ORDER BY teamname ASC" - - Set rs_temp = objConn.Execute(sql) - - ' Count rows - count = 0 - While Not rs_temp.EOF - count = count + 1 - rs_temp.MoveNext - Wend - - If count = 0 Then - Set rs_temp = Nothing - GetSupportTeamsCached = Array() - Exit Function - End If - - ' Reset to beginning - rs_temp.MoveFirst - - ' Build array - ReDim resultArray(count - 1, 1) ' supporteamid, teamname - i = 0 - While Not rs_temp.EOF - resultArray(i, 0) = rs_temp("supporteamid") - resultArray(i, 1) = rs_temp("teamname") - i = i + 1 - rs_temp.MoveNext - Wend - - rs_temp.Close - Set rs_temp = Nothing - - ' Cache it - Application.Lock - Application(cacheKey) = resultArray - Application(cacheKey & "_time") = Now() - Application.Unlock - - GetSupportTeamsCached = resultArray -End Function - -' Render dropdown options from cached support team data -Function RenderSupportTeamOptions(selectedID) - Dim teams, output, i - teams = GetSupportTeamsCached() - output = "" - - On Error Resume Next - If Not IsArray(teams) Or UBound(teams) < 0 Then - RenderSupportTeamOptions = "" - Exit Function - End If - On Error Goto 0 - - For i = 0 To UBound(teams) - If CLng(teams(i, 0)) = CLng(selectedID) Then - output = output & "" - Else - output = output & "" - End If - Next - - RenderSupportTeamOptions = output -End Function - -' Clear dropdown cache (call after adding/editing vendors or models) -Sub ClearDropdownCache() - Application.Lock - Application("dropdown_printer_vendors") = Empty - Application("dropdown_printer_vendors_time") = Empty - Application("dropdown_printer_models") = Empty - Application("dropdown_printer_models_time") = Empty - Application("dropdown_support_teams") = Empty - Application("dropdown_support_teams_time") = Empty - Application.Unlock -End Sub - -' Clear list cache (call after adding/editing printers) -Sub ClearListCache() - Application.Lock - Application("list_printers") = Empty - Application("list_printers_time") = Empty - Application.Unlock -End Sub - -' Clear ALL data cache -Sub ClearAllDataCache() - Dim key, keysToRemove(), count, i - count = 0 - - ' First pass: collect keys to remove - ReDim keysToRemove(100) ' Initial size - For Each key In Application.Contents - If Left(key, 9) = "dropdown_" Or Left(key, 5) = "list_" Then - keysToRemove(count) = key - count = count + 1 - If count Mod 100 = 0 Then - ReDim Preserve keysToRemove(count + 100) - End If - End If - Next - - ' Second pass: remove collected keys - Application.Lock - For i = 0 To count - 1 - Application.Contents.Remove(keysToRemove(i)) - Next - Application.Unlock -End Sub - -' Get cache stats -Function GetCacheStats() - Dim stats, key, count - count = 0 - - For Each key In Application.Contents - If Left(key, 9) = "dropdown_" Or Left(key, 5) = "list_" Or Left(key, 7) = "zabbix_" Then - If Right(key, 5) <> "_time" And Right(key, 11) <> "_refreshing" Then - count = count + 1 - End If - End If - Next - - stats = "Cached items: " & count - GetCacheStats = stats -End Function -%> diff --git a/includes/sql.asp.production b/includes/sql.asp.production deleted file mode 100644 index 674ede7..0000000 --- a/includes/sql.asp.production +++ /dev/null @@ -1,8 +0,0 @@ -<% - ' objConn - script-global connection object (no Dim for global scope) - Session.Timeout=15 - Set objConn=Server.CreateObject("ADODB.Connection") - objConn.ConnectionString="DSN=shopdb;Uid=root;Pwd=WJF11sql;Option=3;Pooling=True;Max Pool Size=100;" - objConn.Open - set rs = server.createobject("ADODB.Recordset") -%> \ No newline at end of file diff --git a/includes/wjf_employees-sql.asp.produciton b/includes/wjf_employees-sql.asp.produciton deleted file mode 100644 index 889f105..0000000 --- a/includes/wjf_employees-sql.asp.produciton +++ /dev/null @@ -1,8 +0,0 @@ -<% - Dim objConn - Session.Timeout=15 - Set objConn=Server.CreateObject("ADODB.Connection") - objConn.ConnectionString="DSN=wjf_employees;Uid=root;Pwd=WJF11sql;Option=3;Pooling=True;Max Pool Size=100;" - objConn.Open - set rs = server.createobject("ADODB.Recordset") -%> \ No newline at end of file diff --git a/includes/zabbix_cached.asp.backup-20251113-064547 b/includes/zabbix_cached.asp.backup-20251113-064547 deleted file mode 100644 index 6a5c735..0000000 --- a/includes/zabbix_cached.asp.backup-20251113-064547 +++ /dev/null @@ -1,130 +0,0 @@ -<% -' Cached Zabbix API wrapper with background refresh -' Include the base zabbix.asp functions -%> - -<% - -' Main cached function - returns data immediately, refreshes in background if stale -Function GetPrinterDataCached(hostIP) - Dim cacheKey, cacheAge, forceRefresh - cacheKey = "zabbix_" & hostIP - - ' Check if manual refresh was requested - forceRefresh = (Request.QueryString("refresh") = "1" And Request.QueryString("ip") = hostIP) - - If forceRefresh Then - ' Clear cache for manual refresh - Application.Lock - Application(cacheKey) = Empty - Application(cacheKey & "_time") = Empty - Application(cacheKey & "_refreshing") = "false" - Application.Unlock - End If - - ' Check if cache exists - If Not IsEmpty(Application(cacheKey)) And Not forceRefresh Then - cacheAge = DateDiff("n", Application(cacheKey & "_time"), Now()) - - ' If cache is stale (>5 min) AND not already refreshing, trigger background update - If cacheAge >= 5 And Application(cacheKey & "_refreshing") <> "true" Then - ' Mark as refreshing - Application.Lock - Application(cacheKey & "_refreshing") = "true" - Application.Unlock - - ' Trigger async background refresh (non-blocking) - On Error Resume Next - Dim http - Set http = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0") - ' True = async (doesn't block user) - http.Open "GET", "http://localhost/refresh_zabbix_cache.asp?ip=" & Server.URLEncode(hostIP), True - http.Send - Set http = Nothing - On Error Goto 0 - End If - - ' Return cached data immediately (user doesn't wait) - GetPrinterDataCached = Application(cacheKey) - Exit Function - End If - - ' No cache exists - fetch initial data (first time only, or after manual refresh) - Dim freshData, zabbixConnected, pingStatus, tonerJSON - - zabbixConnected = ZabbixLogin() - - If zabbixConnected = "1" Then - pingStatus = GetPrinterPingStatus(hostIP) - tonerJSON = GetPrinterTonerLevels(hostIP) - Else - pingStatus = "-1" - tonerJSON = "" - End If - - ' Store as array: [connected, pingStatus, tonerJSON] - Dim resultData(2) - resultData(0) = zabbixConnected - resultData(1) = pingStatus - resultData(2) = tonerJSON - - ' Cache the result - Application.Lock - Application(cacheKey) = resultData - Application(cacheKey & "_time") = Now() - Application(cacheKey & "_refreshing") = "false" - Application.Unlock - - GetPrinterDataCached = resultData -End Function - -' Helper function to get cache age (for display purposes) -Function GetCacheAge(hostIP) - Dim cacheKey, cacheTime - cacheKey = "zabbix_" & hostIP - - If IsEmpty(Application(cacheKey & "_time")) Then - GetCacheAge = -1 - Exit Function - End If - - GetCacheAge = DateDiff("s", Application(cacheKey & "_time"), Now()) -End Function - -' Clear cache for a specific printer (called by manual refresh) -Sub ClearPrinterCache(hostIP) - Dim cacheKey - cacheKey = "zabbix_" & hostIP - - Application.Lock - Application(cacheKey) = Empty - Application(cacheKey & "_time") = Empty - Application(cacheKey & "_refreshing") = "false" - Application.Unlock -End Sub - -' Clear all Zabbix cache (admin function) -Sub ClearAllZabbixCache() - Dim key, keysToRemove(), count, i - count = 0 - - ' First pass: collect keys to remove - ReDim keysToRemove(100) ' Initial size - For Each key In Application.Contents - If Left(key, 7) = "zabbix_" Then - keysToRemove(count) = key - count = count + 1 - If count Mod 100 = 0 Then - ReDim Preserve keysToRemove(count + 100) - End If - End If - Next - - ' Second pass: remove collected keys - Application.Lock - For i = 0 To count - 1 - Application.Contents.Remove(keysToRemove(i)) - Next - Application.Unlock -End Sub -%> diff --git a/listpcs.asp b/listpcs.asp deleted file mode 100644 index 8901cc6..0000000 --- a/listpcs.asp +++ /dev/null @@ -1,297 +0,0 @@ -<%' Cache buster: 20251110-1430 %> - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-
PCs
- -
-<% -Dim currentPCType, currentPCStatus, recentFilter, deviceTypeFilter, sel -currentPCType = Request.QueryString("pctype") -currentPCStatus = Request.QueryString("pcstatus") -recentFilter = Request.QueryString("recent") -deviceTypeFilter = Request.QueryString("devicetype") -%> -
- - - - - <% If currentPCType <> "" Or currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Then %> - - Clear - - <% End If %> - -
-
-
- - - - - - - - - - - - - -<% - ' Build query based on filters - Dim pcTypeFilter, pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, whereClause - pcTypeFilter = Request.QueryString("pctype") - pcStatusFilter = Request.QueryString("pcstatus") - recentDaysFilter = Request.QueryString("recent") - deviceTypeFilterSQL = Request.QueryString("devicetype") - - ' Base query with LEFT JOINs to show all PCs - strSQL = "SELECT m.machineid, m.hostname, m.alias, m.serialnumber, m.machinenumber, m.pctypeid, m.machinestatusid, " & _ - "m.modelnumberid, m.businessunitid, m.osid, m.loggedinuser, m.lastupdated, " & _ - "vendors.vendor, models.modelnumber, operatingsystems.operatingsystem, " & _ - "c.address AS ipaddress, c.macaddress, " & _ - "models.machinetypeid, pctype.typename, machinestatus.machinestatus " & _ - "FROM machines m " & _ - "LEFT JOIN models ON m.modelnumberid = models.modelnumberid " & _ - "LEFT JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "LEFT JOIN operatingsystems ON m.osid = operatingsystems.osid " & _ - "LEFT JOIN communications c ON c.machineid = m.machineid AND c.isprimary = 1 " & _ - "LEFT JOIN pctype ON m.pctypeid = pctype.pctypeid " & _ - "LEFT JOIN machinestatus ON m.machinestatusid = machinestatus.machinestatusid " & _ - "WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL" - - ' Apply filters - whereClause = "" - If pcTypeFilter <> "" Then - whereClause = whereClause & "AND m.pctypeid = " & pcTypeFilter & " " - End If - - If pcStatusFilter <> "" Then - whereClause = whereClause & "AND m.machinestatusid = " & pcStatusFilter & " " - End If - - If recentDaysFilter <> "" And IsNumeric(recentDaysFilter) Then - whereClause = whereClause & "AND m.lastupdated >= DATE_SUB(NOW(), INTERVAL " & recentDaysFilter & " DAY) " - End If - - ' Filter by device type (laptop vs desktop) based on model name patterns - If deviceTypeFilterSQL = "laptop" Then - whereClause = whereClause & "AND (models.modelnumber LIKE '%Latitude%' OR models.modelnumber LIKE '%Precision%' AND (models.modelnumber NOT LIKE '%Tower%')) " - ElseIf deviceTypeFilterSQL = "desktop" Then - whereClause = whereClause & "AND (models.modelnumber LIKE '%OptiPlex%' OR models.modelnumber LIKE '%Tower%' OR models.modelnumber LIKE '%Micro%') " - End If - - strSQL = strSQL & whereClause & " GROUP BY m.machineid ORDER BY m.machinenumber ASC, m.hostname ASC" - - set rs = objconn.Execute(strSQL) - while not rs.eof - -%> - - - - - - - - -<% - rs.movenext - wend - objConn.Close -%> - -
HostnameSerialIPModelOSMachine
" title="Click to Show PC Details"><% - Dim displayName - If IsNull(rs("hostname")) Or rs("hostname") = "" Then - displayName = rs("serialnumber") - Else - displayName = rs("hostname") - End If - Response.Write(displayName) - %><%Response.Write(rs("serialnumber"))%><%Response.Write(rs("ipaddress"))%><%Response.Write(rs("modelnumber"))%><%Response.Write(rs("operatingsystem"))%>" title="Click to Show Machine Details"><%Response.Write(rs("machinenumber"))%>
-
-
-
-
-
- - - -
- - - - - -
-
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - diff --git a/network_map.asp.backup-20251113-064542 b/network_map.asp.backup-20251113-064542 deleted file mode 100644 index 4337926..0000000 --- a/network_map.asp.backup-20251113-064542 +++ /dev/null @@ -1,443 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-   Network Infrastructure Map -
-
- - - -
-
-
-
-
-
- -
-
-
- Legend -
-
-

- Equipment type color codes: -

- -
-
- - Printer -
-
- - Access Point -
-
- - IDF -
-
- - Camera -
-
- - Switch -
-
- - Server -
-
- -
- Tips: -
    -
  • Hover over markers for details
  • -
  • Use search to find specific equipment
  • -
  • Filter by type to focus on specific equipment
  • -
  • Click "View Details" for full information
  • -
-
-
-
-
-
- -
- - - - - -
- - - - - - - - - - - - - - - - - - - diff --git a/pc_edit.asp.broken b/pc_edit.asp.broken deleted file mode 100644 index 9803269..0000000 --- a/pc_edit.asp.broken +++ /dev/null @@ -1,1136 +0,0 @@ - - - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - ' Get and validate pcid parameter - Dim machineid, machineData, strSQL - machineid = Request.QueryString("pcid") - - ' Security validation - ensure pcid is numeric - If NOT IsNumeric(machineid) OR machineid = "" Then - Response.Redirect("./displaypcs.asp") - Response.End - End If - - ' Load PC data (pctypeid IS NOT NULL identifies PCs) - strSQL = "SELECT m.*, " &_ - "mo.modelnumber, mo.vendorid AS modelvendorid, mo.machinetypeid, mo.image AS modelimage, " &_ - "v.vendor, " &_ - "bu.businessunit, " &_ - "mt.machinetype " &_ - "FROM machines m " &_ - "LEFT JOIN models mo ON m.modelnumberid = mo.modelnumberid " &_ - "LEFT JOIN vendors v ON mo.vendorid = v.vendorid " &_ - "LEFT JOIN businessunits bu ON m.businessunitid = bu.businessunitid " &_ - "LEFT JOIN machinetypes mt ON mo.machinetypeid = mt.machinetypeid " &_ - "WHERE m.machineid = ? AND m.pctypeid IS NOT NULL" - - Dim cmd, rsMachine - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Set rsMachine = cmd.Execute - - If rsMachine.EOF Then - rsMachine.Close - Set rsMachine = Nothing - Set cmd = Nothing - objConn.Close - Response.Redirect("./displaypcs.asp") - Response.End - End If - - ' Store machine data - Dim machinenumber, modelid, businessunitid, alias, machinenotes, mapleft, maptop - machinenumber = "" : If NOT IsNull(rsMachine("machinenumber")) Then machinenumber = rsMachine("machinenumber") & "" - modelid = "" : If NOT IsNull(rsMachine("modelnumberid")) Then modelid = rsMachine("modelnumberid") - businessunitid = "" : If NOT IsNull(rsMachine("businessunitid")) Then businessunitid = rsMachine("businessunitid") - alias = "" : If NOT IsNull(rsMachine("alias")) Then alias = rsMachine("alias") & "" - machinenotes = "" : If NOT IsNull(rsMachine("machinenotes")) Then machinenotes = rsMachine("machinenotes") & "" - mapleft = "" : If NOT IsNull(rsMachine("mapleft")) Then mapleft = rsMachine("mapleft") - maptop = "" : If NOT IsNull(rsMachine("maptop")) Then maptop = rsMachine("maptop") - - rsMachine.Close - Set rsMachine = Nothing - Set cmd = Nothing - - ' Load network interfaces from communications table - Dim ip1, mac1, ip2, mac2, ip3, mac3 - ip1 = "" : mac1 = "" : ip2 = "" : mac2 = "" : ip3 = "" : mac3 = "" - - strSQL = "SELECT address, macaddress FROM communications WHERE machineid = ? AND isactive = 1 ORDER BY isprimary DESC" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsComms - Set rsComms = cmd.Execute - - Dim interfaceCount - interfaceCount = 0 - While NOT rsComms.EOF AND interfaceCount < 3 - interfaceCount = interfaceCount + 1 - If interfaceCount = 1 Then - If NOT IsNull(rsComms("address")) Then ip1 = rsComms("address") - If NOT IsNull(rsComms("macaddress")) Then mac1 = rsComms("macaddress") - ElseIf interfaceCount = 2 Then - If NOT IsNull(rsComms("address")) Then ip2 = rsComms("address") - If NOT IsNull(rsComms("macaddress")) Then mac2 = rsComms("macaddress") - ElseIf interfaceCount = 3 Then - If NOT IsNull(rsComms("address")) Then ip3 = rsComms("address") - If NOT IsNull(rsComms("macaddress")) Then mac3 = rsComms("macaddress") - End If - rsComms.MoveNext - Wend - rsComms.Close - Set rsComms = Nothing - Set cmd = Nothing - - ' Load controlling PC from machinerelationships - ' Note: Controls relationship is PC → Equipment, so we need machineid (PC) where related_machineid is this equipment - Dim controllingpcid - controllingpcid = "" - strSQL = "SELECT mr.machineid AS controlpcid FROM machinerelationships mr " &_ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ - "WHERE mr.related_machineid = ? AND rt.relationshiptype = 'Controls' AND mr.isactive = 1" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsControlPC - Set rsControlPC = cmd.Execute - If NOT rsControlPC.EOF Then - If NOT IsNull(rsControlPC("controlpcid")) Then controllingpcid = rsControlPC("controlpcid") - End If - rsControlPC.Close - Set rsControlPC = Nothing - Set cmd = Nothing - - ' Load dualpath from machinerelationships - Dim dualpathid - dualpathid = "" - strSQL = "SELECT related_machineid FROM machinerelationships mr " &_ - "JOIN relationshiptypes rt ON mr.relationshiptypeid = rt.relationshiptypeid " &_ - "WHERE mr.machineid = ? AND rt.relationshiptype = 'Dualpath' AND mr.isactive = 1" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsDualpath - Set rsDualpath = cmd.Execute - If NOT rsDualpath.EOF Then - If NOT IsNull(rsDualpath("related_machineid")) Then dualpathid = rsDualpath("related_machineid") - End If - rsDualpath.Close - Set rsDualpath = Nothing - Set cmd = Nothing - - ' Load compliance data - Dim thirdpartymanaged, thirdpartymanager, otassetsystem, dodassettype - thirdpartymanaged = "NA" : thirdpartymanager = "" : otassetsystem = "" : dodassettype = "" - - strSQL = "SELECT * FROM compliance WHERE machineid = ?" - Set cmd = Server.CreateObject("ADODB.Command") - cmd.ActiveConnection = objConn - cmd.CommandText = strSQL - cmd.CommandType = 1 - cmd.Parameters.Append cmd.CreateParameter("@machineid", 3, 1, , machineid) - Dim rsCompliance - Set rsCompliance = cmd.Execute - If NOT rsCompliance.EOF Then - If NOT IsNull(rsCompliance("is_third_party_managed")) Then thirdpartymanaged = rsCompliance("is_third_party_managed") - If NOT IsNull(rsCompliance("third_party_manager")) Then thirdpartymanager = rsCompliance("third_party_manager") - If NOT IsNull(rsCompliance("ot_asset_system")) Then otassetsystem = rsCompliance("ot_asset_system") - If NOT IsNull(rsCompliance("ot_asset_device_type")) Then dodassettype = rsCompliance("ot_asset_device_type") - End If - rsCompliance.Close - Set rsCompliance = Nothing - Set cmd = Nothing -%> - - - -
- - -
- - - - -
- -
-
- -
-
-
-
-
-
- Edit Equipment -
- - Back to Machines - -
- -
- - - - - - -
- - - - -
- -
- - - Machine number cannot be changed -
- -
- -
- -
- -
-
-
- - - - -
- -
- -
- -
-
-
- - - - -
- - -
- -
- - -
- -
- - - - -
-
Network Communications
-

Configure network interfaces for this equipment. You can add up to 3 interfaces.

- - -
-
- Interface 1 (Primary) -
-
-
-
-
- - - Example: 192.168.1.100 -
-
-
-
- - - Example: 00:1A:2B:3C:4D:5E -
-
-
-
-
- - -
-
- Interface 2 (Optional) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
-
- Interface 3 (Optional) -
-
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- -
- - - - -
-
Machine Relationships
-

Define relationships between this equipment and other machines or PCs.

- -
- - - Select a PC that controls this equipment -
- -
- - - Select a backup/redundant machine (creates bidirectional relationship) -
- -
- - - - -
-
Compliance & Security
-

Track compliance and security information for this equipment.

- -
- - - Is this equipment managed by a third party? -
- -
- -
- -
- -
-
- Select the vendor managing this equipment -
- - - - -
- - - Operational Technology asset classification -
- -
- - - Department of Defense asset classification -
- -
- - - - -
-
Location
-

Set the physical location of this equipment on the shop floor map.

- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- - -
-
- - - Cancel - -
- -
- -
-
-
-
- - -
- -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - -
-
-
-
Select Location on Map
- -
-
-
-
-
-
No location selected
-
- - -
-
-
-
- - - - - -<% - objConn.Close -%> diff --git a/pclist.asp b/pclist.asp deleted file mode 100644 index 8d3de8f..0000000 --- a/pclist.asp +++ /dev/null @@ -1,297 +0,0 @@ -<%' Cache buster: 20251110-1432 %> - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-
PCs
- -
-<% -Dim currentPCType, currentPCStatus, recentFilter, deviceTypeFilter, sel -currentPCType = Request.QueryString("pctype") -currentPCStatus = Request.QueryString("pcstatus") -recentFilter = Request.QueryString("recent") -deviceTypeFilter = Request.QueryString("devicetype") -%> -
- - - - - <% If currentPCType <> "" Or currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Then %> - - Clear - - <% End If %> - -
-
-
- - - - - - - - - - - - - -<% - ' Build query based on filters - Dim pcTypeFilter, pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, whereClause - pcTypeFilter = Request.QueryString("pctype") - pcStatusFilter = Request.QueryString("pcstatus") - recentDaysFilter = Request.QueryString("recent") - deviceTypeFilterSQL = Request.QueryString("devicetype") - - ' Base query with LEFT JOINs to show all PCs - strSQL = "SELECT m.machineid, m.hostname, m.alias, m.serialnumber, m.machinenumber, m.pctypeid, m.machinestatusid, " & _ - "m.modelnumberid, m.businessunitid, m.osid, m.loggedinuser, m.lastupdated, " & _ - "vendors.vendor, models.modelnumber, operatingsystems.operatingsystem, " & _ - "c.address AS ipaddress, c.macaddress, " & _ - "models.machinetypeid, pctype.typename, machinestatus.machinestatus " & _ - "FROM machines m " & _ - "LEFT JOIN models ON m.modelnumberid = models.modelnumberid " & _ - "LEFT JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "LEFT JOIN operatingsystems ON m.osid = operatingsystems.osid " & _ - "LEFT JOIN communications c ON c.machineid = m.machineid AND c.isprimary = 1 " & _ - "LEFT JOIN pctype ON m.pctypeid = pctype.pctypeid " & _ - "LEFT JOIN machinestatus ON m.machinestatusid = machinestatus.machinestatusid " & _ - "WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL" - - ' Apply filters - whereClause = "" - If pcTypeFilter <> "" Then - whereClause = whereClause & "AND m.pctypeid = " & pcTypeFilter & " " - End If - - If pcStatusFilter <> "" Then - whereClause = whereClause & "AND m.machinestatusid = " & pcStatusFilter & " " - End If - - If recentDaysFilter <> "" And IsNumeric(recentDaysFilter) Then - whereClause = whereClause & "AND m.lastupdated >= DATE_SUB(NOW(), INTERVAL " & recentDaysFilter & " DAY) " - End If - - ' Filter by device type (laptop vs desktop) based on model name patterns - If deviceTypeFilterSQL = "laptop" Then - whereClause = whereClause & "AND (models.modelnumber LIKE '%Latitude%' OR models.modelnumber LIKE '%Precision%' AND (models.modelnumber NOT LIKE '%Tower%')) " - ElseIf deviceTypeFilterSQL = "desktop" Then - whereClause = whereClause & "AND (models.modelnumber LIKE '%OptiPlex%' OR models.modelnumber LIKE '%Tower%' OR models.modelnumber LIKE '%Micro%') " - End If - - strSQL = strSQL & whereClause & " GROUP BY m.machineid ORDER BY m.machinenumber ASC, m.hostname ASC" - - set rs = objconn.Execute(strSQL) - while not rs.eof - -%> - - - - - - - - -<% - rs.movenext - wend - objConn.Close -%> - -
HostnameSerialIPModelOSMachine
" title="Click to Show PC Details"><% - Dim displayName - If IsNull(rs("hostname")) Or rs("hostname") = "" Then - displayName = rs("serialnumber") - Else - displayName = rs("hostname") - End If - Response.Write(displayName) - %><%Response.Write(rs("serialnumber"))%><%Response.Write(rs("ipaddress"))%><%Response.Write(rs("modelnumber"))%><%Response.Write(rs("operatingsystem"))%>" title="Click to Show Machine Details"><%Response.Write(rs("machinenumber"))%>
-
-
-
-
-
- - - -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcs.asp b/pcs.asp deleted file mode 100644 index 8901cc6..0000000 --- a/pcs.asp +++ /dev/null @@ -1,297 +0,0 @@ -<%' Cache buster: 20251110-1430 %> - - - - - - - -<% - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-
PCs
- -
-<% -Dim currentPCType, currentPCStatus, recentFilter, deviceTypeFilter, sel -currentPCType = Request.QueryString("pctype") -currentPCStatus = Request.QueryString("pcstatus") -recentFilter = Request.QueryString("recent") -deviceTypeFilter = Request.QueryString("devicetype") -%> -
- - - - - <% If currentPCType <> "" Or currentPCStatus <> "" Or recentFilter <> "" Or deviceTypeFilter <> "" Then %> - - Clear - - <% End If %> - -
-
-
- - - - - - - - - - - - - -<% - ' Build query based on filters - Dim pcTypeFilter, pcStatusFilter, recentDaysFilter, deviceTypeFilterSQL, whereClause - pcTypeFilter = Request.QueryString("pctype") - pcStatusFilter = Request.QueryString("pcstatus") - recentDaysFilter = Request.QueryString("recent") - deviceTypeFilterSQL = Request.QueryString("devicetype") - - ' Base query with LEFT JOINs to show all PCs - strSQL = "SELECT m.machineid, m.hostname, m.alias, m.serialnumber, m.machinenumber, m.pctypeid, m.machinestatusid, " & _ - "m.modelnumberid, m.businessunitid, m.osid, m.loggedinuser, m.lastupdated, " & _ - "vendors.vendor, models.modelnumber, operatingsystems.operatingsystem, " & _ - "c.address AS ipaddress, c.macaddress, " & _ - "models.machinetypeid, pctype.typename, machinestatus.machinestatus " & _ - "FROM machines m " & _ - "LEFT JOIN models ON m.modelnumberid = models.modelnumberid " & _ - "LEFT JOIN vendors ON models.vendorid = vendors.vendorid " & _ - "LEFT JOIN operatingsystems ON m.osid = operatingsystems.osid " & _ - "LEFT JOIN communications c ON c.machineid = m.machineid AND c.isprimary = 1 " & _ - "LEFT JOIN pctype ON m.pctypeid = pctype.pctypeid " & _ - "LEFT JOIN machinestatus ON m.machinestatusid = machinestatus.machinestatusid " & _ - "WHERE m.isactive = 1 AND m.pctypeid IS NOT NULL" - - ' Apply filters - whereClause = "" - If pcTypeFilter <> "" Then - whereClause = whereClause & "AND m.pctypeid = " & pcTypeFilter & " " - End If - - If pcStatusFilter <> "" Then - whereClause = whereClause & "AND m.machinestatusid = " & pcStatusFilter & " " - End If - - If recentDaysFilter <> "" And IsNumeric(recentDaysFilter) Then - whereClause = whereClause & "AND m.lastupdated >= DATE_SUB(NOW(), INTERVAL " & recentDaysFilter & " DAY) " - End If - - ' Filter by device type (laptop vs desktop) based on model name patterns - If deviceTypeFilterSQL = "laptop" Then - whereClause = whereClause & "AND (models.modelnumber LIKE '%Latitude%' OR models.modelnumber LIKE '%Precision%' AND (models.modelnumber NOT LIKE '%Tower%')) " - ElseIf deviceTypeFilterSQL = "desktop" Then - whereClause = whereClause & "AND (models.modelnumber LIKE '%OptiPlex%' OR models.modelnumber LIKE '%Tower%' OR models.modelnumber LIKE '%Micro%') " - End If - - strSQL = strSQL & whereClause & " GROUP BY m.machineid ORDER BY m.machinenumber ASC, m.hostname ASC" - - set rs = objconn.Execute(strSQL) - while not rs.eof - -%> - - - - - - - - -<% - rs.movenext - wend - objConn.Close -%> - -
HostnameSerialIPModelOSMachine
" title="Click to Show PC Details"><% - Dim displayName - If IsNull(rs("hostname")) Or rs("hostname") = "" Then - displayName = rs("serialnumber") - Else - displayName = rs("hostname") - End If - Response.Write(displayName) - %><%Response.Write(rs("serialnumber"))%><%Response.Write(rs("ipaddress"))%><%Response.Write(rs("modelnumber"))%><%Response.Write(rs("operatingsystem"))%>" title="Click to Show Machine Details"><%Response.Write(rs("machinenumber"))%>
-
-
-
-
-
- - - -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/printerlookup.asp b/printerlookup.asp deleted file mode 100644 index cdab2cf..0000000 --- a/printerlookup.asp +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - -<% -' Lookup printer by IP address and redirect to displayprinter.asp -Dim ipaddress, strSQL, rs - -ipaddress = Request.QueryString("ip") - -If ipaddress <> "" Then - strSQL = "SELECT printerid FROM printers WHERE ipaddress = '" & Replace(ipaddress, "'", "''") & "' AND isactive = 1" - Set rs = objConn.Execute(strSQL) - - If Not rs.EOF Then - Response.Redirect("displayprinter.asp?printerid=" & rs("printerid")) - Else - Response.Write("Printer not found with IP: " & Server.HTMLEncode(ipaddress)) - End If - - rs.Close - Set rs = Nothing -Else - Response.Write("No IP address provided") -End If - -objConn.Close -%> - - diff --git a/save_network_device.asp.backup-20251027 b/save_network_device.asp.backup-20251027 deleted file mode 100644 index 226af30..0000000 --- a/save_network_device.asp.backup-20251027 +++ /dev/null @@ -1,448 +0,0 @@ - - - - - -<% -' Universal save endpoint for all network devices (IDF, Server, Switch, Camera) -' Routes to appropriate table based on device type - -' Get device type and ID -Dim deviceType, deviceId, isDelete -deviceType = Trim(Request.Form("type")) -deviceId = Trim(Request.Form("id")) -isDelete = Trim(Request.Form("delete")) - -' Validate device type -If deviceType <> "idf" And deviceType <> "server" And deviceType <> "switch" And deviceType <> "camera" And deviceType <> "accesspoint" Then - Response.Write("
Error: Invalid device type
") - Response.Write("Back to Network Devices") - objConn.Close - Response.End -End If - -' Validate device ID -If deviceId = "" Then deviceId = "0" -If Not IsNumeric(deviceId) Then - Response.Write("
Error: Invalid device ID
") - Response.Write("Back to Network Devices") - objConn.Close - Response.End -End If - -' Map type to table and fields -Dim tableName, idField, nameField, redirectUrl -Select Case deviceType - Case "idf" - tableName = "idfs" - idField = "idfid" - nameField = "idfname" - redirectUrl = "network_devices.asp?filter=IDF" - Case "server" - tableName = "servers" - idField = "serverid" - nameField = "servername" - redirectUrl = "network_devices.asp?filter=Server" - Case "switch" - tableName = "switches" - idField = "switchid" - nameField = "switchname" - redirectUrl = "network_devices.asp?filter=Switch" - Case "camera" - tableName = "cameras" - idField = "cameraid" - nameField = "cameraname" - redirectUrl = "network_devices.asp?filter=Camera" - Case "accesspoint" - tableName = "accesspoints" - idField = "apid" - nameField = "apname" - redirectUrl = "network_devices.asp?filter=Access Point" -End Select - -' Handle DELETE request -If isDelete = "1" Then - ' Soft delete - set isactive = 0 - Dim strDelete - strDelete = "UPDATE " & tableName & " SET isactive = 0 WHERE " & idField & " = " & deviceId - objConn.Execute(strDelete) - objConn.Close - Response.Redirect(redirectUrl) - Response.End -End If - -' Get form data -Dim deviceName, description, maptop, mapleft, isactiveForm -deviceName = Trim(Request.Form(nameField)) -description = Trim(Request.Form("description")) -maptop = Trim(Request.Form("maptop")) -mapleft = Trim(Request.Form("mapleft")) -isactiveForm = Trim(Request.Form("isactive")) - -' Handle isactive - checkbox: checked=1, unchecked=empty string -' Default to 0 (inactive) if not provided (unchecked) -If isactiveForm = "1" Then - isactiveForm = "1" -Else - isactiveForm = "0" -End If - -' Validate name field (required for all) -If deviceName = "" Then - Response.Write("
Error: " & UCase(Left(nameField, 1)) & Mid(nameField, 2) & " is required
") - Response.Write("Go back") - objConn.Close - Response.End -End If - -' Validate field lengths -If Len(deviceName) > 100 Or Len(description) > 255 Then - Response.Write("
Error: Field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End -End If - -' Handle NULL values for optional numeric fields -If maptop = "" Or Not IsNumeric(maptop) Then maptop = "NULL" Else maptop = CLng(maptop) -If mapleft = "" Or Not IsNumeric(mapleft) Then mapleft = "NULL" Else mapleft = CLng(mapleft) - -' Escape single quotes for SQL -deviceName = Replace(deviceName, "'", "''") -description = Replace(description, "'", "''") - -' Build SQL based on device type -Dim strSQL - -If deviceType = "idf" Then - ' IDF - no model/vendor - If deviceId = "0" Then - ' INSERT - strSQL = "INSERT INTO idfs (idfname, description, maptop, mapleft, isactive) " & _ - "VALUES ('" & deviceName & "', '" & description & "', " & maptop & ", " & mapleft & ", " & isactiveForm & ")" - Else - ' UPDATE - strSQL = "UPDATE idfs SET " & _ - "idfname = '" & deviceName & "', " & _ - "description = '" & description & "', " & _ - "maptop = " & maptop & ", " & _ - "mapleft = " & mapleft & ", " & _ - "isactive = " & isactiveForm & " " & _ - "WHERE idfid = " & deviceId - End If - -ElseIf deviceType = "server" Or deviceType = "switch" Or deviceType = "accesspoint" Then - ' Server/Switch/Access Point - has modelid but NO idfid - Dim modelid, serialnumber, ipaddress - modelid = Trim(Request.Form("modelid")) - serialnumber = Trim(Request.Form("serialnumber")) - ipaddress = Trim(Request.Form("ipaddress")) - - ' Handle new model creation - If modelid = "new" Then - Dim newmodelnumber, newvendorid, newmodelnotes, newmodeldocpath, newvendorname - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - newmodelnotes = Trim(Request.Form("newmodelnotes")) - newmodeldocpath = Trim(Request.Form("newmodeldocpath")) - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields for new model - If newmodelnumber = "" Then - Response.Write("
Error: Model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If newvendorid = "" Then - Response.Write("
Error: Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If newvendorname = "" Then - Response.Write("
Error: Vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape and insert new vendor - Dim escapedVendorName, sqlNewVendor - escapedVendorName = Replace(newvendorname, "'", "''") - sqlNewVendor = "INSERT INTO vendors (vendor, isactive) VALUES ('" & escapedVendorName & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewVendor - If Err.Number <> 0 Then - Response.Write("
Error creating vendor: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = rsNewVendor("newid") - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Escape and insert new model - Dim escapedModelNumber, escapedModelNotes, escapedModelDocPath, sqlNewModel - escapedModelNumber = Replace(newmodelnumber, "'", "''") - escapedModelNotes = Replace(newmodelnotes, "'", "''") - escapedModelDocPath = Replace(newmodeldocpath, "'", "''") - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) " & _ - "VALUES ('" & escapedModelNumber & "', " & newvendorid & ", '" & escapedModelNotes & "', '" & escapedModelDocPath & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - If Err.Number <> 0 Then - Response.Write("
Error creating model: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = rsNewModel("newid") - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - ' Handle NULL/empty modelid - ElseIf modelid = "" Or Not IsNumeric(modelid) Then - modelid = "NULL" - Else - modelid = CLng(modelid) - End If - - ' Escape strings - serialnumber = Replace(serialnumber, "'", "''") - ipaddress = Replace(ipaddress, "'", "''") - - ' Validate lengths - If Len(serialnumber) > 100 Or Len(ipaddress) > 45 Then - Response.Write("
Error: Field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If deviceId = "0" Then - ' INSERT - strSQL = "INSERT INTO " & tableName & " (" & nameField & ", modelid, serialnumber, ipaddress, description, maptop, mapleft, isactive) " & _ - "VALUES ('" & deviceName & "', " & modelid & ", '" & serialnumber & "', '" & ipaddress & "', '" & description & "', " & maptop & ", " & mapleft & ", " & isactiveForm & ")" - Else - ' UPDATE - strSQL = "UPDATE " & tableName & " SET " & _ - nameField & " = '" & deviceName & "', " & _ - "modelid = " & modelid & ", " & _ - "serialnumber = '" & serialnumber & "', " & _ - "ipaddress = '" & ipaddress & "', " & _ - "description = '" & description & "', " & _ - "maptop = " & maptop & ", " & _ - "mapleft = " & mapleft & ", " & _ - "isactive = " & isactiveForm & " " & _ - "WHERE " & idField & " = " & deviceId - End If - -ElseIf deviceType = "camera" Then - ' Camera - has modelid, idfid, AND macaddress - Dim cameraModelid, cameraIdfid, cameraSerial, cameraMac, cameraIP - cameraModelid = Trim(Request.Form("modelid")) - cameraIdfid = Trim(Request.Form("idfid")) - cameraSerial = Trim(Request.Form("serialnumber")) - cameraMac = Trim(Request.Form("macaddress")) - cameraIP = Trim(Request.Form("ipaddress")) - - ' Handle new IDF creation for camera - If cameraIdfid = "new" Then - Dim cameraNewidfname, cameraNewidfdescription - cameraNewidfname = Trim(Request.Form("newidfname")) - cameraNewidfdescription = Trim(Request.Form("newidfdescription")) - - ' Validate required fields for new IDF - If cameraNewidfname = "" Then - Response.Write("
Error: IDF name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape and insert new IDF - Dim cameraEscapedIdfName, cameraEscapedIdfDesc, cameraSqlNewIdf - cameraEscapedIdfName = Replace(cameraNewidfname, "'", "''") - cameraEscapedIdfDesc = Replace(cameraNewidfdescription, "'", "''") - cameraSqlNewIdf = "INSERT INTO idfs (idfname, description, isactive) VALUES ('" & cameraEscapedIdfName & "', '" & cameraEscapedIdfDesc & "', 1)" - - On Error Resume Next - objConn.Execute cameraSqlNewIdf - If Err.Number <> 0 Then - Response.Write("
Error creating IDF: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get newly created IDF ID - Dim rsNewIdfCamera - Set rsNewIdfCamera = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - cameraIdfid = CLng(rsNewIdfCamera("newid")) - rsNewIdfCamera.Close - Set rsNewIdfCamera = Nothing - On Error Goto 0 - End If - - ' Validate required idfid for cameras - If cameraIdfid = "" Or Not IsNumeric(cameraIdfid) Or CLng(cameraIdfid) < 1 Then - Response.Write("
Error: IDF location is required for cameras
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new model creation for camera - If cameraModelid = "new" Then - Dim cameraNewmodelnumber, cameraNewvendorid, cameraNewmodelnotes, cameraNewmodeldocpath, cameraNewvendorname - cameraNewmodelnumber = Trim(Request.Form("newmodelnumber")) - cameraNewvendorid = Trim(Request.Form("newvendorid")) - cameraNewmodelnotes = Trim(Request.Form("newmodelnotes")) - cameraNewmodeldocpath = Trim(Request.Form("newmodeldocpath")) - cameraNewvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields for new model - If cameraNewmodelnumber = "" Then - Response.Write("
Error: Model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If cameraNewvendorid = "" Then - Response.Write("
Error: Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If cameraNewvendorid = "new" Then - If cameraNewvendorname = "" Then - Response.Write("
Error: Vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape and insert new vendor - Dim cameraEscapedVendorName, cameraSqlNewVendor - cameraEscapedVendorName = Replace(cameraNewvendorname, "'", "''") - cameraSqlNewVendor = "INSERT INTO vendors (vendor, isactive) VALUES ('" & cameraEscapedVendorName & "', 1)" - - On Error Resume Next - objConn.Execute cameraSqlNewVendor - If Err.Number <> 0 Then - Response.Write("
Error creating vendor: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get newly created vendor ID - Dim rsNewVendorCamera - Set rsNewVendorCamera = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - cameraNewvendorid = rsNewVendorCamera("newid") - rsNewVendorCamera.Close - Set rsNewVendorCamera = Nothing - On Error Goto 0 - End If - - ' Escape and insert new model - Dim cameraEscapedModelNumber, cameraEscapedModelNotes, cameraEscapedModelDocPath, cameraSqlNewModel - cameraEscapedModelNumber = Replace(cameraNewmodelnumber, "'", "''") - cameraEscapedModelNotes = Replace(cameraNewmodelnotes, "'", "''") - cameraEscapedModelDocPath = Replace(cameraNewmodeldocpath, "'", "''") - cameraSqlNewModel = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) " & _ - "VALUES ('" & cameraEscapedModelNumber & "', " & cameraNewvendorid & ", '" & cameraEscapedModelNotes & "', '" & cameraEscapedModelDocPath & "', 1)" - - On Error Resume Next - objConn.Execute cameraSqlNewModel - If Err.Number <> 0 Then - Response.Write("
Error creating model: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get newly created model ID - Dim rsNewModelCamera - Set rsNewModelCamera = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - cameraModelid = rsNewModelCamera("newid") - rsNewModelCamera.Close - Set rsNewModelCamera = Nothing - On Error Goto 0 - ' Handle NULL modelid - ElseIf cameraModelid = "" Or Not IsNumeric(cameraModelid) Then - cameraModelid = "NULL" - Else - cameraModelid = CLng(cameraModelid) - End If - - ' Escape strings - cameraSerial = Replace(cameraSerial, "'", "''") - cameraMac = Replace(cameraMac, "'", "''") - cameraIP = Replace(cameraIP, "'", "''") - - ' Validate lengths - If Len(cameraSerial) > 100 Or Len(cameraMac) > 17 Or Len(cameraIP) > 45 Then - Response.Write("
Error: Field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If deviceId = "0" Then - ' INSERT - strSQL = "INSERT INTO cameras (cameraname, modelid, idfid, serialnumber, macaddress, ipaddress, description, maptop, mapleft, isactive) " & _ - "VALUES ('" & deviceName & "', " & cameraModelid & ", " & cameraIdfid & ", '" & cameraSerial & "', '" & cameraMac & "', '" & cameraIP & "', '" & description & "', " & maptop & ", " & mapleft & ", " & isactiveForm & ")" - Else - ' UPDATE - strSQL = "UPDATE cameras SET " & _ - "cameraname = '" & deviceName & "', " & _ - "modelid = " & cameraModelid & ", " & _ - "idfid = " & cameraIdfid & ", " & _ - "serialnumber = '" & cameraSerial & "', " & _ - "macaddress = '" & cameraMac & "', " & _ - "ipaddress = '" & cameraIP & "', " & _ - "description = '" & description & "', " & _ - "maptop = " & maptop & ", " & _ - "mapleft = " & mapleft & ", " & _ - "isactive = " & isactiveForm & " " & _ - "WHERE cameraid = " & deviceId - End If -End If - -' Execute SQL -On Error Resume Next -objConn.Execute(strSQL) -If Err.Number <> 0 Then - Response.Write("
Error saving device: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - objConn.Close - Response.End -End If -On Error Goto 0 - -' Success - redirect to list -objConn.Close -Response.Redirect(redirectUrl) -%> diff --git a/saveapplication_direct.asp.backup-20251027 b/saveapplication_direct.asp.backup-20251027 deleted file mode 100644 index 3c426e9..0000000 --- a/saveapplication_direct.asp.backup-20251027 +++ /dev/null @@ -1,248 +0,0 @@ - -<% -' Get all form data -Dim appname, appdescription, supportteamid -Dim applicationnotes, installpath, applicationlink, documentationpath, image -Dim isinstallable, isactive, ishidden, isprinter, islicenced -Dim newsupportteamname, newsupportteamurl, newappownerid - -appname = Trim(Request.Form("appname")) -appdescription = Trim(Request.Form("appdescription")) -supportteamid = Trim(Request.Form("supportteamid")) -applicationnotes = Trim(Request.Form("applicationnotes")) -installpath = Trim(Request.Form("installpath")) -applicationlink = Trim(Request.Form("applicationlink")) -documentationpath = Trim(Request.Form("documentationpath")) -image = Trim(Request.Form("image")) - -' New support team fields -newsupportteamname = Trim(Request.Form("newsupportteamname")) -newsupportteamurl = Trim(Request.Form("newsupportteamurl")) -newappownerid = Trim(Request.Form("newappownerid")) - -' Checkboxes -If Request.Form("isinstallable") = "1" Then isinstallable = 1 Else isinstallable = 0 -If Request.Form("isactive") = "1" Then isactive = 1 Else isactive = 0 -If Request.Form("ishidden") = "1" Then ishidden = 1 Else ishidden = 0 -If Request.Form("isprinter") = "1" Then isprinter = 1 Else isprinter = 0 -If Request.Form("islicenced") = "1" Then islicenced = 1 Else islicenced = 0 - -' Basic validation -If Len(appname) < 1 Or Len(appname) > 50 Then - Response.Write("Error: Application name must be 1-50 characters") - objConn.Close - Response.End -End If - -' Validate support team is selected -If supportteamid = "" Then - Response.Write("
Error: Please select a support team.
") - Response.Write("Go back") - objConn.Close - Response.End -End If - -' Check if we need to create a new support team first -If supportteamid = "new" Then - If newsupportteamname = "" Then - Response.Write("
Error: Support team name is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newsupportteamname) > 50 Then - Response.Write("
Error: Support team name too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape quotes for support team name and URL - Dim escapedTeamName, escapedTeamUrl - escapedTeamName = Replace(newsupportteamname, "'", "''") - escapedTeamUrl = Replace(newsupportteamurl, "'", "''") - - ' Check if support team already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM supportteams WHERE LOWER(teamname) = LOWER('" & escapedTeamName & "')" - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck.EOF Then - rsCheck.Close - Response.Write("
Error: Database query failed.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Response.Write("
Error: Support team '" & Server.HTMLEncode(newsupportteamname) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Check if we need to create a new app owner first (nested creation) - If newappownerid = "new" Then - Dim newappownername, newappownersso - newappownername = Trim(Request.Form("newappownername")) - newappownersso = Trim(Request.Form("newappownersso")) - - If newappownername = "" Or newappownersso = "" Then - Response.Write("
Error: App owner name and SSO are required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newappownername) > 50 Or Len(newappownersso) > 50 Then - Response.Write("
Error: App owner name or SSO too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape quotes - Dim escapedOwnerName, escapedSSO - escapedOwnerName = Replace(newappownername, "'", "''") - escapedSSO = Replace(newappownersso, "'", "''") - - ' Check if app owner already exists - checkSQL = "SELECT COUNT(*) as cnt FROM appowners WHERE LOWER(appowner) = LOWER('" & escapedOwnerName & "') OR LOWER(sso) = LOWER('" & escapedSSO & "')" - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck.EOF Then - rsCheck.Close - Response.Write("
Error: Database query failed (app owner check).
") - Response.Write("Go back") - objConn.Close - Response.End - End If - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Response.Write("
Error: App owner with this name or SSO already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Insert new app owner - Dim ownerSQL - ownerSQL = "INSERT INTO appowners (appowner, sso, isactive) VALUES ('" & escapedOwnerName & "', '" & escapedSSO & "', 1)" - - On Error Resume Next - objConn.Execute ownerSQL - - If Err.Number <> 0 Then - Response.Write("
Error creating app owner: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new app owner ID - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newappownerid = rsCheck("newid") - rsCheck.Close - Else - ' Validate existing app owner ID - If Not IsNumeric(newappownerid) Or CLng(newappownerid) < 1 Then - Response.Write("
Error: Invalid app owner.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If - - ' Insert new support team - Dim teamSQL - teamSQL = "INSERT INTO supportteams (teamname, teamurl, appownerid, isactive) VALUES ('" & escapedTeamName & "', '" & escapedTeamUrl & "', " & newappownerid & ", 1)" - - On Error Resume Next - objConn.Execute teamSQL - - If Err.Number <> 0 Then - Response.Write("
Error creating support team: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new support team ID - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - supportteamid = rsCheck("newid") - rsCheck.Close -Else - ' Validate existing support team ID - If Not IsNumeric(supportteamid) Or CLng(supportteamid) < 1 Then - Response.Write("
Error: Invalid support team ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If -End If - -' Escape backslashes and single quotes for SQL -' Must escape backslashes FIRST, then quotes -appname = Replace(appname, "\", "\\") -appname = Replace(appname, "'", "''") -appdescription = Replace(appdescription, "\", "\\") -appdescription = Replace(appdescription, "'", "''") -applicationnotes = Replace(applicationnotes, "\", "\\") -applicationnotes = Replace(applicationnotes, "'", "''") -installpath = Replace(installpath, "\", "\\") -installpath = Replace(installpath, "'", "''") -applicationlink = Replace(applicationlink, "\", "\\") -applicationlink = Replace(applicationlink, "'", "''") -documentationpath = Replace(documentationpath, "\", "\\") -documentationpath = Replace(documentationpath, "'", "''") -image = Replace(image, "\", "\\") -image = Replace(image, "'", "''") - -' Build INSERT statement -Dim strSQL -strSQL = "INSERT INTO applications (" & _ - "appname, appdescription, supportteamid, applicationnotes, " & _ - "installpath, applicationlink, documentationpath, image, " & _ - "isinstallable, isactive, ishidden, isprinter, islicenced" & _ - ") VALUES (" & _ - "'" & appname & "', " & _ - "'" & appdescription & "', " & _ - supportteamid & ", " & _ - "'" & applicationnotes & "', " & _ - "'" & installpath & "', " & _ - "'" & applicationlink & "', " & _ - "'" & documentationpath & "', " & _ - "'" & image & "', " & _ - isinstallable & ", " & _ - isactive & ", " & _ - ishidden & ", " & _ - isprinter & ", " & _ - islicenced & ")" - -On Error Resume Next -objConn.Execute strSQL - -If Err.Number <> 0 Then - Response.Write("Error: " & Err.Description) - objConn.Close - Response.End -End If - -' Get the new application ID -Dim rsNew -Set rsNew = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") -Dim newAppId -newAppId = rsNew("newid") -rsNew.Close -Set rsNew = Nothing - -objConn.Close - -If newAppId > 0 Then - Response.Redirect("displayapplication.asp?appid=" & newAppId) -Else - Response.Write("Error: Could not retrieve new application ID") -End If -%> diff --git a/savedevice_direct.asp.backup-20251027 b/savedevice_direct.asp.backup-20251027 deleted file mode 100644 index 7171986..0000000 --- a/savedevice_direct.asp.backup-20251027 +++ /dev/null @@ -1,55 +0,0 @@ - -<% - ' Get the serial number from the form - Dim serialnumber - serialnumber = Trim(Request.Form("serialnumber")) - - ' Basic validation - serial number should not be empty and should be alphanumeric-ish - If serialnumber = "" Or Len(serialnumber) < 3 Or Len(serialnumber) > 100 Then - objConn.Close - Response.Redirect("./adddevice.asp?error=INVALID_SERIAL") - Response.End - End If - - ' Escape quotes - serialnumber = Replace(serialnumber, "'", "''") - - ' Check if serial number already exists - Dim checkSQL, rsCheck, existingPCID - checkSQL = "SELECT pcid FROM pc WHERE serialnumber = '" & serialnumber & "'" - Set rsCheck = objConn.Execute(checkSQL) - - If Not rsCheck.EOF Then - ' Serial number already exists - redirect to edit page - existingPCID = rsCheck("pcid") - rsCheck.Close - objConn.Close - Response.Redirect("./editdevice.asp?pcid=" & existingPCID & "&scanned=1") - Response.End - End If - - rsCheck.Close - - ' Insert new device with minimal required fields and defaults - ' pcstatusid = 2 (Inventory) - ' isactive = 1 - ' modelnumberid = 1 (default model) - ' requires_manual_machine_config = 0 (no manual config needed) - ' osid = 1 (default OS) - ' machinenumber = 'IT Closet' (default location for new devices) - Dim insertSQL - insertSQL = "INSERT INTO pc (serialnumber, pcstatusid, isactive, modelnumberid, requires_manual_machine_config, osid, machinenumber, dateadded) " & _ - "VALUES ('" & serialnumber & "', 2, 1, 1, 0, 1, 'IT Closet', NOW())" - - On Error Resume Next - objConn.Execute insertSQL - - If Err.Number = 0 Then - objConn.Close - ' Success - redirect back with success message - Response.Redirect("./adddevice.asp?added=" & Server.URLEncode(Request.Form("serialnumber"))) - Else - objConn.Close - Response.Redirect("./adddevice.asp?error=db") - End If -%> diff --git a/savemachine.asp.backup-refactor-20251027 b/savemachine.asp.backup-refactor-20251027 deleted file mode 100644 index 58b98ba..0000000 --- a/savemachine.asp.backup-refactor-20251027 +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - -
-<% - ' Initialize error handling - Call InitializeErrorHandling("savemachine.asp") - - ' Get and validate all inputs - Dim machinenumber, modelid, machinetypeid, businessunitid, alias, machinenotes, mapleft, maptop - machinenumber = Trim(Request.Form("machinenumber")) - modelid = Trim(Request.Form("modelid")) - machinetypeid = Trim(Request.Form("machinetypeid")) - businessunitid = Trim(Request.Form("businessunitid")) - alias = Trim(Request.Form("alias")) - machinenotes = Trim(Request.Form("machinenotes")) - mapleft = Trim(Request.Form("mapleft")) - maptop = Trim(Request.Form("maptop")) - - ' Validate required fields - If machinenumber = "" Then - Call HandleValidationError("addmachine.asp", "INVALID_INPUT") - End If - - If Not ValidateID(modelid) Then - Call HandleValidationError("addmachine.asp", "INVALID_ID") - End If - - If Not ValidateID(machinetypeid) Then - Call HandleValidationError("addmachine.asp", "INVALID_ID") - End If - - If Not ValidateID(businessunitid) Then - Call HandleValidationError("addmachine.asp", "INVALID_ID") - End If - - ' Validate field lengths - If Len(machinenumber) > 50 Then - Call HandleValidationError("addmachine.asp", "INVALID_INPUT") - End If - - If Len(alias) > 50 Then - Call HandleValidationError("addmachine.asp", "INVALID_INPUT") - End If - - ' machinenotes is TEXT field, no length validation needed - - ' Check if machine number already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinenumber = ?" - Set rsCheck = ExecuteParameterizedQuery(objConn, checkSQL, Array(machinenumber)) - If Not rsCheck.EOF Then - If Not IsNull(rsCheck("cnt")) Then - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Set rsCheck = Nothing - Response.Write("
Error: Machine number '" & Server.HTMLEncode(machinenumber) & "' already exists.
") - Response.Write("Go back") - Call CleanupResources() - Response.End - End If - End If - End If - rsCheck.Close - Set rsCheck = Nothing - - ' Build INSERT statement with parameterized query - Dim params, paramList - strSQL = "INSERT INTO machines (machinenumber, modelnumberid, machinetypeid, businessunitid" - - ' Add optional fields to SQL - If alias <> "" Then - strSQL = strSQL & ", alias" - End If - If machinenotes <> "" Then - strSQL = strSQL & ", machinenotes" - End If - If mapleft <> "" And maptop <> "" Then - If IsNumeric(mapleft) And IsNumeric(maptop) Then - strSQL = strSQL & ", mapleft, maptop" - End If - End If - - strSQL = strSQL & ", isactive, islocationonly) VALUES (?, ?, ?, ?" - - ' Build param list dynamically - Dim paramCount - paramCount = 4 ' Start with 4 required params - - ' Count optional params - If alias <> "" Then paramCount = paramCount + 1 - If machinenotes <> "" Then paramCount = paramCount + 1 - If mapleft <> "" And maptop <> "" Then - If IsNumeric(mapleft) And IsNumeric(maptop) Then - paramCount = paramCount + 2 - End If - End If - paramCount = paramCount + 2 ' For isactive and islocationonly - - ' Initialize array with correct size - ReDim paramList(paramCount - 1) - Dim paramIndex - paramIndex = 0 - - ' Add required fields - paramList(paramIndex) = machinenumber - paramIndex = paramIndex + 1 - paramList(paramIndex) = modelid - paramIndex = paramIndex + 1 - paramList(paramIndex) = machinetypeid - paramIndex = paramIndex + 1 - paramList(paramIndex) = businessunitid - paramIndex = paramIndex + 1 - - ' Add optional fields to param list - If alias <> "" Then - strSQL = strSQL & ", ?" - paramList(paramIndex) = alias - paramIndex = paramIndex + 1 - End If - If machinenotes <> "" Then - strSQL = strSQL & ", ?" - paramList(paramIndex) = machinenotes - paramIndex = paramIndex + 1 - End If - If mapleft <> "" And maptop <> "" Then - If IsNumeric(mapleft) And IsNumeric(maptop) Then - strSQL = strSQL & ", ?, ?" - paramList(paramIndex) = mapleft - paramIndex = paramIndex + 1 - paramList(paramIndex) = maptop - paramIndex = paramIndex + 1 - End If - End If - - ' Add isactive and islocationonly values - strSQL = strSQL & ", ?, ?)" - paramList(paramIndex) = 1 ' isactive = 1 - paramIndex = paramIndex + 1 - paramList(paramIndex) = 0 ' islocationonly = 0 - - ' Execute parameterized insert - Dim recordsAffected - recordsAffected = ExecuteParameterizedInsert(objConn, strSQL, paramList) - - ' Get the new machine ID - Dim newMachineId - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newMachineId = 0 - If Not rsCheck.EOF Then - If Not IsNull(rsCheck("newid")) Then - newMachineId = CLng(rsCheck("newid")) - End If - End If - rsCheck.Close - Set rsCheck = Nothing - - ' Cleanup resources - Call CleanupResources() - - ' Redirect to display page - If recordsAffected > 0 And newMachineId > 0 Then -%> - -<% - Else - Response.Write("Error: Machine was not added successfully.") - End If -%> -
- - diff --git a/savemachine_direct.asp.backup-20251027 b/savemachine_direct.asp.backup-20251027 deleted file mode 100644 index 3e166ed..0000000 --- a/savemachine_direct.asp.backup-20251027 +++ /dev/null @@ -1,409 +0,0 @@ - - - - - - - -
-<% - ' Get and validate all inputs - Dim machinenumber, modelid, machinetypeid, businessunitid, alias, machinenotes, mapleft, maptop - machinenumber = Trim(Request.Form("machinenumber")) - modelid = Trim(Request.Form("modelid")) - machinetypeid = Trim(Request.Form("machinetypeid")) - businessunitid = Trim(Request.Form("businessunitid")) - alias = Trim(Request.Form("alias")) - machinenotes = Trim(Request.Form("machinenotes")) - mapleft = Trim(Request.Form("mapleft")) - maptop = Trim(Request.Form("maptop")) - - ' Get form inputs for new business unit - Dim newbusinessunit - newbusinessunit = Trim(Request.Form("newbusinessunit")) - - ' Get form inputs for new machine type - Dim newmachinetype, newmachinedescription, newfunctionalaccountid - newmachinetype = Trim(Request.Form("newmachinetype")) - newmachinedescription = Trim(Request.Form("newmachinedescription")) - newfunctionalaccountid = Trim(Request.Form("newfunctionalaccountid")) - - ' Get form inputs for new functional account - Dim newfunctionalaccount - newfunctionalaccount = Trim(Request.Form("newfunctionalaccount")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid, newmodelimage - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - newmodelimage = Trim(Request.Form("newmodelimage")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields - If machinenumber = "" Then - Response.Write("
Error: Machine number is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate ID fields - allow "new" as a valid value - If modelid <> "new" And Not IsNumeric(modelid) Then - Response.Write("
Error: Invalid model ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If machinetypeid <> "new" And Not IsNumeric(machinetypeid) Then - Response.Write("
Error: Invalid machine type ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If businessunitid <> "new" And Not IsNumeric(businessunitid) Then - Response.Write("
Error: Invalid business unit ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate field lengths - If Len(machinenumber) > 50 Or Len(alias) > 50 Then - Response.Write("
Error: Field length exceeded.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Check if machine number already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinenumber = '" & Replace(machinenumber, "'", "''") & "'" - Set rsCheck = objConn.Execute(checkSQL) - If Not rsCheck.EOF Then - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Set rsCheck = Nothing - Response.Write("
Error: Machine number '" & Server.HTMLEncode(machinenumber) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If - rsCheck.Close - Set rsCheck = Nothing - - ' Handle new business unit creation - If businessunitid = "new" Then - If Len(newbusinessunit) = 0 Then - Response.Write("
New business unit name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newbusinessunit) > 50 Then - Response.Write("
Business unit name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedBUName - escapedBUName = Replace(newbusinessunit, "'", "''") - - ' Insert new business unit - Dim sqlNewBU - sqlNewBU = "INSERT INTO businessunits (businessunit, isactive) VALUES ('" & escapedBUName & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewBU - - If Err.Number <> 0 Then - Response.Write("
Error creating new business unit: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created business unit ID - Dim rsNewBU - Set rsNewBU = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - businessunitid = CLng(rsNewBU("newid")) - rsNewBU.Close - Set rsNewBU = Nothing - On Error Goto 0 - End If - - ' Handle new machine type creation - If machinetypeid = "new" Then - If Len(newmachinetype) = 0 Then - Response.Write("
New machine type name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccountid) = 0 Then - Response.Write("
Functional account is required for new machine type
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmachinetype) > 50 Or Len(newmachinedescription) > 255 Then - Response.Write("
Machine type field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new functional account creation (nested) - If newfunctionalaccountid = "new" Then - If Len(newfunctionalaccount) = 0 Then - Response.Write("
New functional account name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccount) > 50 Then - Response.Write("
Functional account name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedFAName - escapedFAName = Replace(newfunctionalaccount, "'", "''") - - ' Insert new functional account - Dim sqlNewFA - sqlNewFA = "INSERT INTO functionalaccounts (functionalaccount, isactive) VALUES ('" & escapedFAName & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewFA - - If Err.Number <> 0 Then - Response.Write("
Error creating new functional account: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created functional account ID - Dim rsNewFA - Set rsNewFA = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newfunctionalaccountid = CLng(rsNewFA("newid")) - rsNewFA.Close - Set rsNewFA = Nothing - On Error Goto 0 - End If - - ' Escape single quotes - Dim escapedMTName, escapedMTDesc - escapedMTName = Replace(newmachinetype, "'", "''") - escapedMTDesc = Replace(newmachinedescription, "'", "''") - - ' Insert new machine type - Dim sqlNewMT - sqlNewMT = "INSERT INTO machinetypes (machinetype, machinedescription, functionalaccountid, isactive) " & _ - "VALUES ('" & escapedMTName & "', '" & escapedMTDesc & "', " & newfunctionalaccountid & ", 1)" - - On Error Resume Next - objConn.Execute sqlNewMT - - If Err.Number <> 0 Then - Response.Write("
Error creating new machine type: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created machine type ID - Dim rsNewMT - Set rsNewMT = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - machinetypeid = CLng(rsNewMT("newid")) - rsNewMT.Close - Set rsNewMT = Nothing - On Error Goto 0 - End If - - ' Handle new model creation - If modelid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Write("
New model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Write("
Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 50 Or Len(newmodelimage) > 100 Then - Response.Write("
Model field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Write("
New vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Write("
Vendor name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedVendorName - escapedVendorName = Replace(newvendorname, "'", "''") - - ' Insert new vendor (with ismachine=1) - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) " & _ - "VALUES ('" & escapedVendorName & "', 1, 0, 0, 1)" - - On Error Resume Next - objConn.Execute sqlNewVendor - - If Err.Number <> 0 Then - Response.Write("
Error creating new vendor: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for model - Dim escapedModelNumber, escapedModelImage - escapedModelNumber = Replace(newmodelnumber, "'", "''") - escapedModelImage = Replace(newmodelimage, "'", "''") - - ' Set default image if not specified - If escapedModelImage = "" Then - escapedModelImage = "default.png" - End If - - ' Insert new model - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, image, isactive) " & _ - "VALUES ('" & escapedModelNumber & "', " & newvendorid & ", '" & escapedModelImage & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - - If Err.Number <> 0 Then - Response.Write("
Error creating new model: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - End If - - ' Escape single quotes - machinenumber = Replace(machinenumber, "'", "''") - alias = Replace(alias, "'", "''") - machinenotes = Replace(machinenotes, "'", "''") - - ' Build INSERT statement - Dim strSQL, fields, values - fields = "machinenumber, modelnumberid, machinetypeid, businessunitid" - values = "'" & machinenumber & "', " & modelid & ", " & machinetypeid & ", " & businessunitid - - If alias <> "" Then - fields = fields & ", alias" - values = values & ", '" & alias & "'" - End If - - If machinenotes <> "" Then - fields = fields & ", machinenotes" - values = values & ", '" & machinenotes & "'" - End If - - If mapleft <> "" And maptop <> "" And IsNumeric(mapleft) And IsNumeric(maptop) Then - fields = fields & ", mapleft, maptop" - values = values & ", " & mapleft & ", " & maptop - End If - - fields = fields & ", isactive, islocationonly" - values = values & ", 1, 0" - - strSQL = "INSERT INTO machines (" & fields & ") VALUES (" & values & ")" - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number <> 0 Then - Response.Write("
Error: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new machine ID - Dim newMachineId - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newMachineId = CLng(rsCheck("newid")) - rsCheck.Close - Set rsCheck = Nothing - - ' Link selected PC to this machine by updating its machinenumber field - Dim pcid, updatePCSQL - pcid = Trim(Request.Form("pcid")) - - If pcid <> "" And IsNumeric(pcid) And CLng(pcid) > 0 Then - updatePCSQL = "UPDATE pc SET machinenumber = '" & machinenumber & "' WHERE pcid = " & CLng(pcid) - On Error Resume Next - objConn.Execute updatePCSQL - On Error Goto 0 - End If - - objConn.Close - - If CLng(newMachineId) > 0 Then -%> - -<% - Else - Response.Write("Error: Machine was not added successfully.") - End If -%> -
- - diff --git a/savemachine_direct.asp.backup-refactor-20251027 b/savemachine_direct.asp.backup-refactor-20251027 deleted file mode 100644 index 45d0047..0000000 --- a/savemachine_direct.asp.backup-refactor-20251027 +++ /dev/null @@ -1,459 +0,0 @@ -<% -'============================================================================= -' FILE: savemachine_direct.asp -' PURPOSE: Create new machine with nested entity creation (vendor, model, machine type, functional account, business unit) -' SECURITY: Parameterized queries, HTML encoding, input validation -' UPDATED: 2025-10-27 - Migrated to secure patterns -'============================================================================= -%> - - - - - - - -
-<% - ' Get and validate all inputs - Dim machinenumber, modelid, machinetypeid, businessunitid, alias, machinenotes, mapleft, maptop - machinenumber = Trim(Request.Form("machinenumber")) - modelid = Trim(Request.Form("modelid")) - machinetypeid = Trim(Request.Form("machinetypeid")) - businessunitid = Trim(Request.Form("businessunitid")) - alias = Trim(Request.Form("alias")) - machinenotes = Trim(Request.Form("machinenotes")) - mapleft = Trim(Request.Form("mapleft")) - maptop = Trim(Request.Form("maptop")) - - ' Get form inputs for new business unit - Dim newbusinessunit - newbusinessunit = Trim(Request.Form("newbusinessunit")) - - ' Get form inputs for new machine type - Dim newmachinetype, newmachinedescription, newfunctionalaccountid - newmachinetype = Trim(Request.Form("newmachinetype")) - newmachinedescription = Trim(Request.Form("newmachinedescription")) - newfunctionalaccountid = Trim(Request.Form("newfunctionalaccountid")) - - ' Get form inputs for new functional account - Dim newfunctionalaccount - newfunctionalaccount = Trim(Request.Form("newfunctionalaccount")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid, newmodelimage - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - newmodelimage = Trim(Request.Form("newmodelimage")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields - If machinenumber = "" Then - Response.Write("
Error: Machine number is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate ID fields - allow "new" as a valid value - If modelid <> "new" And Not IsNumeric(modelid) Then - Response.Write("
Error: Invalid model ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If machinetypeid <> "new" And Not IsNumeric(machinetypeid) Then - Response.Write("
Error: Invalid machine type ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If businessunitid <> "new" And Not IsNumeric(businessunitid) Then - Response.Write("
Error: Invalid business unit ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate field lengths - If Len(machinenumber) > 50 Or Len(alias) > 50 Then - Response.Write("
Error: Field length exceeded.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Check if machine number already exists - Dim checkSQL, rsCheck, cmdCheck - checkSQL = "SELECT COUNT(*) as cnt FROM machines WHERE machinenumber = ?" - Set cmdCheck = Server.CreateObject("ADODB.Command") - cmdCheck.ActiveConnection = objConn - cmdCheck.CommandText = checkSQL - cmdCheck.CommandType = 1 - cmdCheck.Parameters.Append cmdCheck.CreateParameter("@machinenumber", 200, 1, 50, machinenumber) - Set rsCheck = cmdCheck.Execute - If Not rsCheck.EOF Then - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Set rsCheck = Nothing - Set cmdCheck = Nothing - Response.Write("
Error: Machine number '" & Server.HTMLEncode(machinenumber) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If - rsCheck.Close - Set rsCheck = Nothing - Set cmdCheck = Nothing - - ' Handle new business unit creation - If businessunitid = "new" Then - If Len(newbusinessunit) = 0 Then - Response.Write("
New business unit name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newbusinessunit) > 50 Then - Response.Write("
Business unit name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Insert new business unit using parameterized query - Dim sqlNewBU, cmdNewBU - sqlNewBU = "INSERT INTO businessunits (businessunit, isactive) VALUES (?, 1)" - Set cmdNewBU = Server.CreateObject("ADODB.Command") - cmdNewBU.ActiveConnection = objConn - cmdNewBU.CommandText = sqlNewBU - cmdNewBU.CommandType = 1 - cmdNewBU.Parameters.Append cmdNewBU.CreateParameter("@businessunit", 200, 1, 50, newbusinessunit) - - On Error Resume Next - cmdNewBU.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new business unit: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdNewBU = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created business unit ID - Dim rsNewBU - Set rsNewBU = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - businessunitid = CLng(rsNewBU("newid")) - rsNewBU.Close - Set rsNewBU = Nothing - Set cmdNewBU = Nothing - On Error Goto 0 - End If - - ' Handle new machine type creation - If machinetypeid = "new" Then - If Len(newmachinetype) = 0 Then - Response.Write("
New machine type name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccountid) = 0 Then - Response.Write("
Functional account is required for new machine type
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmachinetype) > 50 Or Len(newmachinedescription) > 255 Then - Response.Write("
Machine type field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new functional account creation (nested) - If newfunctionalaccountid = "new" Then - If Len(newfunctionalaccount) = 0 Then - Response.Write("
New functional account name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newfunctionalaccount) > 50 Then - Response.Write("
Functional account name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Insert new functional account using parameterized query - Dim sqlNewFA, cmdNewFA - sqlNewFA = "INSERT INTO functionalaccounts (functionalaccount, isactive) VALUES (?, 1)" - Set cmdNewFA = Server.CreateObject("ADODB.Command") - cmdNewFA.ActiveConnection = objConn - cmdNewFA.CommandText = sqlNewFA - cmdNewFA.CommandType = 1 - cmdNewFA.Parameters.Append cmdNewFA.CreateParameter("@functionalaccount", 200, 1, 50, newfunctionalaccount) - - On Error Resume Next - cmdNewFA.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new functional account: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdNewFA = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created functional account ID - Dim rsNewFA - Set rsNewFA = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newfunctionalaccountid = CLng(rsNewFA("newid")) - rsNewFA.Close - Set rsNewFA = Nothing - Set cmdNewFA = Nothing - On Error Goto 0 - End If - - ' Insert new machine type using parameterized query - Dim sqlNewMT, cmdNewMT - sqlNewMT = "INSERT INTO machinetypes (machinetype, machinedescription, functionalaccountid, isactive) VALUES (?, ?, ?, 1)" - Set cmdNewMT = Server.CreateObject("ADODB.Command") - cmdNewMT.ActiveConnection = objConn - cmdNewMT.CommandText = sqlNewMT - cmdNewMT.CommandType = 1 - cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@machinetype", 200, 1, 50, newmachinetype) - cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@machinedescription", 200, 1, 255, newmachinedescription) - cmdNewMT.Parameters.Append cmdNewMT.CreateParameter("@functionalaccountid", 3, 1, , CLng(newfunctionalaccountid)) - - On Error Resume Next - cmdNewMT.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new machine type: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdNewMT = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created machine type ID - Dim rsNewMT - Set rsNewMT = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - machinetypeid = CLng(rsNewMT("newid")) - rsNewMT.Close - Set rsNewMT = Nothing - Set cmdNewMT = Nothing - On Error Goto 0 - End If - - ' Handle new model creation - If modelid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Write("
New model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Write("
Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 50 Or Len(newmodelimage) > 100 Then - Response.Write("
Model field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Write("
New vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Write("
Vendor name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Insert new vendor using parameterized query (with ismachine=1) - Dim sqlNewVendor, cmdNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) VALUES (?, 1, 0, 0, 1)" - Set cmdNewVendor = Server.CreateObject("ADODB.Command") - cmdNewVendor.ActiveConnection = objConn - cmdNewVendor.CommandText = sqlNewVendor - cmdNewVendor.CommandType = 1 - cmdNewVendor.Parameters.Append cmdNewVendor.CreateParameter("@vendor", 200, 1, 50, newvendorname) - - On Error Resume Next - cmdNewVendor.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new vendor: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdNewVendor = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - Set cmdNewVendor = Nothing - On Error Goto 0 - End If - - ' Set default image if not specified - Dim modelImageValue - If Len(newmodelimage) > 0 Then - modelImageValue = newmodelimage - Else - modelImageValue = "default.png" - End If - - ' Insert new model using parameterized query - Dim sqlNewModel, cmdNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, image, isactive) VALUES (?, ?, ?, 1)" - Set cmdNewModel = Server.CreateObject("ADODB.Command") - cmdNewModel.ActiveConnection = objConn - cmdNewModel.CommandText = sqlNewModel - cmdNewModel.CommandType = 1 - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@modelnumber", 200, 1, 50, newmodelnumber) - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@vendorid", 3, 1, , CLng(newvendorid)) - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@image", 200, 1, 100, modelImageValue) - - On Error Resume Next - cmdNewModel.Execute - - If Err.Number <> 0 Then - Response.Write("
Error creating new model: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdNewModel = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - Set cmdNewModel = Nothing - On Error Goto 0 - End If - - ' Build INSERT statement with parameterized query - Dim strSQL, cmdMachine - strSQL = "INSERT INTO machines (machinenumber, modelnumberid, machinetypeid, businessunitid, alias, machinenotes, mapleft, maptop, isactive, islocationonly) " & _ - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, 0)" - - Set cmdMachine = Server.CreateObject("ADODB.Command") - cmdMachine.ActiveConnection = objConn - cmdMachine.CommandText = strSQL - cmdMachine.CommandType = 1 - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinenumber", 200, 1, 50, machinenumber) - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@modelnumberid", 3, 1, , CLng(modelid)) - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinetypeid", 3, 1, , CLng(machinetypeid)) - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@businessunitid", 3, 1, , CLng(businessunitid)) - - ' Handle optional alias - If alias <> "" Then - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@alias", 200, 1, 50, alias) - Else - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@alias", 200, 1, 50, Null) - End If - - ' Handle optional machinenotes - If machinenotes <> "" Then - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinenotes", 200, 1, 500, machinenotes) - Else - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@machinenotes", 200, 1, 500, Null) - End If - - ' Handle optional map coordinates - If mapleft <> "" And maptop <> "" And IsNumeric(mapleft) And IsNumeric(maptop) Then - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@mapleft", 3, 1, , CLng(mapleft)) - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@maptop", 3, 1, , CLng(maptop)) - Else - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@mapleft", 3, 1, , Null) - cmdMachine.Parameters.Append cmdMachine.CreateParameter("@maptop", 3, 1, , Null) - End If - - On Error Resume Next - cmdMachine.Execute - - If Err.Number <> 0 Then - Response.Write("
Error: " & Server.HTMLEncode(Err.Description) & "
") - Response.Write("Go back") - Set cmdMachine = Nothing - objConn.Close - Response.End - End If - Set cmdMachine = Nothing - - ' Get the new machine ID - Dim newMachineId - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newMachineId = CLng(rsCheck("newid")) - rsCheck.Close - Set rsCheck = Nothing - - ' Link selected PC to this machine by updating its machinenumber field - Dim pcid - pcid = Trim(Request.Form("pcid")) - - If pcid <> "" And IsNumeric(pcid) And CLng(pcid) > 0 Then - Dim updatePCSQL, cmdUpdatePC - updatePCSQL = "UPDATE pc SET machinenumber = ? WHERE pcid = ?" - Set cmdUpdatePC = Server.CreateObject("ADODB.Command") - cmdUpdatePC.ActiveConnection = objConn - cmdUpdatePC.CommandText = updatePCSQL - cmdUpdatePC.CommandType = 1 - cmdUpdatePC.Parameters.Append cmdUpdatePC.CreateParameter("@machinenumber", 200, 1, 50, machinenumber) - cmdUpdatePC.Parameters.Append cmdUpdatePC.CreateParameter("@pcid", 3, 1, , CLng(pcid)) - - On Error Resume Next - cmdUpdatePC.Execute - Set cmdUpdatePC = Nothing - On Error Goto 0 - End If - - objConn.Close - - If CLng(newMachineId) > 0 Then -%> - -<% - Else - Response.Write("Error: Machine was not added successfully.") - End If -%> -
- - diff --git a/savemodel.asp.backup-20251027 b/savemodel.asp.backup-20251027 deleted file mode 100644 index 7d496f4..0000000 --- a/savemodel.asp.backup-20251027 +++ /dev/null @@ -1,181 +0,0 @@ - - - - - - - - - - - -
-<% - ' Initialize error handling - Call InitializeErrorHandling("savemodel.asp") - - ' Get and validate all inputs - Dim modelnumber, vendorid, notes, documentationpath - Dim newvendorname, isprinter, ispc, ismachine - Dim modelisprinter, modelispc, modelismachine - - modelnumber = Trim(Request.Form("modelnumber")) - vendorid = Trim(Request.Form("vendorid")) - notes = Trim(Request.Form("notes")) - documentationpath = Trim(Request.Form("documentationpath")) - - ' New vendor fields - newvendorname = Trim(Request.Form("newvendorname")) - isprinter = Request.Form("isprinter") - ispc = Request.Form("ispc") - ismachine = Request.Form("ismachine") - - ' Model type checkboxes (NOTE: these are different from vendor checkboxes above) - modelisprinter = Request.Form("modelisprinter") - modelispc = Request.Form("modelispc") - modelismachine = Request.Form("modelismachine") - - ' Validate required fields - If modelnumber = "" Then - Call HandleValidationError("addmodel.asp", "INVALID_INPUT") - End If - - ' Validate field lengths - If Len(modelnumber) > 255 Then - Call HandleValidationError("addmodel.asp", "INVALID_INPUT") - End If - - If Len(notes) > 255 Then - Call HandleValidationError("addmodel.asp", "INVALID_INPUT") - End If - - If Len(documentationpath) > 255 Then - Call HandleValidationError("addmodel.asp", "INVALID_INPUT") - End If - - ' Check if we need to create a new vendor first - If vendorid = "new" Then - If newvendorname = "" Then - Response.Write("
Error: Manufacturer name is required when adding a new manufacturer.
") - Response.Write("Go back") - Call CleanupResources() - Response.End - End If - - If Len(newvendorname) > 50 Then - Call HandleValidationError("addmodel.asp", "INVALID_INPUT") - End If - - ' Check if vendor already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM vendors WHERE LOWER(vendor) = LOWER(?)" - Set rsCheck = ExecuteParameterizedQuery(objConn, checkSQL, Array(newvendorname)) - If rsCheck("cnt") > 0 Then - rsCheck.Close - Set rsCheck = Nothing - Response.Write("
Error: Manufacturer '" & Server.HTMLEncode(newvendorname) & "' already exists.
") - Response.Write("Go back") - Call CleanupResources() - Response.End - End If - rsCheck.Close - Set rsCheck = Nothing - - ' Insert new vendor - Dim vendorSQL - vendorSQL = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) VALUES (?, 1, ?, ?, ?)" - - Dim vendorParams - vendorParams = Array(newvendorname, _ - IIf(isprinter = "1", 1, 0), _ - IIf(ispc = "1", 1, 0), _ - IIf(ismachine = "1", 1, 0)) - - Call ExecuteParameterizedUpdate(objConn, vendorSQL, vendorParams) - - ' Get the new vendor ID - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - vendorid = rsCheck("newid") - rsCheck.Close - Set rsCheck = Nothing - Else - ' Validate existing vendor ID - If Not ValidateID(vendorid) Then - Call HandleValidationError("addmodel.asp", "INVALID_ID") - End If - End If - - ' Now we need to update the vendor's type flags based on model type selection - ' If model is for printer, ensure vendor.isprinter = 1, etc. - If modelisprinter = "1" OR modelispc = "1" OR modelismachine = "1" Then - Dim updateVendorSQL - updateVendorSQL = "UPDATE vendors SET " - Dim updateParts() - ReDim updateParts(-1) - - If modelisprinter = "1" Then - ReDim Preserve updateParts(UBound(updateParts) + 1) - updateParts(UBound(updateParts)) = "isprinter = 1" - End If - If modelispc = "1" Then - ReDim Preserve updateParts(UBound(updateParts) + 1) - updateParts(UBound(updateParts)) = "ispc = 1" - End If - If modelismachine = "1" Then - ReDim Preserve updateParts(UBound(updateParts) + 1) - updateParts(UBound(updateParts)) = "ismachine = 1" - End If - - If UBound(updateParts) >= 0 Then - updateVendorSQL = updateVendorSQL & Join(updateParts, ", ") & " WHERE vendorid = ?" - Call ExecuteParameterizedUpdate(objConn, updateVendorSQL, Array(vendorid)) - End If - End If - - ' Check if model already exists for this vendor - checkSQL = "SELECT COUNT(*) as cnt FROM models WHERE LOWER(modelnumber) = LOWER(?) AND vendorid = ?" - Set rsCheck = ExecuteParameterizedQuery(objConn, checkSQL, Array(modelnumber, vendorid)) - If rsCheck("cnt") > 0 Then - rsCheck.Close - Set rsCheck = Nothing - Response.Write("
Error: Model '" & Server.HTMLEncode(modelnumber) & "' already exists for this manufacturer.
") - Response.Write("Go back") - Call CleanupResources() - Response.End - End If - rsCheck.Close - Set rsCheck = Nothing - - ' Insert the new model - Dim modelSQL, modelParams - modelSQL = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) VALUES (?, ?, ?, ?, 1)" - modelParams = Array(modelnumber, vendorid, notes, documentationpath) - - Dim recordsAffected - recordsAffected = ExecuteParameterizedUpdate(objConn, modelSQL, modelParams) - - ' Get the new model ID - Dim newModelId - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newModelId = rsCheck("newid") - rsCheck.Close - Set rsCheck = Nothing - - ' Cleanup resources - Call CleanupResources() - - ' Redirect back to where they came from or to a success page - If recordsAffected > 0 And newModelId > 0 Then - Response.Write("
Model added successfully!
") - Response.Write("

Model '" & Server.HTMLEncode(modelnumber) & "' has been added.

") - Response.Write("

Add Another Model ") - Response.Write("Add Printer ") - Response.Write("Add Machine

") - Else - Response.Write("
Error: Model was not added successfully.
") - Response.Write("Go back") - End If -%> -
- - diff --git a/savemodel_direct.asp.backup-20251027 b/savemodel_direct.asp.backup-20251027 deleted file mode 100644 index bd41eeb..0000000 --- a/savemodel_direct.asp.backup-20251027 +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - -
-<% - ' Get and validate all inputs - Dim modelnumber, vendorid, notes, documentationpath - Dim newvendorname, isprinter, ispc, ismachine - Dim modelisprinter, modelispc, modelismachine - - modelnumber = Trim(Request.Form("modelnumber")) - vendorid = Trim(Request.Form("vendorid")) - notes = Trim(Request.Form("notes")) - documentationpath = Trim(Request.Form("documentationpath")) - - ' New vendor fields - newvendorname = Trim(Request.Form("newvendorname")) - isprinter = Request.Form("isprinter") - ispc = Request.Form("ispc") - ismachine = Request.Form("ismachine") - - ' Model type checkboxes - modelisprinter = Request.Form("modelisprinter") - modelispc = Request.Form("modelispc") - modelismachine = Request.Form("modelismachine") - - ' Validate required fields - If modelnumber = "" Then - Response.Write("
Error: Model number is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate field lengths - If Len(modelnumber) > 255 Then - Response.Write("
Error: Model number too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(notes) > 255 Then - Response.Write("
Error: Notes too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(documentationpath) > 255 Then - Response.Write("
Error: Documentation path too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape quotes - modelnumber = Replace(modelnumber, "'", "''") - notes = Replace(notes, "'", "''") - documentationpath = Replace(documentationpath, "'", "''") - newvendorname = Replace(newvendorname, "'", "''") - - ' Check if we need to create a new vendor first - If vendorid = "new" Then - If newvendorname = "" Then - Response.Write("
Error: Manufacturer name is required when adding a new manufacturer.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Write("
Error: Manufacturer name too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Check if vendor already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM vendors WHERE LOWER(vendor) = LOWER('" & newvendorname & "')" - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck("cnt") > 0 Then - rsCheck.Close - Response.Write("
Error: Manufacturer '" & Server.HTMLEncode(Request.Form("newvendorname")) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Convert vendor checkboxes - Dim iPrint, iPC, iMach - If isprinter = "1" Then iPrint = 1 Else iPrint = 0 - If ispc = "1" Then iPC = 1 Else iPC = 0 - If ismachine = "1" Then iMach = 1 Else iMach = 0 - - ' Insert new vendor - Dim vendorSQL - vendorSQL = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) " & _ - "VALUES ('" & newvendorname & "', 1, " & iPrint & ", " & iPC & ", " & iMach & ")" - - On Error Resume Next - objConn.Execute vendorSQL - - If Err.Number <> 0 Then - Response.Write("
Error creating manufacturer: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new vendor ID - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - vendorid = rsCheck("newid") - rsCheck.Close - Else - ' Validate existing vendor ID - If Not IsNumeric(vendorid) Or CLng(vendorid) < 1 Then - Response.Write("
Error: Invalid manufacturer ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If - - ' Update vendor's type flags based on model type selection - If modelisprinter = "1" OR modelispc = "1" OR modelismachine = "1" Then - Dim updateVendorSQL, updateParts - updateParts = "" - - If modelisprinter = "1" Then - If updateParts <> "" Then updateParts = updateParts & ", " - updateParts = updateParts & "isprinter = 1" - End If - If modelispc = "1" Then - If updateParts <> "" Then updateParts = updateParts & ", " - updateParts = updateParts & "ispc = 1" - End If - If modelismachine = "1" Then - If updateParts <> "" Then updateParts = updateParts & ", " - updateParts = updateParts & "ismachine = 1" - End If - - If updateParts <> "" Then - updateVendorSQL = "UPDATE vendors SET " & updateParts & " WHERE vendorid = " & vendorid - objConn.Execute updateVendorSQL - End If - End If - - ' Check if model already exists for this vendor - checkSQL = "SELECT COUNT(*) as cnt FROM models WHERE LOWER(modelnumber) = LOWER('" & modelnumber & "') AND vendorid = " & vendorid - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck("cnt") > 0 Then - rsCheck.Close - Response.Write("
Error: Model '" & Server.HTMLEncode(Request.Form("modelnumber")) & "' already exists for this manufacturer.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Insert the new model - Dim modelSQL - modelSQL = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) " & _ - "VALUES ('" & modelnumber & "', " & vendorid & ", '" & notes & "', '" & documentationpath & "', 1)" - - On Error Resume Next - objConn.Execute modelSQL - - If Err.Number <> 0 Then - Response.Write("
Error: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the new model ID - Dim newModelId - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newModelId = rsCheck("newid") - rsCheck.Close - - objConn.Close - - If newModelId > 0 Then - Response.Write("
Model added successfully!
") - Response.Write("

Model '" & Server.HTMLEncode(Request.Form("modelnumber")) & "' has been added.

") - Response.Write("

Add Another Model ") - Response.Write("Add Printer ") - Response.Write("Add Machine

") - Else - Response.Write("
Error: Model was not added successfully.
") - Response.Write("Go back") - End If -%> -
- - diff --git a/savenotification_direct.asp.backup-20251027 b/savenotification_direct.asp.backup-20251027 deleted file mode 100644 index b08a24a..0000000 --- a/savenotification_direct.asp.backup-20251027 +++ /dev/null @@ -1,74 +0,0 @@ - -<% -' Get form inputs -Dim notification, ticketnumber, starttime, endtime, isactive, isshopfloor, notificationtypeid, businessunitid -notification = Trim(Request.Form("notification")) -ticketnumber = Trim(Request.Form("ticketnumber")) -starttime = Trim(Request.Form("starttime")) -endtime = Trim(Request.Form("endtime")) -isactive = Request.Form("isactive") -isshopfloor = Request.Form("isshopfloor") -notificationtypeid = Trim(Request.Form("notificationtypeid")) -businessunitid = Trim(Request.Form("businessunitid")) - -If isactive = "" Then isactive = 0 Else isactive = 1 -If isshopfloor = "" Then isshopfloor = 0 Else isshopfloor = 1 - -' Default to TBD if no type selected -If notificationtypeid = "" Or Not IsNumeric(notificationtypeid) Then - notificationtypeid = "1" -End If - -' Validate required fields (endtime is now optional) -If Len(notification) = 0 Or Len(starttime) = 0 Then - Response.Write("Required fields missing") - objConn.Close - Response.End -End If - -If Len(notification) > 500 Or Len(ticketnumber) > 50 Then - Response.Write("Field length exceeded") - objConn.Close - Response.End -End If - -' Escape quotes -notification = Replace(notification, "'", "''") -ticketnumber = Replace(ticketnumber, "'", "''") - -' Convert datetime format for starttime -starttime = Replace(starttime, "T", " ") & ":00" - -' Handle optional endtime - leave as NULL if blank (indefinite) -Dim strSQL, endtimeSQL, businessunitSQL -If Len(endtime) = 0 Then - ' No end date - store as NULL for indefinite notifications - endtimeSQL = "NULL" -Else - ' End date specified - convert format and wrap in quotes - endtime = Replace(endtime, "T", " ") & ":00" - endtimeSQL = "'" & endtime & "'" -End If - -' Handle optional businessunitid - NULL means applies to all business units -If businessunitid = "" Or Not IsNumeric(businessunitid) Then - businessunitSQL = "NULL" -Else - businessunitSQL = businessunitid -End If - -' INSERT -strSQL = "INSERT INTO notifications (notificationtypeid, businessunitid, notification, ticketnumber, starttime, endtime, isactive, isshopfloor) " & _ - "VALUES (" & notificationtypeid & ", " & businessunitSQL & ", '" & notification & "', '" & ticketnumber & "', '" & starttime & "', " & endtimeSQL & ", " & isactive & ", " & isshopfloor & ")" - -On Error Resume Next -objConn.Execute strSQL - -If Err.Number = 0 Then - objConn.Close - Response.Redirect("displaynotifications.asp") -Else - Response.Write("Error: " & Err.Description) - objConn.Close -End If -%> diff --git a/saveprinter_direct.asp.backup-20251027 b/saveprinter_direct.asp.backup-20251027 deleted file mode 100644 index 975353a..0000000 --- a/saveprinter_direct.asp.backup-20251027 +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - -
-<% - ' Get and validate all inputs - Dim modelid, serialnumber, ipaddress, fqdn, printercsfname, printerwindowsname, machineid, maptop, mapleft - modelid = Trim(Request.Form("modelid")) - serialnumber = Trim(Request.Form("serialnumber")) - ipaddress = Trim(Request.Form("ipaddress")) - fqdn = Trim(Request.Form("fqdn")) - printercsfname = Trim(Request.Form("printercsfname")) - printerwindowsname = Trim(Request.Form("printerwindowsname")) - machineid = Trim(Request.Form("machineid")) - maptop = Trim(Request.Form("maptop")) - mapleft = Trim(Request.Form("mapleft")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid, newmodelnotes, newmodeldocpath - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - newmodelnotes = Trim(Request.Form("newmodelnotes")) - newmodeldocpath = Trim(Request.Form("newmodeldocpath")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required fields - If modelid = "" Then - Response.Write("
Error: Model is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If modelid <> "new" And Not IsNumeric(modelid) Then - Response.Write("
Error: Invalid model ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Not IsNumeric(machineid) Then - Response.Write("
Error: Invalid machine ID.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If serialnumber = "" Or ipaddress = "" Or printerwindowsname = "" Then - Response.Write("
Error: Required fields missing.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Validate field lengths - If Len(serialnumber) > 100 Or Len(fqdn) > 255 Or Len(printercsfname) > 50 Or Len(printerwindowsname) > 255 Then - Response.Write("
Error: Field length exceeded.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Check if printer with same IP already exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM printers WHERE ipaddress = '" & Replace(ipaddress, "'", "''") & "' AND isactive = 1" - Set rsCheck = objConn.Execute(checkSQL) - If Not rsCheck.EOF Then - If CLng(rsCheck("cnt")) > 0 Then - rsCheck.Close - Set rsCheck = Nothing - Response.Write("
Error: A printer with IP address '" & Server.HTMLEncode(ipaddress) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - End If - rsCheck.Close - Set rsCheck = Nothing - - ' Handle new model creation - If modelid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Write("
New model number is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Write("
Vendor is required for new model
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 255 Or Len(newmodelnotes) > 255 Or Len(newmodeldocpath) > 255 Then - Response.Write("
Model field length exceeded
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Write("
New vendor name is required
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Write("
Vendor name too long
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedVendorName - escapedVendorName = Replace(newvendorname, "'", "''") - - ' Insert new vendor (with isprinter=1) - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) " & _ - "VALUES ('" & escapedVendorName & "', 1, 1, 0, 0)" - - On Error Resume Next - objConn.Execute sqlNewVendor - - If Err.Number <> 0 Then - Response.Write("
Error creating new vendor: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = rsNewVendor("newid") - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for model - Dim escapedModelNumber, escapedModelNotes, escapedModelDocPath - escapedModelNumber = Replace(newmodelnumber, "'", "''") - escapedModelNotes = Replace(newmodelnotes, "'", "''") - escapedModelDocPath = Replace(newmodeldocpath, "'", "''") - - ' Insert new model - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, notes, documentationpath, isactive) " & _ - "VALUES ('" & escapedModelNumber & "', " & newvendorid & ", '" & escapedModelNotes & "', '" & escapedModelDocPath & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - - If Err.Number <> 0 Then - Response.Write("
Error creating new model: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelid = rsNewModel("newid") - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - End If - - ' Escape single quotes - serialnumber = Replace(serialnumber, "'", "''") - ipaddress = Replace(ipaddress, "'", "''") - fqdn = Replace(fqdn, "'", "''") - printercsfname = Replace(printercsfname, "'", "''") - printerwindowsname = Replace(printerwindowsname, "'", "''") - - ' Build INSERT statement with map coordinates (default to 50,50 if not provided) - Dim strSQL, maptopSQL, mapleftSQL - - ' Handle map coordinates - default to 50 if not provided - If maptop <> "" And IsNumeric(maptop) Then - maptopSQL = maptop - Else - maptopSQL = "50" - End If - - If mapleft <> "" And IsNumeric(mapleft) Then - mapleftSQL = mapleft - Else - mapleftSQL = "50" - End If - - strSQL = "INSERT INTO printers (modelid, serialnumber, ipaddress, fqdn, printercsfname, printerwindowsname, machineid, maptop, mapleft, isactive) " & _ - "VALUES (" & modelid & ", '" & serialnumber & "', '" & ipaddress & "', '" & fqdn & "', '" & printercsfname & "', '" & printerwindowsname & "', " & machineid & ", " & maptopSQL & ", " & mapleftSQL & ", 1)" - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number <> 0 Then - Response.Write("
Error inserting printer: " & Err.Description & "
") - Response.Write("
SQL: " & Server.HTMLEncode(strSQL) & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - On Error Goto 0 - - ' Get the new printer ID - Dim newPrinterId - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - newPrinterId = CLng(rsCheck("newid")) - rsCheck.Close - Set rsCheck = Nothing - - objConn.Close - - If CLng(newPrinterId) > 0 Then -%> - -<% - Else - Response.Write("Error: Printer was not added successfully.") - End If -%> -
- - diff --git a/savevendor_direct.asp.backup-20251027 b/savevendor_direct.asp.backup-20251027 deleted file mode 100644 index 92ea518..0000000 --- a/savevendor_direct.asp.backup-20251027 +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - -
-<% - Dim vendor, isprinter, ispc, ismachine - vendor = Trim(Request.Form("vendor")) - isprinter = Request.Form("isprinter") - ispc = Request.Form("ispc") - ismachine = Request.Form("ismachine") - - ' Validate - If vendor = "" Then - Response.Write("
Error: Manufacturer name is required.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If Len(vendor) > 50 Then - Response.Write("
Error: Manufacturer name too long.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - If isprinter <> "1" AND ispc <> "1" AND ismachine <> "1" Then - Response.Write("
Error: Please select at least one category.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - ' Check if exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM vendors WHERE LOWER(vendor) = LOWER('" & Replace(vendor, "'", "''") & "')" - Set rsCheck = objConn.Execute(checkSQL) - If rsCheck("cnt") > 0 Then - rsCheck.Close - Response.Write("
Error: Manufacturer '" & Server.HTMLEncode(vendor) & "' already exists.
") - Response.Write("Go back") - objConn.Close - Response.End - End If - rsCheck.Close - - ' Escape quotes - vendor = Replace(vendor, "'", "''") - - ' Convert checkboxes - Dim iPrint, iPC, iMach - If isprinter = "1" Then iPrint = 1 Else iPrint = 0 - If ispc = "1" Then iPC = 1 Else iPC = 0 - If ismachine = "1" Then iMach = 1 Else iMach = 0 - - ' INSERT - Dim vendorSQL - vendorSQL = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) " & _ - "VALUES ('" & vendor & "', 1, " & iPrint & ", " & iPC & ", " & iMach & ")" - - On Error Resume Next - objConn.Execute vendorSQL - - If Err.Number <> 0 Then - Response.Write("
Error: " & Err.Description & "
") - Response.Write("Go back") - objConn.Close - Response.End - End If - - Set rsCheck = objConn.Execute("SELECT LAST_INSERT_ID() as newid") - Dim newVendorId - newVendorId = rsCheck("newid") - rsCheck.Close - - objConn.Close - - If newVendorId > 0 Then - Response.Write("
Manufacturer added successfully!
") - Response.Write("

Manufacturer '" & Server.HTMLEncode(Request.Form("vendor")) & "' has been added.

") - Response.Write("

Add Another Manufacturer ") - Response.Write("Add Model

") - Else - Response.Write("
Error: Manufacturer was not added.
") - Response.Write("Go back") - End If -%> -
- - diff --git a/tonerreport.asp.backup b/tonerreport.asp.backup deleted file mode 100644 index ceaa2e6..0000000 --- a/tonerreport.asp.backup +++ /dev/null @@ -1,951 +0,0 @@ - - - - - - - - -<% - ' ============================================================================ - ' FUNCTION: SafeGetZabbixData - ' PURPOSE: Safely call Zabbix function with error handling - ' ============================================================================ - Function SafeGetZabbixData(ipaddress) - On Error Resume Next - Dim result - result = GetAllPrinterSuppliesCached(ipaddress) - If Err.Number <> 0 Then - result = Empty - Err.Clear - End If - On Error Goto 0 - SafeGetZabbixData = result - End Function - - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - ' ============================================================================ - ' FUNCTION: GetMarketingName - ' PURPOSE: Convert OEM part numbers to marketing names for easier supply closet matching - ' ============================================================================ - Function GetMarketingName(oemPartNumber) - Dim oem, marketing - oem = UCase(Trim(oemPartNumber)) - - ' HP M454dw / M454dn / M479fdw (414A/414X series) - If oem = "W2020A" Or oem = "W2020X" Then marketing = "414A/414X Black" - ElseIf oem = "W2021A" Or oem = "W2021X" Then marketing = "414A/414X Cyan" - ElseIf oem = "W2022A" Or oem = "W2022X" Then marketing = "414A/414X Yellow" - ElseIf oem = "W2023A" Or oem = "W2023X" Then marketing = "414A/414X Magenta" - - ' HP M254dw / M255dw (202A/202X series) - ElseIf oem = "CF500A" Or oem = "CF500X" Then marketing = "202A/202X Black" - ElseIf oem = "CF501A" Or oem = "CF501X" Then marketing = "202A/202X Cyan" - ElseIf oem = "CF502A" Or oem = "CF502X" Then marketing = "202A/202X Yellow" - ElseIf oem = "CF503A" Or oem = "CF503X" Then marketing = "202A/202X Magenta" - - ' HP M251nw / M252dw (201A/201X series) - ElseIf oem = "CF400A" Or oem = "CF400X" Then marketing = "201A/201X Black" - ElseIf oem = "CF401A" Or oem = "CF401X" Then marketing = "201A/201X Cyan" - ElseIf oem = "CF402A" Or oem = "CF402X" Then marketing = "201A/201X Yellow" - ElseIf oem = "CF403A" Or oem = "CF403X" Then marketing = "201A/201X Magenta" - - ' HP LaserJet 200 color M251nw (131A/131X series) - ElseIf oem = "CF210A" Or oem = "CF210X" Then marketing = "131A/131X Black" - ElseIf oem = "CF211A" Then marketing = "131A Cyan" - ElseIf oem = "CF212A" Then marketing = "131A Yellow" - ElseIf oem = "CF213A" Then marketing = "131A Magenta" - - ' HP M404n / M406 (58A/58X series) - ElseIf oem = "CF258A" Or oem = "CF258X" Then marketing = "58A/58X Black" - - ' HP M506 / M607 (87A/87X series) - ElseIf oem = "CF287A" Or oem = "CF287X" Then marketing = "87A/87X Black" - - ' HP M602 (90A/90X series) - ElseIf oem = "CE390A" Or oem = "CE390X" Then marketing = "90A/90X Black" - - ' HP P3015dn (55A/55X series) - ElseIf oem = "CE255A" Or oem = "CE255X" Then marketing = "55A/55X Black" - - ' HP LaserJet 4250tn (42A/42X series) - ElseIf oem = "Q5942A" Or oem = "Q5942X" Then marketing = "42A/42X Black" - - ' HP LaserJet Pro 4001n (147A/147X series) - ElseIf oem = "W1470A" Or oem = "W1470X" Then marketing = "147A/147X Black" - - ' HP Imaging Drums - ElseIf oem = "CF234A" Then marketing = "34A Drum" - ElseIf oem = "CF219A" Then marketing = "19A Drum" - ElseIf oem = "W2030A" Or oem = "W2030X" Then marketing = "415A/415X Drum" - - ' HP Maintenance Kits - ElseIf oem = "CF254A" Then marketing = "54A Maintenance Kit" - ElseIf oem = "CF247A" Then marketing = "47A Maintenance Kit" - - ' Xerox (note: many use numeric part numbers) - ElseIf oem = "006R01697" Then marketing = "Xerox Black Toner" - ElseIf oem = "006R01698" Then marketing = "Xerox Cyan Toner" - ElseIf oem = "006R01699" Then marketing = "Xerox Yellow Toner" - ElseIf oem = "006R01700" Then marketing = "Xerox Magenta Toner" - - Else - marketing = "" ' No mapping found - will display OEM number only - End If - - GetMarketingName = marketing - End Function -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-
  Supplies Alert Report
-

- Monitors: Toner/Ink <20%, Drums <20%, Maintenance Kits <20%, Waste Cartridges >80% -

-
-
- - -
-
-
- - - - - - - - - - - - -<% - ' Declare all variables at top level to avoid scope issues - Dim strSQL, rs, printerid, printerwindowsname, printercsfname, ipaddress, machinenumber, modelnumber, machineid, vendor - Dim printerData, zabbixConnected, pingStatus, suppliesJSON - Dim lowSuppliesFound - Dim alertItems() - Dim alertCount - Dim itemStart, itemEnd, currentPos, itemBlock - Dim itemName, itemValue, itemStatus, itemState - Dim namePos, nameStart, nameEnd - Dim valuePos, valueStart, valueEnd - Dim statusPos, statusStart, statusEnd - Dim statePos, stateStart, stateEnd - Dim baseName, numericValue - Dim statusIcon, statusColor, statusText - Dim partNumber, lookupName - Dim partNumbers - Dim debugPartNumbers, debugAllItems, debugItemCount - Dim isSupplyItem, isWasteItem, showItem - Dim marketingName, displayPartNumber - Dim urgencyScore, alertItem - Dim i, j, tempAlert, outputItem, k - Dim partKeyName, tryName, partKey, foundMatch - Dim primaryWord, supplyType, colorPos - Dim typeMatches, colorMatches - - alertCount = 0 - ReDim alertItems(500) ' Pre-allocate space for up to 500 alerts - lowSuppliesFound = False - - strSQL = "SELECT printers.printerid, printers.printerwindowsname, printers.printercsfname, printers.ipaddress, " &_ - "machines.machinenumber, machines.machineid, models.modelnumber, machines.alias, vendors.vendor " &_ - "FROM printers " &_ - "INNER JOIN models ON printers.modelid = models.modelnumberid " &_ - "INNER JOIN machines ON printers.machineid = machines.machineid " &_ - "INNER JOIN vendors ON models.vendorid = vendors.vendorid " &_ - "WHERE printers.isactive = 1 AND printers.ipaddress IS NOT NULL AND printers.ipaddress != '' " &_ - "ORDER BY machines.machinenumber ASC" - - set rs = objconn.Execute(strSQL) - - While Not rs.EOF - printerid = rs("printerid") - printerwindowsname = rs("printerwindowsname") - printercsfname = rs("printercsfname") - ipaddress = rs("ipaddress") - modelnumber = rs("modelnumber") - machineid = rs("machineid") - vendor = rs("vendor") - - ' Use alias if available, otherwise machinenumber - If NOT IsNull(rs("alias")) AND rs("alias") <> "" Then - machinenumber = rs("alias") - Else - machinenumber = rs("machinenumber") - End If - - ' Get cached Zabbix data for this printer (all supplies including maintenance) - printerData = SafeGetZabbixData(ipaddress) - - If Not IsEmpty(printerData) And IsArray(printerData) Then - zabbixConnected = printerData(0) - pingStatus = printerData(1) - suppliesJSON = printerData(2) - - ' Parse supplies JSON to find items below 20% - If zabbixConnected = "1" And suppliesJSON <> "" And InStr(suppliesJSON, """result"":[") > 0 Then - ' Check if result array is not empty - If InStr(suppliesJSON, """result"":[]") = 0 Then - ' First pass: Build lookup of part numbers (type:info items) - ' Use Dictionary object for more reliable storage - Set partNumbers = Server.CreateObject("Scripting.Dictionary") - debugPartNumbers = "" - debugAllItems = "" - debugItemCount = 0 - - currentPos = InStr(suppliesJSON, """result"":[") + 11 - - ' Scan for part number items (containing "Part Number" in name) - Do While currentPos > 11 And currentPos < Len(suppliesJSON) - itemStart = InStr(currentPos, suppliesJSON, "{""itemid"":") - If itemStart = 0 Then Exit Do - - itemEnd = InStr(itemStart, suppliesJSON, "},{") - If itemEnd = 0 Then itemEnd = InStr(itemStart, suppliesJSON, "}]") - If itemEnd = 0 Then Exit Do - - itemBlock = Mid(suppliesJSON, itemStart, itemEnd - itemStart + 1) - - ' Extract name - namePos = InStr(itemBlock, """name"":""") - If namePos > 0 Then - nameStart = namePos + 8 - nameEnd = InStr(nameStart, itemBlock, """") - itemName = Mid(itemBlock, nameStart, nameEnd - nameStart) - Else - itemName = "" - End If - - ' DEBUG: Track all items scanned - debugItemCount = debugItemCount + 1 - If debugItemCount <= 10 Then - debugAllItems = debugAllItems & itemName & " | " - End If - - ' If this is a part number item, store it - ' Look for various part number patterns (case-insensitive) - If InStr(1, itemName, "Part Number", 1) > 0 Or InStr(1, itemName, "Part number", 1) > 0 Or InStr(1, itemName, "OEM", 1) > 0 Or InStr(1, itemName, "SKU", 1) > 0 Then - valuePos = InStr(itemBlock, """lastvalue"":""") - If valuePos > 0 Then - valueStart = valuePos + 13 - valueEnd = InStr(valueStart, itemBlock, """") - itemValue = Mid(itemBlock, valueStart, valueEnd - valueStart) - - ' Store in dictionary with full item name as key (e.g., "Black Toner Part Number") - If Not partNumbers.Exists(itemName) Then - partNumbers.Add itemName, itemValue - debugPartNumbers = debugPartNumbers & "[" & itemName & "=" & itemValue & "] " - End If - End If - End If - - currentPos = itemEnd + 1 - Loop - - ' Debug disabled - uncomment to show part number matching debug info - ' Response.Write("") - - ' Second pass: Find level items below 20% - currentPos = InStr(suppliesJSON, """result"":[") + 11 - - Do While currentPos > 11 And currentPos < Len(suppliesJSON) - ' Find next item - itemStart = InStr(currentPos, suppliesJSON, "{""itemid"":") - If itemStart = 0 Then Exit Do - - ' Find end of this item - itemEnd = InStr(itemStart, suppliesJSON, "},{") - If itemEnd = 0 Then - ' Last item in array - itemEnd = InStr(itemStart, suppliesJSON, "}]") - End If - If itemEnd = 0 Then Exit Do - - itemBlock = Mid(suppliesJSON, itemStart, itemEnd - itemStart + 1) - - ' Extract item name - "name":" is 8 characters - namePos = InStr(itemBlock, """name"":""") - If namePos > 0 Then - nameStart = namePos + 8 - nameEnd = InStr(nameStart, itemBlock, """") - itemName = Mid(itemBlock, nameStart, nameEnd - nameStart) - Else - itemName = "Unknown" - End If - - ' Extract lastvalue - "lastvalue":" is 13 characters - valuePos = InStr(itemBlock, """lastvalue"":""") - If valuePos > 0 Then - valueStart = valuePos + 13 - valueEnd = InStr(valueStart, itemBlock, """") - itemValue = Mid(itemBlock, valueStart, valueEnd - valueStart) - Else - itemValue = "0" - End If - - ' Extract status (0 = enabled, 1 = disabled) - "status":" is 10 characters - statusPos = InStr(itemBlock, """status"":""") - If statusPos > 0 Then - statusStart = statusPos + 10 - statusEnd = InStr(statusStart, itemBlock, """") - itemStatus = Mid(itemBlock, statusStart, statusEnd - statusStart) - Else - itemStatus = "0" - End If - - ' Extract state (0 = normal, 1 = not supported) - "state":" is 9 characters - statePos = InStr(itemBlock, """state"":""") - If statePos > 0 Then - stateStart = statePos + 9 - stateEnd = InStr(stateStart, itemBlock, """") - itemState = Mid(itemBlock, stateStart, stateEnd - stateStart) - Else - itemState = "0" - End If - - ' Convert value to number and check if below 20% - On Error Resume Next - numericValue = CDbl(itemValue) - On Error Goto 0 - - ' Filter: Only show actual supply level items (must have "Level" in name) - isSupplyItem = False - If InStr(1, itemName, "Level", 1) > 0 Then - ' Exclude non-supply items - If InStr(1, itemName, "Part Number", 1) = 0 And _ - InStr(1, itemName, "ICMP", 1) = 0 And _ - InStr(1, itemName, "ping", 1) = 0 And _ - InStr(1, itemName, "loss", 1) = 0 And _ - InStr(1, itemName, "response", 1) = 0 And _ - InStr(1, itemName, "Hostname", 1) = 0 And _ - InStr(1, itemName, "Model", 1) = 0 And _ - InStr(1, itemName, "Serial", 1) = 0 And _ - InStr(1, itemName, "Location", 1) = 0 And _ - InStr(1, itemName, "Firmware", 1) = 0 And _ - InStr(1, itemName, "Current", 1) = 0 And _ - InStr(1, itemName, " Max", 1) = 0 Then - isSupplyItem = True - End If - End If - - ' Detect if this is a waste cartridge (works backwards - high % is bad) - isWasteItem = (InStr(1, itemName, "Waste", 1) > 0) - - ' Check if item should be shown based on type - showItem = False - - If isSupplyItem And itemStatus = "0" And itemState = "0" Then - If isWasteItem Then - ' Waste cartridges: alert when ABOVE 80% (nearly full) - If numericValue > 80 And numericValue <= 100 Then - showItem = True - End If - Else - ' Regular supplies: alert when BELOW 20% (running low) - If numericValue < 20 And numericValue >= 0 Then - showItem = True - End If - End If - End If - - If showItem Then - lowSuppliesFound = True - - ' Determine status indicator - If isWasteItem Then - ' Waste cartridge status (high % = bad) - If numericValue >= 95 Then - statusIcon = "zmdi-alert-circle" - statusColor = "#ff0000" - statusText = "Critical - Nearly Full" - ElseIf numericValue >= 90 Then - statusIcon = "zmdi-alert-triangle" - statusColor = "#ff6600" - statusText = "Very High" - Else - statusIcon = "zmdi-info" - statusColor = "#ffaa00" - statusText = "High" - End If - Else - ' Regular supply status (low % = bad) - If numericValue <= 5 Then - statusIcon = "zmdi-alert-circle" - statusColor = "#ff0000" - statusText = "Critical" - ElseIf numericValue <= 10 Then - statusIcon = "zmdi-alert-triangle" - statusColor = "#ff6600" - statusText = "Very Low" - Else - statusIcon = "zmdi-info" - statusColor = "#ffaa00" - statusText = "Low" - End If - End If - - ' Look up part number for this item - partNumber = "-" - If partNumbers.Count > 0 Then - ' Extract base name for lookup - remove " Level" suffix - lookupName = Replace(itemName, " Level", "") - lookupName = Trim(lookupName) - - ' Comprehensive matching strategy for all template versions - foundMatch = False - - ' Strategy 1: EXACT match - NEW template format (preferred) - ' "Black Toner Level" → "Black Toner Part Number" - ' "Cyan Ink Level" → "Cyan Ink Part Number" - ' "Black Drum Level" → "Black Drum Part Number" - partKeyName = lookupName & " Part Number" - If partNumbers.Exists(partKeyName) Then - partNumber = partNumbers(partKeyName) - foundMatch = True - End If - - ' Strategy 2: Add " Cartridge" - OLD Xerox template format - ' "Black Drum Level" → "Black Drum Cartridge Part Number" - ' "Black Toner Level" → "Black Toner Cartridge Part Number" - If Not foundMatch Then - tryName = lookupName & " Cartridge Part Number" - If partNumbers.Exists(tryName) Then - partNumber = partNumbers(tryName) - foundMatch = True - End If - End If - - ' Strategy 3: Replace supply type with "Cartridge" - OLD HP template format - ' "Black Toner Level" → "Black Cartridge Part Number" - ' "Cyan Ink Level" → "Cyan Cartridge Part Number" - If Not foundMatch Then - ' Replace common supply types with "Cartridge" - If InStr(1, lookupName, "Toner", 1) > 0 Then - tryName = Replace(lookupName, "Toner", "Cartridge", 1, -1, 1) & " Part Number" - ElseIf InStr(1, lookupName, "Ink", 1) > 0 Then - tryName = Replace(lookupName, "Ink", "Cartridge", 1, -1, 1) & " Part Number" - ElseIf InStr(1, lookupName, "Drum", 1) > 0 Then - tryName = Replace(lookupName, "Drum", "Cartridge", 1, -1, 1) & " Part Number" - Else - tryName = "" - End If - - If tryName <> "" And partNumbers.Exists(tryName) Then - partNumber = partNumbers(tryName) - foundMatch = True - End If - End If - - ' Strategy 4: Check for "Standard MIB" suffix variation - ' "Maintenance Kit Level" → "Maintenance Kit Part Number (Standard MIB)" - If Not foundMatch Then - tryName = lookupName & " Part Number (Standard MIB)" - If partNumbers.Exists(tryName) Then - partNumber = partNumbers(tryName) - foundMatch = True - End If - End If - - ' Strategy 5: Intelligent fuzzy match by type and color - If Not foundMatch Then - ' Extract primary identifier (first significant word) - primaryWord = "" - supplyType = "" - - ' Determine supply type - If InStr(1, lookupName, "Toner", 1) > 0 Then - supplyType = "Toner" - ElseIf InStr(1, lookupName, "Ink", 1) > 0 Then - supplyType = "Ink" - ElseIf InStr(1, lookupName, "Drum", 1) > 0 Then - supplyType = "Drum" - ElseIf InStr(1, lookupName, "Waste", 1) > 0 Then - supplyType = "Waste" - ElseIf InStr(1, lookupName, "Fuser", 1) > 0 Then - supplyType = "Fuser" - ElseIf InStr(1, lookupName, "Maintenance", 1) > 0 Then - supplyType = "Maintenance" - End If - - ' Extract color/identifier (first word before supply type) - If supplyType <> "" Then - colorPos = InStr(1, lookupName, supplyType, 1) - If colorPos > 1 Then - primaryWord = Trim(Left(lookupName, colorPos - 1)) - End If - End If - - ' Search all keys for matching type and color - For Each partKey In partNumbers.Keys - If InStr(1, partKey, "Part Number", 1) > 0 Then - ' Must match supply type - typeMatches = False - If supplyType <> "" Then - typeMatches = (InStr(1, partKey, supplyType, 1) > 0) Or (InStr(1, partKey, "Cartridge", 1) > 0) - Else - ' For items without obvious type, just look for any match - typeMatches = True - End If - - ' Must match color/identifier if present - colorMatches = True - If primaryWord <> "" Then - colorMatches = (InStr(1, partKey, primaryWord, 1) > 0) - End If - - If typeMatches And colorMatches Then - partNumber = partNumbers(partKey) - foundMatch = True - Exit For - End If - End If - Next - End If - End If - - ' Get marketing name for this part number - marketingName = GetMarketingName(partNumber) - - If marketingName <> "" Then - ' Show marketing name prominently with OEM number in smaller text - displayPartNumber = "" & Server.HTMLEncode(marketingName) & "
" & Server.HTMLEncode(partNumber) & "" - Else - ' No mapping found, just show OEM number - displayPartNumber = Server.HTMLEncode(partNumber) - End If - - ' Calculate urgency score for sorting - ' For regular supplies: lower % = higher urgency (5% = 95 urgency) - ' For waste: higher % = higher urgency (95% = 95 urgency) - If isWasteItem Then - urgencyScore = numericValue - Else - urgencyScore = 100 - numericValue - End If - - ' Store alert data for later sorting - alertItem = Array( _ - urgencyScore, _ - vendor, _ - printerid, _ - printerwindowsname, _ - machineid, _ - machinenumber, _ - modelnumber, _ - numericValue, _ - statusColor, _ - displayPartNumber, _ - itemName _ - ) - - alertItems(alertCount) = alertItem - alertCount = alertCount + 1 - End If - - ' Move to next item - currentPos = itemEnd + 1 - Loop - End If - End If - End If - - rs.MoveNext - Wend - - ' Sort alerts by urgency (highest urgency first = most critical) - ' Simple bubble sort with error handling - On Error Resume Next - If alertCount > 1 Then - For i = 0 To alertCount - 2 - For j = 0 To alertCount - i - 2 - ' alertItems(j)(0) is the urgency score - If Not IsEmpty(alertItems(j)) And Not IsEmpty(alertItems(j + 1)) Then - If CDbl(alertItems(j)(0)) < CDbl(alertItems(j + 1)(0)) Then - ' Swap items - tempAlert = alertItems(j) - alertItems(j) = alertItems(j + 1) - alertItems(j + 1) = tempAlert - End If - End If - Next - Next - End If - - ' Output sorted alerts - If alertCount > 0 Then - lowSuppliesFound = True - For k = 0 To alertCount - 1 - If Not IsEmpty(alertItems(k)) And IsArray(alertItems(k)) Then - outputItem = alertItems(k) - ' Array indices: 0=urgencyScore, 1=vendor, 2=printerid, 3=printerwindowsname, - ' 4=machineid, 5=machinenumber, 6=modelnumber, 7=numericValue, - ' 8=statusColor, 9=displayPartNumber, 10=itemName - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - End If - Next - End If - On Error Goto 0 - - If Not lowSuppliesFound Then - Response.Write("") - End If - - objConn.Close -%> - -
PrinterLocationModelLevelPart Number
") - ' Response.Write("DEBUG (" & ipaddress & "): Scanned " & debugItemCount & " items | ") - ' Response.Write("First 10: " & Server.HTMLEncode(debugAllItems) & "
") - ' If debugPartNumbers <> "" Then - ' Response.Write("Part Numbers Found: " & Server.HTMLEncode(debugPartNumbers)) - ' Else - ' Response.Write("No part numbers found!") - ' End If - ' Response.Write("
" & Server.HTMLEncode(outputItem(3)) & "" & Server.HTMLEncode(outputItem(5)) & "" & Server.HTMLEncode(outputItem(6)) & "" & Round(CDbl(outputItem(7)), 1) & "%" & outputItem(9) & "
") - Response.Write("
") - Response.Write("No supply issues found - All printers have adequate supplies") - Response.Write("
-
- -
-
-
-
- - - -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tonerreport.asp.broken b/tonerreport.asp.broken deleted file mode 100644 index ceaa2e6..0000000 --- a/tonerreport.asp.broken +++ /dev/null @@ -1,951 +0,0 @@ - - - - - - - - -<% - ' ============================================================================ - ' FUNCTION: SafeGetZabbixData - ' PURPOSE: Safely call Zabbix function with error handling - ' ============================================================================ - Function SafeGetZabbixData(ipaddress) - On Error Resume Next - Dim result - result = GetAllPrinterSuppliesCached(ipaddress) - If Err.Number <> 0 Then - result = Empty - Err.Clear - End If - On Error Goto 0 - SafeGetZabbixData = result - End Function - - theme = Request.Cookies("theme") - IF theme = "" THEN - theme="bg-theme1" - END IF - - ' ============================================================================ - ' FUNCTION: GetMarketingName - ' PURPOSE: Convert OEM part numbers to marketing names for easier supply closet matching - ' ============================================================================ - Function GetMarketingName(oemPartNumber) - Dim oem, marketing - oem = UCase(Trim(oemPartNumber)) - - ' HP M454dw / M454dn / M479fdw (414A/414X series) - If oem = "W2020A" Or oem = "W2020X" Then marketing = "414A/414X Black" - ElseIf oem = "W2021A" Or oem = "W2021X" Then marketing = "414A/414X Cyan" - ElseIf oem = "W2022A" Or oem = "W2022X" Then marketing = "414A/414X Yellow" - ElseIf oem = "W2023A" Or oem = "W2023X" Then marketing = "414A/414X Magenta" - - ' HP M254dw / M255dw (202A/202X series) - ElseIf oem = "CF500A" Or oem = "CF500X" Then marketing = "202A/202X Black" - ElseIf oem = "CF501A" Or oem = "CF501X" Then marketing = "202A/202X Cyan" - ElseIf oem = "CF502A" Or oem = "CF502X" Then marketing = "202A/202X Yellow" - ElseIf oem = "CF503A" Or oem = "CF503X" Then marketing = "202A/202X Magenta" - - ' HP M251nw / M252dw (201A/201X series) - ElseIf oem = "CF400A" Or oem = "CF400X" Then marketing = "201A/201X Black" - ElseIf oem = "CF401A" Or oem = "CF401X" Then marketing = "201A/201X Cyan" - ElseIf oem = "CF402A" Or oem = "CF402X" Then marketing = "201A/201X Yellow" - ElseIf oem = "CF403A" Or oem = "CF403X" Then marketing = "201A/201X Magenta" - - ' HP LaserJet 200 color M251nw (131A/131X series) - ElseIf oem = "CF210A" Or oem = "CF210X" Then marketing = "131A/131X Black" - ElseIf oem = "CF211A" Then marketing = "131A Cyan" - ElseIf oem = "CF212A" Then marketing = "131A Yellow" - ElseIf oem = "CF213A" Then marketing = "131A Magenta" - - ' HP M404n / M406 (58A/58X series) - ElseIf oem = "CF258A" Or oem = "CF258X" Then marketing = "58A/58X Black" - - ' HP M506 / M607 (87A/87X series) - ElseIf oem = "CF287A" Or oem = "CF287X" Then marketing = "87A/87X Black" - - ' HP M602 (90A/90X series) - ElseIf oem = "CE390A" Or oem = "CE390X" Then marketing = "90A/90X Black" - - ' HP P3015dn (55A/55X series) - ElseIf oem = "CE255A" Or oem = "CE255X" Then marketing = "55A/55X Black" - - ' HP LaserJet 4250tn (42A/42X series) - ElseIf oem = "Q5942A" Or oem = "Q5942X" Then marketing = "42A/42X Black" - - ' HP LaserJet Pro 4001n (147A/147X series) - ElseIf oem = "W1470A" Or oem = "W1470X" Then marketing = "147A/147X Black" - - ' HP Imaging Drums - ElseIf oem = "CF234A" Then marketing = "34A Drum" - ElseIf oem = "CF219A" Then marketing = "19A Drum" - ElseIf oem = "W2030A" Or oem = "W2030X" Then marketing = "415A/415X Drum" - - ' HP Maintenance Kits - ElseIf oem = "CF254A" Then marketing = "54A Maintenance Kit" - ElseIf oem = "CF247A" Then marketing = "47A Maintenance Kit" - - ' Xerox (note: many use numeric part numbers) - ElseIf oem = "006R01697" Then marketing = "Xerox Black Toner" - ElseIf oem = "006R01698" Then marketing = "Xerox Cyan Toner" - ElseIf oem = "006R01699" Then marketing = "Xerox Yellow Toner" - ElseIf oem = "006R01700" Then marketing = "Xerox Magenta Toner" - - Else - marketing = "" ' No mapping found - will display OEM number only - End If - - GetMarketingName = marketing - End Function -%> - - - -
- - -
- - - - -
-
-
-
-
-
-
-
-
  Supplies Alert Report
-

- Monitors: Toner/Ink <20%, Drums <20%, Maintenance Kits <20%, Waste Cartridges >80% -

-
-
- - -
-
-
- - - - - - - - - - - - -<% - ' Declare all variables at top level to avoid scope issues - Dim strSQL, rs, printerid, printerwindowsname, printercsfname, ipaddress, machinenumber, modelnumber, machineid, vendor - Dim printerData, zabbixConnected, pingStatus, suppliesJSON - Dim lowSuppliesFound - Dim alertItems() - Dim alertCount - Dim itemStart, itemEnd, currentPos, itemBlock - Dim itemName, itemValue, itemStatus, itemState - Dim namePos, nameStart, nameEnd - Dim valuePos, valueStart, valueEnd - Dim statusPos, statusStart, statusEnd - Dim statePos, stateStart, stateEnd - Dim baseName, numericValue - Dim statusIcon, statusColor, statusText - Dim partNumber, lookupName - Dim partNumbers - Dim debugPartNumbers, debugAllItems, debugItemCount - Dim isSupplyItem, isWasteItem, showItem - Dim marketingName, displayPartNumber - Dim urgencyScore, alertItem - Dim i, j, tempAlert, outputItem, k - Dim partKeyName, tryName, partKey, foundMatch - Dim primaryWord, supplyType, colorPos - Dim typeMatches, colorMatches - - alertCount = 0 - ReDim alertItems(500) ' Pre-allocate space for up to 500 alerts - lowSuppliesFound = False - - strSQL = "SELECT printers.printerid, printers.printerwindowsname, printers.printercsfname, printers.ipaddress, " &_ - "machines.machinenumber, machines.machineid, models.modelnumber, machines.alias, vendors.vendor " &_ - "FROM printers " &_ - "INNER JOIN models ON printers.modelid = models.modelnumberid " &_ - "INNER JOIN machines ON printers.machineid = machines.machineid " &_ - "INNER JOIN vendors ON models.vendorid = vendors.vendorid " &_ - "WHERE printers.isactive = 1 AND printers.ipaddress IS NOT NULL AND printers.ipaddress != '' " &_ - "ORDER BY machines.machinenumber ASC" - - set rs = objconn.Execute(strSQL) - - While Not rs.EOF - printerid = rs("printerid") - printerwindowsname = rs("printerwindowsname") - printercsfname = rs("printercsfname") - ipaddress = rs("ipaddress") - modelnumber = rs("modelnumber") - machineid = rs("machineid") - vendor = rs("vendor") - - ' Use alias if available, otherwise machinenumber - If NOT IsNull(rs("alias")) AND rs("alias") <> "" Then - machinenumber = rs("alias") - Else - machinenumber = rs("machinenumber") - End If - - ' Get cached Zabbix data for this printer (all supplies including maintenance) - printerData = SafeGetZabbixData(ipaddress) - - If Not IsEmpty(printerData) And IsArray(printerData) Then - zabbixConnected = printerData(0) - pingStatus = printerData(1) - suppliesJSON = printerData(2) - - ' Parse supplies JSON to find items below 20% - If zabbixConnected = "1" And suppliesJSON <> "" And InStr(suppliesJSON, """result"":[") > 0 Then - ' Check if result array is not empty - If InStr(suppliesJSON, """result"":[]") = 0 Then - ' First pass: Build lookup of part numbers (type:info items) - ' Use Dictionary object for more reliable storage - Set partNumbers = Server.CreateObject("Scripting.Dictionary") - debugPartNumbers = "" - debugAllItems = "" - debugItemCount = 0 - - currentPos = InStr(suppliesJSON, """result"":[") + 11 - - ' Scan for part number items (containing "Part Number" in name) - Do While currentPos > 11 And currentPos < Len(suppliesJSON) - itemStart = InStr(currentPos, suppliesJSON, "{""itemid"":") - If itemStart = 0 Then Exit Do - - itemEnd = InStr(itemStart, suppliesJSON, "},{") - If itemEnd = 0 Then itemEnd = InStr(itemStart, suppliesJSON, "}]") - If itemEnd = 0 Then Exit Do - - itemBlock = Mid(suppliesJSON, itemStart, itemEnd - itemStart + 1) - - ' Extract name - namePos = InStr(itemBlock, """name"":""") - If namePos > 0 Then - nameStart = namePos + 8 - nameEnd = InStr(nameStart, itemBlock, """") - itemName = Mid(itemBlock, nameStart, nameEnd - nameStart) - Else - itemName = "" - End If - - ' DEBUG: Track all items scanned - debugItemCount = debugItemCount + 1 - If debugItemCount <= 10 Then - debugAllItems = debugAllItems & itemName & " | " - End If - - ' If this is a part number item, store it - ' Look for various part number patterns (case-insensitive) - If InStr(1, itemName, "Part Number", 1) > 0 Or InStr(1, itemName, "Part number", 1) > 0 Or InStr(1, itemName, "OEM", 1) > 0 Or InStr(1, itemName, "SKU", 1) > 0 Then - valuePos = InStr(itemBlock, """lastvalue"":""") - If valuePos > 0 Then - valueStart = valuePos + 13 - valueEnd = InStr(valueStart, itemBlock, """") - itemValue = Mid(itemBlock, valueStart, valueEnd - valueStart) - - ' Store in dictionary with full item name as key (e.g., "Black Toner Part Number") - If Not partNumbers.Exists(itemName) Then - partNumbers.Add itemName, itemValue - debugPartNumbers = debugPartNumbers & "[" & itemName & "=" & itemValue & "] " - End If - End If - End If - - currentPos = itemEnd + 1 - Loop - - ' Debug disabled - uncomment to show part number matching debug info - ' Response.Write("") - - ' Second pass: Find level items below 20% - currentPos = InStr(suppliesJSON, """result"":[") + 11 - - Do While currentPos > 11 And currentPos < Len(suppliesJSON) - ' Find next item - itemStart = InStr(currentPos, suppliesJSON, "{""itemid"":") - If itemStart = 0 Then Exit Do - - ' Find end of this item - itemEnd = InStr(itemStart, suppliesJSON, "},{") - If itemEnd = 0 Then - ' Last item in array - itemEnd = InStr(itemStart, suppliesJSON, "}]") - End If - If itemEnd = 0 Then Exit Do - - itemBlock = Mid(suppliesJSON, itemStart, itemEnd - itemStart + 1) - - ' Extract item name - "name":" is 8 characters - namePos = InStr(itemBlock, """name"":""") - If namePos > 0 Then - nameStart = namePos + 8 - nameEnd = InStr(nameStart, itemBlock, """") - itemName = Mid(itemBlock, nameStart, nameEnd - nameStart) - Else - itemName = "Unknown" - End If - - ' Extract lastvalue - "lastvalue":" is 13 characters - valuePos = InStr(itemBlock, """lastvalue"":""") - If valuePos > 0 Then - valueStart = valuePos + 13 - valueEnd = InStr(valueStart, itemBlock, """") - itemValue = Mid(itemBlock, valueStart, valueEnd - valueStart) - Else - itemValue = "0" - End If - - ' Extract status (0 = enabled, 1 = disabled) - "status":" is 10 characters - statusPos = InStr(itemBlock, """status"":""") - If statusPos > 0 Then - statusStart = statusPos + 10 - statusEnd = InStr(statusStart, itemBlock, """") - itemStatus = Mid(itemBlock, statusStart, statusEnd - statusStart) - Else - itemStatus = "0" - End If - - ' Extract state (0 = normal, 1 = not supported) - "state":" is 9 characters - statePos = InStr(itemBlock, """state"":""") - If statePos > 0 Then - stateStart = statePos + 9 - stateEnd = InStr(stateStart, itemBlock, """") - itemState = Mid(itemBlock, stateStart, stateEnd - stateStart) - Else - itemState = "0" - End If - - ' Convert value to number and check if below 20% - On Error Resume Next - numericValue = CDbl(itemValue) - On Error Goto 0 - - ' Filter: Only show actual supply level items (must have "Level" in name) - isSupplyItem = False - If InStr(1, itemName, "Level", 1) > 0 Then - ' Exclude non-supply items - If InStr(1, itemName, "Part Number", 1) = 0 And _ - InStr(1, itemName, "ICMP", 1) = 0 And _ - InStr(1, itemName, "ping", 1) = 0 And _ - InStr(1, itemName, "loss", 1) = 0 And _ - InStr(1, itemName, "response", 1) = 0 And _ - InStr(1, itemName, "Hostname", 1) = 0 And _ - InStr(1, itemName, "Model", 1) = 0 And _ - InStr(1, itemName, "Serial", 1) = 0 And _ - InStr(1, itemName, "Location", 1) = 0 And _ - InStr(1, itemName, "Firmware", 1) = 0 And _ - InStr(1, itemName, "Current", 1) = 0 And _ - InStr(1, itemName, " Max", 1) = 0 Then - isSupplyItem = True - End If - End If - - ' Detect if this is a waste cartridge (works backwards - high % is bad) - isWasteItem = (InStr(1, itemName, "Waste", 1) > 0) - - ' Check if item should be shown based on type - showItem = False - - If isSupplyItem And itemStatus = "0" And itemState = "0" Then - If isWasteItem Then - ' Waste cartridges: alert when ABOVE 80% (nearly full) - If numericValue > 80 And numericValue <= 100 Then - showItem = True - End If - Else - ' Regular supplies: alert when BELOW 20% (running low) - If numericValue < 20 And numericValue >= 0 Then - showItem = True - End If - End If - End If - - If showItem Then - lowSuppliesFound = True - - ' Determine status indicator - If isWasteItem Then - ' Waste cartridge status (high % = bad) - If numericValue >= 95 Then - statusIcon = "zmdi-alert-circle" - statusColor = "#ff0000" - statusText = "Critical - Nearly Full" - ElseIf numericValue >= 90 Then - statusIcon = "zmdi-alert-triangle" - statusColor = "#ff6600" - statusText = "Very High" - Else - statusIcon = "zmdi-info" - statusColor = "#ffaa00" - statusText = "High" - End If - Else - ' Regular supply status (low % = bad) - If numericValue <= 5 Then - statusIcon = "zmdi-alert-circle" - statusColor = "#ff0000" - statusText = "Critical" - ElseIf numericValue <= 10 Then - statusIcon = "zmdi-alert-triangle" - statusColor = "#ff6600" - statusText = "Very Low" - Else - statusIcon = "zmdi-info" - statusColor = "#ffaa00" - statusText = "Low" - End If - End If - - ' Look up part number for this item - partNumber = "-" - If partNumbers.Count > 0 Then - ' Extract base name for lookup - remove " Level" suffix - lookupName = Replace(itemName, " Level", "") - lookupName = Trim(lookupName) - - ' Comprehensive matching strategy for all template versions - foundMatch = False - - ' Strategy 1: EXACT match - NEW template format (preferred) - ' "Black Toner Level" → "Black Toner Part Number" - ' "Cyan Ink Level" → "Cyan Ink Part Number" - ' "Black Drum Level" → "Black Drum Part Number" - partKeyName = lookupName & " Part Number" - If partNumbers.Exists(partKeyName) Then - partNumber = partNumbers(partKeyName) - foundMatch = True - End If - - ' Strategy 2: Add " Cartridge" - OLD Xerox template format - ' "Black Drum Level" → "Black Drum Cartridge Part Number" - ' "Black Toner Level" → "Black Toner Cartridge Part Number" - If Not foundMatch Then - tryName = lookupName & " Cartridge Part Number" - If partNumbers.Exists(tryName) Then - partNumber = partNumbers(tryName) - foundMatch = True - End If - End If - - ' Strategy 3: Replace supply type with "Cartridge" - OLD HP template format - ' "Black Toner Level" → "Black Cartridge Part Number" - ' "Cyan Ink Level" → "Cyan Cartridge Part Number" - If Not foundMatch Then - ' Replace common supply types with "Cartridge" - If InStr(1, lookupName, "Toner", 1) > 0 Then - tryName = Replace(lookupName, "Toner", "Cartridge", 1, -1, 1) & " Part Number" - ElseIf InStr(1, lookupName, "Ink", 1) > 0 Then - tryName = Replace(lookupName, "Ink", "Cartridge", 1, -1, 1) & " Part Number" - ElseIf InStr(1, lookupName, "Drum", 1) > 0 Then - tryName = Replace(lookupName, "Drum", "Cartridge", 1, -1, 1) & " Part Number" - Else - tryName = "" - End If - - If tryName <> "" And partNumbers.Exists(tryName) Then - partNumber = partNumbers(tryName) - foundMatch = True - End If - End If - - ' Strategy 4: Check for "Standard MIB" suffix variation - ' "Maintenance Kit Level" → "Maintenance Kit Part Number (Standard MIB)" - If Not foundMatch Then - tryName = lookupName & " Part Number (Standard MIB)" - If partNumbers.Exists(tryName) Then - partNumber = partNumbers(tryName) - foundMatch = True - End If - End If - - ' Strategy 5: Intelligent fuzzy match by type and color - If Not foundMatch Then - ' Extract primary identifier (first significant word) - primaryWord = "" - supplyType = "" - - ' Determine supply type - If InStr(1, lookupName, "Toner", 1) > 0 Then - supplyType = "Toner" - ElseIf InStr(1, lookupName, "Ink", 1) > 0 Then - supplyType = "Ink" - ElseIf InStr(1, lookupName, "Drum", 1) > 0 Then - supplyType = "Drum" - ElseIf InStr(1, lookupName, "Waste", 1) > 0 Then - supplyType = "Waste" - ElseIf InStr(1, lookupName, "Fuser", 1) > 0 Then - supplyType = "Fuser" - ElseIf InStr(1, lookupName, "Maintenance", 1) > 0 Then - supplyType = "Maintenance" - End If - - ' Extract color/identifier (first word before supply type) - If supplyType <> "" Then - colorPos = InStr(1, lookupName, supplyType, 1) - If colorPos > 1 Then - primaryWord = Trim(Left(lookupName, colorPos - 1)) - End If - End If - - ' Search all keys for matching type and color - For Each partKey In partNumbers.Keys - If InStr(1, partKey, "Part Number", 1) > 0 Then - ' Must match supply type - typeMatches = False - If supplyType <> "" Then - typeMatches = (InStr(1, partKey, supplyType, 1) > 0) Or (InStr(1, partKey, "Cartridge", 1) > 0) - Else - ' For items without obvious type, just look for any match - typeMatches = True - End If - - ' Must match color/identifier if present - colorMatches = True - If primaryWord <> "" Then - colorMatches = (InStr(1, partKey, primaryWord, 1) > 0) - End If - - If typeMatches And colorMatches Then - partNumber = partNumbers(partKey) - foundMatch = True - Exit For - End If - End If - Next - End If - End If - - ' Get marketing name for this part number - marketingName = GetMarketingName(partNumber) - - If marketingName <> "" Then - ' Show marketing name prominently with OEM number in smaller text - displayPartNumber = "" & Server.HTMLEncode(marketingName) & "
" & Server.HTMLEncode(partNumber) & "" - Else - ' No mapping found, just show OEM number - displayPartNumber = Server.HTMLEncode(partNumber) - End If - - ' Calculate urgency score for sorting - ' For regular supplies: lower % = higher urgency (5% = 95 urgency) - ' For waste: higher % = higher urgency (95% = 95 urgency) - If isWasteItem Then - urgencyScore = numericValue - Else - urgencyScore = 100 - numericValue - End If - - ' Store alert data for later sorting - alertItem = Array( _ - urgencyScore, _ - vendor, _ - printerid, _ - printerwindowsname, _ - machineid, _ - machinenumber, _ - modelnumber, _ - numericValue, _ - statusColor, _ - displayPartNumber, _ - itemName _ - ) - - alertItems(alertCount) = alertItem - alertCount = alertCount + 1 - End If - - ' Move to next item - currentPos = itemEnd + 1 - Loop - End If - End If - End If - - rs.MoveNext - Wend - - ' Sort alerts by urgency (highest urgency first = most critical) - ' Simple bubble sort with error handling - On Error Resume Next - If alertCount > 1 Then - For i = 0 To alertCount - 2 - For j = 0 To alertCount - i - 2 - ' alertItems(j)(0) is the urgency score - If Not IsEmpty(alertItems(j)) And Not IsEmpty(alertItems(j + 1)) Then - If CDbl(alertItems(j)(0)) < CDbl(alertItems(j + 1)(0)) Then - ' Swap items - tempAlert = alertItems(j) - alertItems(j) = alertItems(j + 1) - alertItems(j + 1) = tempAlert - End If - End If - Next - Next - End If - - ' Output sorted alerts - If alertCount > 0 Then - lowSuppliesFound = True - For k = 0 To alertCount - 1 - If Not IsEmpty(alertItems(k)) And IsArray(alertItems(k)) Then - outputItem = alertItems(k) - ' Array indices: 0=urgencyScore, 1=vendor, 2=printerid, 3=printerwindowsname, - ' 4=machineid, 5=machinenumber, 6=modelnumber, 7=numericValue, - ' 8=statusColor, 9=displayPartNumber, 10=itemName - - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - Response.Write("") - End If - Next - End If - On Error Goto 0 - - If Not lowSuppliesFound Then - Response.Write("") - End If - - objConn.Close -%> - -
PrinterLocationModelLevelPart Number
") - ' Response.Write("DEBUG (" & ipaddress & "): Scanned " & debugItemCount & " items | ") - ' Response.Write("First 10: " & Server.HTMLEncode(debugAllItems) & "
") - ' If debugPartNumbers <> "" Then - ' Response.Write("Part Numbers Found: " & Server.HTMLEncode(debugPartNumbers)) - ' Else - ' Response.Write("No part numbers found!") - ' End If - ' Response.Write("
" & Server.HTMLEncode(outputItem(3)) & "" & Server.HTMLEncode(outputItem(5)) & "" & Server.HTMLEncode(outputItem(6)) & "" & Round(CDbl(outputItem(7)), 1) & "%" & outputItem(9) & "
") - Response.Write("
") - Response.Write("No supply issues found - All printers have adequate supplies") - Response.Write("
-
- -
-
-
-
- - - -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/updatedevice_direct.asp.backup-20251027 b/updatedevice_direct.asp.backup-20251027 deleted file mode 100644 index 73e0968..0000000 --- a/updatedevice_direct.asp.backup-20251027 +++ /dev/null @@ -1,223 +0,0 @@ - -<% - ' Get form data - Dim pcid, pcstatusid, pctypeid, hostname, modelnumberid, machinenumber, isactive - - pcid = Trim(Request.Form("pcid")) - pcstatusid = Trim(Request.Form("pcstatusid")) - pctypeid = Trim(Request.Form("pctypeid")) - hostname = Trim(Request.Form("hostname")) - modelnumberid = Trim(Request.Form("modelnumberid")) - machinenumber = Trim(Request.Form("machinenumber")) - isactive = Trim(Request.Form("isactive")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required ID fields - If Not IsNumeric(pcid) Or CLng(pcid) < 1 Then - Response.Write("Invalid PC ID") - objConn.Close - Response.End - End If - - If Not IsNumeric(pcstatusid) Or CLng(pcstatusid) < 1 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - ' Verify the PC exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM pc WHERE pcid = " & CLng(pcid) - Set rsCheck = objConn.Execute(checkSQL) - If Not rsCheck.EOF Then - If CLng(rsCheck("cnt")) = 0 Then - rsCheck.Close - objConn.Close - Response.Redirect("default.asp") - Response.End - End If - End If - rsCheck.Close - - ' Set isactive: if checkbox not checked, it won't be in form data - If isactive = "1" Then - isactive = 1 - Else - isactive = 0 - End If - - ' Validate optional ID fields - allow "new" as a valid value for model - If pctypeid <> "" Then - If Not IsNumeric(pctypeid) Or CLng(pctypeid) < 1 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - End If - - If modelnumberid <> "" And modelnumberid <> "new" Then - If Not IsNumeric(modelnumberid) Or CLng(modelnumberid) < 1 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - End If - - ' Handle new model creation - If modelnumberid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 50 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedVendorName - escapedVendorName = Replace(newvendorname, "'", "''") - - ' Insert new vendor (with ispc=1) - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) VALUES ('" & escapedVendorName & "', 1, 0, 1, 0)" - - On Error Resume Next - objConn.Execute sqlNewVendor - - If Err.Number <> 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Err.Description)) - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for model - Dim escapedModelNumber - escapedModelNumber = Replace(newmodelnumber, "'", "''") - - ' Insert new model - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, isactive) VALUES ('" & escapedModelNumber & "', " & newvendorid & ", 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - - If Err.Number <> 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Err.Description)) - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelnumberid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - End If - - ' Validate field lengths - If hostname <> "" And Len(hostname) > 255 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - If machinenumber <> "" And Len(machinenumber) > 50 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Escape quotes - hostname = Replace(hostname, "'", "''") - machinenumber = Replace(machinenumber, "'", "''") - - ' Build UPDATE query dynamically - Dim updateSQL - updateSQL = "UPDATE pc SET pcstatusid = " & pcstatusid & ", isactive = " & isactive & ", " - - ' Add optional fields - If pctypeid <> "" Then - updateSQL = updateSQL & "pctypeid = " & pctypeid & ", " - Else - updateSQL = updateSQL & "pctypeid = NULL, " - End If - - If hostname <> "" Then - updateSQL = updateSQL & "hostname = '" & hostname & "', " - Else - updateSQL = updateSQL & "hostname = NULL, " - End If - - If modelnumberid <> "" Then - updateSQL = updateSQL & "modelnumberid = " & modelnumberid & ", " - Else - updateSQL = updateSQL & "modelnumberid = NULL, " - End If - - If machinenumber <> "" Then - updateSQL = updateSQL & "machinenumber = '" & machinenumber & "', " - Else - updateSQL = updateSQL & "machinenumber = NULL, " - End If - - ' Add lastupdated timestamp and WHERE clause - updateSQL = updateSQL & "lastupdated = NOW() WHERE pcid = " & pcid - - ' Execute update - On Error Resume Next - objConn.Execute updateSQL - - If Err.Number = 0 Then - objConn.Close - ' Success - redirect back to scan page ready for next scan - Response.Redirect("./adddevice.asp") - Else - Dim errMsg - errMsg = Err.Description - objConn.Close - Response.Redirect("./editdevice.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(errMsg)) - End If -%> diff --git a/updatedevice_direct.asp.backup-20251114 b/updatedevice_direct.asp.backup-20251114 deleted file mode 100644 index 29f870a..0000000 --- a/updatedevice_direct.asp.backup-20251114 +++ /dev/null @@ -1,230 +0,0 @@ -<% -'============================================================================= -' FILE: updatedevice_direct.asp -' PURPOSE: Update PC/device with optional vendor and model creation -' SECURITY: Parameterized queries, HTML encoding, input validation -' UPDATED: 2025-10-27 - Migrated to secure patterns -'============================================================================= -%> - -<% - ' Get form data - Dim pcid, machinestatusid, pctypeid, hostname, modelnumberid, machinenumber, isactive - - pcid = Trim(Request.Form("pcid")) - machinestatusid = Trim(Request.Form("machinestatusid")) - pctypeid = Trim(Request.Form("pctypeid")) - hostname = Trim(Request.Form("hostname")) - modelnumberid = Trim(Request.Form("modelnumberid")) - machinenumber = Trim(Request.Form("machinenumber")) - isactive = Trim(Request.Form("isactive")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid - newmodelnumber = Trim(Request.Form("newmodelnumber")) - newvendorid = Trim(Request.Form("newvendorid")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newvendorname")) - - ' Validate required ID fields - If Not IsNumeric(pcid) Or CLng(pcid) < 1 Then - Response.Write("Invalid PC ID") - objConn.Close - Response.End - End If - - If Not IsNumeric(machinestatusid) Or CLng(machinestatusid) < 1 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - ' Set isactive: if checkbox not checked, it won't be in form data - If isactive = "1" Then - isactive = 1 - Else - isactive = 0 - End If - - ' Validate optional ID fields - allow "new" as a valid value for model - If pctypeid <> "" Then - If Not IsNumeric(pctypeid) Or CLng(pctypeid) < 1 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - End If - - If modelnumberid <> "" And modelnumberid <> "new" Then - If Not IsNumeric(modelnumberid) Or CLng(modelnumberid) < 1 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - End If - - ' Handle new model creation - If modelnumberid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 50 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Handle new vendor creation (nested) - If newvendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Insert new vendor using parameterized query (with ispc=1) - Dim sqlNewVendor, cmdNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) VALUES (?, 1, 0, 1, 0)" - Set cmdNewVendor = Server.CreateObject("ADODB.Command") - cmdNewVendor.ActiveConnection = objConn - cmdNewVendor.CommandText = sqlNewVendor - cmdNewVendor.CommandType = 1 - cmdNewVendor.Parameters.Append cmdNewVendor.CreateParameter("@vendor", 200, 1, 50, newvendorname) - - On Error Resume Next - cmdNewVendor.Execute - - If Err.Number <> 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Server.HTMLEncode(Err.Description))) - Set cmdNewVendor = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newvendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - Set cmdNewVendor = Nothing - On Error Goto 0 - End If - - ' Insert new model using parameterized query - Dim sqlNewModel, cmdNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, isactive) VALUES (?, ?, 1)" - Set cmdNewModel = Server.CreateObject("ADODB.Command") - cmdNewModel.ActiveConnection = objConn - cmdNewModel.CommandText = sqlNewModel - cmdNewModel.CommandType = 1 - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@modelnumber", 200, 1, 50, newmodelnumber) - cmdNewModel.Parameters.Append cmdNewModel.CreateParameter("@vendorid", 3, 1, , CLng(newvendorid)) - - On Error Resume Next - cmdNewModel.Execute - - If Err.Number <> 0 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Server.HTMLEncode(Err.Description))) - Set cmdNewModel = Nothing - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelnumberid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - Set cmdNewModel = Nothing - On Error Goto 0 - End If - - ' Validate field lengths - If hostname <> "" And Len(hostname) > 255 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - If machinenumber <> "" And Len(machinenumber) > 50 Then - Response.Redirect("editdevice.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Build UPDATE query using parameterized query - Dim updateSQL, cmdUpdate - updateSQL = "UPDATE machines SET machinestatusid = ?, isactive = ?, pctypeid = ?, hostname = ?, modelnumberid = ?, machinenumber = ?, lastupdated = NOW() WHERE machineid = ? AND pctypeid IS NOT NULL" - Set cmdUpdate = Server.CreateObject("ADODB.Command") - cmdUpdate.ActiveConnection = objConn - cmdUpdate.CommandText = updateSQL - cmdUpdate.CommandType = 1 - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@machinestatusid", 3, 1, , CLng(machinestatusid)) - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@isactive", 3, 1, , isactive) - - ' Handle optional pctypeid - If pctypeid <> "" Then - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@pctypeid", 3, 1, , CLng(pctypeid)) - Else - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@pctypeid", 3, 1, , Null) - End If - - ' Handle optional hostname - If hostname <> "" Then - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@hostname", 200, 1, 255, hostname) - Else - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@hostname", 200, 1, 255, Null) - End If - - ' Handle optional modelnumberid - If modelnumberid <> "" Then - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@modelnumberid", 3, 1, , CLng(modelnumberid)) - Else - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@modelnumberid", 3, 1, , Null) - End If - - ' Handle optional machinenumber - If machinenumber <> "" Then - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@machinenumber", 200, 1, 50, machinenumber) - Else - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@machinenumber", 200, 1, 50, Null) - End If - - cmdUpdate.Parameters.Append cmdUpdate.CreateParameter("@machineid", 3, 1, , CLng(pcid)) - - ' Execute update - On Error Resume Next - cmdUpdate.Execute - - If Err.Number = 0 Then - Set cmdUpdate = Nothing - objConn.Close - ' Success - redirect back to scan page ready for next scan - Response.Redirect("./adddevice.asp") - Else - Dim errMsg - errMsg = Server.HTMLEncode(Err.Description) - Set cmdUpdate = Nothing - objConn.Close - Response.Redirect("./editdevice.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(errMsg)) - End If -%> diff --git a/updatelink_direct.asp.backup-20251027 b/updatelink_direct.asp.backup-20251027 deleted file mode 100644 index c1b8e0a..0000000 --- a/updatelink_direct.asp.backup-20251027 +++ /dev/null @@ -1,227 +0,0 @@ - -<% -' Get form inputs for KB article -Dim linkid, linkurl, shortdescription, keywords, appid -linkid = Trim(Request.Form("linkid")) -linkurl = Trim(Request.Form("linkurl")) -shortdescription = Trim(Request.Form("shortdescription")) -keywords = Trim(Request.Form("keywords")) -appid = Trim(Request.Form("appid")) - -' Get form inputs for new topic -Dim newappname, newappdescription, newsupportteamid -Dim newapplicationnotes, newinstallpath, newdocumentationpath, newisactive -newappname = Trim(Request.Form("newappname")) -newappdescription = Trim(Request.Form("newappdescription")) -newsupportteamid = Trim(Request.Form("newsupportteamid")) -newapplicationnotes = Trim(Request.Form("newapplicationnotes")) -newinstallpath = Trim(Request.Form("newinstallpath")) -newdocumentationpath = Trim(Request.Form("newdocumentationpath")) -newisactive = Request.Form("newisactive") - -' Get form inputs for new support team -Dim newsupportteamname, newsupportteamurl, newappownerid -newsupportteamname = Trim(Request.Form("newsupportteamname")) -newsupportteamurl = Trim(Request.Form("newsupportteamurl")) -newappownerid = Trim(Request.Form("newappownerid")) - -' Get form inputs for new app owner -Dim newappownername, newappownersso -newappownername = Trim(Request.Form("newappownername")) -newappownersso = Trim(Request.Form("newappownersso")) - -' Basic validation -If Not IsNumeric(linkid) Or CLng(linkid) < 1 Then - Response.Write("Invalid link ID") - objConn.Close - Response.End -End If - -If Len(linkurl) = 0 Or Len(shortdescription) = 0 Or Len(appid) = 0 Then - Response.Write("Required fields missing") - objConn.Close - Response.End -End If - -If Len(linkurl) > 2000 Or Len(shortdescription) > 500 Or Len(keywords) > 500 Then - Response.Write("Field length exceeded") - objConn.Close - Response.End -End If - -' Handle new topic creation -If appid = "new" Then - If Len(newappname) = 0 Then - Response.Write("New topic name is required") - objConn.Close - Response.End - End If - - If Len(newsupportteamid) = 0 Then - Response.Write("Support team is required for new topic") - objConn.Close - Response.End - End If - - ' Validate field lengths for new topic - If Len(newappname) > 50 Or Len(newappdescription) > 255 Or Len(newapplicationnotes) > 512 Or Len(newinstallpath) > 255 Or Len(newdocumentationpath) > 512 Then - Response.Write("New topic field length exceeded") - objConn.Close - Response.End - End If - - ' Handle new support team creation (nested) - If newsupportteamid = "new" Then - If Len(newsupportteamname) = 0 Then - Response.Write("New support team name is required") - objConn.Close - Response.End - End If - - If Len(newappownerid) = 0 Then - Response.Write("App owner is required for new support team") - objConn.Close - Response.End - End If - - If Len(newsupportteamname) > 50 Or Len(newsupportteamurl) > 512 Then - Response.Write("New support team field length exceeded") - objConn.Close - Response.End - End If - - ' Handle new app owner creation (doubly nested) - If newappownerid = "new" Then - If Len(newappownername) = 0 Or Len(newappownersso) = 0 Then - Response.Write("App owner name and SSO are required") - objConn.Close - Response.End - End If - - If Len(newappownername) > 50 Or Len(newappownersso) > 255 Then - Response.Write("App owner field length exceeded") - objConn.Close - Response.End - End If - - ' Escape single quotes for new app owner - Dim escapedOwnerName, escapedOwnerSSO - escapedOwnerName = Replace(newappownername, "'", "''") - escapedOwnerSSO = Replace(newappownersso, "'", "''") - - ' Insert new app owner - Dim sqlNewOwner - sqlNewOwner = "INSERT INTO appowners (appowner, sso, isactive) " & _ - "VALUES ('" & escapedOwnerName & "', '" & escapedOwnerSSO & "', 1)" - - On Error Resume Next - objConn.Execute sqlNewOwner - - If Err.Number <> 0 Then - Response.Write("Error creating new app owner: " & Err.Description) - objConn.Close - Response.End - End If - - ' Get the newly created app owner ID - Dim rsNewOwner - Set rsNewOwner = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newappownerid = rsNewOwner("newid") - rsNewOwner.Close - Set rsNewOwner = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for new support team - Dim escapedTeamName, escapedTeamURL - escapedTeamName = Replace(newsupportteamname, "'", "''") - escapedTeamURL = Replace(newsupportteamurl, "'", "''") - - ' Insert new support team with selected or newly created app owner - Dim sqlNewTeam - sqlNewTeam = "INSERT INTO supportteams (teamname, teamurl, appownerid, isactive) " & _ - "VALUES ('" & escapedTeamName & "', '" & escapedTeamURL & "', " & newappownerid & ", 1)" - - On Error Resume Next - objConn.Execute sqlNewTeam - - If Err.Number <> 0 Then - Response.Write("Error creating new support team: " & Err.Description) - objConn.Close - Response.End - End If - - ' Get the newly created support team ID - Dim rsNewTeam - Set rsNewTeam = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - newsupportteamid = rsNewTeam("newid") - rsNewTeam.Close - Set rsNewTeam = Nothing - On Error Goto 0 - End If - - ' Escape single quotes for new topic - Dim escapedAppName, escapedAppDesc, escapedAppNotes, escapedInstallPath, escapedDocPath - escapedAppName = Replace(newappname, "'", "''") - escapedAppDesc = Replace(newappdescription, "'", "''") - escapedAppNotes = Replace(newapplicationnotes, "'", "''") - escapedInstallPath = Replace(newinstallpath, "'", "''") - escapedDocPath = Replace(newdocumentationpath, "'", "''") - - ' Convert isactive checkbox - Dim isActiveValue - If newisactive = "1" Then - isActiveValue = 1 - Else - isActiveValue = 0 - End If - - ' Insert new application/topic - Dim sqlNewApp - sqlNewApp = "INSERT INTO applications (appname, appdescription, supportteamid, applicationnotes, installpath, documentationpath, isactive, isinstallable, ishidden, isprinter, islicenced) " & _ - "VALUES ('" & escapedAppName & "', '" & escapedAppDesc & "', " & newsupportteamid & ", '" & escapedAppNotes & "', '" & escapedInstallPath & "', '" & escapedDocPath & "', " & isActiveValue & ", 0, 0, 0, 0)" - - On Error Resume Next - objConn.Execute sqlNewApp - - If Err.Number <> 0 Then - Response.Write("Error creating new topic: " & Err.Description) - objConn.Close - Response.End - End If - - ' Get the newly created topic ID - Dim rsNewApp - Set rsNewApp = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - appid = rsNewApp("newid") - rsNewApp.Close - Set rsNewApp = Nothing - On Error Goto 0 -End If - -' Escape single quotes for KB article -linkurl = Replace(linkurl, "'", "''") -shortdescription = Replace(shortdescription, "'", "''") -keywords = Replace(keywords, "'", "''") - -' Build UPDATE statement -Dim strSQL -strSQL = "UPDATE knowledgebase SET " & _ - "linkurl = '" & linkurl & "', " & _ - "shortdescription = '" & shortdescription & "', " & _ - "keywords = '" & keywords & "', " & _ - "appid = " & appid & ", " & _ - "lastupdated = NOW() " & _ - "WHERE linkid = " & linkid - -On Error Resume Next -objConn.Execute strSQL - -If Err.Number = 0 Then - objConn.Close - Response.Redirect("displayknowledgearticle.asp?linkid=" & linkid & "&status=updated") -Else - objConn.Close - Response.Redirect("displayknowledgearticle.asp?linkid=" & linkid & "&status=error&msg=" & Server.URLEncode("Error: " & Err.Description)) -End If -%> diff --git a/updatenotification_direct.asp.backup-20251027 b/updatenotification_direct.asp.backup-20251027 deleted file mode 100644 index 02d1b90..0000000 --- a/updatenotification_direct.asp.backup-20251027 +++ /dev/null @@ -1,117 +0,0 @@ - -<% -' Get form inputs -Dim notificationid, notification, ticketnumber, starttime, endtime, isactive, isshopfloor, notificationtypeid, businessunitid -notificationid = Trim(Request.Form("notificationid")) -notification = Trim(Request.Form("notification")) -ticketnumber = Trim(Request.Form("ticketnumber")) -starttime = Trim(Request.Form("starttime")) -endtime = Trim(Request.Form("endtime")) -notificationtypeid = Trim(Request.Form("notificationtypeid")) -businessunitid = Trim(Request.Form("businessunitid")) - -' Handle checkbox - if the hidden field is submitted but checkbox isn't, it means unchecked -If Request.Form("isactive_submitted") = "1" Then - If Request.Form("isactive") = "1" Then - isactive = 1 - Else - isactive = 0 - End If -Else - ' Fallback for backward compatibility - If Request.Form("isactive") = "" Then - isactive = 0 - Else - isactive = 1 - End If -End If - -' Handle isshopfloor checkbox - same pattern as isactive -If Request.Form("isshopfloor_submitted") = "1" Then - If Request.Form("isshopfloor") = "1" Then - isshopfloor = 1 - Else - isshopfloor = 0 - End If -Else - ' Fallback for backward compatibility - If Request.Form("isshopfloor") = "" Then - isshopfloor = 0 - Else - isshopfloor = 1 - End If -End If - -' Validate -If Not IsNumeric(notificationid) Or CLng(notificationid) < 1 Then - Response.Write("Invalid notification ID") - objConn.Close - Response.End -End If - -' Default to TBD if no type selected -If notificationtypeid = "" Or Not IsNumeric(notificationtypeid) Then - notificationtypeid = "1" -End If - -' Validate required fields (endtime is now optional) -If Len(notification) = 0 Or Len(starttime) = 0 Then - Response.Write("Required fields missing") - objConn.Close - Response.End -End If - -If Len(notification) > 500 Or Len(ticketnumber) > 50 Then - Response.Write("Field length exceeded") - objConn.Close - Response.End -End If - -' Escape quotes -notification = Replace(notification, "'", "''") -ticketnumber = Replace(ticketnumber, "'", "''") - -' Convert datetime format for starttime -starttime = Replace(starttime, "T", " ") & ":00" - -' Handle optional endtime - leave as NULL if blank (indefinite) -Dim strSQL, endtimeSQL, businessunitSQL -If Len(endtime) = 0 Then - ' No end date - store as NULL for indefinite notifications - endtimeSQL = "NULL" -Else - ' End date specified - convert format and wrap in quotes - endtime = Replace(endtime, "T", " ") & ":00" - endtimeSQL = "'" & endtime & "'" -End If - -' Handle optional businessunitid - NULL means applies to all business units -If businessunitid = "" Or Not IsNumeric(businessunitid) Then - businessunitSQL = "NULL" -Else - businessunitSQL = businessunitid -End If - -' UPDATE -strSQL = "UPDATE notifications SET " & _ - "notificationtypeid = " & notificationtypeid & ", " & _ - "businessunitid = " & businessunitSQL & ", " & _ - "notification = '" & notification & "', " & _ - "ticketnumber = '" & ticketnumber & "', " & _ - "starttime = '" & starttime & "', " & _ - "endtime = " & endtimeSQL & ", " & _ - "isactive = " & isactive & ", " & _ - "isshopfloor = " & isshopfloor & " " & _ - "WHERE notificationid = " & notificationid - -On Error Resume Next -objConn.Execute strSQL - -If Err.Number = 0 Then - objConn.Close - Response.Redirect("displaynotifications.asp") -Else - Response.Write("Error: " & Err.Description) - objConn.Close -End If -%> diff --git a/updatepc_direct.asp.backup-20251027 b/updatepc_direct.asp.backup-20251027 deleted file mode 100644 index 5ce71c7..0000000 --- a/updatepc_direct.asp.backup-20251027 +++ /dev/null @@ -1,193 +0,0 @@ - -<% - ' Get form data - Dim pcid, vendorid, modelnumberid, machinenumber - - pcid = Trim(Request.Form("pcid")) - vendorid = Trim(Request.Form("vendorid")) - modelnumberid = Trim(Request.Form("modelid")) - machinenumber = Trim(Request.Form("machinenumber")) - - ' Get form inputs for new model - Dim newmodelnumber, newvendorid - newmodelnumber = Trim(Request.Form("newpcmodelnumber")) - newvendorid = Trim(Request.Form("newpcmodelvendorid")) - - ' Get form inputs for new vendor - Dim newvendorname - newvendorname = Trim(Request.Form("newpcvendorname")) - - ' Validate required ID fields - If Not IsNumeric(pcid) Or CLng(pcid) < 1 Then - Response.Write("Invalid PC ID") - objConn.Close - Response.End - End If - - ' Verify the PC exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM pc WHERE pcid = " & CLng(pcid) - Set rsCheck = objConn.Execute(checkSQL) - If Not rsCheck.EOF Then - If CLng(rsCheck("cnt")) = 0 Then - rsCheck.Close - objConn.Close - Response.Redirect("displaypcs.asp") - Response.End - End If - End If - rsCheck.Close - - ' Validate optional ID fields - allow "new" as a valid value for model and vendor - If vendorid <> "" And vendorid <> "new" Then - If Not IsNumeric(vendorid) Or CLng(vendorid) < 1 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - End If - - If modelnumberid <> "" And modelnumberid <> "new" Then - If Not IsNumeric(modelnumberid) Or CLng(modelnumberid) < 1 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - End If - - ' Handle new vendor creation - If vendorid = "new" Then - If Len(newvendorname) = 0 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newvendorname) > 50 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Escape single quotes - Dim escapedVendorName - escapedVendorName = Replace(newvendorname, "'", "''") - - ' Insert new vendor (with ispc=1) - Dim sqlNewVendor - sqlNewVendor = "INSERT INTO vendors (vendor, isactive, isprinter, ispc, ismachine) VALUES ('" & escapedVendorName & "', 1, 0, 1, 0)" - - On Error Resume Next - objConn.Execute sqlNewVendor - - If Err.Number <> 0 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Err.Description)) - objConn.Close - Response.End - End If - - ' Get the newly created vendor ID - Dim rsNewVendor - Set rsNewVendor = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - vendorid = CLng(rsNewVendor("newid")) - rsNewVendor.Close - Set rsNewVendor = Nothing - On Error Goto 0 - End If - - ' Handle new model creation - If modelnumberid = "new" Then - If Len(newmodelnumber) = 0 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newvendorid) = 0 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - If Len(newmodelnumber) > 50 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' If vendor was also created new, use that vendor ID - If vendorid <> "" And IsNumeric(vendorid) Then - newvendorid = vendorid - End If - - ' Escape single quotes for model - Dim escapedModelNumber - escapedModelNumber = Replace(newmodelnumber, "'", "''") - - ' Insert new model - Dim sqlNewModel - sqlNewModel = "INSERT INTO models (modelnumber, vendorid, isactive) VALUES ('" & escapedModelNumber & "', " & newvendorid & ", 1)" - - On Error Resume Next - objConn.Execute sqlNewModel - - If Err.Number <> 0 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=db&msg=" & Server.URLEncode(Err.Description)) - objConn.Close - Response.End - End If - - ' Get the newly created model ID - Dim rsNewModel - Set rsNewModel = objConn.Execute("SELECT LAST_INSERT_ID() AS newid") - modelnumberid = CLng(rsNewModel("newid")) - rsNewModel.Close - Set rsNewModel = Nothing - On Error Goto 0 - End If - - ' Validate machine number length - If machinenumber <> "" And Len(machinenumber) > 50 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Escape single quotes for machine number - If machinenumber <> "" Then - machinenumber = Replace(machinenumber, "'", "''") - End If - - ' Build UPDATE statement for PC - Dim strSQL - strSQL = "UPDATE pc SET " - - ' Update model if provided - If modelnumberid <> "" And IsNumeric(modelnumberid) Then - strSQL = strSQL & "modelnumberid = " & modelnumberid & ", " - End If - - ' Update machine number - If machinenumber <> "" Then - strSQL = strSQL & "machinenumber = '" & machinenumber & "', " - Else - strSQL = strSQL & "machinenumber = NULL, " - End If - - ' Add lastupdated timestamp - strSQL = strSQL & "lastupdated = NOW() WHERE pcid = " & pcid - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number <> 0 Then - Response.Redirect("displaypc.asp?pcid=" & pcid & "&error=db") - objConn.Close - Response.End - End If - - objConn.Close - - ' Success - redirect back to displaypc - Response.Redirect("./displaypc.asp?pcid=" & pcid) -%> diff --git a/updatesubnet_direct.asp.backup-20251027 b/updatesubnet_direct.asp.backup-20251027 deleted file mode 100644 index 75d5e16..0000000 --- a/updatesubnet_direct.asp.backup-20251027 +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - -
-<% - ' Get form inputs - Dim subnetid, vlan, ipstart, cidr, description, subnettypeid, cidrarray, ipend - - subnetid = Trim(Request.Querystring("subnetid")) - vlan = Trim(Request.Form("vlan")) - ipstart = Trim(Request.Form("ipstart")) - cidr = Trim(Request.Form("cidr")) - description = Trim(Request.Form("description")) - subnettypeid = Trim(Request.Form("subnettypeid")) - - ' Validate required ID fields - If Not IsNumeric(subnetid) Or CLng(subnetid) < 1 Then - Response.Write("Invalid subnet ID") - objConn.Close - Response.End - End If - - ' Verify the subnet exists - Dim checkSQL, rsCheck - checkSQL = "SELECT COUNT(*) as cnt FROM subnets WHERE subnetid = " & subnetid - Set rsCheck = objConn.Execute(checkSQL) - - Dim subnetExists - subnetExists = False - If Not rsCheck.EOF Then - If Not IsNull(rsCheck("cnt")) Then - If CLng(rsCheck("cnt")) > 0 Then - subnetExists = True - End If - End If - End If - rsCheck.Close - Set rsCheck = Nothing - - If Not subnetExists Then - Response.Redirect("displaysubnets.asp") - objConn.Close - Response.End - End If - - ' Validate required fields - If vlan = "" Or ipstart = "" Or cidr = "" Or subnettypeid = "" Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=REQUIRED_FIELD") - objConn.Close - Response.End - End If - - ' Validate VLAN is numeric - If Not IsNumeric(vlan) Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Basic IP address validation - If Len(ipstart) < 7 Or Len(ipstart) > 15 Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_IP") - objConn.Close - Response.End - End If - - ' Validate subnet type ID - If Not IsNumeric(subnettypeid) Or CLng(subnettypeid) < 1 Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_ID") - objConn.Close - Response.End - End If - - ' Parse CIDR value (expected format: "cidr,ipend") - If InStr(cidr, ",") = 0 Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - cidrarray = Split(cidr, ",") - If UBound(cidrarray) < 1 Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ipend = Trim(cidrarray(1)) - cidr = Trim(cidrarray(0)) - - ' Remove leading slash if present (CIDR comes as "/24" format) - If Left(cidr, 1) = "/" Then - cidr = Mid(cidr, 2) - End If - - ' Validate CIDR is numeric (0-32) - If Not IsNumeric(cidr) Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - If CInt(cidr) < 0 Or CInt(cidr) > 32 Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Validate ipend is numeric - If Not IsNumeric(ipend) Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Validate description length - If Len(description) > 500 Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=INVALID_INPUT") - objConn.Close - Response.End - End If - - ' Escape quotes - description = Replace(description, "'", "''") - ipstart = Replace(ipstart, "'", "''") - - ' Verify subnet type exists - checkSQL = "SELECT COUNT(*) as cnt FROM subnettypes WHERE subnettypeid = " & subnettypeid - Set rsCheck = objConn.Execute(checkSQL) - - Dim typeExists - typeExists = False - If Not rsCheck.EOF Then - If Not IsNull(rsCheck("cnt")) Then - If CLng(rsCheck("cnt")) > 0 Then - typeExists = True - End If - End If - End If - rsCheck.Close - Set rsCheck = Nothing - - If Not typeExists Then - Response.Redirect("displaysubnet.asp?subnetid=" & subnetid & "&error=NOT_FOUND") - objConn.Close - Response.End - End If - - ' Update - Dim strSQL - strSQL = "UPDATE subnets SET vlan = " & vlan & ", ipstart = INET_ATON('" & ipstart & "'), ipend = (INET_ATON('" & ipstart & "') + " & ipend & "), cidr = '" & cidr & "', subnettypeid = " & subnettypeid & ", description = '" & description & "' WHERE subnetid = " & subnetid - - On Error Resume Next - objConn.Execute strSQL - - If Err.Number = 0 Then - objConn.Close - Response.Redirect("./displaysubnet.asp?subnetid=" & subnetid) - Else - Response.Write("Error: " & Err.Description) - objConn.Close - End If -%>