<% '----------General section------------ CURRENT_VERSION = ("0") CURRENT_STYLE = ("../Default_Style.css") FormAction = ("Guest_Book.asp") ScriptRelativeFolder = ("CGI_BIN") pos=InstrRev(LCase(Request.ServerVariables("PATH_TRANSLATED")),LCase(ScriptRelativeFolder) & "\" & LCase(FormAction)) BS_Root = Left(Request.ServerVariables("PATH_TRANSLATED"), pos-1 ) DB_Path =BS_Root & "\" ScriptFolderAddress =BS_Root & "\" & ScriptRelativeFolder & "\" URL =Request.ServerVariables("URL") SERVER_NAME=Request.ServerVariables("SERVER_NAME") ScriptAbsoluteUrl="http://"&SERVER_NAME&URL ScriptRelativeFolder = ("CGI_BIN") pos=InstrRev(LCase(ScriptAbsoluteUrl),LCase(ScriptRelativeFolder) & "/" & LCase(FormAction)) BS_Root_URL = Left(ScriptAbsoluteUrl, pos-1) CurrentFolder = BS_Root_URL &ScriptRelativeFolder& "/" bHeaderFired = FALSE 'Enumeration Of Shipping Payment Methods '==========Enumeration Of Payment Methods============= FRSC = 1 'Flat rate shipping cost CPI = 2 'Cost per item FRPW = 3 'Fixed rate per weight (Kg or lb.) POFS = 4 'Percentage of sales '==========Constants============= '---- CursorTypeEnum Values ---- Const adOpenForwardOnly = 0 Const adOpenKeyset = 1 Const adOpenDynamic = 2 Const adOpenStatic = 3 '---- LockTypeEnum Values ---- Const adLockReadOnly = 1 Const adLockPessimistic = 2 Const adLockOptimistic = 3 Const adLockBatchOptimistic = 4 '=========End of Section=========== '----------Parameters section------------ Parameter_1 = Request("GuestName") if Request("GuestName")= "" Then Parameter_1 = "" 'Default value else if Request("GuestName").Count = 1 then Parameter_1 = Request("GuestName") end if end if Parameter_2 = Request("GuestEmail") if Request("GuestEmail")= "" Then Parameter_2 = "" 'Default value else if Request("GuestEmail").Count = 1 then Parameter_2 = Request("GuestEmail") end if end if Parameter_3 = Request("GuestComments") if Request("GuestComments")= "" Then Parameter_3 = "" 'Default value else if Request("GuestComments").Count = 1 then Parameter_3 = Request("GuestComments") end if end if '----------Variables section------------ Dim VarArray(0,0) VarNum = 1 'Initialization of Vars Variable_4 = "mailto:" 'Initial value 'Subroutins and functions Sub PushVars() VarArray(0,0)=Variable_4 end sub Sub PopVars() end sub Sub RestoreVars() Variable_4=VarArray(0,0) end sub 'Functions that in the future should be placed in stanalone .INC File 'Function to format date string Function format_date(date,dataformat) months =Array("January","February","March","April","May","June","July","August","September","October","November","December") mon = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") 'dd-MMM-yyyy = 0 'MM/dd/yyyy = 1 'dd MMMM,yyyy = 2 'MMMM dd,yyyy = 3 daypart = Day(date) monthpart = Month(date) yearpart = Year(date) monthpart = monthpart -1 if(dataformat = 0) then format_date = daypart & " " & mon(monthpart) & "," & yearpart end if if(dataformat = 1) then format_date = monthpart & "-" & daypart & "-" & yearpart end if if(dataformat = 2) then format_date = daypart & " " & months(monthpart) & "," & yearpart end if if(dataformat = 3) then format_date = months(monthpart) & " " & daypart & "," & yearpart end if end Function 'Function to format time string Function format_time(date,dataformat) hourpart = Hour(date) minutepart = Minute(date) secondpart = Second(date) format_time = hourpart & ":" & minutepart & ":" & secondpart end Function Function L_HTMLEncode(stringToEncode) if IsNull(stringToEncode) OR IsEmpty(stringToEncode) then L_HTMLEncode = stringToEncode else L_HTMLEncode = Server.HTMLEncode(stringToEncode) end if end Function Function GetPhisicalPath(string_to_transform) pos=InstrRev(LCase(Request.ServerVariables("PATH_TRANSLATED")),LCase(FormAction)) GetPhisicalPath = Left(Request.ServerVariables("PATH_TRANSLATED"), pos-1 )&string_to_transform end Function Function escape_symbols(string_to_escape) if IsNull(string_to_escape) OR IsEmpty(string_to_escape) then string_to_escape_ret = string_to_escape else string_to_escape_ret=Replace(string_to_escape,"'","''") end if escape_symbols=string_to_escape_ret end Function '----------Start Algorithm section------------ %> <%if (bHeaderFired = FALSE) then%> Guest Book <% bHeaderFired = TRUE end if %> <%Call PushVars()%>

 

 

<%Call PopVars()%> <%if (bHeaderFired = FALSE) then%> Guest Book <% bHeaderFired = TRUE end if %> <%Call PushVars()%>

 

<%Call PopVars()%> <%if(Parameter_1 <> "") Then%> <% '==============Query_1("GuestBook")================ DataSource3 = "Driver={Microsoft Access Driver (*.mdb)}; DBQ= "& DB_Path &"GuestBook.mdb;" PageSize3 = 1 Parameter_1_A=escape_symbols(Parameter_1) Parameter_2_A=escape_symbols(Parameter_2) Parameter_3_A=escape_symbols(Parameter_3) GeneratedSQL= "INSERT INTO [Guests]([Name],[Email],[Comments])"_ &" VALUES ('"&Parameter_1_A&"','"&Parameter_2_A&"','"&Parameter_3_A&"')" %> <%'===============Execute Query And Get Total Count======================== Set Conn3 = Server.CreateObject("ADODB.Connection") Set RS3 = Server.CreateObject("ADODB.RecordSet") RS3.CursorType = adOpenStatic Conn3.Open DataSource3 if Conn3.State = 0 Then Response.Write "Database connection Error: "&DataSource3 Response.End end if RS3.Open GeneratedSQL,Conn3,adOpenKeyset,adLockReadOnly 'both keys are to be variables if Err.Number <> 0 Then Response.Write "Open Recordset Error:
"&GeneratedSQL Response.End end if %><% Conn3.Close set rs3 = nothing set Conn3 = nothing %> <%else%> <%end if%><% '==============Query_2("GuestBook")================ DataSource1 = "Driver={Microsoft Access Driver (*.mdb)}; DBQ= "& DB_Path &"GuestBook.mdb;" PageSize1 = 1 GeneratedSQL= "SELECT[Guests].[Comments] as QueryOutput_6,[Guests].[Email] as QueryOutput_7,[Guests].[Name] as QueryOutput_8"_ &" FROM [Guests]" %> <%'===============Execute Query And Get Total Count======================== Set Conn1 = Server.CreateObject("ADODB.Connection") Set RS1 = Server.CreateObject("ADODB.RecordSet") RS1.CursorType = adOpenStatic Conn1.Open DataSource1 if Conn1.State = 0 Then Response.Write "Database connection Error: "&DataSource1 Response.End end if RS1.Open GeneratedSQL,Conn1,adOpenKeyset,adLockReadOnly 'both keys are to be variables if Err.Number <> 0 Then Response.Write "Open Recordset Error:
"&GeneratedSQL Response.End end if TotalCount1=RS1.RecordCount if(TotalCount1 > 0) then RS1.PageSize = TotalCount1 'All records PageSize1 = TotalCount1 'All records end if ScrollAction = Request("_NavAction1") if ScrollAction <> "" Then PageNo1 = mid(ScrollAction, 5) if PageNo1 < 1 Then PageNo1 = 1 end if else PageNo1 = 1 end if 'set the page number on which the current record is located. if(TotalCount1 <> 0) then RS1.AbsolutePage = PageNo1 'Page Number end if FromRec1=(PageNo1-1)*PageSize1 +1 if PageNo1*PageSize1 > TotalCount1 Then ToRec1 = TotalCount1 else ToRec1 = PageNo1*PageSize1 end if URLTail1 = "&GuestName="& Parameter_1 &"&GuestEmail="& Parameter_2 &"&GuestComments="& Parameter_3 FNavAhead1 = "Next" FNavBack1 = "Previous" FLinkAhead1 = FormAction & "?_NavAction1=Page" & (PageNo1+1)& URLTail1 FLinkBack1 = FormAction & "?_NavAction1=Page" & (PageNo1-1)& URLTail1 %><%if (bHeaderFired = FALSE) then%> Guest Book <% bHeaderFired = TRUE end if %> <%Call PushVars()%>

 

<% end if %>