<%@ Language=VBScript %> <% Option Explicit %> <% Response.Expires = -5000 %> <% Response.Buffer = False %> <% '-------------------------------------------------------------------- ' Microsoft ADO ' ' (c) 1996 Microsoft Corporation. All Rights Reserved. ' ' ' ' ADO constants include file for VBScript ' '-------------------------------------------------------------------- '---- CursorTypeEnum Values ---- Const adOpenForwardOnly = 0 Const adOpenKeyset = 1 Const adOpenDynamic = 2 Const adOpenStatic = 3 '---- CursorOptionEnum Values ---- Const adHoldRecords = &H00000100 Const adMovePrevious = &H00000200 Const adAddNew = &H01000400 Const adDelete = &H01000800 Const adUpdate = &H01008000 Const adBookmark = &H00002000 Const adApproxPosition = &H00004000 Const adUpdateBatch = &H00010000 Const adResync = &H00020000 Const adNotify = &H00040000 '---- LockTypeEnum Values ---- Const adLockReadOnly = 1 Const adLockPessimistic = 2 Const adLockOptimistic = 3 Const adLockBatchOptimistic = 4 '---- ExecuteOptionEnum Values ---- Const adRunAsync = &H00000010 '---- ObjectStateEnum Values ---- Const adStateClosed = &H00000000 Const adStateOpen = &H00000001 Const adStateConnecting = &H00000002 Const adStateExecuting = &H00000004 '---- CursorLocationEnum Values ---- Const adUseServer = 2 Const adUseClient = 3 '---- DataTypeEnum Values ---- Const adEmpty = 0 Const adTinyInt = 16 Const adSmallInt = 2 Const adInteger = 3 Const adBigInt = 20 Const adUnsignedTinyInt = 17 Const adUnsignedSmallInt = 18 Const adUnsignedInt = 19 Const adUnsignedBigInt = 21 Const adSingle = 4 Const adDouble = 5 Const adCurrency = 6 Const adDecimal = 14 Const adNumeric = 131 Const adBoolean = 11 Const adError = 10 Const adUserDefined = 132 Const adVariant = 12 Const adIDispatch = 9 Const adIUnknown = 13 Const adGUID = 72 Const adDate = 7 Const adDBDate = 133 Const adDBTime = 134 Const adDBTimeStamp = 135 Const adBSTR = 8 Const adChar = 129 Const adVarChar = 200 Const adLongVarChar = 201 Const adWChar = 130 Const adVarWChar = 202 Const adLongVarWChar = 203 Const adBinary = 128 Const adVarBinary = 204 Const adLongVarBinary = 205 '---- FieldAttributeEnum Values ---- Const adFldMayDefer = &H00000002 Const adFldUpdatable = &H00000004 Const adFldUnknownUpdatable = &H00000008 Const adFldFixed = &H00000010 Const adFldIsNullable = &H00000020 Const adFldMayBeNull = &H00000040 Const adFldLong = &H00000080 Const adFldRowID = &H00000100 Const adFldRowVersion = &H00000200 Const adFldCacheDeferred = &H00001000 '---- EditModeEnum Values ---- Const adEditNone = &H0000 Const adEditInProgress = &H0001 Const adEditAdd = &H0002 Const adEditDelete = &H0004 '---- RecordStatusEnum Values ---- Const adRecOK = &H0000000 Const adRecNew = &H0000001 Const adRecModified = &H0000002 Const adRecDeleted = &H0000004 Const adRecUnmodified = &H0000008 Const adRecInvalid = &H0000010 Const adRecMultipleChanges = &H0000040 Const adRecPendingChanges = &H0000080 Const adRecCanceled = &H0000100 Const adRecCantRelease = &H0000400 Const adRecConcurrencyViolation = &H0000800 Const adRecIntegrityViolation = &H0001000 Const adRecMaxChangesExceeded = &H0002000 Const adRecObjectOpen = &H0004000 Const adRecOutOfMemory = &H0008000 Const adRecPermissionDenied = &H0010000 Const adRecSchemaViolation = &H0020000 Const adRecDBDeleted = &H0040000 '---- GetRowsOptionEnum Values ---- Const adGetRowsRest = -1 '---- PositionEnum Values ---- Const adPosUnknown = -1 Const adPosBOF = -2 Const adPosEOF = -3 '---- enum Values ---- Const adBookmarkCurrent = 0 Const adBookmarkFirst = 1 Const adBookmarkLast = 2 '---- MarshalOptionsEnum Values ---- Const adMarshalAll = 0 Const adMarshalModifiedOnly = 1 '---- AffectEnum Values ---- Const adAffectCurrent = 1 Const adAffectGroup = 2 Const adAffectAll = 3 '---- FilterGroupEnum Values ---- Const adFilterNone = 0 Const adFilterPendingRecords = 1 Const adFilterAffectedRecords = 2 Const adFilterFetchedRecords = 3 Const adFilterPredicate = 4 '---- SearchDirection Values ---- Const adSearchForward = 1 Const adSearchBackward = -1 '---- ConnectPromptEnum Values ---- Const adPromptAlways = 1 Const adPromptComplete = 2 Const adPromptCompleteRequired = 3 Const adPromptNever = 4 '---- ConnectModeEnum Values ---- Const adModeUnknown = 0 Const adModeRead = 1 Const adModeWrite = 2 Const adModeReadWrite = 3 Const adModeShareDenyRead = 4 Const adModeShareDenyWrite = 8 Const adModeShareExclusive = &Hc Const adModeShareDenyNone = &H10 '---- IsolationLevelEnum Values ---- Const adXactUnspecified = &Hffffffff Const adXactChaos = &H00000010 Const adXactReadUncommitted = &H00000100 Const adXactBrowse = &H00000100 Const adXactCursorStability = &H00001000 Const adXactReadCommitted = &H00001000 Const adXactRepeatableRead = &H00010000 Const adXactSerializable = &H00100000 Const adXactIsolated = &H00100000 '---- XactAttributeEnum Values ---- Const adXactCommitRetaining = &H00020000 Const adXactAbortRetaining = &H00040000 '---- PropertyAttributesEnum Values ---- Const adPropNotSupported = &H0000 Const adPropRequired = &H0001 Const adPropOptional = &H0002 Const adPropRead = &H0200 Const adPropWrite = &H0400 '---- ErrorValueEnum Values ---- Const adErrInvalidArgument = &Hbb9 Const adErrNoCurrentRecord = &Hbcd Const adErrIllegalOperation = &Hc93 Const adErrInTransaction = &Hcae Const adErrFeatureNotAvailable = &Hcb3 Const adErrItemNotFound = &Hcc1 Const adErrObjectInCollection = &Hd27 Const adErrObjectNotSet = &Hd5c Const adErrDataConversion = &Hd5d Const adErrObjectClosed = &He78 Const adErrObjectOpen = &He79 Const adErrProviderNotFound = &He7a Const adErrBoundToCommand = &He7b Const adErrInvalidParamInfo = &He7c Const adErrInvalidConnection = &He7d Const adErrStillExecuting = &He7f Const adErrStillConnecting = &He81 '---- ParameterAttributesEnum Values ---- Const adParamSigned = &H0010 Const adParamNullable = &H0040 Const adParamLong = &H0080 '---- ParameterDirectionEnum Values ---- Const adParamUnknown = &H0000 Const adParamInput = &H0001 Const adParamOutput = &H0002 Const adParamInputOutput = &H0003 Const adParamReturnValue = &H0004 '---- CommandTypeEnum Values ---- Const adCmdUnknown = &H0008 Const adCmdText = &H0001 Const adCmdTable = &H0002 Const adCmdStoredProc = &H0004 '---- SchemaEnum Values ---- Const adSchemaProviderSpecific = -1 Const adSchemaAsserts = 0 Const adSchemaCatalogs = 1 Const adSchemaCharacterSets = 2 Const adSchemaCollations = 3 Const adSchemaColumns = 4 Const adSchemaCheckConstraints = 5 Const adSchemaConstraintColumnUsage = 6 Const adSchemaConstraintTableUsage = 7 Const adSchemaKeyColumnUsage = 8 Const adSchemaReferentialContraints = 9 Const adSchemaTableConstraints = 10 Const adSchemaColumnsDomainUsage = 11 Const adSchemaIndexes = 12 Const adSchemaColumnPrivileges = 13 Const adSchemaTablePrivileges = 14 Const adSchemaUsagePrivileges = 15 Const adSchemaProcedures = 16 Const adSchemaSchemata = 17 Const adSchemaSQLLanguages = 18 Const adSchemaStatistics = 19 Const adSchemaTables = 20 Const adSchemaTranslations = 21 Const adSchemaProviderTypes = 22 Const adSchemaViews = 23 Const adSchemaViewColumnUsage = 24 Const adSchemaViewTableUsage = 25 Const adSchemaProcedureParameters = 26 Const adSchemaForeignKeys = 27 Const adSchemaPrimaryKeys = 28 Const adSchemaProcedureColumns = 29 %> <% dim Form, GuestName, Message, PostDate, PostTime, FSO, TextStream, HTML, _ HTMLarray, Section, TemplateURL, ErrorMessage, Password, Username, _ Confirm, Review, Query, Path, RootDir, ScriptURL, Conn, RS, NewUsername, _ NewPassword, RevEnCh, RevDisCh, RevMessage, Number, SQLState, OrderMes, _ RevNumber, DelHighNumber, RevHighNumber, DelSig, AddSig, RS2, NumOfRev, NumOfDel, _ InsUser, InsPass, ExpirNum, User, Pass, footerbar, titlebar, menu_bar, _ DelRevHTML, DelRevURL, DRHTML, tempdel, temprev, HomePage, SubmitStatement, _ ScriptLocal, progRel, progUpd, OS, CA OS = Request.ServerVariables("SERVER_SOFTWARE") progRel = "April, 2001" progUpd = "April, 2001" footerbar = " 2001 ASP World.Com of i2-Services, Inc." titlebar = "Guestbook v.1.0" SetupPath RootDir, ScriptURL, ScriptLocal Set Conn = Server.CreateObject("ADODB.Connection") Conn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DBQ=" & RootDir & "guestbook.mdb" Conn.Open GetForm Form GetAdminSettings Conn, RS, Review, Homepage GetLoginInfo Conn, RS, Username, Password GetExpiration RS, ExpirNum CheckExpiration Set FSO = Server.CreateObject("Scripting.FileSystemObject") InsertMenu menu_bar CA = 0 CheckQuery TemplateURL, TextStream, FSO, GuestName, Message, PostDate, PostTime, _ RootDir, ScriptURL, Conn, RS, Number, RevNumber, DelHighNumber, RevHighNumber CheckForm Form, GuestName, Message, PostDate, PostTime, ErrorMessage, TemplateURL, _ Username, Password, Confirm, RootDir, ScriptURL, Conn, RS, NewPassword, _ NewUsername, Review, RevEnCh, RevDisCh, RevMessage, Number, RevNumber, _ DelHighNumber, RevHighNumber, DelSig, AddSig, RS2 Conn.Close Set Conn = Nothing Set FSO = Nothing '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub InsertMenu (menu_bar) GetNumOfReview RS, NumOfRev, temprev GetNumOfDelete RS, NumOfDel, tempdel Set TextStream = FSO.OpenTextFile(RootDir & "_menu_bar.html", 1) menu_bar = TextStream.ReadAll menu_bar = Replace(menu_bar, "$ScriptURL$", ScriptLocal, 1, -1, 1) menu_bar = Replace(menu_bar, "$NumOfRev$", NumOfRev, 1, -1, 1) menu_bar = Replace(menu_bar, "$NumOfDel$", NumOfDel, 1, -1, 1) TextStream.Close Set TextStream = Nothing end Sub Sub AssignForm (Form, GuestName, Message, PostDate, PostTime) GuestName = Form("GuestName") Message = Form("Message") PostDate = Form("PostDate") PostTime = Form("PostTime") end Sub Sub GetExpiration (RS, ExpirNum) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , , adCmdTable ExpirNum = RS("Expires") RS.Close Set RS = Nothing end Sub Sub CheckExpiration dim arrDateSig, arrDateComp if ExpirNum > 0 then Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , adLockOptimistic, adCmdTable do while not RS.EOF arrDateSig = Split(RS("PostDate"), "/") arrDateComp = Split(Date, "/") if (arrDateComp(1) - arrDateSig(1)) > ExpirNum then RS.Delete end if RS.MoveNext loop RS.Close Set RS = Nothing end if end Sub Sub GetNumOfReview (RS, NumOfRev, temprev) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "unreviewed", Conn, , , adCmdTable temprev = 0 do while not RS.EOF if len(RS("GuestName")) then temprev = temprev + 1 end if RS.MoveNext loop NumOfRev = " (" & temprev & ")" RS.Close Set RS = Nothing end Sub Sub GetNumOfDelete (RS, NumOfDel, tempdel) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , , adCmdTable tempdel = 0 do while not RS.EOF if len(RS("GuestName")) then tempdel = tempdel + 1 end if RS.MoveNext loop NumOfDel = " (" & tempdel & ")" RS.Close Set RS = Nothing end Sub Sub UpdateUserPass (Conn, RS, NewUsername, NewPassword) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , adLockOptimistic, adCmdTable RS("Username") = NewUsername RS("Password") = NewPassword RS.Update RS.MoveFirst RS.Close Set RS = Nothing end Sub Sub UpdateRevCook (Conn, RS, Form) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , adLockOptimistic, adCmdTable RS("Review") = Form("Review") RS("Expires") = Form("Expires") RS("Homepage") = Form("Homepage") RS.Update RS.Close Set RS = Nothing end Sub Sub GetAdminSettings (Conn, RS, Review, Homepage) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , , adCmdTable Review = RS("Review") Homepage = RS("Homepage") RS.Close Set RS = Nothing end Sub Sub UpdateGuestbook (Conn, RS, GuestName, PostDate, PostTime, Message, Number) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , adLockOptimistic, adCmdTable RS.AddNew RS("GuestName") = GuestName RS("PostDate") = PostDate RS("PostTime") = PostTime RS("Message") = Message RS.Update RS.Close Set RS = Nothing end Sub Sub UpdateRevbook (Conn, RS, GuestName, PostDate, PostTime, Message, RevNumber, RevHighNumber) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "unreviewed", Conn, , adLockOptimistic, adCmdTable RS.AddNew RS("GuestName") = GuestName RS("PostDate") = PostDate RS("PostTime") = PostTime RS("Message") = Message RS.Update RS.Close Set RS = Nothing end Sub Sub GetLoginInfo (Conn, RS, Username, Password) Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , , adCmdTable Username = RS("Username") Password = RS("Password") RS.Close Set RS = Nothing End Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub SetupPath (RootDir, ScriptURL, ScriptLocal) Set Path = CreateObject("Scripting.Dictionary") Path("ScriptURL") = Request.ServerVariables("SCRIPT_NAME") Path("ScriptURL") = Mid(Path("ScriptURL"),InstrRev(Path("ScriptURL"),"/") + 1) Path("CurDir") = Request.ServerVariables("PATH_TRANSLATED") Path("CurDir") = Replace(Path("CurDir"), Path("ScriptURL"), "") ScriptLocal = Path("ScriptURL") ScriptURL = Path("CurDir") & Path("ScriptURL") RootDir = Path("CurDir") end Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub Initialize (Conn, RS, GuestName, Message, PostDate, PostTime, ErrorMessage, Confirm) GuestName = "" Message = "" PostDate = Date () PostTime = Time () ErrorMessage = "" Confirm = "" end Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub GetForm (Form) dim subName Set Form = createobject("Scripting.Dictionary") for each subName in Request.Form Form(subName) = Request.Form(subName) next end Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub CheckQuery (TemplateURL, TextStream, FSO, GuestName, Message, PostDate, PostTime, _ RootDir, ScriptURL, Conn, RS, Number, RevNumber, DelHighNumber, RevHighNumber) if Request.QueryString = "sign" then Initialize Conn, RS, GuestName, Message, PostDate, PostTime, ErrorMessage, Confirm TemplateURL = RootDir & "_sign_guestbook.html" InsertTemplate elseif Request.QueryString = "admin" then if Request.Cookies("ASPGuestbook")("Login") = "LoggedIn" then ErrorMessage = "" GetNumOfReview RS, NumOfRev, temprev GetNumOfDelete RS, NumOfDel, tempdel InsertMenu menu_bar InsertAdmin DRHTML TemplateURL = RootDir & "_admin_main.html" InsertTemplate else GetLoginInfo Conn, RS, Username, Password TemplateURL = RootDir & "_admin_login.html" InsertTemplate end if elseif Request.QueryString = "update" and Request.Cookies("ASPGuestbook")("Login") = "LoggedIn" then Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , , adCmdTable User = RS("Username") Pass = RS("Password") RS.Close Set RS = Nothing GetAdminSettings Conn, RS, Review, Homepage if Review = "Enabled" then RevEnCh = "checked" RevDisCh = "" RevMessage = "* Review Guestbook Postings" else RevDisCh = "checked" RevEnCh = "" RevMessage = "* Review Guestbook Postings Disabled" end if GetExpiration RS, ExpirNum InsertMenu menu_bar TemplateURL = RootDir & "_update_admin.html" InsertTemplate elseif Request.QueryString = "view" then SQLState = "SELECT Num, GuestName, PostDate, PostTime, Message FROM guestbook ORDER BY Num DESC" OrderMes = "Sort By:    Newest | Oldest | Guest Name" ViewGuestbook Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, SQLState, OrderMes, RevNumber elseif Request.QueryString = "review" and Request.Cookies("ASPGuestbook")("Login") = "LoggedIn" then GetNumOfReview RS, NumOfRev, temprev if temprev = 0 then ErrorMessage = "
There are no messages to be reviewed.

" else ErrorMessage = "" end if ReviewGuestbook Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, RevNumber, RevHighNumber elseif Request.QueryString = "delete" and Request.Cookies("ASPGuestbook")("Login") = "LoggedIn" then GetNumOfDelete RS, NumOfDel, tempdel if tempdel = 0 then ErrorMessage = "
There are no messages to be deleted.

" else ErrorMessage = "" end if DeleteGuestbook Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, RevNumber, DelHighNumber elseif Request.QueryString = "view&sortby=guestname" then SQLState = "SELECT Num, GuestName, PostDate, PostTime, Message FROM guestbook ORDER BY GuestName ASC" OrderMes = "Sort By:    Newest | Oldest | Guest Name" ViewGuestbook Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, SQLState, OrderMes, RevNumber elseif Request.QueryString = "view&sortby=time" then SQLState = "SELECT Num, GuestName, PostDate, PostTime, Message FROM guestbook ORDER BY PostTime ASC" OrderMes = "Sort By:    Newest First | Oldest | Guest Name" ViewGuestbook Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, SQLState, OrderMes, RevNumber elseif Request.QueryString = "logoff" and Request.Cookies("ASPGuestbook")("Login") = "LoggedIn" then Response.Cookies("ASPGuestbook")("Login") = "LoggedOut" Response.Redirect HomePage elseif Request.QueryString = "logoff" and Request.Cookies("ASPGuestbook")("Login") <> "LoggedIn" then Response.Redirect HomePage elseif Request.QueryString = "about" then TemplateURL = RootDir & "_about.html" InsertTemplate else CA = 1 end if end Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub ReviewGuestbook (Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, RevNumber, RevHighNumber) RevHighNumber = 0 DRHTML = "" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "unreviewed", Conn, , , adCmdTable Do While Not RS.EOF RevNumber = RS("Num") GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") if RevNumber > RevHighNumber then RevHighNumber = RevNumber end if DelRevURL = RootDir & "_rev_mid.html" InsertDelRev DelRevHTML DRHTML = DRHTML & DelRevHTML RS.MoveNext Loop RS.Close Set RS = Nothing Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , adLockOptimistic, adCmdTable RS("RevHighNum") = RevHighNumber RS.Update RS.Close Set RS = Nothing if RevHighNumber = 0 then SubmitStatement = "" else SubmitStatement = "  " end if InsertMenu menu_bar TemplateURL = RootDir & "_rev_main.html" InsertTemplate End Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub DeleteGuestbook (Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, RevNumber, DelHighNumber) DelHighNumber = 0 DRHTML = "" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , , adCmdTable Do While Not RS.EOF Number = RS("Num") GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") if Number > DelHighNumber then DelHighNumber = Number end if DelRevURL = RootDir & "_del_mid.html" InsertDelRev DelRevHTML DRHTML = DRHTML & DelRevHTML RS.MoveNext Loop RS.Close Set RS = Nothing Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , adLockOptimistic, adCmdTable RS("DelHighNum") = DelHighNumber RS.Update RS.Close Set RS = Nothing if DelHighNumber = 0 then SubmitStatement = "" else SubmitStatement = "  " end if InsertMenu menu_bar TemplateURL = RootDir & "_del_main.html" InsertTemplate End Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub ViewGuestbook (Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, SQLState, OrderMes, RevNumber) TemplateURL = RootDir & "_view_begin.html" InsertTemplate Set RS = Server.CreateObject("ADODB.Recordset") RS.Open SQLState, Conn Do While Not RS.EOF GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") TemplateURL = RootDir & "_view_mid.html" InsertTemplate RS.MoveNext Loop RS.Close Set RS = Nothing GetAdminSettings Conn, RS, Review, Homepage TemplateURL = RootDir & "_view_end.html" InsertTemplate End Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub CheckForm (Form, GuestName, Message, PostDate, PostTime, ErrorMessage, TemplateURL, _ Username, Password, Confirm, RootDir, ScriptURL, Conn, RS, NewPassword, _ NewUsername, Review, RevEnCh, RevDisCh, RevMessage, Number, RevNumber, _ DelHighNumber, RevHighNumber, DelSig, AddSig, RS2) AssignForm Form, GuestName, Message, PostDate, PostTime if Form("GuestName") = "" AND Form("Message") = "" AND len(Form("PostDate")) AND _ Form("Submit") = "Sign Guestbook" then ErrorMessage = "
ERROR: Name and Message may not be left blank
" TemplateURL = RootDir & "_sign_guestbook.html" InsertTemplate response.end elseif Form("GuestName") = "" AND Form("Message") <> "" AND len(Form("PostDate")) AND _ Form("Submit") = "Sign Guestbook" then ErrorMessage = "
ERROR: Name may not be left blank
" TemplateURL = RootDir & "_sign_guestbook.html" InsertTemplate response.end elseif Form("GuestName") <> "" AND Form("Message") = "" AND len(Form("PostDate")) AND _ Form("Submit") = "Sign Guestbook" then ErrorMessage = "
ERROR: Message may not be left blank.
" TemplateURL = RootDir & "_sign_guestbook.html" InsertTemplate response.end elseif Form("GuestName") <> "" AND Form("Message") <> "" AND len(Form("PostDate")) AND _ Form("Submit") = "Sign Guestbook" then TemplateURL = RootDir & "_user_review.html" InsertTemplate elseif Form("UserConfirm") = "Post" then if Review = "Enabled" then UpdateRevbook Conn, RS, GuestName, PostDate, PostTime, Message, RevNumber, RevHighNumber RevMessage = "Your message has been sent to the administrator for review.

" else UpdateGuestbook Conn, RS, GuestName, PostDate, PostTime, Message, Number RevMessage = "" end if TemplateURL = RootDir & "_thank_you.html" InsertTemplate elseif Form("UserConfirm") = "Revise" then TemplateURL = RootDir & "_sign_guestbook.html" InsertTemplate elseif Form("Username") = Username AND Form("Password") = Password then Response.Cookies("ASPGuestbook")("Login") = "LoggedIn" GetAdminSettings Conn, RS, Review, Homepage if Review = "Enabled" then RevEnCh = "checked" RevDisCh = "" RevMessage = "* Review Guestbook Postings" else RevDisCh = "checked" RevEnCh = "" RevMessage = "* Review Guestbook Postings Disabled" end if ErrorMessage = "" GetNumOfReview RS, NumOfRev, temprev GetNumOfDelete RS, NumOfDel, tempdel InsertMenu menu_bar InsertAdmin DRHTML TemplateURL = RootDir & "_admin_main.html" InsertTemplate elseif Form("Submit") = "Login" AND (Form("Username") <> Username OR Form("Password") <> Password) then ErrorMessage = "Invalid" TemplateURL = RootDir & "_admin_login.html" InsertTemplate elseif Form("Submit") = "Cancel" then Response.Redirect HomePage elseif Form("Submit") = "Update Info" then NewUsername = Form("NewUsername") NewPassword = Form("NewPassword") UpdateUserPass Conn, RS, NewUsername, NewPassword elseif Form("Review") = "Enabled" OR Form("Review") = "Disabled"then ErrorMessage = "Settings have been updated!
" UpdateRevCook Conn, RS, Form GetAdminSettings Conn, RS, Review, Homepage if Form("Review") = "Enabled" then RevEnCh = "checked" RevDisCh = "" RevMessage = "* Review Guestbook Postings" else RevDisCh = "checked" RevEnCh = "" RevMessage = "* Review Guestbook Postings Disabled" end if if len(Form("NewUsername")) AND len(Form("NewPassword")) then NewUsername = Form("NewUsername") NewPassword = Form("NewPassword") UpdateUserPass Conn, RS, NewUsername, NewPassword end if GetNumOfReview RS, NumOfRev, temprev GetNumOfDelete RS, NumOfDel, tempdel GetExpiration RS, ExpirNum InsertMenu menu_bar TemplateURL = RootDir & "_update_admin.html" InsertTemplate elseif Form("Submit") = "Update" then DRHTML = "" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , , adCmdTable RevHighNumber = RS("RevHighNum") RS.Close Set RS = Nothing Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "unreviewed", Conn, , , adCmdTable dim Counter Counter = 1 if not RS.EOF then Counter = RS("Num") end if if not RS.BOF then RS.MoveFirst end if do while Counter <= RevHighNumber and not RS.EOF if Form("Rev" & Counter) = "Delete" OR Form("Rev" & Counter) = "Post" then dim ExitNum ExitNum = 0 if Form("Rev" & Counter) = "Delete" then DelSig = "checked" AddSig = "" else AddSig = "checked" DelSig = "" end if do while ExitNum = 0 AND NOT RS.EOF if RS("Num") = Counter then RevNumber = RS("Num") GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") DelRevURL = RootDir & "_rev_conf_mid.html" InsertDelRev DelRevHTML DRHTML = DRHTML & DelRevHTML ExitNum = 1 else RS.MoveNext end if loop end if Counter = Counter + 1 loop RS.Close Set RS = Nothing InsertMenu menu_bar TemplateURL = RootDir & "_rev_conf_main.html" InsertTemplate elseif Form("Submit") = "Confirm Update" then Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "unreviewed", Conn, adOpenStatic, adLockOptimistic, adCmdTable Set RS2 = Server.CreateObject("ADODB.Recordset") RS2.Open "guestbook", Conn, , adLockOptimistic, adCmdTable RevHighNumber = 0 Do while not RS.EOF if len(RS("GuestName")) then RevNumber = RS("Num") if RevNumber > RevHighNumber then RevHighNumber = RevNumber end if RS.MoveNext end if Loop if not RS.BOF then RS.MoveFirst end if DelHighNumber = 0 Do While Not RS2.EOF Number = RS2("Num") if Number > DelHighNumber then DelHighNumber = Number end if RS2.MoveNext Loop DelHighNumber = DelHighNumber + 1 dim RevConfNum Counter = 1 if not RS.EOF then Counter = RS("Num") end if do while Counter <= RevHighNumber and not RS.EOF RS.MoveFirst if len(Form("Rev" & Counter)) then ExitNum = 0 RS.MoveFirst if Form("Rev" & Counter) = "Delete" then do while ExitNum = 0 and not RS.EOF if RS("Num") = Counter then RS.Delete ExitNum = 1 RevConfNum = 1 else RS.MoveNext end if loop elseif Form("Rev" & Counter) = "Post" then do while ExitNum = 0 and not RS.EOF if RS("Num") = Counter then RS.MovePrevious RS.MoveNext GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") RS.Delete ExitNum = 1 RevConfNum = 1 PostDate = Date() PostTime = Time() RS2.AddNew RS2("GuestName") = GuestName RS2("PostDate") = PostDate RS2("PostTime") = PostTime RS2("Message") = Message RS2.Update else RS.MoveNext end if loop DelHighNumber = DelHighNumber + 1 end if end if Counter = Counter + 1 loop RS.Close Set RS = Nothing RS2.Close Set RS2 = Nothing if RevConfNum = 1 then ErrorMessage = "
Selected updates were made!
" else ErrorMessage = "
No updates were made!
" end if GetAdminSettings Conn, RS, Review, Homepage if Review = "Enabled" then RevEnCh = "checked" RevDisCh = "" RevMessage = "* Review Guestbook Postings" else RevDisCh = "checked" RevEnCh = "" RevMessage = "* Review Guestbook Postings Disabled" end if GetNumOfReview RS, NumOfRev, temprev GetNumOfDelete RS, NumOfDel, tempdel InsertMenu menu_bar InsertAdmin DRHTML TemplateURL = RootDir & "_admin_main.html" InsertTemplate elseif Form("Submit") = "Confirm Delete" then Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , adLockOptimistic, adCmdTable DelHighNumber = 0 Do While Not RS.EOF if len(RS("GuestName")) then Number = RS("Num") if Number > DelHighNumber then DelHighNumber = Number end if RS.MoveNext end if Loop DelHighNumber = DelHighNumber RS.Close RS.Open "guestbook", Conn, adOpenStatic, adLockOptimistic, adCmdTable dim DelConfNum Counter = 1 if not RS.EOF then Counter = RS("Num") end if if not RS.BOF then RS.MoveFirst end if do while Counter <= DelHighNumber and not RS.EOF if len(Form("Del" & Counter)) then ExitNum = 0 if Form("Del" & Counter) = "Yes" then RS.MoveFirst do while ExitNum = 0 and not RS.EOF if RS("Num") = Counter then RS.MovePrevious RS.MoveNext RS.Delete ExitNum = 1 DelConfNum = 1 else RS.MoveNext end if loop end if end if Counter = Counter + 1 loop RS.Close Set RS = Nothing GetAdminSettings Conn, RS, Review, Homepage if DelConfNum = 1 then ErrorMessage = "
Selected postings have been deleted!
" else ErrorMessage = "
No postings have been deleted!
" end if if Review = "Enabled" then RevEnCh = "checked" RevDisCh = "" RevMessage = "* Review Guestbook Postings" else RevDisCh = "checked" RevEnCh = "" RevMessage = "* Review Guestbook Postings Disabled" end if GetNumOfReview RS, NumOfRev, temprev GetNumOfDelete RS, NumOfDel, temprev InsertMenu menu_bar InsertAdmin DRHTML TemplateURL = RootDir & "_admin_main.html" InsertTemplate elseif Form("Submit") = "Delete" then DRHTML = "" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "admininfo", Conn, , , adCmdTable DelHighNumber = RS("DelHighNum") RS.Close Set RS = Nothing Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , , adCmdTable Counter = 1 if not RS.EOF then Counter = RS("Num") end if if not RS.BOF then RS.MoveFirst end if do while Counter <= DelHighNumber and not RS.EOF if len(Form("Del" & Counter)) then ExitNum = 0 do while ExitNum = 0 and not RS.EOF if RS("Num") = Counter then Number = RS("Num") GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") DelRevURL = RootDir & "_del_conf_mid.html" InsertDelRev DelRevHTML DRHTML = DRHTML & DelRevHTML ExitNum = 1 else RS.MoveNext end if loop end if Counter = Counter + 1 loop RS.Close Set RS = Nothing InsertMenu menu_bar TemplateURL = RootDir & "_del_conf_main.html" InsertTemplate elseif CA = 1 then SQLState = "SELECT Num, GuestName, PostDate, PostTime, Message FROM guestbook ORDER BY Num DESC" OrderMes = "Sort By:    Newest | Oldest | Guest Name" ViewGuestbook Conn, RS, TemplateURL, GuestName, Message, PostDate, PostTime, _ ErrorMessage, Number, SQLState, OrderMes, RevNumber end if end Sub '----------------------------------------------------------------------------------------- ' '----------------------------------------------------------------------------------------- Sub InsertAdmin (DRHTML) DRHTML = "" Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "guestbook", Conn, , , adCmdTable Do While Not RS.EOF Number = RS("Num") GuestName = RS("GuestName") PostDate = RS("PostDate") PostTime = RS("PostTime") Message = RS("Message") DelRevURL = RootDir & "_view_mid.html" InsertDelRev DelRevHTML DRHTML = DRHTML & DelRevHTML RS.MoveNext Loop RS.Close Set RS = Nothing if tempdel = 0 then ErrorMessage = "There no messages in the guestbook at this time." end if end Sub Sub InsertDelRev (DelRevHTML) Set TextStream = FSO.OpenTextFile(DelRevURL, 1) DelRevHTML = TextStream.ReadAll DelRevHTML = Replace(DelRevHTML, "$Number$", Number, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$RevNumber$", RevNumber, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$GuestName$", GuestName, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$PostDate$", PostDate, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$PostTime$", PostTime, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$Message$", Message, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$ErrorMessage$", ErrorMessage, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$DelSig$", DelSig, 1, -1, 1) DelRevHTML = Replace(DelRevHTML, "$AddSig$", AddSig, 1, -1, 1) TextStream.Close Set TextStream = Nothing end Sub Sub InsertTemplate Set TextStream = FSO.OpenTextFile(TemplateURL, 1) HTML = TextStream.ReadAll HTMLarray = Split(HTML, "$") for each Section in HTMLarray if Section = "GuestName" then Response.Write(GuestName) elseif Section = "PostDate" then Response.Write(PostDate) elseif Section = "PostTime" then Response.Write(PostTime) elseif Section = "Message" then Response.Write(Message) elseif Section = "ErrorMessage" then Response.Write(ErrorMessage) elseif Section = "RevEnCh" then Response.Write RevEnCh elseif Section = "RevDisCh" then Response.Write RevDisCh elseif Section = "RevMessage" then Response.Write RevMessage elseif Section = "Number" then Response.Write Number elseif Section = "Order" then Response.Write OrderMes elseif Section = "RevNumber" then Response.Write RevNumber elseif Section = "DelSig" then Response.Write DelSig elseif Section = "AddSig" then Response.Write AddSig elseif Section = "NumOfRev" then Response.Write NumOfRev elseif Section = "NumOfDel" then Response.Write NumOfDel elseif Section = "Username" then Response.Write InsUser elseif Section = "Password" then Response.Write InsPass elseif Section = "ExpirNum" then Response.Write ExpirNum elseif Section = "User" then Response.Write User elseif Section = "Pass" then Response.Write Pass elseif Section = "RootDir" then Response.Write RootDir elseif Section = "ScriptURL" then Response.Write ScriptURL elseif Section = "titlebar" then Response.Write titlebar elseif Section = "footerbar" then Response.Write footerbar elseif Section = "menu_bar" then Response.Write menu_bar elseif Section = "DRHTML" then Response.Write DRHTML elseif Section = "Homepage" then Response.Write Homepage elseif Section = "SubmitStatement" then Response.Write SubmitStatement elseif Section = "progRel" then Response.Write progRel elseif Section = "progUpd" then Response.Write progUpd else Response.Write Section end if next TextStream.Close Set TextStream = Nothing end Sub %>