<%= OutputCSS() %>

<% Dim objCom, Stream, FileLocation, msgID, allforum, appid, ContentType, returnedValue, downRestriction Dim rights, mode Dim forcedDownload:forcedDownload = true 'enable forced download or not msgID = request.querystring("m") allforum = Application(dbName&"foruminfo") Dim filename:filename = "" Set objCom = server.createobject("adodb.command") with objCom .activeconnection = datastore .commandText = dbOwnerPrefix&"spDownloadAttachment" .commandType = adCmdStoredProc .Parameters.Append .Createparameter("@RETURN_VALUE", adInteger, adParamReturnValue, 0 ) .Parameters.Append .Createparameter("@msgID", adInteger, adParamInput, 0, msgID) .Parameters.Append .Createparameter("@memID", adInteger, adParamInput, 0, memID) .Parameters.Append .Createparameter("@fileLocation", adVarChar, adParamOutput, 150 ) .Parameters.Append .Createparameter("@forumID", adInteger, adParamOutput, 0 ) .Parameters.Append .Createparameter("@upfile", adVarChar, adParamOutput, 500 ) .Parameters.Append .Createparameter("@downRestriction", adUnsignedTinyInt, adParamOutput, 0 ) .execute , , adExecuteNoRecords returnedValue = .parameters("@RETURN_VALUE") FileLocation = .parameters("@fileLocation") appid = ForumIDtoAppid(.parameters("@forumID")) filename = .parameters("@upfile") downRestriction = .parameters("@downRestriction") end with Set objCom = nothing Dim allowdownload:allowdownload = false if len(appid) > 0 then Dim objPermission Set objPermission = new PermissionSetting With objPermission .memID = memID .appid = appid .GetPermission(false) rights = .post Mode = .isModerator End With Set objPermission = nothing if returnedValue <> -1 then allowdownload = true else if Mode or isAdmin then allowdownload = true end if end if if rights>0 and allowdownload and len(filename)<>0 then Dim i, arrUpfiles:arrUpfiles = split(filename,"|") Dim tempFileLocation tempFileLocation = left(FileLocation,inStrRev(FileLocation,"/")) response.write ("
    ") for i=0 to ubound(arrUpfiles) if forcedDownload then response.write ("
  1. "&tmAttachedFile&fileExt(arrUpfiles(i))&"
    ") else response.write ("
  2. "&arrUpfiles(i)&"
    ") end if next response.write ("
") response.write ("
"&javascriptCloseWindow&"
") elseif returnedValue = -1 then response.write(replace(downloadErrorMsg,"{0}",downRestriction)) else response.end end if end if %>