/_plugins_/tinymce/tinymce_1_9_1_et_plus/files/filemanager/InsertFile/functions.php

https://bitbucket.org/pombredanne/spip-zone-treemap · PHP · 60 lines · 47 code · 4 blank · 9 comment · 9 complexity · b7f2493c09b40ecda2d2b494f2b069a7 MD5 · raw file

  1. <?php
  2. /***********************************************************************
  3. ** Title.........: Insert File Dialog, File Manager
  4. ** Version.......: 1.1
  5. ** Authors.......: Al Rashid <alrashid@klokan.sk>
  6. ** Xiang Wei ZHUO <wei@zhuo.org>
  7. ** Filename......: functions.php
  8. ** URL...........: http://alrashid.klokan.sk/insFile/
  9. ** Last changed..: 23 July 2004
  10. ***********************************************************************/
  11. function dirs($dir,$abs_path) {
  12. $d = dir($dir);
  13. $dirs = array();
  14. while (false !== ($entry = $d->read())) {
  15. if(is_dir($dir.'/'.$entry) && substr($entry,0,1) != '.') {
  16. $path['path'] = $dir.'/'.$entry;
  17. $path['name'] = $entry;
  18. $dirs[$entry] = $path;
  19. }
  20. }
  21. $d->close();
  22. ksort($dirs);
  23. $cntDir = count($dirs);
  24. for($i=0; $i<$cntDir; $i++) {
  25. $name = key($dirs);
  26. $current_dir = $abs_path.'/'.$dirs[$name]['name'];
  27. echo ", '".sanitize($current_dir)."/'\n";
  28. dirs($dirs[$name]['path'],$current_dir);
  29. next($dirs);
  30. }
  31. }
  32. function checkName($name) {
  33. $name = str_replace('../', '', $name);
  34. $name = str_replace('./', '', $name);
  35. $accent = 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËéèêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ "&()[]$£%,?;:!§\'';
  36. $noaccent='AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn-----------------';
  37. $name = strtr($name,$accent,$noaccent);
  38. $name = stripslashes($name);
  39. return $name;
  40. }
  41. function sanitize($name) {
  42. return str_replace("'", "\'", $name);
  43. }
  44. function unsanitize($name) {
  45. return str_replace("\'", "'", $name);
  46. }
  47. function pathSlashes($path) {
  48. if ('/' != substr($path,0,1)) $path = '/'.$path;
  49. if ('/' != substr($path,-1,1)) $path = $path.'/';
  50. return $path;
  51. }
  52. function alertSanitize($path) {
  53. return ( sanitize(str_replace("\\", "\\\\", $path)) );
  54. }
  55. ?>