DeleteFolder.php
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

Java

  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. $this->foldername=str_replace(array("..","/"),"",$_GET['FolderName']);
  32. }
  33. function run() {
  34. if ($this->delDir($this->real_cwd.'/'.$this->foldername)) {
  35. $err_no=0;
  36. } else {
  37. $err_no=402;
  38. }
  39. header ("content-type: text/xml");
  40. echo "<?xml version="1.0" encoding="utf-8" ?>n";
  41. ?>
  42. <Connector command="DeleteFolder" resourceType="<?php echo $this->type; ?>">
  43. <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  44. <Error number="<?php echo "".$err_no; ?>" />
  45. </Connector>
  46. <?php
  47. }
  48. function delDir($dir) {
  49. $dh=opendir($dir);
  50. if ($dh) {
  51. while ($entry=readdir($dh)) {
  52. if (($entry!=".")&&($entry!="..")) {
  53. if (is_dir($dir.'/'.$entry)) {
  54. $this->delDir($dir.'/'.$entry);
  55. } else {
  56. $thumb=$dir.'/.thumb_'.$entry;
  57. if (file_exists($thumb)) if (!unlink($thumb)) return false;
  58. if (!unlink($dir.'/'.$entry)) return false;
  59. }
  60. }
  61. }
  62. closedir($dh);
  63. return rmdir($dir);
  64. } else {
  65. return false;
  66. }
  67. }
  68. }
  69. ?>