<% Dim db,rst,DSNtemp,fso Dim userid,username,deleteids,authenticated Dim i,file,fileid,fileids,filename,filenames authenticated = Session("PrivateAreaAuthenticated") If authenticated <> True Then Response.Redirect("http://www.goaction.com") ElseIf Session("PrivateAreaAdmin") <> True Then Response.Redirect(Session("PrivateAreaUserpage")) End if Set db = Server.CreateObject("ADODB.Connection") Set rst = Server.CreateObject("ADODB.Recordset") DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/data/private.mdb") db.Open DSNtemp userid = 0 If Not IsNull(Request.QueryString("UserID")) Then userid = Request.QueryString("UserID") End If deleteids = "" If Not IsNull(Request.QueryString("FileIDs")) Then deleteids = Request.QueryString("FileIDs") End If username ="" Set rst = db.Execute("SELECT * FROM tblUser WHERE UserID=" & userid) If Not rst.EOF Then username = rst("UserName") %> Action Systems: Private Download Area: Admin Page: Delete files
Private Download Area
Admin Page
Delete file(s)
<% If userid = 0 Then Response.Write "No user account specified. Aborting update." ElseIf username = "" Then Response.Write "Invalid user account specified. Aborting update." Else If deleteids <> "" Then fileids = split(deleteids,"|",-1,1) For i = 0 to UBound(fileids) Set rst = db.Execute("SELECT * FROM qryUserFiles WHERE UserID=" & userid & " AND FileID=" & fileids(i)) filename = "" If Not rst.EOF Then filenames = filenames & rst("FileName") & "|" filename = rst("FileName") End If rst.Close Set rst = Nothing If filename <> "" Then Set fso = Server.CreateObject("Scripting.FileSystemObject") file = Server.MapPath("/private/" & username & "/" & filename) If fso.FileExists(file) Then fso.DeleteFile(file) Set fso = Nothing End If Set rst = db.Execute("SELECT * FROM qryUserFiles WHERE UserID=" & userid) Do While Not rst.EOF If rst("FileID") <> "" Or Not IsNull(rst("FileID")) Then fileid = rst("FileID") If CInt(fileid) = CInt(fileids(i)) Then db.Execute("DELETE FROM tblUserFiles WHERE UserID=" & userid & " AND FileID=" & fileid) db.Execute("DELETE FROM tblFiles WHERE FileID=" & fileid) End If End If rst.MoveNext Loop Next Response.Write "Successfully deleted the following file(s) for user " & username & ":
" filenames = split(filenames,"|",-1,1) For i = 0 to UBound(filenames) Response.Write filenames(i) & "
" Next End If End If db.Close Set db = Nothing %>

Close this window