<% Sub zDelete_News() If z1_AccessLevel < 1 Then Response.Redirect "ui_index.asp?msg=you may not edit categories" End If '-- delete news by id -- zobjComm.CommandText = "DELETE FROM news WHERE PostID IN (" & z_DeleteIDs & ")" zobjComm.Execute '-- delete the accompanying comments -- zobjComm.CommandText = "DELETE FROM comments WHERE PostID IN (" & z_DeleteIDs & ")" zobjComm.Execute End Sub Sub zDelete_Comments() If z1_AccessLevel < 1 Then Response.Redirect "ui_index.asp?msg=you may not edit categories" End If '-- delete comments by id -- zobjComm.CommandText = "DELETE FROM comments WHERE CommentID IN (" & z_DeleteIDs & ")" zobjComm.Execute '-- change number of comments in the news post -- '# this is probably possible with a single sql query, but dunno what that is ;) so this'll do for the time being z_DeleteIDs = Replace(z_DeleteIDs,", ",",") z_DeleteIDs = Split(z_DeleteIDs,",") zintPostID = Request.Form("deleteID") '-- get the total of comments for the post -- ui only deletes from a single post at a time zobjComm.CommandText = "SELECT COUNT(*) As rscount FROM comments WHERE comments.PostID LIKE " & zintPostID Dim zobjRS Set zobjRS = zobjComm.Execute '-- set this total as the news.Comments value -- zobjComm.CommandText = "UPDATE news SET Comments = " & zobjRS("rscount") & " WHERE news.PostID LIKE " & zintPostID zobjComm.Execute Set zobjRS = Nothing End Sub Sub zDelete_Users() If z1_AccessLevel < 2 Then Response.Redirect "ui_index.asp?msg=you may not edit categories" End If '-- get postids of posts written by the users to be deleted shortly -- z_DeleteIDs = Replace((" " & z_DeleteIDs & ",")," 1,","") 'stops the default login from being deleted zobjComm.CommandText = "SELECT news.PostID FROM news WHERE news.PostedBy IN (" & z_DeleteIDs & ")" Dim zobjRS,zTmp,zTmp1 Set zobjRS = zobjComm.Execute If Not zobjRS.EOF Then zTmp = zobjRS.GetRows() Set zobjRS = Nothing zTmp1 = Join(zTmp,", ") '-- delete comments associated with posts by the user -- zobjComm.CommandText = "DELETE FROM comments WHERE PostID IN (" & zTmp1 & ")" zobjComm.Execute '-- delete posts by user -- zobjComm.CommandText = "DELETE FROM news WHERE PostID IN (" & zTmp1 & ")" zobjComm.Execute End If '-- delete users by id -- zobjComm.CommandText = "DELETE FROM userInfo WHERE UserID IN (" & z_DeleteIDs & ")" zobjComm.Execute End Sub Sub zDelete_Category() If z1_AccessLevel < 3 Then Response.Redirect "ui_index.asp?msg=you may not delete categories" End If '-- delete posts associated with the category(ies) -- zobjComm.CommandText = "DELETE FROM news WHERE Category IN (" & z_DeleteIDs & ")" zobjComm.Execute '-- delete the category(ies) -- zobjComm.CommandText = "DELETE FROM categories WHERE Category IN (" & z_DeleteIDs & ")" zobjComm.Execute End Sub Dim zstrDeleteType,z_DeleteIDs zstrDeleteType = LCase(Trim(Request.Form("deletetype"))) z_DeleteIDs = Trim(Request.Form("selectID")) '-- set up command object -- Dim zobjComm Set zobjComm = Server.CreateObject("ADODB.Command") zobjComm.ActiveConnection = zobjConn zobjComm.CommandType = adCmdText '-- perform the delete -- Select Case zstrDeleteType Case "news" Call zDelete_News() Case "comments" Call zDelete_Comments() Case "userinfo" Call zDelete_Users() Case "categories" Call zDelete_Category() End Select '-- close down Set zobjComm = Nothing zobjConn.Close Set zobjConn = Nothing Response.Redirect "ui_index.asp?msg=delete done." %>