root/trunk/website/blog/admin/filemanager.cfm

Revision 5, 4.5 kB (checked in by DanWilson, 17 years ago)

Initial Commit Of ModelGlue? Website (upgrade to blogcfc 511)

Line 
1<cfsetting enablecfoutputonly=true>
2<cfprocessingdirective pageencoding="utf-8">
3<!---
4        Name         : /client/admin/filemanager.cfm
5        Author       : Raymond Camden
6        Created      : 09/14/06
7        Last Updated : 3/9/07
8        History      : Removed UDF to udf.cfm (rkc 11/29/06)
9                                 : Check filebrowse prop (rkc 12/12/06)
10                                 : Security fix (rkc 3/9/07)
11--->
12
13<cfif not application.filebrowse>
14        <cflocation url="index.cfm" addToken="false">
15</cfif>
16
17<cfset rootDirectory = getDirectoryFromPath(getCurrentTemplatePath())>
18<cfset rootDirectory = reReplaceNoCase(rootDirectory, "[\\/]admin", "")>
19<cfparam name="url.dir" default="/">
20
21<!--- do not allow any .. --->
22<cfif find("..", url.dir)>
23        <cfset url.dir = "/">
24</cfif>
25
26<cfset currentDirectory = rootDirectory & url.dir>
27
28<cfif structKeyExists(url, "download")>
29        <cfset fullfile = currentDirectory & url.download>
30        <cfif fileExists(fullFile)>
31                <cfheader name="Content-disposition" value="attachment;filename=#url.download#">               
32                <cfcontent file="#fullfile#" type="application/unknown">               
33        </cfif>
34</cfif>
35
36<cfif structKeyExists(url, "delete")>
37        <cfset fullfile = currentDirectory & url.delete>
38        <cfif fileExists(fullFile)>
39                <cffile action="delete" file="#fullfile#">
40        </cfif>
41</cfif>
42
43<cfif structKeyExists(form, "cancel")>
44        <cflocation url="index.cfm" addToken="false">
45</cfif>
46
47<cfif structKeyExists(form, "fileupload")>
48        <cffile action="upload" filefield="form.newfile" destination="#currentDirectory#" nameconflict="overwrite">
49</cfif>
50
51<cfmodule template="../tags/adminlayout.cfm" title="File Manager">
52
53        <cfoutput>
54        <p>
55        This tool lets you manage the files on your blog. <b>WARNING: Deletes are FINAL.</b>
56        If you do not know what you are doing, step away from the browser.
57        </p>
58        </cfoutput>
59       
60        <cfif structKeyExists(variables, "errors") and arrayLen(errors)>
61                <cfoutput>
62                <div class="errors">
63                Please correct the following error(s):
64                <ul>
65                <cfloop index="x" from="1" to="#arrayLen(errors)#">
66                <li>#errors[x]#</li>
67                </cfloop>
68                </ul>
69                </div>
70                </cfoutput>
71        </cfif>
72
73        <cfdirectory name="files" directory="#currentDirectory#" sort="type asc">
74       
75        <cfoutput>
76        <table border="1" width="100%">
77                <tr bgcolor="##e0e0e0">
78                        <td colspan="3"><b>Current Directory:</b> #url.dir#</td>
79                        <td align="center">
80                        <cfif url.dir is not "/">
81                        <cfset higherdir = replace(url.dir, "/" & listLast(currentDirectory, "/"), "")>
82                        <a href="filemanager.cfm?dir=#higherdir#"><img src="#application.rooturl#/images/arrow_up.png" title="Go up one directory" border="0"></a>
83                        <cfelse>
84                        &nbsp;
85                        </cfif>
86                        </td>
87                </tr>
88                <cfloop query="files">
89                <tr <cfif currentRow mod 2>bgcolor="##fffecf"</cfif>>
90                        <td>
91                        <cfif type is "Dir">
92                                <img src="#application.rooturl#/images/folder.png"> <a href="filemanager.cfm?dir=#url.dir##urlencodedformat(name)#/">#name#</a>
93                        <cfelse>
94                                <cfswitch expression="#listLast(name,".")#">
95                                        <cfcase value="xls,ods">
96                                                <cfset img = "page_white_excel.png">
97                                        </cfcase>
98                                        <cfcase value="ppt">
99                                                <cfset img = "page_white_powerpoint.png">
100                                        </cfcase>
101                                        <cfcase value="doc,odt">
102                                                <cfset img = "page_white_word.png">
103                                        </cfcase>                                                                               
104                                        <cfcase value="cfm">
105                                                <cfset img = "page_white_coldfusion.png">
106                                        </cfcase>
107                                        <cfcase value="zip">
108                                                <cfset img = "page_white_compressed.png">
109                                        </cfcase>
110                                        <cfcase value="gif,jpg,png">
111                                                <cfset img = "photo.png">
112                                        </cfcase>
113                                        <cfdefaultcase>
114                                                <cfset img = "page_white_text.png">
115                                        </cfdefaultcase>
116                                       
117                                </cfswitch>
118
119                                <img src="#application.rooturl#/images/#img#"> #name#
120
121                        </cfif>
122                        </td>
123                        <td><cfif type is not "Dir">#kbytes(size)#<cfelse>&nbsp;</cfif></td>
124                        <td>#dateFormat(datelastmodified)# #timeFormat(datelastmodified)#</td>
125                        <td width="50" align="center">
126                        <cfif type is not "Dir">
127                                <a href="filemanager.cfm?dir=#urlencodedformat(url.dir)#&download=#urlEncodedFormat(name)#"><img src="#application.rooturl#/images/disk.png" border="0" title="Download"></a>
128                                <a href="filemanager.cfm?dir=#urlencodedformat(url.dir)#&delete=#urlEncodedFormat(name)#" onClick="return confirm('Are you sure?')"><img src="#application.rooturl#/images/bin_closed.png" border="0" title="Delete"></a>
129                        <cfelse>
130                                &nbsp;
131                        </cfif>
132                        </td>
133                </tr>
134                </cfloop>
135                <tr>
136                        <td colspan="4" align="right">
137                        <form action="filemanager.cfm?dir=#urlencodedformat(url.dir)#" method="post" enctype="multipart/form-data">
138                        <input type="file" name="newfile"> <input type="submit" name="fileupload" value="Upload File">
139                        </form>
140                        </td>
141                </tr>
142        </table>
143        </cfoutput>
144               
145</cfmodule>
146
147<cfsetting enablecfoutputonly=false>
Note: See TracBrowser for help on using the browser.