<% Sub zStart_PostIDs() '-- user variables -- Dim zintIncludeComments,zstrFileName,zstrFileType ',zstrDaysOfNews,zstrIncludeNews zstrFileType = LCase(Trim(Request.Form("fileType"))) zintIncludeComments = Trim(Request.Form("fileComments")) 'no of comments per post zstrFileName = Trim(Request.Form("fileName")) If zstrFileType = "" Then zstrFileType = AutoFileTypes End If If zintIncludeComments = "" Or Not IsNumeric(zintIncludeComments) Then zintIncludeComments = AutoNoOfComments Else zintIncludeComments = CInt(zintIncludeComments) End If If zstrFileName = "" Then zstrFileName = AutoFileName Else Dim zobjRegExp,Matches,Match Set zobjRegExp = New RegExp zobjRegExp.IgnoreCase = True zobjRegExp.Global = True zobjRegExp.Pattern = "[^\w]" If zobjRegExp.Test(zstrFileName) Then zstrFileName = AutoFileName End If Set zobjRegExp = Nothing End If '-- get news posts -- If InStr(z_PostIDs,",") <> 0 Then 'multiple posts zstrSQL = "SELECT news.PostID, news.Title, news.PostedDate, news.Content, news.Comments, categories.CategoryName, userInfo.UserName, userInfo.Email, userInfo.UserID, categories.Category FROM userInfo INNER JOIN (news INNER JOIN categories ON news.Category LIKE categories.Category) ON news.PostedBy LIKE userInfo.UserID WHERE news.PostID IN (" & z_PostIDs & ") ORDER BY news.PostID DESC" Else 'only a single post submitted zstrSQL = "SELECT news.PostID, news.Title, news.PostedDate, news.Content, news.Comments, categories.CategoryName, userInfo.UserName, userInfo.Email, userInfo.UserID, categories.Category FROM userInfo INNER JOIN (news INNER JOIN categories ON news.Category LIKE categories.Category) ON news.PostedBy LIKE userInfo.UserID WHERE news.PostID LIKE " & z_PostIDs & " ORDER BY news.PostID DESC" End If zobjRS1.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockReadOnly, adCmdText If Not zobjRS1.EOF Then zobjRS = zobjRS1.GetRows() Else ErrorOccured = True zobjRS1.Close Set zobjRS1 = Nothing Exit Sub End If zobjRS1.Close '-- get comments -- If zintIncludeComments <> -1 Then If InStr(z_PostIDs,",") <> 0 Then 'multiple posts zstrSQL = "SELECT comments.CommentID, comments.PostID, comments.PostedDate, comments.PostedBy, comments.Comment FROM comments WHERE comments.PostID IN (" & z_PostIDs & ") ORDER BY comments.CommentID" Else 'single postid given zstrSQL = "SELECT comments.CommentID, comments.PostID, comments.PostedDate, comments.PostedBy, comments.Comment FROM comments WHERE comments.PostID LIKE " & z_PostIDs & " ORDER BY comments.CommentID" End If zobjRS1.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockReadOnly, adCmdText Else Set zobjRS1 = Nothing End If '-- write the xml/html file -- If InStr(zstrFileType,"html") <> 0 Then Call zFile_HTML(zstrFileName,zintIncludeComments) End If If InStr(zstrFileType,"xml") <> 0 Then Call zFile_XML(zstrFileName,zintIncludeComments) End If '-- closedown -- If IsArray(zobjRS) Then Erase zobjRS End If If zintIncludeComments <> -1 Then 'comments rs exists zobjRS1.Close Set zobjRS1 = Nothing End If End Sub Sub zStart_Normal() zstrSQL = "SELECT news.PostID, news.Title, news.PostedDate, news.Content, news.Comments, categories.CategoryName, userInfo.UserName, userInfo.Email, userInfo.UserID, categories.Category FROM userInfo INNER JOIN (news INNER JOIN categories ON news.Category LIKE categories.Category) ON news.PostedBy LIKE userInfo.UserID WHERE " '-- date search -- If AutoDaysPerPage >= 1 Then Dim zTmpDate1 zTmpDate1 = DateAdd("d",(AutoDaysPerPage * -1),Now) 'gets date from [AutoDaysPerPage] days ago zTmpDate1 = Year(zTmpDate1) & Right("0"&Month(zTmpDate1),2) & Right("0"&Day(zTmpDate1),2) 'converts it to yyyymmdd zstrSQL = zstrSQL & "news.DateStamp >= " & zTmpDate1 & " AND " End If '-- category search -- If InStr(AutoFileCategory,",") <> 0 Then 'multiple categories zstrSQL = zstrSQL & "news.Category IN (" & AutoFileCategory & ")" Else 'single zstrSQL = zstrSQL & "news.Category LIKE " & AutoFileCategory End If zstrSQL = zstrSQL & " ORDER BY news.PostID DESC" zobjRS1.CursorLocation = 3 zobjRS1.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockReadOnly, adCmdText If Not zobjRS1.EOF Then If AutoNoOfPosts > 0 And zobjRS1.RecordCount > AutoNoOfPosts Then zobjRS = zobjRS1.GetRows(AutoNoOfPosts) Else zobjRS = zobjRS1.GetRows() End If Else ErrorOccured = True zobjRS1.Close Set zobjRS1 = Nothing Exit Sub End If zobjRS1.Close '-- comments -- If AutoNoOfComments <> -1 Then zstrSQL = "SELECT comments.CommentID, comments.PostID, comments.PostedDate, comments.PostedBy, comments.Comment FROM comments WHERE comments.PostID BETWEEN " & zobjRS(0,0) & " AND " & zobjRS(0,UBound(zobjRS,2)) & " ORDER BY comments.CommentID" zobjRS1.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockReadOnly, adCmdText Else Set zobjRS1 = Nothing End If '-- write files -- If InStr(AutoFileTypes,"html") <> 0 Then Call zFile_HTML(AutoFileName,AutoNoOfComments) End If If InStr(AutoFileTypes,"xml") <> 0 Then Call zFile_XML(AutoFileName,AutoNoOfComments) End If '-- closedown -- If IsArray(zobjRS) Then Erase zobjRS End If If AutoNoOfComments <> -1 Then 'comments rs exists zobjRS1.Close Set zobjRS1 = Nothing End If End Sub Dim z_PostIDs,ErrorOccured z_PostIDs = Request.Form("selectID") 'seperate id list ErrorOccured = False '-- brain -- Dim zobjRS,zobjRS1,zstrSQL Set zobjRS1 = Server.CreateObject("ADODB.Recordset") If z_PostIDs <> "" Then Call zStart_PostIDs() Else Call zStart_Normal() 'sets up the array containing posts End If '-- closedown -- zobjConn.Close '### maybe move this into code to use a disconned recordset? Set zobjConn = Nothing Response.Redirect "ui_index.asp?msg=action completed" %>