I've got a DB driven connector... I'll hack it and... what, post the source to this thread? Shouldn't be too big... gotta download RC1 first tho, check out the changes...
I know Josh has been working on (and nearly completed?) a CF connector. I have it up and running and it's working fine. I'm still interested in figuring out how to change the upload location on it, but otherwise, seems to be great.
I'm not sure if Josh is still reading the list. He's been quiet recently.
Here is a little bit of code. I havn't seen Josh's stuff as yet, and I said I'd post this. Not the best place for it, but as we know, SF's forum leaves a little to be desired (this place still rocks, oc;), and I'm not so hip as to have to jump to look over my pelvis. Or have a personal site, for that matter. =] So I post this here.
Keep in mind, these file connectors are DANGEROUS!!! Not that anything is safe, but this will be a real concern as this project gets more widely used.
At any rate, here's a rudimentary CF connector, bad spelling and everything, no recursive delete, not much safe-guards, but functioning. I did this to test a theory of mine about how folders/subfolders are listed in the connector. Was it my crappy code or a querk, ya know? Eh. Here it is, non-renaming and all!
<!--- Turn off dubug output (it invalidates XML data if on) and set some defaults. Path is real path and URL is relative to site ---> <cfsetting showdebugoutput="no"> <cfset request.fckUserFolderPath = '/www/WEBSITES/den/UserFiles/'> <cfset request.fckUserFolderURL = '/den/UserFiles/'> <!--- just doesn't upload the below extentions. No sigh to user why not tho ---> <cfset deniedExtentions = ".exe .asp .php .aspx .js .cfm .dll .vbs .ws .vb"> <!--- defaults ---> <cfparam name="url.command" default="GetFoldersAndFiles"> <cfparam name="url.type" default="File"> <cfparam name="url.CurrentFolder" default="/">
<!--- Set 2 vars so we can do cleaning to request. Might want to check if requested folder even exists... one way to tell if someone is trying to inject things would be to keep a counter of 'bad' requests, and lockout... obviously not implimented =] ---> <cfset request.fckReqFolderPath = rereplace("#request.fckUserFolderPath#/#url.type#/#url.currentFolder#",'//','/','all')> <cfset request.fckReqFolderURL = rereplace("#request.fckUserFolderURL#/#url.type#/#url.currentFolder#",'//','/','all')>
<!--- Below are the commands. They are rudimentary and could be cleaned up A LOT ---> <cfif findNoCase('GetFolders',url.command)> <cfdirectory name="getFoldersAndFiles" directory="#request.fckReqFolderPath#" sort="name ASC, size DESC"> <cfquery name="getFolders" dbtype="query"> SELECT * FROM getFoldersAndFiles WHERE type = 'Dir' </cfquery> <cfquery name="getFiles" dbtype="query"> SELECT * FROM getFoldersAndFiles WHERE type != 'Dir' </cfquery>
<cfelseif url.command eq 'FileUpload'> <cfset request.fileResults = 0> <cfloop list="#deniedExtentions#" index="de" delimiters=" "> <cfif left(form.newFile,4) eq de><script language="javascript">alert('NOT ALLOWED');</script><cfabort></cfif> </cfloop> <cftry> <cffile action="upload" filefield="newFile" destination="#request.fckReqFolderPath#" nameconflict="makeunique"> <cfif file.ClientFile neq file.ServerFile> <cfset request.fileResults = "201,'#file.ServerFile#'"> </cfif> <cfcatch> <!--- SAMPLE: connector.ext?Command=FileUpload&Type=File&CurrentFolder=/Samples/Docs/ The "OnUploadCompleted" is a JavaScript function that is called to expose the upload result. The possible values are: o OnUploadCompleted( 0 ) : no errors found on the upload process. o OnUploadCompleted( 201, 'FileName(1).ext' ) : the file has been uploaded successfully, but it's name has been changed to "FileName(1).ext". o OnUploadCompleted( 202 ) : invalid file. ---> <cfoutput> <cfset request.fileResults = 202> </cfoutput> </cfcatch> </cftry> <script type="text/javascript"> window.parent.frames['frmUpload'].OnUploadCompleted(<cfoutput>#request.fileResults#</cfoutput>) ; </script>
I'll take the above and add some to it. We need mime-type try/catch on the file uploads for starters.
Is there a reason I'm missing that you surrounded, for example,
<cfset request.deleteFolderResults = 302>
in cfoutput tags? That should do nothing from what I can see. Actually I can't see that catch block doing anything outside of CF's control. Am I missing something or are you just knocking this out as a skeleton?
Not bad. I like the idea. Tried the code. Needs to have the < > changed back to <>, and the listcontains isn't working right. Also, with CF, if you don't use the <cfoutput query="'> format you have to set the index of the variable you want back. ie #GetFolders.someVar[LoopCount]... I can send you the mostly corrected code if you'd like. Think you'd be able to host this stuff? I've heard Josh's connector code showed up, maybe we can combine the best aspects of these and come up with something worthy?
I'm about to send Matt the revised revised code. I've added renamefile and renamefolder but renamefolder isn't working for some reason and I broke fileupload. Both are easy fixes I'm sure, I'm just at that point where I have to bang on plugins or something... maybe some procrastinated stuff... but anywayz...
The > was my bad, stoopid browser cut'n'paste. ;]
Easy to modify upload location at least... please ask Josh if it's ok to share his, as why reinvent the wheel, right?
At any rate, maybe we should try to get cvs stuff going or some such... we could ask the F-Man, or start a SF project on an SF project... won't be the first... =]
and yeah sure i'll host the code, but I'd want Frederico to incorporate it into the project, which I think is likely and best for all of us, of course.
Go ahead and send files to theking[at]mysecretbase.com. Forwarding thru my SF address will probably get bagged by my antispam.
I'll check the ListContains. has to be something dumb as I have that working for FCK 1.6.
You can't use cfoutput query="" for cfdirectory output? Sure you can. Its a query var (assuming thats what you are referring to) but if you have a different way to do it by all means lets use it.
Gotta have file uploads. Without 'em I'm dead in the water.
I've talked to Frederico and he's looking for a new CF guy, period. In our discussion he pointed me to this thread (I approached him independently) so whatever we come up with, if it works, I imagine it'll go in as official and won't start a fork.
I did a fair bit of testing with the code I had in the test harness FCK provides, and it seemed to spit out what it was supposed to, but no matter what would not find any files. I assume I was setting the origin pathways/urls wrong (they were on a totally separate tree) but didn't have time to go further. I got the same bad results with your file so it must have been my settings.
The code I sent you was working in all reguards except file upload and directory rename. The file upload works if you take it out the the try block, so it should be easy to fix. The directory rename might be becase I have the folder open or files in them open or some such, as I think I got the syntax correct.
I was referring to the age-old confusion about say this chunk of code: <cfloop query="fooQry"> #fooQry.varName# </cfloop>
that right there will generally give you the first record of the query, over and over and over again. Both of these next ones would give the expected results:
See? This little bit catches me every once in a while.
That's it. I'll download the lastest source off mysecretbase, and see if I can't get uploading and renameing working better. Won't be till later tho.. still recoving from a doul root canal. Ouch! =]
But are you saying it's not displaying folders and files and such, currently? The code I sent was working for me, excluding said uploads and dirRenames. Tried it in IE and Netscape. How's that for browser-compat testing? ;] I'm gonna go get firefox now, and then at least the main ones will be covered.
Maybe we can release stuff as patches... did the F-man say anything about CVS? That stuff I'd like to learn...
Maybe I'm too stoned to make sense of that best practices page... anyway, I had to add that[LoopCount] to keep from getting 'File','File','File','File' in the folder list loop, so either it wasn't scoped, or something...
You should have the code now... I'll figure out why the upload isn't working (unless it jumps out at you) later on tonight. I'd like to see the code Josh has come up with too...
The two file paths you set don't have anything to do with where FCKeditor is located, it is specifiing where the directory that contains these sub directories: Image/, File/,Flash/ and Media/ is. Like /www/FCKeditor/UserFolders/
Most of what I say is crap, prolly %80 percent, so I isn't surprised if I'm confusing. =] Thanks for the patience!
Very nice Rick! I think I'll include this with my next software release of CFWebstore, I've been including the various betas of V2 for my Firefox users to play with and I know they'll be thrilled to have a file browse/upload that works! I was able to pretty easily edit it to work without the users having to enter any configuration information but one thing I miss is the ability to preview the image...I'll have to look a bit further to see if this is available, but right now, if you click on either the image name or icon, it closes the form and dumps the image into the editor.
If I do end up using this long term, I"ll be glad to send you a donation for your work.
ouch! CF 5 compatibility is a must for me too. Big-time bummer.
In response to the folks who have asked me privately, I've been buried under work that gets the bills paid for awhile and haven't had a chance to touch the connector Denny and I were tinkering with. At some point in the near future I plan to come up with a cut-down version that matches FredCK's desired minimal feature set and offer it to him for inclusion in the final release.
I'll continue to keep the expanded version Denny made available via the above link, and anyone who wants a hot file manager and is using CF6+ can/should use Rick's excellent tool.
I am in the same boat, still using CF5. After some thought, I realized there is no reason I couldn't use a PHP or ASP connector for handling the upload, while the main editor was embedded within a CFM page.
I didn't try with ASP since my local development is running Apache, not IIS, but I got the PHP connector working in a matter of 10 minutes (had to hardcode the directorypaths etc) but otherwise it just worked. I would imagine the ASP would work as easily. If your running CF5 on windows, your probably already running IIS and ASP is there are waiting to be used, if your running CF5 on linux, well, PHP is usually installed by default, and is easily added if it's not...
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
bbl
RE: Coldfusion Connector - File Upload/View
I'm not sure if Josh is still reading the list. He's been quiet recently.
RE: Coldfusion Connector - File Upload/View
Keep in mind, these file connectors are DANGEROUS!!! Not that anything is safe, but this will be a real concern as this project gets more widely used.
At any rate, here's a rudimentary CF connector, bad spelling and everything, no recursive delete, not much safe-guards, but functioning. I did this to test a theory of mine about how folders/subfolders are listed in the connector. Was it my crappy code or a querk, ya know? Eh. Here it is, non-renaming and all!
<!--- Turn off dubug output (it invalidates XML data if on) and set some defaults. Path is real path and URL is relative to site --->
<cfsetting showdebugoutput="no">
<cfset request.fckUserFolderPath = '/www/WEBSITES/den/UserFiles/'>
<cfset request.fckUserFolderURL = '/den/UserFiles/'>
<!--- just doesn't upload the below extentions. No sigh to user why not tho --->
<cfset deniedExtentions = ".exe .asp .php .aspx .js .cfm .dll .vbs .ws .vb">
<!--- defaults --->
<cfparam name="url.command" default="GetFoldersAndFiles">
<cfparam name="url.type" default="File">
<cfparam name="url.CurrentFolder" default="/">
<!--- Set 2 vars so we can do cleaning to request. Might want to check if requested folder even exists... one way
to tell if someone is trying to inject things would be to keep a counter of 'bad' requests, and lockout... obviously not implimented =] --->
<cfset request.fckReqFolderPath = rereplace("#request.fckUserFolderPath#/#url.type#/#url.currentFolder#",'//','/','all')>
<cfset request.fckReqFolderURL = rereplace("#request.fckUserFolderURL#/#url.type#/#url.currentFolder#",'//','/','all')>
<!--- Below are the commands. They are rudimentary and could be cleaned up A LOT --->
<cfif findNoCase('GetFolders',url.command)>
<cfdirectory name="getFoldersAndFiles" directory="#request.fckReqFolderPath#" sort="name ASC, size DESC">
<cfquery name="getFolders" dbtype="query">
SELECT * FROM getFoldersAndFiles WHERE type = 'Dir'
</cfquery>
<cfquery name="getFiles" dbtype="query">
SELECT * FROM getFoldersAndFiles WHERE type != 'Dir'
</cfquery>
<cfset daFile = '<?xml version="1.0" encoding="utf-8" ?><Connector command="#url.command#" resourceType="#url.type#">
<CurrentFolder path="#url.currentFolder#" url="#request.fckUserFolderURL#/#url.type##url.currentFolder#/" />
<Folders>'>
<cfloop query="getFolders">
<cfset daFile = daFile & '<Folder name="#name#" />'>
</cfloop>
<cfset daFile = daFile & '</Folders>'>
<cfif findNoCase('AndFiles',url.command)>
<cfset daFile = daFile & '<Files>'>
<cfloop query="getFiles">
<cfset daFile = daFile & '<File name="#name#" size="#size#" />'>
</cfloop>
<cfset daFile = daFile & '</Files>'>
</cfif>
<cfset daFile = daFile & '</Connector>'>
<cfoutput><cfcontent type="text/xml">#daFile#</cfoutput>
<cfelseif url.command eq 'CreateFolder'>
<cfdirectory name="getFoldersAndFiles" directory="#request.fckUserFolderPATH#/#type#/#url.currentFolder#" sort="name ASC, size DESC">
<cfquery name="getFolders" dbtype="query">
SELECT * FROM getFoldersAndFiles WHERE type = 'Dir'
</cfquery>
<cfset daError = 0>
<cftry>
<cfdirectory name="CreateFolder" action="create" directory="#request.fckUserFolderPATH#/#type#/#url.currentFolder#/#url.newFolderName#">
<cfcatch>
<!---
Possible Error Numbers are:
o 0 : No Errors Found. The folder has been created.
o 101 : Folder already exists.
o 102 : Invalid folder name.
o 103 : You have no permissions to create the folder.
o 110 : Unknown error creating folder.
--->
<cfif findNoCase('could not be created',CFCATCH.Message)>
<cfif listFindNoCase(valuelist(getFolders.name),url.newFolderName)>
<cfset daError = 101>
<cfelseif findOneOf('?><"/\:*',url.newFolderName)>
<cfset daError = 102>
<cfelse>
<cfset daError = 110>
</cfif>
</cfif>
</cfcatch>
</cftry>
<cfset daFile = '<?xml version="1.0" encoding="utf-8" ?><Connector command="#url.command#" resourceType="#url.type#">
<CurrentFolder path="#url.currentFolder#" url="#request.fckReqFolderURL#/" />'>
<cfset daFile = daFile & '<Error number="#daError#" />'>
<cfset daFile = daFile & '</Connector>'>
<cfoutput><cfcontent type="text/xml">#daFile#</cfoutput>
<cfelseif url.command eq 'FileUpload'>
<cfset request.fileResults = 0>
<cfloop list="#deniedExtentions#" index="de" delimiters=" ">
<cfif left(form.newFile,4) eq de><script language="javascript">alert('NOT ALLOWED');</script><cfabort></cfif>
</cfloop>
<cftry>
<cffile action="upload" filefield="newFile" destination="#request.fckReqFolderPath#" nameconflict="makeunique">
<cfif file.ClientFile neq file.ServerFile>
<cfset request.fileResults = "201,'#file.ServerFile#'">
</cfif>
<cfcatch>
<!--- SAMPLE: connector.ext?Command=FileUpload&Type=File&CurrentFolder=/Samples/Docs/
The "OnUploadCompleted" is a JavaScript function that is called to expose the upload result. The possible values are:
o OnUploadCompleted( 0 ) : no errors found on the upload process.
o OnUploadCompleted( 201, 'FileName(1).ext' ) : the file has been uploaded successfully, but it's name has been changed to "FileName(1).ext".
o OnUploadCompleted( 202 ) : invalid file. --->
<cfoutput>
<cfset request.fileResults = 202>
</cfoutput>
</cfcatch>
</cftry>
<script type="text/javascript">
window.parent.frames['frmUpload'].OnUploadCompleted(<cfoutput>#request.fileResults#</cfoutput>) ;
</script>
<cfelseif url.command eq 'DeleteFile'>
<cfset request.deleteFileResults = 0>
<cftry>
<cffile action="delete" file="#request.fckReqFolderPath##url.FileName#">
<cfcatch>
<!--- SAMPLE: connector.ext?Command=DeleteFile&Type=File&CurrentFolder=/Docs/&FileName=archive.zip
* 0 : No Errors. File deleted successfully
* 302 : Failed to delete file --->
<cfoutput>
<cfset request.deleteFileResults = 302>
</cfoutput>
<cfabort>
</cfcatch>
</cftry>
<cfset daFile = '<?xml version="1.0" encoding="utf-8" ?><Connector command="#url.command#" resourceType="#url.type#">
<CurrentFolder path="#url.currentFolder#" url="#request.fckReqFolderURL#/" />'>
<cfset daFile = daFile & '<Error number="#request.deleteFileResults#" />'>
<cfset daFile = daFile & '</Connector>'>
<cfoutput><cfcontent type="text/xml">#daFile#</cfoutput>
<cfelseif url.command eq 'DeleteFolder'>
<cfset request.deleteFolderResults = 0>
<cftry>
<cfdirectory action="delete" directory="#request.fckReqFolderPath##url.FolderName#">
<cfcatch>
<cfoutput>
<cfset request.deleteFolderResults = 302>
</cfoutput>
<cfabort>
</cfcatch>
</cftry>
<cfset daFile = '<?xml version="1.0" encoding="utf-8" ?><Connector command="#url.command#" resourceType="#url.type#">
<CurrentFolder path="#url.currentFolder#" url="#request.fckReqFolderURL#/" />'>
<cfset daFile = daFile & '<Error number="#request.deleteFolderResults#" />'>
<cfset daFile = daFile & '</Connector>'>
<cfoutput><cfcontent type="text/xml">#daFile#</cfoutput>
</cfif>
RE: Coldfusion Connector - File Upload/View
I'll take the above and add some to it. We need mime-type try/catch on the file uploads for starters.
Is there a reason I'm missing that you surrounded, for example,
<cfset request.deleteFolderResults = 302>
in cfoutput tags? That should do nothing from what I can see. Actually I can't see that catch block doing anything outside of CF's control. Am I missing something or are you just knocking this out as a skeleton?
RE: Coldfusion Connector - File Upload/View
http://mysecretbase.com/connector2.txt
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
Any luck on being able to change the upload location with the CF connector? That's really important to me, but I've yet to figure out how to do it.
Jake
RE: Coldfusion Connector - File Upload/View
Seems kopesetic if it's kewl with the creator. Maybe we could put all these together and come up with a working connector!
And maybe Matt will host the code for us?
RE: Coldfusion Connector - File Upload/View
The > was my bad, stoopid browser cut'n'paste. ;]
Easy to modify upload location at least... please ask Josh if it's ok to share his, as why reinvent the wheel, right?
At any rate, maybe we should try to get cvs stuff going or some such... we could ask the F-Man, or start a SF project on an SF project... won't be the first... =]
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
Go ahead and send files to theking[at]mysecretbase.com. Forwarding thru my SF address will probably get bagged by my antispam.
I'll check the ListContains. has to be something dumb as I have that working for FCK 1.6.
You can't use cfoutput query="" for cfdirectory output? Sure you can. Its a query var (assuming thats what you are referring to) but if you have a different way to do it by all means lets use it.
Gotta have file uploads. Without 'em I'm dead in the water.
I've talked to Frederico and he's looking for a new CF guy, period. In our discussion he pointed me to this thread (I approached him independently) so whatever we come up with, if it works, I imagine it'll go in as official and won't start a fork.
I did a fair bit of testing with the code I had in the test harness FCK provides, and it seemed to spit out what it was supposed to, but no matter what would not find any files. I assume I was setting the origin pathways/urls wrong (they were on a totally separate tree) but didn't have time to go further. I got the same bad results with your file so it must have been my settings.
RE: Coldfusion Connector - File Upload/View
I was referring to the age-old confusion about say this chunk of code:
<cfloop query="fooQry">
#fooQry.varName#
</cfloop>
that right there will generally give you the first record of the query, over and over and over again. Both of these next ones would give the expected results:
<cfloop query="fooQry">
#fooQry.varName[currentrow]#
</cfloop>
OR
<cfloop query="fooQry">
#varName#
</cfloop>
See? This little bit catches me every once in a while.
That's it. I'll download the lastest source off mysecretbase, and see if I can't get uploading and renameing working better. Won't be till later tho.. still recoving from a doul root canal. Ouch! =]
But are you saying it's not displaying folders and files and such, currently? The code I sent was working for me, excluding said uploads and dirRenames. Tried it in IE and Netscape. How's that for browser-compat testing? ;] I'm gonna go get firefox now, and then at least the main ones will be covered.
Maybe we can release stuff as patches... did the F-man say anything about CVS? That stuff I'd like to learn...
RE: Coldfusion Connector - File Upload/View
http://livedocs.macromedia.com/coldfusi ... #wp1101138
RE: Coldfusion Connector - File Upload/View
You should have the code now... I'll figure out why the upload isn't working (unless it jumps out at you) later on tonight. I'd like to see the code Josh has come up with too...
The two file paths you set don't have anything to do with where FCKeditor is located, it is specifiing where the directory that contains these sub directories: Image/, File/,Flash/ and Media/ is.
Like /www/FCKeditor/UserFolders/
Most of what I say is crap, prolly %80 percent, so I isn't surprised if I'm confusing. =] Thanks for the patience!
RE: Coldfusion Connector - File Upload/View
http://www.unm.edu/~dvalliant/FCKeditor/
RE: Coldfusion Connector - File Upload/View
http://mysecretbase.com/connector2.txt
RE: Coldfusion Connector - File Upload/View
http://www.webworksllc.com/cffm
RE: Coldfusion Connector - File Upload/View
Sent you message. I'm interested in taking a look at the connector.
Thanks!
RE: Coldfusion Connector - File Upload/View
Count me in, please! I'll drop you a line off list.
RE: Coldfusion Connector - File Upload/View
http://www.webworksllc.com/cffm
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
If I do end up using this long term, I"ll be glad to send you a donation for your work.
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
http://www.webworksllc.com/filemanager/
RE: Coldfusion Connector - File Upload/View
RE: Coldfusion Connector - File Upload/View
http://www.webworksllc.com/cffm
RE: Coldfusion Connector - File Upload/View
In response to the folks who have asked me privately, I've been buried under work that gets the bills paid for awhile and haven't had a chance to touch the connector Denny and I were tinkering with. At some point in the near future I plan to come up with a cut-down version that matches FredCK's desired minimal feature set and offer it to him for inclusion in the final release.
I'll continue to keep the expanded version Denny made available via the above link, and anyone who wants a hot file manager and is using CF6+ can/should use Rick's excellent tool.
RE: Coldfusion Connector - File Upload/View
I didn't try with ASP since my local development is running Apache, not IIS, but I got the PHP connector working in a matter of 10 minutes (had to hardcode the directorypaths etc) but otherwise it just worked. I would imagine the ASP would work as easily. If your running CF5 on windows, your probably already running IIS and ASP is there are waiting to be used, if your running CF5 on linux, well, PHP is usually installed by default, and is easily added if it's not...