ajhvdb
Junior Member
Netherlands
392 Posts |
Posted - 27 June 2002 : 18:14:08
|
The following i'm working on because i need this in my forum. I've done all the testing already at what things are possible or not but didn't created the mod for release. (it will take some more days). I know it's a bit large to read and I don't know whats inside 3.4 (maybe attachments are standard) Could you please shoot some holes into this, did i forgot something?
Offcourse i didn't invented this from scratch. I first took a good look at HUWR mods sources how uploading works but couldn't get this working the way i wanted. A lot off people are using his att mod but hey maybe you like my mod or not. I'm open for any remarks but keep it nice.
Below you find a description for the tables and fields needed for this mod. After this i included att_defaults.asp. In here i explain in detail how things will work.
Within the forumtable 4 fields are added:
Field F_ATT_UPLOAD (who can upload) 0=None (default) 1=Members 2=Moderators
Field F_ATT_DOWNLOAD (who can download) 0=None (default) 1=Members (only if allowed at file, forumlevel) 2=Moderators (only if allowed at file, forumlevel)
Field F_ATT_VALIDATION (Is the file ready for download) 0=No validation needed (default) 1=Moderators
Admin members can up/download/validate also offcourse.
Field F_ATT_EMAIL (Email is send to moderators and admins when a file is uploaded) 0=Off (default) 1=On
TABLE FORUM_ATTACHMENTS Field ATT_ID (Autonumber)
Field MEMBER_ID (member who uploaded this file)
Field ATT_FILENAME !member can edit this, "filename but not the extension"!
Field ATT_FILESIZE
Field REPLY_ID (maybe i need this when a reply is deleted)
Field TOPIC_ID !member can edit this!
Field ATT_UPCOUNT (how many times uploaded) Field ATT_DLCOUNT (how many times downloaded)
Field ATT_DATE (latest upload date)
Field ATT_VALID (validated by moderator or admin or automatic) 0=Off (No download possible) 1=On
Field ATT_VIEW (If file is image can it be viewed within topic) 0=Off (Default) 1=On (Only possible if imagepath exist) !member can edit this!
Field ATT_LIBRARY (It is not only an attachment but can also be viewed if you click at the top on href-downloads) 0=Off (Default) 1=On (Only Admin can change this, file can not be deleted anymore)
Field F_ATT_DOWNLOAD (who can download) !member can edit this! 0=All Members (default) 1=Topic poster 2=Members in thread 3=Moderators 4=Admin
####What needs to change in default forum:#### in message: [att="1"]text[att] --> will be automatically replaced with "Text" [att="2"][att] --> will be automatically replaced with "(DiskIcon) file.zip (100 Kb)" [att="3"][att] --> if imagefile then will be replaced with a included IMG tag on all those example you can click to download.
only when a topic or post is inserted/updated will processing of the uploaded file(s) be needed.
in the topic view a check has to be made if [att] is in the post text then (AttachmentIcon) with subject. when you delete topic or reply the attached files will be deleted also.
####Which extra asp files will this mod have:#### edit file information (Admin and member edit only) check if files exist on harddisk but not in database. maintenance all attachments by admin or members own files. vars in att_default.asp, save to table and create admin_att_config.asp file library. (maybe later)
-------------------ATT_DEFAULTS.ASP------------------------------------------ A little example how things work with this attachment mod: When a member (MemberId=78) uploads a file "abc.zip" the mods creates a new attachment record in the database. The first record contains a FileID with a value of 1 and the name "abc.zip". The uploaded file will be saved in the folder "D:\attachments\78" with the name "1.zip" When an other member clicks on download, the file "D:\attachments\78\1.zip" is send to the members browser with the filename "abc.zip". When an other member (MemberId=301) uploads a file it is saved with the next FileID --> "D:\attachments\301\2.doc"
Why do we use these numbers and save a members upload in a separate folder? - Members can change there name but not there ID. - Filenames can change but within every topic only the FileId is saved. - Members can upload a new file and don't want to overwrite an old file. - If we save all members uploaded files in one folder it will slow down downloads,maintenance. - Uploaded files could be saved into the database but will slow things down.
At no moment will any member see where things are stored and in the example above i didn't explain that there are security checks also. For example: is the member allowed to download?. For example: is the member allowed to the topic where the attachment was added?, etc.
if an uploaded file is an image (see below), it is moved from the attachment folder to the image folder. (ex. "D:\attachments\50\301.jpg" moved to "/Forum/AttImage/50/301.jpg") This image folder can be reached by the webserver so users can view attached images but no other attachments.
If you don't care fore security and want to allow members to download, upload, use a normal filename, etc. then below you will find examples where you can accomplish this also!
Dim strAttDefAllowedUploadFiles, strAttDefExcludedUploadFiles Dim strAttDefAllowedDownloadFiles, strAttDefExcludedDownloadFiles Dim strAttDefIsImage, strAttDefChangeFileNameToID, strAttDefConvertToLC Dim strAttDefPath, strAttDefPathImage Dim strAttDefAllowedUploadEvery, strAttDefUploadTimeOut Dim strAttDefMaxSize, strAttDefMaxFolderSize
#Allowed files to upload or download# Which files can users upload or download? Every extension you type in must start with : strAttDefAllowedUploadFiles = ":zip:mdb:txt:asp:htm:html:jpg:jpeg:gif:bmp:doc:ppt:xls:pdf:eml:wav:exe" strAttDefAllowedDownloadFiles = ":zip:mdb:txt:asp:htm:html:jpg:jpeg:gif:bmp:doc:ppt:xls:pdf:eml:wav:exe"
#Excluded files to upload or download# You can make allowedfiles empty and use exclusion! Every extension you type in must start with : Note if you use ":" (means no extension), a file with no extension can NOT be uploaded Note if you use ":*" no user can upload strAttDefExcludedUploadFiles = ":" Note if you use ":" (means no extension), a file with no extension can NOT be downloaded Note if you use ":*" no user can download strAttDefExcludedDownloadFiles = ":"
#Case# If you want the characters of an uploaded filename changed to lowercase? strAttDefConvertToLC = 0 'example 0=No 1=AbC.Zip -> abc.zip
#Image# Which files are images that should be moved to the image path? Every extension you type in must start with : strAttDefIsImage = ":jpg:jpeg:gif"
#Attachment location# In which folder location shuold uploaded files be saved and from where they can be downloaded? Make sure this folder EXIST on your harddisk and set the folderrights to READ, WRITE, DELETE (In WindowsNT you should give this right to user "IUSR_????" or the group "Everyone")
You can type in a relative path like "/updown", so if your webserver is "http://domain.com" users can bypass all the security enhancements this mod has. NOTE: Only when they now the name of your attachment path "http://domain.com/updown", users can bypass it.
This mod will NEVER show the name of your attachment path on screen (if you use the security settings!) or in the html source. So you can use a relative path, but be careful. You'd better use a folder path that's not located in your root web (reacheble through the webserver). Do NOT end this variable with a \ or / strAttDefPath = "D:\Attachments" 'example "D:\Attachments","C:\WEBDATA\Attachments","/attachments"
#Image location# In which relative folder location should uploaded images be saved and from where they can be viewed Make sure this folder EXIST on your harddisk and set the folderrights to READ, WRITE, DELETE (In WindowsNT you should give this right to user "IUSR_????" or the group "Everyone")
This is a relative path so do NOT USE "C:\etc","D:\etc","E:\etc" If this path is different from strAttDefPath (and not empty) an uploaded image will be moved to this path and can be viewed as an image within the topic Do NOT end this variable with a / strAttDefPathImage = "" 'example "","/Forum/AttImage","/images"
#TimeOut# This is the default time in milliSeconds the webserver waits for the uploaded file. The member can change this setting during upload strAttDefUploadTimeOut = 10000
#Upload every minute# Upload a file every ? minutes, a member can for example upload another file after 20 minutes. If this value = 0 then NO check on repeat strAttDefAllowedUploadEvery = 30 'example 0,60,180
#FileSize# Maximum filesize in Kb a uploaded file can be. If this value = 0 then NO check on filesize strAttDefMaxSize = 256 'example 50,100,1024
#FolderSize# Maximum foldersize in Kb all uploaded files a member can have. If this value = 0 then NO check on foldersize This value is a total of the attachment folder and image folder strAttDefMaxFolderSize = 1024 'example 1024,
#FileName or ID# If you don't want those filenames with 1.zip, 1003.jpg, etc. change the next variable strAttDefChangeFileNameToID = 1 'example 0=Use abc.zip, mod.zip,etc 1=Use 1.zip,2.jpg,400.mdb Note: - when a member uploads abc.zip within a topic and a fews days later abc.zip within an other topic the first abc.zip is overwritten. - Do NOT change this variable when members already uploaded files. Those files are already saved on disk with a filename 1.zip, 2.jpg, etc. or vice versa.
#Security# If you don't care fore security and want to allow members to download every file. To keep it simple, just type a relative path in strAttDefPath and remove the ' from the next line 'strAttDefPathImage = strAttDefPath
ASP level: beginner ajhvdb |
|