jqueryFileTree.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. //
  3. // jQuery File Tree PHP Connector
  4. //
  5. // Version 1.01
  6. //
  7. // Cory S.N. LaViska
  8. // A Beautiful Site (http://abeautifulsite.net/)
  9. // 24 March 2008
  10. //
  11. // History:
  12. //
  13. // 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
  14. // 1.00 - released (24 March 2008)
  15. //
  16. // Output a list of files for jQuery File Tree
  17. //
  18. $root = '/home/aqva2/domains/aqvatarius.com/public_html/themes/leo_v12/php/uploads/';
  19. $_POST['dir'] = urldecode($_POST['dir']);
  20. if( file_exists($root . $_POST['dir']) ) {
  21. $files = scandir($root . $_POST['dir']);
  22. natcasesort($files);
  23. if( count($files) > 2 ) { /* The 2 accounts for . and .. */
  24. echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
  25. // All dirs
  26. foreach( $files as $file ) {
  27. if( file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && is_dir($root . $_POST['dir'] . $file) && substr($file, 0, 1) != '.') {
  28. echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>";
  29. }
  30. }
  31. // All files
  32. foreach( $files as $file ) {
  33. if( file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && !is_dir($root . $_POST['dir'] . $file) ) {
  34. $ext = preg_replace('/^.*\./', '', $file);
  35. echo "<li class=\"file ext_$ext\"><a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>";
  36. }
  37. }
  38. echo "</ul>";
  39. }
  40. }
  41. ?>