Rhydd Activity Tracking System Create a Site/Activity/Equipment |
%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% ' *** Restrict Access To Page: Grant or deny access to this page MM_authorizedUsers="userEdit,webmaster" MM_authFailedURL="/Bookings/Secure/sorryAccess.asp" MM_grantAccess=false If Session("MM_Username") <> "" Then If (false Or CStr(Session("MM_UserAuthorization"))="") Or _ (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then MM_grantAccess = true End If End If If Not MM_grantAccess Then MM_qsChar = "?" If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&" MM_referrer = Request.ServerVariables("URL") if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString() MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer) Response.Redirect(MM_authFailedURL) End If %> <% Dim MM_editAction MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")) If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString) End If ' boolean to abort record edit Dim MM_abortEdit MM_abortEdit = false %> <% ' *** Redirect if username exists MM_flag = "MM_insert" If (CStr(Request(MM_flag)) <> "") Then Dim MM_rsKey Dim MM_rsKey_cmd MM_dupKeyRedirect = "/Bookings/existsUnit.asp" MM_dupKeyUsernameValue = CStr(Request.Form("Uname")) Set MM_rsKey_cmd = Server.CreateObject ("ADODB.Command") MM_rsKey_cmd.ActiveConnection = MM_trevs_STRING MM_rsKey_cmd.CommandText = "SELECT Uname FROM Units WHERE Uname = ?" MM_rsKey_cmd.Prepared = true MM_rsKey_cmd.Parameters.Append MM_rsKey_cmd.CreateParameter("param1", 200, 1, 63, MM_dupKeyUsernameValue) ' adVarChar Set MM_rsKey = MM_rsKey_cmd.Execute If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then ' the username was found - can not add the requested username MM_qsChar = "?" If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&" MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue Response.Redirect(MM_dupKeyRedirect) End If MM_rsKey.Close End If %> <% ' IIf implementation Function MM_IIf(condition, ifTrue, ifFalse) If condition = "" Then MM_IIf = ifFalse Else MM_IIf = ifTrue End If End Function %> <% If (CStr(Request("MM_insert")) = "form1") Then If (Not MM_abortEdit) Then ' execute the insert Dim MM_editCmd Set MM_editCmd = Server.CreateObject ("ADODB.Command") MM_editCmd.ActiveConnection = MM_trevs_STRING MM_editCmd.CommandText = "INSERT INTO Units (Uname, Udetail, UType, UpermitNeeded, UpermitType, Unote) VALUES (?, ?, ?, ?, ?, ?)" MM_editCmd.Prepared = true MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 63, Request.Form("Uname")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("Udetail")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 63, Request.Form("UType")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 5, 1, -1, MM_IIF(Request.Form("UpermitNeeded"), 1, 0)) ' adDouble MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("UpermitType")) ' adVarWChar MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("Unote")) ' adVarWChar MM_editCmd.Execute MM_editCmd.ActiveConnection.Close ' append the query string to the redirect URL Dim MM_editRedirectUrl MM_editRedirectUrl = "/Bookings/selectUnit.asp" If (Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If Response.Redirect(MM_editRedirectUrl) End If End If %> <% Dim Unit Dim Unit_cmd Dim Unit_numRows Set Unit_cmd = Server.CreateObject ("ADODB.Command") Unit_cmd.ActiveConnection = MM_trevs_STRING Unit_cmd.CommandText = "SELECT * FROM Units" Unit_cmd.Prepared = true Set Unit = Unit_cmd.Execute Unit_numRows = 0 %>