PageRenderTime 32ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/4.6/mambots/editors/mostlyce/jscripts/tiny_mce/filemanager/connectors/php/Commands/DeleteFolder.php

http://miacms.googlecode.com/
PHP | 85 lines | 59 code | 9 blank | 17 comment | 14 complexity | db56a820eb6b772c26d0cd490161fd6b MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, LGPL-2.0
  1. <?php
  2. /*
  3. * FCKeditor - The text editor for internet
  4. * Copyright (C) 2003-2005 Frederico Caldeira Knabben
  5. *
  6. * Licensed under the terms of the GNU Lesser General Public License:
  7. * http://www.opensource.org/licenses/lgpl-license.php
  8. *
  9. * For further information visit:
  10. * http://www.fckeditor.net/
  11. *
  12. * File Name: DeleteFolder.php
  13. * Implements the DeleteFolder command to delete a folder
  14. * in the current directory. Output is in XML.
  15. *
  16. * File Authors:
  17. * Grant French (grant@mcpuk.net)
  18. */
  19. class DeleteFolder {
  20. var $fckphp_config;
  21. var $type;
  22. var $cwd;
  23. var $actual_cwd;
  24. var $newfolder;
  25. function DeleteFolder($fckphp_config,$type,$cwd) {
  26. $this->fckphp_config=$fckphp_config;
  27. $this->type=$type;
  28. $this->raw_cwd=$cwd;
  29. $this->actual_cwd=str_replace("//","/",($this->fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
  30. $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
  31. if (isset($_GET['FolderName'])) {
  32. $this->foldername=str_replace(array("..","/"),"",$_GET['FolderName']);
  33. } else {
  34. $this->foldername='';
  35. }
  36. }
  37. function run() {
  38. if ($this->delDir($this->real_cwd.'/'.$this->foldername)) {
  39. $err_no=0;
  40. } else {
  41. $err_no=402;
  42. }
  43. header ("content-type: text/xml");
  44. echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
  45. ?>
  46. <Connector command="DeleteFolder" resourceType="<?php echo $this->type; ?>">
  47. <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  48. <Error number="<?php echo "".$err_no; ?>" />
  49. </Connector>
  50. <?php
  51. }
  52. function delDir($dir) {
  53. if (!is_dir($dir)) {
  54. return false;
  55. }
  56. $dh=opendir($dir);
  57. if ($dh) {
  58. while ($entry=readdir($dh)) {
  59. if (($entry!=".")&&($entry!="..")) {
  60. if (is_dir($dir.'/'.$entry)) {
  61. $this->delDir($dir.'/'.$entry);
  62. } else {
  63. $thumb=$dir.'/.thumb_'.$entry;
  64. if (file_exists($thumb)) if (!unlink($thumb)) return false;
  65. if (!unlink($dir.'/'.$entry)) return false;
  66. }
  67. }
  68. }
  69. closedir($dh);
  70. return rmdir($dir);
  71. } else {
  72. return false;
  73. }
  74. }
  75. }
  76. ?>