<%@ Language=VBScript %> <% Option Explicit %> <% Response.Buffer = True %> <% Dim gstrDatabaseType, gstrConnectToDatabase, gstrNewsDatabaseTemplatePage, gstrNewsDatabaseVirtualAddress, gstrNewsPostingPassword, gstrNewsAdminPassword %> <% '******************************************** '* News Database By Smo * '* Print File * '* (c) 2001 By Tim Smulders * '* Version 3 * '* http://www.iamsmo.com * '******************************************** 'Dims Dim objConn, gstrElsid, gstrComments, gstrFFType, gintFontSize, gstrDateAndTimeFormat Response.Write "Article Print" gstrElsid = Session.LCID Select Case Request.QueryString("pcmd") Case "previewarticleprint" previewarticleprint Case "adminpreviewcommentprint" adminpreviewcommentprint Case "previewcommentprint" previewcommentprint Case "adminarticleprint" adminarticleprint Case "articleprint" articleprint Case "admincommentprint" admincommentprint Case "commentprint" commentprint Case Else Response.Write "Please use the form when accessing this page!" End Select Response.Write "" '******************************************************************* '* Subroutines below... * '******************************************************************* '******************************************************************* '* Subroutines to print preview article. * '******************************************************************* Sub previewarticleprint Response.Write "" & Session("ArticleHeadline") & "
" If Session("ArticleActive") = "OnThisDate" Then Response.Write "[ " & Session("ArticleMonth") & "/" & Session("ArticleDay") & "/" & Session("ArticleYear") & " " & Session("ArticleHour") & ":00:00 " & Session("ArticleAMPM") & " ]" Else Response.Write "[ " & Session("ArticleDateAndTime") & " ]" End If Response.Write "  By " & Session("ArticleAuthor") & "  " & Session("ArticleAuthorEmail") & "

" Response.Write Replace(Session("ArticleLeadIn"), vbCrLf, "
") If Session("ArticleFull") <> "" Then Response.Write "

" Response.Write Replace(Session("ArticleFull"), vbCrLf, "
") End If End Sub '******************************************************************* '* Subroutines to print admin preview comment. * '******************************************************************* Sub adminpreviewcommentprint Response.Write "" & Session("AdminAddArticleCommentHeading") & "
[ " & Session("AdminAddCommentDateAndTime") & " ]  By " & Session("AdminAddCommentAuthor") & "  " & Session("AdminAddCommentAuthorEmail") & "

" Response.Write Replace(Session("AdminAddArticleComment"), vbCrLf, "
") End Sub '******************************************************************* '* Subroutines to print preview comment. * '******************************************************************* Sub previewcommentprint printgetoptions Response.Write "" & Session("AddArticleCommentHeading") & "
[ " & FormatDateAndTime(Session("AddCommentDateAndTime")) & " ]  By " & Session("AddCommentAuthor") & "  " & Session("AddCommentAuthorEmail") & "

" Response.Write "" & Replace(Session("AddArticleComment"), vbCrLf, "
") & "
" End Sub '******************************************************************* '* Subroutines to admin print article. * '******************************************************************* Sub adminarticleprint checkadmin Dim intAdminPrintArticleId, strArticleLeadInAdminPrintArticle, strArticleFullAdminPrintArticle intAdminPrintArticleId = Request.QueryString("articleid") If NOT IsNumeric(intAdminPrintArticleId) Then Response.Write "Please use the form when accessing this page!" Exit Sub Else intAdminPrintArticleId = Cint(intAdminPrintArticleId) End If 'Create The SQL Dim strSQLAdminPrintArticle strSQLAdminPrintArticle = "SELECT ArticleId, ArticleAuthor, ArticleAuthorEmail, ArticleDateAndTime, ArticleHeadline, ArticleLeadIn, ArticleFull FROM tblNewsDatabaseBySmo WHERE ArticleId = " & intAdminPrintArticleId & ";" 'Open Connection openconn 'Open Recordset Dim objAdminPrintArticle Set objAdminPrintArticle = Server.CreateObject("ADODB.Recordset") objAdminPrintArticle.Open strSQLAdminPrintArticle, objConn, 0, 1 If objAdminPrintArticle.EOF Then Response.Write "Please use the form when accessing this page!" 'Close Recordset objAdminPrintArticle.Close Set objAdminPrintArticle = Nothing 'Close Connection closeconn Exit Sub Else strArticleLeadInAdminPrintArticle = objAdminPrintArticle("ArticleLeadIn") strArticleFullAdminPrintArticle = objAdminPrintArticle("ArticleFull") Response.Write "" & objAdminPrintArticle("ArticleHeadline") & "
[ " & objAdminPrintArticle("ArticleDateAndTime") & " ]  By " & objAdminPrintArticle("ArticleAuthor") & "  " & objAdminPrintArticle("ArticleAuthorEmail") & "

" Response.Write Replace(strArticleLeadInAdminPrintArticle, vbCrLf, "
") If strArticleFullAdminPrintArticle <> "" Then Response.Write "

" Response.Write Replace(strArticleFullAdminPrintArticle, vbCrLf, "
") End If 'Close Recordset objAdminPrintArticle.Close Set objAdminPrintArticle = Nothing 'Close Connection closeconn End If End Sub '******************************************************************* '* Subroutines to print article. * '******************************************************************* Sub articleprint printgetoptions Dim intPrintArticleId, strArticleLeadInPrintArticle, strArticleFullPrintArticle intPrintArticleId = Request.QueryString("articleid") If NOT IsNumeric(intPrintArticleId) Then Response.Write "Please use the form when accessing this page!" Exit Sub Else intPrintArticleId = Cint(intPrintArticleId) End If 'Create The SQL Dim strSQLPrintArticle Select Case gstrDatabaseType Case "Access" Session.LCID = 1033 strSQLPrintArticle = "SELECT ArticleId, ArticleAuthor, ArticleAuthorEmail, ArticleDateAndTime, ArticleHeadline, ArticleLeadIn, ArticleFull FROM tblNewsDatabaseBySmo WHERE DateDiff('s', Now(), ArticleDateAndTime) <= 0 AND ArticleId = " & intPrintArticleId & ";" Session.LCID = gstrElsid Case "SQLServer" Session.LCID = 1033 strSQLPrintArticle = "SELECT ArticleId, ArticleAuthor, ArticleAuthorEmail, ArticleDateAndTime, ArticleHeadline, ArticleLeadIn, ArticleFull FROM tblNewsDatabaseBySmo WHERE DateDiff(s, GetDate(), ArticleDateAndTime) <= 0 AND ArticleId = " & intPrintArticleId & ";" Session.LCID = gstrElsid Case Else Response.Clear Response.Write "Administrator check database type." Response.End End Select 'Open Connection openconn 'Open Recordset Dim objPrintArticle Set objPrintArticle = Server.CreateObject("ADODB.Recordset") objPrintArticle.Open strSQLPrintArticle, objConn, 0, 1 If objPrintArticle.EOF Then Response.Write "Please use the form when accessing this page!" 'Close Recordset objPrintArticle.Close Set objPrintArticle = Nothing 'Close Connection closeconn Exit Sub Else strArticleLeadInPrintArticle = objPrintArticle("ArticleLeadIn") strArticleFullPrintArticle = objPrintArticle("ArticleFull") Response.Write "" & objPrintArticle("ArticleHeadline") & "
[ " & FormatDateAndTime(objPrintArticle("ArticleDateAndTime")) & " ]  From files at EVERYTHINGANGUS.COM

" Response.Write "" & Replace(strArticleLeadInPrintArticle, vbCrLf, "
") & "
" If strArticleFullPrintArticle <> "" Then Response.Write "

" Response.Write "" & Replace(strArticleFullPrintArticle, vbCrLf, "
") & "
" End If 'Close Recordset objPrintArticle.Close Set objPrintArticle = Nothing 'Close Connection closeconn End If End Sub '******************************************************************* '* Subroutines to admin print comment. * '******************************************************************* Sub admincommentprint checkadmin Dim intAdminPrintCommentId, strArticleCommentAdminPrintComment intAdminPrintCommentId = Request.QueryString("commentid") If NOT IsNumeric(intAdminPrintCommentId) Then Response.Write "Please use the form when accessing this page!" Exit Sub Else intAdminPrintCommentId = Cint(intAdminPrintCommentId) End If 'Create The SQL Dim strSQLAdminPrintComment strSQLAdminPrintComment = "SELECT CommentId, ArticleId, CommentAuthor, CommentAuthorEmail, CommentDateAndTime, ArticleCommentHeading, ArticleComment FROM tblComments WHERE CommentId = " & intAdminPrintCommentId & ";" 'Open Connection openconn 'Open Recordset Dim objAdminPrintComment Set objAdminPrintComment = Server.CreateObject("ADODB.Recordset") objAdminPrintComment.Open strSQLAdminPrintComment, objConn, 0, 1 If objAdminPrintComment.EOF Then Response.Write "Please use the form when accessing this page!" 'Close Recordset objAdminPrintComment.Close Set objAdminPrintComment = Nothing 'Close Connection closeconn Exit Sub Else strArticleCommentAdminPrintComment = objAdminPrintComment("ArticleComment") Response.Write "" & objAdminPrintComment("ArticleCommentHeading") & "
[ " & objAdminPrintComment("CommentDateAndTime") & " ]  By " & objAdminPrintComment("CommentAuthor") & "  " & objAdminPrintComment("CommentAuthorEmail") & "

" & Replace(strArticleCommentAdminPrintComment, vbCrLf, "
") 'Close Recordset objAdminPrintComment.Close Set objAdminPrintComment = Nothing 'Close Connection closeconn End If End Sub '******************************************************************* '* Subroutines to print comment. * '******************************************************************* Sub commentprint printgetoptions If gstrComments <> "Yes" Then Response.Clear Response.Write "You do not have permission to access this data." Response.End End If Dim intPrintCommentId, strArticleCommentPrintComment intPrintCommentId = Request.QueryString("commentid") If NOT IsNumeric(intPrintCommentId) Then Response.Write "Please use the form when accessing this page!" Exit Sub Else intPrintCommentId = Cint(intPrintCommentId) End If 'Create The SQL Dim strSQLPrintComment Select Case gstrDatabaseType Case "Access" Session.LCID = 1033 strSQLPrintComment = "SELECT tblComments.CommentId, tblComments.ArticleId, tblComments.CommentAuthor, tblComments.CommentAuthorEmail, tblComments.CommentDateAndTime, tblComments.ArticleCommentHeading, tblComments.ArticleComment, tblNewsDatabaseBySmo.ArticleDateAndTime FROM tblNewsDatabaseBySmo INNER JOIN tblComments ON tblNewsDatabaseBySmo.ArticleId = tblComments.ArticleId WHERE DateDiff('s', Now(), tblNewsDatabaseBySmo.ArticleDateAndTime) <= 0 AND tblComments.CommentId = " & intPrintCommentId & ";" Session.LCID = gstrElsid Case "SQLServer" Session.LCID = 1033 strSQLPrintComment = "SELECT tblComments.CommentId, tblComments.ArticleId, tblComments.CommentAuthor, tblComments.CommentAuthorEmail, tblComments.CommentDateAndTime, tblComments.ArticleCommentHeading, tblComments.ArticleComment, tblNewsDatabaseBySmo.ArticleDateAndTime FROM tblNewsDatabaseBySmo INNER JOIN tblComments ON tblNewsDatabaseBySmo.ArticleId = tblComments.ArticleId WHERE DateDiff(s, GetDate(), tblNewsDatabaseBySmo.ArticleDateAndTime) <= 0 AND tblComments.CommentId = " & intPrintCommentId & ";" Session.LCID = gstrElsid Case Else Response.Clear Response.Write "Administrator check database type." Response.End End Select 'Open Connection openconn 'Open Recordset Dim objPrintComment Set objPrintComment = Server.CreateObject("ADODB.Recordset") objPrintComment.Open strSQLPrintComment, objConn, 0, 1 If objPrintComment.EOF Then Response.Write "Please use the form when accessing this page!" 'Close Recordset objPrintComment.Close Set objPrintComment = Nothing 'Close Connection closeconn Exit Sub Else strArticleCommentPrintComment = objPrintComment("ArticleComment") Response.Write "" & objPrintComment("ArticleCommentHeading") & "
[ " & FormatDateAndTime(objPrintComment("CommentDateAndTime")) & " ]  By " & objPrintComment("CommentAuthor") & "  " & objPrintComment("CommentAuthorEmail") & "

" Response.Write "" & Replace(strArticleCommentPrintComment, vbCrLf, "
") & "
" 'Close Recordset objPrintComment.Close Set objPrintComment = Nothing 'Close Connection closeconn End If End Sub '******************************************************************* '* Subroutine to get options for print. * '******************************************************************* Sub printgetoptions 'Open Connection openconn 'Open Recordset Dim objPrintGetOptions Set objPrintGetOptions = Server.CreateObject("ADODB.Recordset") objPrintGetOptions.Open "tblNewsDatabaseBySmoOptions", objConn, 0, 1, 2 If objPrintGetOptions.EOF Then 'Close Recordset objPrintGetOptions.Close Set objPrintGetOptions = Nothing 'Close Connection closeconn Response.Clear Response.Write "Error: Administrator reset options." Response.End Else gstrComments = objPrintGetOptions("Comments") gstrFFType = objPrintGetOptions("FFType") gintFontSize = objPrintGetOptions("FontSize") gstrDateAndTimeFormat = objPrintGetOptions("DateAndTimeFormat") 'Close Recordset objPrintGetOptions.Close Set objPrintGetOptions = Nothing 'Close Connection closeconn End If End Sub '******************************************************************* '* Subroutine to check admin. * '******************************************************************* Sub checkadmin If Session("CheckNewsDatabasePassword") <> gstrNewsAdminPassword Then Response.Write "You do not have permission to use this page." Response.End End If End Sub '******************************************************************* '* Subroutine to open connection to the database. * '******************************************************************* Sub openconn Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open gstrConnectToDatabase End Sub '******************************************************************* '* Subroutine to close connection to the database. * '******************************************************************* Sub closeconn objConn.Close Set objConn = Nothing End Sub '******************************************************************* '* Function to format date and time. * '******************************************************************* Function FormatDateAndTime(dtDateAndTime) Dim dtFormattedDateAndTime, intDay, strOrdDay, strHour24, intHour, strMinute, strSecond, strAMPM dtFormattedDateAndTime = gstrDateAndTimeFormat intDay = DatePart("d", dtDateAndTime) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%d", intDay, 1, -1, 0) Select Case intDay Case 1, 21, 31 strOrdDay = "st" Case 2, 22 strOrdDay = "nd" Case 3, 23 strOrdDay = "rd" Case Else strOrdDay = "th" End Select dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%O", strOrdDay, 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%w", DatePart("w", dtDateAndTime), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%A", WeekDayName(DatePart("w", dtDateAndTime), False), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%a", WeekDayName(DatePart("w", dtDateAndTime), True), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%m", DatePart("m", dtDateAndTime), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%B", MonthName(DatePart("m", dtDateAndTime), False), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%b", MonthName(DatePart("m", dtDateAndTime), True), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%j", DatePart("y", dtDateAndTime), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%Y", DatePart("yyyy", dtDateAndTime), 1, -1, 0) dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%y", Right(DatePart("yyyy", dtDateAndTime), 2), 1, -1, 0) strHour24 = DatePart("h", dtDateAndTime) If Len(strHour24) < 2 Then strHour24 = "0" & strHour24 End If dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%H", strHour24, 1, -1, 0) intHour = DatePart("h",dtDateAndTime) Mod 12 If intHour = 0 Then intHour = 12 End If dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%h", intHour, 1, -1, 0) strMinute = DatePart("n", dtDateAndTime) If Len(strMinute) < 2 Then strMinute = "0" & strMinute End If dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%N", strMinute, 1, -1, 0) If Cint(strMinute) = 0 Then dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%n", "", 1, -1, 0) Else If Cint(strMinute) < 10 Then strMinute = "0" & strMinute End if strMinute = ":" & strMinute dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%n", strMinute, 1, -1, 0) End if strSecond = DatePart("s", dtDateAndTime) If Len(strSecond) < 2 Then strSecond = "0" & DatePart("s", dtDateAndTime) End If dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%S", strSecond, 1, -1, 0) If DatePart("h",dtDateAndTime) >= 12 Then strAMPM = "PM" Else strAMPM = "AM" End If dtFormattedDateAndTime = Replace(dtFormattedDateAndTime, "%P", strAMPM, 1, -1, 0) FormatDateAndTime = dtFormattedDateAndTime End Function %>