Posted By

brownrl on 02/03/15


Tagged

ckeditor filemanger


Versions (?)

CKEditor Simple Filemanager


 / Published in: PHP
 

URL: https://www.itsgotto.be/cv

This is a plain jane very simple file manager for ckeditor, this has very limited... ^NO^ features.

  1. <?php
  2.  
  3. $callback = $_GET['CKEditorFuncNum'];
  4.  
  5. $root = "uploads/ck";
  6.  
  7. if (!is_dir($root)) {
  8. mkdir($root);
  9. chmod($root, 0777);
  10. }
  11.  
  12. if (!is_dir($root)) {
  13. die("The uploads/ck does not exists and can not be created. run ./permissions?");
  14. }
  15.  
  16. if (isset($_FILES['upload']) && !empty($_FILES['upload'])) {
  17. move_uploaded_file($_FILES['upload']['tmp_name'], $root . "/" . $_FILES['upload']['name']);
  18. chmod($root . "/" . $_FILES['upload']['name'], 0777);
  19. die('<html><body><script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $callback . ', "' . $root . "/" . $_FILES['upload']['name'] . '","' . $msg . '");</script></body></html>');
  20. }
  21.  
  22. $files = scandir($root);
  23. array_shift($files);
  24. array_shift($files);
  25.  
  26. ?>
  27. <!DOCTYPE html>
  28. <html lang=en-us>
  29. <head>
  30. <!-- KEEP THIS IN to avoid potential exploits. -->
  31. <meta charset="utf-8">
  32. <!-- Make it responsive for mobile sites. -->
  33. <meta name="viewport" content="width=device-width, initial-scale=1">
  34. <title>Filemanager</title>
  35. <!-- Key to filename:
  36. jqboot means uses jQuery and Bootstrap
  37. cdn means they're loaded from a CDN
  38. ec means error correction. I really meant error handling
  39. v0101 is the version number, 1.01. -->
  40.  
  41. <!-- Obtain Bootstrap style sheet from CDN (online service) so it doesn't have to be on my machine -->
  42. <!-- Check http://www.bootstrapcdn.com/ for latest version. -->
  43. <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
  44.  
  45. </head>
  46. <body>
  47.  
  48. <!-- Body of web page goes inside container tags -->
  49. <div class="container">
  50. <h1>Files</h1>
  51.  
  52. <hr />
  53.  
  54.  
  55. <?php if (count($files)) {?>
  56. <ul>
  57. <?php foreach ($files as $file) {?>
  58. <li>
  59. <a href="#" onClick="window.opener.CKEDITOR.tools.callFunction(<?php echo $callback;?>, '<?php echo $root . "/" . $file;?>');window.close();return false;"><?php echo $file;?></a>
  60. </li>
  61. <?php }?>
  62. </ul>
  63. <?php }?>
  64.  
  65.  
  66.  
  67. </div>
  68. <!-- NOTE: Seems to be best to keep this above window.onload -->
  69. <!-- Obtain the latest version of jquery from CDN -->
  70. <script src="http://code.jquery.com/jquery.min.js"></script>
  71.  
  72. <!-- NOTE: Seems to be best to keep this above window.onload -->
  73. <!-- Obtain Bootstrap javascript library from CDN (online service) so it doesn't have to be on my machine -->
  74. <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
  75.  
  76. <script>
  77. // window.onload is only way to check if jQuery is missing,
  78. // because (document).ready() depnds on jQuery.
  79. // Put this before (document).ready()
  80. window.onload = function() {
  81. if (jQueryMissing()) {
  82. alert('jQuery is missing');
  83. }
  84. }
  85.  
  86. //
  87. // App's event handling & command dispatch go here.
  88. // This is also where persistent variables would go.
  89. //
  90. $(document).ready(function() {
  91. if (bootstrapMissing()) {
  92. alert('Bootstrap is missing');
  93. }
  94. });
  95.  
  96. // Utility functions
  97.  
  98. // If Bootstrap isn't available return true,
  99. // otherwise return false.
  100. function bootstrapMissing() {
  101. return(!(typeof $().modal == 'function'));
  102. }
  103.  
  104. // If jQuery isn't available, return true,
  105. // otherwise, return values
  106. // Call this only from window.onload
  107. function jQueryMissing() {
  108. return(typeof jQuery == 'undefined');
  109. }
  110.  
  111. </script>
  112. </body>
  113. </html>

Report this snippet  

You need to login to post a comment.