<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% server.ScriptTimeout=2400%> <% '********************************************************** '* Fixit DMS Pro v1.4 by Fixit Knowledge Solutions * '* Copyright © 2002-2004, Mark Tait. All rights reserved. * '* http://www.fixitks.co.uk * '********************************************************** %> <% 'Get parentid reference to add to redirect mt_id=request("mt_id") if mt_id="" then mt_id="0" parentID=request.querystring("parentid") if parentid="" then parentid="0" if request.querystring("orderby")<>"" and request.querystring("dir")<>"" then session("orderby")=request.querystring("orderby") session("dir")=request.querystring("dir") end if %> <% ' **************************************************** Dim Upload, fileName, fileSize, ks, i, fileKey mt_path=server.MapPath(file_folder) mt_temp=server.MapPath(file_folder_temp) function SaveFiles Set Upload = New FreeASPUpload Upload.SaveUnique mt_path, true, "" If Err.Number<>0 then Exit function unique= upload.form("unique") mt_title=replace(upload.form("title"),"'","''") if mt_title="" then mt_title=filename mt_titledesc=replace(upload.form("titledesc"),"'","''") parentid= upload.form("parentid") mt_mt_version=replace( upload.form("mt_version"),"'","''") end function function SaveUnlockFiles Set Upload = New FreeASPUpload Upload.SaveUnlock(mt_path) If Err.Number<>0 then Exit function mt_title=replace(upload.form("title"),"'","''") mt_titledesc=replace(upload.form("titledesc"),"'","''") mt_commenttitle="" mt_commenttext="" mt_commenttitle=replace(upload.form("mt_commenttitle"),"'","''") mt_commenttext=replace(upload.form("mt_commenttext"),"'","''") mt_commenttext=replace(mt_commenttext,chr(10),"
") parentid=upload.form("parentid") mt_version=replace(upload.form("mt_version"),"'","''") mt_id = upload.form("mt_id") if mt_title="" then mt_title=FileName end function %> <% Dim oFileUp Dim strExistAction Dim error_message error_message="" if request.querystring("error_message")<>"" then error_message="" & server.HTMLEncode(request.querystring("error_message")) & "" %> <% 'check if folder can be deleted if request.querystring("action")="delf" and request.querystring("delid")<>"" and session("mt_deletefiles")=1 then idtodel=request.querystring("delid") Set mt_checkParent = Server.CreateObject("ADODB.Recordset") mt_checkParent.ActiveConnection = MM_conTT_STRING mt_checkParent.Source = "SELECT ID FROM tblfiles where parentid=" & idtodel mt_checkParent.CursorType = 0 mt_checkParent.CursorLocation = 2 mt_checkParent.LockType = 1 mt_checkParent.Open() mt_checkParentrecs=false if not(mt_checkParent.eof) then mt_checkParentrecs=true mt_checkParent.close set mt_checkParent=nothing if mt_checkParentrecs=true then error_message="That folder cannot be deleted. It has folders/files beneath it." Response.Redirect "filelist.asp?parentid="& parentid& "&error_message=" & server.URLEncode(error_message) end if Set mt_delCmdf = Server.CreateObject("ADODB.Command") mt_delCmdf.ActiveConnection = MM_conTT_STRING mt_delCmdf.CommandText = "delete from tblfiles where id = " & idtodel mt_delCmdf.CommandType = 1 mt_delCmdf.CommandTimeout = 0 mt_delCmdf.Prepared = true mt_delCmdf.Execute() mt_delCmdf.ActiveConnection.Close checkSub parentid, "A folder has been deleted in a folder you subscribe to" end if %> <% 'check if folder to be subscribed to if request.querystring("subfolder")="yes" and request.querystring("parentid")<>"" and request.querystring("subEmail")<>"" then idtosub=request.querystring("parentid") emailtosub=request.querystring("subEmail") if request.querystring("rbsub")=0 then 'wants to unsubscribe Set mt_unSub = Server.CreateObject("ADODB.Command") mt_unSub.ActiveConnection = MM_conTT_STRING mt_unSub.CommandText = "delete from tblsubscribe where mt_folderid = " & idtosub & " AND mt_useremail = '" & emailtosub & "'" mt_unSub.CommandType = 1 mt_unSub.CommandTimeout = 0 mt_unSub.Prepared = true mt_unSub.Execute() mt_unSub.ActiveConnection.Close error_message="You have now unsubscribed from this folder" Response.Redirect "filelist.asp?parentid="& parentid& "&error_message=" & server.URLEncode(error_message) end if Set mt_checkSub = Server.CreateObject("ADODB.Recordset") mt_checkSub.ActiveConnection = MM_conTT_STRING mt_checkSub.Source = "SELECT ID FROM tblsubscribe where mt_folderid=" & idtosub & " and mt_useremail='" & emailtosub & "'" mt_checkSub.CursorType = 0 mt_checkSub.CursorLocation = 2 mt_checkSub.LockType = 1 mt_checkSub.Open() mt_checkSubrecs=false if not(mt_checkSub.eof) then mt_checkSubrecs=true mt_checkSub.close set mt_checkSub=nothing if mt_checkSubrecs=true then error_message="You are already subscribed to this folder" Response.Redirect "filelist.asp?parentid="& parentid& "&error_message=" & server.URLEncode(error_message) end if Set mt_checkSub2 = Server.CreateObject("ADODB.Command") mt_checkSub2.ActiveConnection = MM_conTT_STRING mt_checkSub2.CommandText = "insert into tblsubscribe (mt_folderid, mt_useremail) values (" & idtosub & ",'" & emailtosub & "')" mt_checkSub2.CommandType = 1 mt_checkSub2.CommandTimeout = 0 mt_checkSub2.Prepared = true mt_checkSub2.Execute() mt_checkSub2.ActiveConnection.Close error_message="You are now subscribed to this folder" Response.Redirect "filelist.asp?parentid="& parentid& "&error_message=" & server.URLEncode(error_message) end if %> <% if Request.QueryString("action")="del" and request.querystring("filename")<>"" and request.querystring("delid")<>"" and session("mt_deletefiles")=1 then idtodel=request.querystring("delid") filepath = request.QueryString("filename") on error resume next Set objFSO1 = Server.CreateObject("Scripting.FileSystemObject") Set MyFile = objFSO1.GetFile(mt_path & "\" & filepath) MyFile.Delete set MyFile=nothing set objFSO1=nothing Set mt_delCmd = Server.CreateObject("ADODB.Command") mt_delCmd.ActiveConnection = MM_conTT_STRING mt_delCmd.CommandText = "delete from tblfiles where id = " & idtodel mt_delCmd.CommandType = 1 mt_delCmd.CommandTimeout = 0 mt_delCmd.Prepared = true mt_delCmd.Execute() mt_delCmd.CommandText = "delete from tblcomments where mt_commentfileid = " & idtodel mt_delCmd.CommandType = 1 mt_delCmd.CommandTimeout = 0 mt_delCmd.Prepared = true mt_delCmd.Execute() mt_delCmd.ActiveConnection.Close if err.number<>0 then error_message="There was an error while deleteing... The error number was:" & Err.number & " and the most likely cause is the file you were trying to delete has either been renamed, or does not exist at the path specified" Response.Redirect "filelist.asp?parentid="& parentid& "&error_message=" & server.URLEncode(error_message) end if checkSub parentid, "A file has been deleted in a folder you subscribe to" Response.Redirect "filelist.asp?parentid="& parentid end if if Request.QueryString("action")="upload" and session("mt_addfiles")=1 then 'Check if FileUpload component is to be used if Upload_comp = True and upload_type="abcupload" then Set theForm = Server.CreateObject("ABCUpload4.XForm") theForm.AbsolutePath = True theForm.Overwrite = false Set theField = theForm.Files("inpFile") fullfilename=mt_path & "\" & theField.FileName filename=theField.FileName Set objFSO2 = Server.CreateObject("Scripting.FileSystemObject") mt_fileexist=false mt_full_filename=fullfilename if objFSO2.FileExists(mt_full_filename) then response.write("file exists
") mt_fileexist=true Begin_Name_Num=0 While mt_fileexist Begin_Name_Num=Begin_Name_Num+1 mt_full_filename=mt_path&"\"&objFSO2.GetBaseName(FileName) & "_" & Begin_Name_Num & "." & objFSO2.GetExtensionName(FileName) mt_fileexist=objFSO2.FileExists(mt_full_filename) Wend filename=objFSO2.GetBaseName(FileName) & "_" & Begin_Name_Num & "." & objFSO2.GetExtensionName(FileName) End If set objFSO2=nothing theField.Save mt_path & "/" & filename set thefield=nothing mt_title=replace(theForm.Form("title"),"'","''") mt_titledesc=replace(theForm.Form("titledesc"),"'","''") parentid=theForm.Form("parentid") mt_mt_version=replace(theForm.Form("mt_version"),"'","''") Set theForm = Nothing if mt_title="" then mt_title=FileName Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "INSERT INTO tblfiles (parentID, mt_type, description, datecreated, createdby, dateupdated, updatedby, mt_action, mt_locked, mt_lockedby, filepath, filename, mt_version, titledesc) VALUES (" & parentid & ", 10, '" & mt_title & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "','',0,'','" & mt_path & "','" & filename & "','" & mt_mt_version & "','" & mt_titledesc & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close set Upload = nothing checkSub parentid, "A file '" & mt_title & "' has been uploaded to a folder you subscribe to" Response.Redirect "filelist.asp?parentid=" & parentid 'End of Check if FileUpload component is to be used elseif Upload_comp = True and upload_type="safileup" then Set oFileUp = Server.CreateObject("SoftArtisans.FileUp") oFileUp.Path = Server.MapPath(file_folder_temp) oFileUp.CreateNewFile = True oFileUp.OverWriteFiles = False fname_mt=oFileUp.Form("inpFile").ShortFileName oFileUp.Form("inpFile").SaveAs mt_path & "\" & fname_mt mt_title=replace(oFileUp.Form("title"),"'","''") mt_titledesc=replace(oFileUp.Form("titledesc"),"'","''") parentid=oFileUp.Form("parentid") mt_mt_version=replace(oFileUp.Form("mt_version"),"'","''") FileName = Right(oFileUp.Form("inpFile").ServerName,Len(oFileUp.Form("inpFile").ServerName)-InstrRev(oFileUp.Form("inpFile").ServerName,"\")) Set oFileUp = Nothing if mt_title="" then mt_title=FileName Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "INSERT INTO tblfiles (parentID, mt_type, description, datecreated, createdby, dateupdated, updatedby, mt_action, mt_locked, mt_lockedby, filepath, filename, mt_version, titledesc) VALUES (" & parentid & ", 10, '" & mt_title & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "','',0,'','" & mt_path & "','" & filename & "','" & mt_mt_version & "','" & mt_titledesc & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close set Upload = nothing checkSub parentid, "A file '" & mt_title & "' has been uploaded to a folder you subscribe to" Response.Redirect "filelist.asp?parentid=" & parentid 'End of Check if FileUpload component is to be used elseif Upload_comp = True and upload_type="persists" then Set Upload = Server.CreateObject("Persits.Upload") Upload.OverwriteFiles = False Upload.IgnoreNoPost = True Upload.Save mt_path mt_title=replace(Upload.Form("title"),"'","''") mt_titledesc=replace(Upload.Form("titledesc"),"'","''") parentid=Upload.Form("parentid") mt_mt_version=replace(Upload.Form("mt_version"),"'","''") FilePathName = Upload.Files("inpFile").path FileName = Upload.Files("inpFile").filename if mt_title="" then mt_title=FileName Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "INSERT INTO tblfiles (parentID, mt_type, description, datecreated, createdby, dateupdated, updatedby, mt_action, mt_locked, mt_lockedby, filepath, filename, mt_version, titledesc) VALUES (" & parentid & ", 10, '" & mt_title & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "','',0,'','" & mt_path & "','" & filename & "','" & mt_mt_version & "','" & mt_titledesc & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close set Upload = nothing checkSub parentid, "A file '" & mt_title & "' has been uploaded to a folder you subscribe to" Response.Redirect "filelist.asp?parentid=" & parentid 'End of Check if FileUpload component is to be used else unique="" mt_title="" mt_titledesc="" parentid=0 mt_mt_version="" filename="" SaveFiles() Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "INSERT INTO tblfiles (parentID, mt_type, description, datecreated, createdby, dateupdated, updatedby, mt_action, mt_locked, mt_lockedby, filepath, filename, mt_version, titledesc) VALUES (" & parentid & ", 10, '" & mt_title & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & session("mt_username") & "','',0,'','" & mt_path & "','" & filename & "','" & mt_mt_version & "','" & mt_titledesc & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close checkSub parentid, "A file '" & mt_title & "' has been uploaded to a folder you subscribe to" Response.Redirect "filelist.asp?parentid=" & parentid end if End If if Request.QueryString("action")="unlockonly" and session("mt_lockfiles")=1 then mt_title=replace(request.form("title"),"'","''") mt_titledesc=replace(request.form("titledesc"),"'","''") mt_commenttitle="" mt_commenttext="" mt_commenttitle=replace(request.form("mt_commenttitle"),"'","''") mt_commenttext=replace(request.form("mt_commenttext"),"'","''") mt_commenttext=replace(mt_commenttext,chr(10),"
") parentid=request.form("parentid") mt_version=replace(request.form("mt_version"),"'","''") mt_id = request.form("mt_id") Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "update tblfiles set description='" & mt_title & "', dateupdated = " & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ", updatedby='" & session("mt_username") & "', mt_locked = 0, mt_lockedby='', mt_version='" & mt_version & "', titledesc='" & mt_titledesc & "' where id = " & mt_id mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close if mt_commenttext<>"" or mt_commenttitle<>"" then Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "insert into tblcomments (mt_commentfileid, mt_commentby, mt_commentdate, mt_commenttitle, mt_commenttext) values (" & mt_id & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & mt_commenttitle & "','" & mt_commenttext & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close end if checkSub parentid, "A file '" & mt_title & "' has been unlocked in a folder you subscribe to" Response.Redirect "filelist.asp?parentid=" & parentid 'check if file to be unlocked and refreshed elseif Request.QueryString("action")="unlock" and session("mt_lockfiles")=1 then 'Check if FileUpload component is to be used if Upload_comp = True and upload_type="abcupload" then Set theForm = Server.CreateObject("ABCUpload4.XForm") theForm.AbsolutePath = True theForm.Overwrite = true Set theField = theForm.Files("inpFile") fullfilename=mt_path & "\" & theField.FileName filename=theField.FileName theField.Save mt_path & "/" & theForm.Form("ufname") set thefield=nothing mt_title=replace(theForm.Form("title"),"'","''") mt_titledesc=replace(theForm.Form("titledesc"),"'","''") parentid=theForm.Form("parentid") mt_mt_version=replace(theForm.Form("mt_version"),"'","''") Set theForm = Nothing if mt_title="" then mt_title=FileName if mt_title="" then mt_title=FileName if FileName<>"" then if mt_title="" then mt_title=FileName mt_folderName=trim(replace(request.querystring("foldername"),"'","''")) Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "update tblfiles set description='" & mt_title & "', dateupdated = " & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ", updatedby='" & session("mt_username") & "', mt_locked = 0, mt_lockedby='', filename='" & Filename & "', mt_version='" & mt_version & "', titledesc='" & mt_titledesc & "' where id = " & mt_id 'response.write(mt_editCmd.CommandText) mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close if mt_commenttext<>"" or mt_commenttitle<>"" then Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "insert into tblcomments (mt_commentfileid, mt_commentby, mt_commentdate, mt_commenttitle, mt_commenttext) values (" & mt_id & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & mt_commenttitle & "','" & mt_commenttext & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close checkSub parentid, "A file '" & mt_title & "' has been unlocked in a folder you subscribe to" end if 'End of Check if FileUpload component is to be used end if elseif Upload_comp = True and upload_type="safileup" then Set oFileUp = Server.CreateObject("SoftArtisans.FileUp") oFileUp.Path = Server.MapPath(file_folder_temp) oFileUp.CreateNewFile = True oFileUp.OverWriteFiles = False fname_mt=oFileUp.Form("inpFile").ShortFileName oFileUp.Form("inpFile").SaveAs mt_path & "\" & fname_mt mt_filetodel=mt_path & "\" & replace(oFileUp.Form("ufname"),"'","''") if oFileUp.fileexists(mt_filetodel) then oFileUp.delete mt_filetodel end if mt_commenttitle="" mt_commenttext="" mt_commenttitle=replace(oFileUp.Form("mt_commenttitle"),"'","''") mt_commenttext=replace(oFileUp.Form("mt_commenttext"),"'","''") mt_commenttext=replace(mt_commenttext,chr(10),"
") mt_version=replace(oFileUp.Form("mt_version"),"'","''") mt_id=oFileUp.Form("mt_id") mt_title=replace(oFileUp.Form("title"),"'","''") mt_titledesc=replace(oFileUp.Form("titledesc"),"'","''") parentid=oFileUp.Form("parentid") mt_mt_version=replace(oFileUp.Form("mt_version"),"'","''") FileName = Right(oFileUp.Form("inpFile").ServerName,Len(oFileUp.Form("inpFile").ServerName)-InstrRev(oFileUp.Form("inpFile").ServerName,"\")) Set oFileUp = Nothing if mt_title="" then mt_title=FileName if mt_title="" then mt_title=FileName if FileName<>"" then if mt_title="" then mt_title=FileName mt_folderName=trim(replace(request.querystring("foldername"),"'","''")) Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "update tblfiles set description='" & mt_title & "', dateupdated = " & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ", updatedby='" & session("mt_username") & "', mt_locked = 0, mt_lockedby='', filename='" & Filename & "', mt_version='" & mt_version & "', titledesc='" & mt_titledesc & "' where id = " & mt_id mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close if mt_commenttext<>"" or mt_commenttitle<>"" then Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "insert into tblcomments (mt_commentfileid, mt_commentby, mt_commentdate, mt_commenttitle, mt_commenttext) values (" & mt_id & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & mt_commenttitle & "','" & mt_commenttext & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close checkSub parentid, "A file '" & mt_title & "' has been unlocked in a folder you subscribe to" end if 'End of Check if FileUpload component is to be used end if '************************************************ elseif Upload_comp = True and upload_type="persists" then Set Upload = Server.CreateObject("Persits.Upload") Upload.OverwriteFiles = False Upload.IgnoreNoPost = True Upload.Save mt_path mt_filetodel=mt_path & "\" & replace(Upload.Form("ufname"),"'","''") if upload.fileexists(mt_filetodel) then upload.deletefile mt_filetodel end if mt_commenttitle="" mt_commenttext="" mt_commenttitle=replace(Upload.Form("mt_commenttitle"),"'","''") mt_commenttext=replace(Upload.Form("mt_commenttext"),"'","''") mt_commenttext=replace(mt_commenttext,chr(10),"
") mt_version=replace(Upload.Form("mt_version"),"'","''") mt_id=Upload.Form("mt_id") mt_title=replace(Upload.Form("title"),"'","''") mt_titledesc=replace(Upload.Form("titledesc"),"'","''") parentid=Upload.Form("parentid") FilePathName = Upload.Files("inpFile").path FileName = Upload.Files("inpFile").filename if mt_title="" then mt_title=FileName if FileName<>"" then if mt_title="" then mt_title=FileName mt_folderName=trim(replace(request.querystring("foldername"),"'","''")) Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "update tblfiles set description='" & mt_title & "', dateupdated = " & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ", updatedby='" & session("mt_username") & "', mt_locked = 0, mt_lockedby='', filename='" & Filename & "', mt_version='" & mt_version & "', titledesc='" & mt_titledesc & "' where id = " & mt_id mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close if mt_commenttext<>"" or mt_commenttitle<>"" then Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "insert into tblcomments (mt_commentfileid, mt_commentby, mt_commentdate, mt_commenttitle, mt_commenttext) values (" & mt_id & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & mt_commenttitle & "','" & mt_commenttext & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close checkSub parentid, "A file '" & mt_title & "' has been unlocked in a folder you subscribe to" end if 'End of Check if FileUpload component is to be used end if else mt_title="" mt_titledesc="" mt_commenttitle="" mt_commenttext="" parentid=0 mt_version="" mt_id = 0 SaveUnlockFiles() Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "update tblfiles set description='" & mt_title & "', dateupdated = " & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ", updatedby='" & session("mt_username") & "', mt_locked = 0, mt_lockedby='', filename='" & Filename & "', mt_version='" & mt_version & "', titledesc='" & mt_titledesc & "' where id = " & mt_id mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close if mt_commenttext<>"" or mt_commenttitle<>"" then Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "insert into tblcomments (mt_commentfileid, mt_commentby, mt_commentdate, mt_commenttitle, mt_commenttext) values (" & mt_id & ",'" & session("mt_username") & "'," & mtCons_dbDel & mt_curdatetime & mtCons_dbDel & ",'" & mt_commenttitle & "','" & mt_commenttext & "')" mt_editCmd.CommandType = 1 mt_editCmd.CommandTimeout = 0 mt_editCmd.Prepared = true mt_editCmd.Execute() mt_editCmd.ActiveConnection.Close end if checkSub parentid, "A file '" & mt_title & "' has been unlocked in a folder you subscribe to" Response.Redirect "filelist.asp?parentid=" & parentid End If end if %> <% ' check if file to be locked if request.querystring("lock")="yes" and request.querystring("id")<>"" and session("mt_username")<>"" and session("mt_lockfiles")=1 then idtoupdate=request.querystring("id") Set mt_lockCmd = Server.CreateObject("ADODB.Command") mt_lockCmd.ActiveConnection = MM_conTT_STRING mt_lockCmd.CommandText = "update tblfiles set mt_locked=1, mt_lockedby='" & session("mt_username") & "' where id = " & idtoupdate mt_lockCmd.CommandType = 1 mt_lockCmd.CommandTimeout = 0 mt_lockCmd.Prepared = true mt_lockCmd.Execute() mt_lockCmd.ActiveConnection.Close checkSub parentid, "A file has been locked in a folder you subscribe to" end if %> <% 'update a folder if request.querystring("updateFolder")="yes" and request.querystring("editfoldername")<>"" and session("mt_addfolder")=1 then foldertoupdate=replace(request.querystring("editfoldername"),"'","''") folderdesctupdate=replace(request.querystring("editfolderdesc"),"'","''") folderidtoupdate=request.querystring("folderidtoupdate") Set mt_updatefoldercmd = Server.CreateObject("ADODB.Command") mt_updatefoldercmd.ActiveConnection = MM_conTT_STRING mt_updatefoldercmd.CommandText = "update tblfiles set description='" & foldertoupdate & "', titledesc='" & folderdesctupdate & "' where id = " & folderidtoupdate mt_updatefoldercmd.CommandType = 1 mt_updatefoldercmd.CommandTimeout = 0 mt_updatefoldercmd.Prepared = true mt_updatefoldercmd.Execute() mt_updatefoldercmd.ActiveConnection.Close response.redirect("filelist.asp?parentid=" & parentid) 'Add a folder elseif request.querystring("addFolder")="yes" and request.querystring("foldername")<>"" and session("mt_addfolder")=1 then mt_folderName=trim(replace(request.querystring("foldername"),"'","''")) mt_folderDesc="" & trim(replace(request.querystring("folderdesc"),"'","''")) Set mt_editCmd = Server.CreateObject("ADODB.Command") mt_editCmd.ActiveConnection = MM_conTT_STRING mt_editCmd.CommandText = "insert into tblfiles (description, titledesc, parentid, mt_type) values ('" & mt_folderName & "','" & mt_folderDesc & "'," & parentid & ", 0)" mt_editCmd.Execute mt_editCmd.ActiveConnection.Close checkSub parentid, "A folder named '" & mt_foldername & "' has been added to a folder you subscribe to" Set mt_GetNewFol = Server.CreateObject("ADODB.Recordset") mt_GetNewFol.ActiveConnection = MM_conTT_STRING mt_GetNewFol.Source = "SELECT max(ID) as mt_id FROM tblfiles where parentid=" & parentid & " and mt_type = 0 and description='" & mt_folderName & "'" mt_GetNewFol.CursorType = 0 mt_GetNewFol.CursorLocation = 2 mt_GetNewFol.LockType = 1 mt_GetNewFol.Open() mt_GetNewFolrecs=false if not(mt_GetNewFol.eof) then newfoldertoadd=trim(Cstr(mt_GetNewFol.fields.Item("mt_id").value)) 'response.write("'" & newfoldertoadd & "'
") session("mt_accessfolders")=session("mt_accessfolders") & "," & newfoldertoadd mt_GetNewFolrecs=true end if mt_GetNewFol.close set mt_GetNewFol=nothing if mt_GetNewFolrecs=true then 'now update the users details to allow them to view their own folder Set mt_updateusercmd = Server.CreateObject("ADODB.Command") mt_updateusercmd.ActiveConnection = MM_conTT_STRING mt_updateusercmd.CommandText = "update tblaccess set accessfolders='" & session("mt_accessfolders") & "' where mt_username='" & session("mt_username") & "' and id = " & session("mt_id") mt_updateusercmd.CommandType = 1 mt_updateusercmd.CommandTimeout = 0 mt_updateusercmd.Prepared = true mt_updateusercmd.Execute() mt_updateusercmd.ActiveConnection.Close if mtCascadeNewFolders = true and parentid<>0 then foldertoadd=parentid foldertoaddlength=len(trim(cstr(foldertoadd))) 'response.Buffer=false foldertoaddlengthm1=foldertoaddlength=-1 if foldertoaddlengthm1<0 then foldertoaddlengthm1="0" foldertoaddlengthm2=foldertoaddlength=-2 if foldertoaddlengthm2<0 then foldertoaddlengthm2="0" 'response.write(foldertoaddlengthm2) select case mtCons_dbType case "MsSQL" foldertoaddsql="SELECT id, accessfolders from tblaccess where (substring(accessfolders,1," & foldertoaddlength+1 & ") = '" & foldertoadd & ",' or " foldertoaddsql=foldertoaddsql & " substring(accessfolders,1," & foldertoaddlength & ") = '" & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " substring(accessfolders,1," & foldertoaddlength + 1 & ") = ' " & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " substring(accessfolders,1," & foldertoaddlength+2 & ") = ' " & foldertoadd & ",' or " foldertoaddsql=foldertoaddsql & " substring(accessfolders,datalength(accessfolders)-" & cint(foldertoaddlengthm1) & "," & foldertoaddlength+1 & ") = '," & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " substring(accessfolders,datalength(accessfolders)-" & cint(foldertoaddlengthm2) & ", " & foldertoaddlength+2 & ") = ', " & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " accessfolders like '%, " & foldertoadd & ",%' or " foldertoaddsql=foldertoaddsql & " accessfolders like '%," & foldertoadd & ",%') and id <> " & session("mt_id") Case else foldertoaddsql="SELECT id, accessfolders from tblaccess where (left(accessfolders," & foldertoaddlength+1 & ") = '" & foldertoadd & ",' or " foldertoaddsql=foldertoaddsql & " accessfolders = '" & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " accessfolders = ' " & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " left(accessfolders," & foldertoaddlength+2 & ") = ' " & foldertoadd & ",' or " foldertoaddsql=foldertoaddsql & " right(accessfolders," & foldertoaddlength+1 & ") = '," & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " right(accessfolders," & foldertoaddlength+2 & ") = ', " & foldertoadd & "' or " foldertoaddsql=foldertoaddsql & " accessfolders like '%, " & foldertoadd & ",%' or " foldertoaddsql=foldertoaddsql & " accessfolders like '%," & foldertoadd & ",%') and id <> " & session("mt_id") End Select 'response.write(foldertoaddsql) Set mt_UpdateFol = Server.CreateObject("ADODB.Recordset") mt_UpdateFol.ActiveConnection = MM_conTT_STRING mt_UpdateFol.Source = foldertoaddsql mt_UpdateFol.CursorType = 0 mt_UpdateFol.CursorLocation = 2 mt_UpdateFol.LockType = 1 mt_UpdateFol.Open() mt_UpdateFolrecs=false if not(mt_UpdateFol.eof) then mt_UpdateFolArr=mt_UpdateFol.getrows numUpdateFolrows=ubound(mt_UpdateFolArr,2) mt_UpdateFolrecs=true end if mt_UpdateFol.close set mt_UpdateFol=nothing if mt_UpdateFolrecs=true then for i = 0 to numUpdateFolrows Set mt_updateusercmd = Server.CreateObject("ADODB.Command") mt_updateusercmd.ActiveConnection = MM_conTT_STRING mt_updateusercmd.CommandText = "update tblaccess set accessfolders='" & mt_UpdateFolArr(1,i) & "," & newfoldertoadd & "' where id = " & mt_UpdateFolArr(0,i) mt_updateusercmd.CommandType = 1 mt_updateusercmd.CommandTimeout = 0 mt_updateusercmd.Prepared = true mt_updateusercmd.Execute() mt_updateusercmd.ActiveConnection.Close next end if end if end if Response.Redirect "filelist.asp?parentid=" & parentid end if %> <% sub getCurPath(curID) rsCurPath.Source = "SELECT ID, parentID, description, titledesc FROM tblfiles where id=" & curID rsCurPath.CursorType = 0 rsCurPath.CursorLocation = 2 rsCurPath.LockType = 1 rsCurPath.Open() If not rsCurPath.EOF then if curpath="" then folderidtoupdate=(rsCurPath.Fields.Item("id").Value) editfoldername=(rsCurPath.Fields.Item("description").Value) editfolderdesc=(rsCurPath.Fields.Item("titledesc").Value) end if curPath= "" & (rsCurPath.Fields.Item("description").Value) & "" & curpath curID=(rsCurPath.Fields.Item("parentid").Value) rsCurPath.Close call getCurPath(curID) end if end sub %> <% curPath="" curParentID=0 folderidtoupdate=0 editfoldername="" editfolderdesc="" if request.querystring("parentid")<>"" then curParentID=request.querystring("parentid") end if Set rsCurPath = Server.CreateObject("ADODB.Recordset") rsCurPath.ActiveConnection = MM_conTT_STRING curID=curParentID call getCurPath(curID) curPath="Root" & curPath rsCurPath.close set rsCurPath=nothing %> <% Set rsFiles = Server.CreateObject("ADODB.Recordset") rsFiles.ActiveConnection = MM_conTT_STRING If session("orderby")<>"" and session("dir")<>"" then select case session("orderby") case "description" ordersql=", description " & session("dir") case "datecreated" ordersql=", datecreated " & session("dir") case "lastcommentdate" ordersql=", Max(tblcomments.mt_commentdate) " & session("dir") case "mt_locked" ordersql=", mt_locked " & session("dir") case "mt_version" ordersql=", mt_version " & session("dir") case "dateupdated" ordersql=", dateupdated " & session("dir") case else ordersql=", description " & session("dir") end select else ordersql=", description " & session("dir") end if if mt_mustregister=false then rsFiles.Source = "SELECT tblfiles.id, tblfiles.parentid, tblfiles.mt_type, tblfiles.description, tblfiles.datecreated, tblfiles.createdby, tblfiles.dateupdated, tblfiles.updatedby, tblfiles.mt_action, tblfiles.mt_locked, tblfiles.mt_lockedby, tblfiles.filepath, tblfiles.filename, tblfiles.mt_version, Count(tblcomments.id) AS num, Max(tblcomments.mt_commentdate) AS lastcommentdate, tblfiles.titledesc FROM tblfiles LEFT JOIN tblcomments ON tblfiles.id = tblcomments.mt_commentfileid GROUP BY tblfiles.id, tblfiles.parentid, tblfiles.mt_type, tblfiles.description, tblfiles.datecreated, tblfiles.createdby, tblfiles.dateupdated, tblfiles.updatedby, tblfiles.mt_action, tblfiles.mt_locked, tblfiles.mt_lockedby, tblfiles.filepath, tblfiles.filename, tblfiles.mt_version, tblfiles.titledesc HAVING (tblfiles.parentid=" & curParentID & " AND tblfiles.mt_type=10 ) OR (tblfiles.parentid=" & curParentID &" AND tblfiles.mt_type=0 ) ORDER BY tblfiles.mt_type" & ordersql else 'response.buffer=false rsFiles.Source = "SELECT tblfiles.id, tblfiles.parentid, tblfiles.mt_type, tblfiles.description, tblfiles.datecreated, tblfiles.createdby, tblfiles.dateupdated, tblfiles.updatedby, tblfiles.mt_action, tblfiles.mt_locked, tblfiles.mt_lockedby, tblfiles.filepath, tblfiles.filename, tblfiles.mt_version, Count(tblcomments.id) AS num, Max(tblcomments.mt_commentdate) AS lastcommentdate, tblfiles.titledesc FROM tblfiles LEFT JOIN tblcomments ON tblfiles.id = tblcomments.mt_commentfileid GROUP BY tblfiles.id, tblfiles.parentid, tblfiles.mt_type, tblfiles.description, tblfiles.datecreated, tblfiles.createdby, tblfiles.dateupdated, tblfiles.updatedby, tblfiles.mt_action, tblfiles.mt_locked, tblfiles.mt_lockedby, tblfiles.filepath, tblfiles.filename, tblfiles.mt_version, tblfiles.titledesc HAVING (tblfiles.parentid=" & curParentID & " AND tblfiles.mt_type=10 and tblfiles.parentid in (" & session("mt_accessfolders") & ")) OR (tblfiles.parentid=" & curParentID &" AND tblfiles.mt_type=0 and tblfiles.id in (" & session("mt_accessfolders") & ")) ORDER BY tblfiles.mt_type" & ordersql 'response.write(rsFiles.Source) end if rsFiles.CursorType = 0 rsFiles.CursorLocation = 2 rsFiles.LockType = 1 rsFiles.Open() rsFilesRecords=false If not rsFiles.EOF then rsFilesRecords=True 'no records to display rsFilesArr=rsFiles.getrows numFilesrows=ubound(rsFilesArr,2) End If rsFiles.close Set rsFiles=nothing sHTML="" %> © Fixit Knowledge Solutions - Fixit DMS Pro "0" then response.write("onload=""javascript:mt_showHide('subscribe','addFile','addFolder','listFile','unlockFile','editfolder');return false;""")%>>
<%=curpath%> <% if mt_mustregister=false and session("mt_id")="0" and mt_allowuserregister = true then %> Subscribe to changes to this folder To subscribe to this folder, please register <% end if %> <% if session("mt_username")<>"" then %> Subscribe to changes to this folder Subscribe <% end if %> <% if session("mt_addusers")=1 then %> <% if session("mt_addfolder")=1 then %> Add new folder New folder <% if parentid<>0 then %> Edit folder Edit folder <% end if %> <% end if %> <% else %> <% if session("mt_addfolder")=1 and parentid<>0 then %> Add new folder New folder <% if parentid<>0 then %> Edit folder Edit folder <% end if %> <% end if %> <% end if %> <% if session("mt_addusers")=1 then %> <% if session("mt_addfiles")=1 then %> Add new document Add File <% end if %> <% else %> <% if session("mt_addfiles")=1 and parentid<>0 then %> Add new document Add File <% end if %> <% end if %>     

<% if error_message<>"" then response.write(error_message) end if %>

<% 'start of checking rsFilesRecords if rsFilesRecords = true then altRowCount=0 for i = 0 to numFilesrows altRowCount=altRowCount+1 if altRowCount mod 2 = 1 then trBG=" bgcolor=""#f7f7f7""" else trBG=" bgcolor=""#ffffff""" end if if rsFilesArr(2,i)=0 then %> > <% else %> > <% end if next erase rsFilesArr 'clear file list array %> <% else %> <% end if 'end of checking rsFilesRecords %>
  Title   Version   Created   Last comment   Comments Lock   Last update   Delete
><%=rsFilesArr(3,i)%><% if rsFilesArr(16,i)<>"" then %>
<%=rsFilesArr(16,i)%><% end if %>
      <% if session("mt_viewcomment")=1 or session("mt_addcomment")=1 then %> <% if cint(rsFilesArr(14,i))>0 and (session("mt_addcomment")=1 or session("mt_viewcomment")=1) then %> View<% if (session("mt_addcomment")=1) then%>/add <% end if %>(<%=rsFilesArr(14,i)%>) <% else %> <% if session("mt_addcomment")=1 then %>Add comment<% else %>n/a<% end if %> <% end if %> <% else %> n/a <% end if %>     <% if session("mt_deletefiles")=1 then %> <% else %> n/a <% end if %>
<% mt_filetype=right(rsFilesArr(12,i),4) select case mt_filetype case ".txt" fileimg="docimages/txt.gif" case ".doc" fileimg="docimages/doc.gif" case ".ppt",".pot" fileimg="docimages/ppt.gif" case ".xls" fileimg="docimages/xls.gif" case ".pdf" fileimg="docimages/pdf.gif" case ".mdb",".mda" fileimg="docimages/mdb.gif" case ".exe" fileimg="docimages/exe.gif" case ".msg" fileimg="docimages/msg.gif" case ".oft" fileimg="docimages/oft.gif" case ".jpg",".bmp",".gif" fileimg="docimages/paint.gif" case ".zip" fileimg="docimages/zip.gif" case else fileimg="docimages/txt.gif" end select %> <%=rsFilesArr(3,i)%><% if rsFilesArr(16,i)<>"" then %>
<%=rsFilesArr(16,i)%><% end if %>
<%=rsFilesArr(13,i)%> <%=dodatetime(rsFilesArr(4,i),0,mtDateLCID) & " by " & rsFilesArr(5,i)%> <% if rsFilesArr(15,i)<>"" then %> <%=dodatetime(rsFilesArr(15,i),0,mtDateLCID)%> <%else%> No comments <%end if %> <% if session("mt_viewcomment")=1 or session("mt_addcomment")=1 then %> <% if cint(rsFilesArr(14,i))>0 and (session("mt_addcomment")=1 or session("mt_viewcomment")=1) then %> View<% if (session("mt_addcomment")=1) then%>/add <% end if %>(<%=rsFilesArr(14,i)%>) <% else %> <% if session("mt_addcomment")=1 then %>Add comment<% else %>n/a<% end if %> <% end if %> <% else %> n/a <% end if %> <% if session("mt_lockfiles")=1 then %> <% if rsFilesArr(9,i)=1 and rsFilesArr(10,i)<>"" then %> ','<%=replace(rsFilesArr(12,i),"'","\'")%>','<%=replace(rsFilesArr(13,i),"'","\'")%>','<%=replace(rsFilesArr(0,i),"'","\'")%>','<%=replace(rsFilesArr(16,i),"'","\'")%>'); return false;">
by <%=rsFilesArr(10,i)%> <% else %> <% end if %> <% else %> <% if rsFilesArr(9,i)=1 and rsFilesArr(10,i)<>"" then %>
by <%=rsFilesArr(10,i)%> <% else %> <% end if %> <% end if %>
<%=dodatetime(rsFilesArr(6,i),0,mtDateLCID) & " by " & rsFilesArr(7,i)%> <% if session("mt_deletefiles")=1 then %> <% if rsFilesArr(9,i)<>"" and rsFilesArr(10,i)<>"" then %> <% else %> <% end if %> <% else %>n/a <% end if %>
 
 There are currently no folders or files within this directory