Return to Snippet

Revision: 68644
at February 3, 2015 00:04 by brownrl


Initial Code
<?php

$callback = $_GET['CKEditorFuncNum'];

$root = "uploads/ck";

if (!is_dir($root)) {
	mkdir($root);
	chmod($root, 0777);
}

if (!is_dir($root)) {
	die("The uploads/ck does not exists and can not be created. run ./permissions?");
}

if (isset($_FILES['upload']) && !empty($_FILES['upload'])) {
	move_uploaded_file($_FILES['upload']['tmp_name'], $root . "/" . $_FILES['upload']['name']);
	chmod($root . "/" . $_FILES['upload']['name'], 0777);
	die('<html><body><script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $callback . ', "' . $root . "/" . $_FILES['upload']['name'] . '","' . $msg . '");</script></body></html>');
}

$files = scandir($root);
array_shift($files);
array_shift($files);

?>
<!DOCTYPE html>
<html lang=en-us>
  <head>
    <!-- KEEP THIS IN to avoid potential exploits. -->
    <meta charset="utf-8">
    <!-- Make it responsive for mobile sites. -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Filemanager</title>
    <!-- Key to filename:
        jqboot means uses jQuery and Bootstrap
        cdn means they're loaded from a CDN
        ec means error correction. I really meant error handling
        v0101 is the version number, 1.01. -->

    <!-- Obtain Bootstrap style sheet from CDN (online service) so it doesn't have to be on my machine -->
  <!-- Check http://www.bootstrapcdn.com/ for latest version. -->
  <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">

  </head>
  <body>

    <!-- Body of web page goes inside container tags -->
    <div class="container">
      <h1>Files</h1>

      <hr />


      <?php if (count($files)) {?>
      <ul>
        <?php foreach ($files as $file) {?>
            <li>
                <a href="#" onClick="window.opener.CKEDITOR.tools.callFunction(<?php echo $callback;?>, '<?php echo $root . "/" . $file;?>');window.close();return false;"><?php echo $file;?></a>
            </li>
        <?php }?>
      </ul>
      <?php }?>



    </div>
  <!-- NOTE: Seems to be best to keep this above window.onload -->
    <!-- Obtain the latest version of jquery from CDN -->
    <script src="http://code.jquery.com/jquery.min.js"></script>

  <!-- NOTE: Seems to be best to keep this above window.onload -->
    <!-- Obtain Bootstrap javascript library from CDN (online service) so it doesn't have to be on my machine -->
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>

  <script>
    // window.onload is only way to check if jQuery is missing,
    // because (document).ready() depnds on jQuery.
    // Put this before (document).ready()
    window.onload = function() {
      if (jQueryMissing()) {
        alert('jQuery is missing');
      }
    }

    //
    // App's event handling & command dispatch go here.
    // This is also where persistent variables would go.
    //
    $(document).ready(function() {
      if (bootstrapMissing()) {
        alert('Bootstrap is missing');
      }
    });

    // Utility functions

    // If Bootstrap isn't available return true,
    // otherwise return false.
    function bootstrapMissing() {
      return(!(typeof $().modal == 'function'));
    }

    // If jQuery isn't available, return true,
    // otherwise, return values
    // Call this only from window.onload
    function jQueryMissing() {
      return(typeof jQuery == 'undefined');
    }

  </script>
  </body>
</html>

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

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

Initial Title
CKEditor Simple Filemanager

Initial Tags

                                

Initial Language
PHP