[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/editors/mostlyce/jscripts/tiny_mce/filemanager/connectors/php/Commands/ -> DeleteFolder.php (source)

   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  
  20  class DeleteFolder {
  21      var $fckphp_config;
  22      var $type;
  23      var $cwd;
  24      var $actual_cwd;
  25      var $newfolder;
  26      
  27  	function DeleteFolder($fckphp_config,$type,$cwd) {
  28          $this->fckphp_config=$fckphp_config;
  29          $this->type=$type;
  30          $this->raw_cwd=$cwd;
  31          $this->actual_cwd=str_replace("//","/",($this->fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
  32          $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
  33          if (isset($_GET['FolderName'])) {
  34              $this->foldername=str_replace(array("..","/"),"",$_GET['FolderName']);
  35          } else {
  36              $this->foldername='';
  37          }
  38      }
  39      
  40  	function run() {
  41          
  42          if ($this->delDir($this->real_cwd.'/'.$this->foldername)) {
  43              $err_no=0;
  44          } else {
  45              $err_no=402;
  46          }
  47          
  48          header ("content-type: text/xml");
  49          echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
  50          ?>
  51  <Connector command="DeleteFolder" resourceType="<?php echo $this->type; ?>">
  52      <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  53      <Error number="<?php echo "".$err_no; ?>" />
  54  </Connector>
  55          <?php
  56      }
  57      
  58      
  59  	function delDir($dir) {
  60          if (!is_dir($dir)) {
  61              return false;
  62          }
  63          
  64          $dh=opendir($dir);
  65          if ($dh) {
  66              while ($entry=readdir($dh)) {
  67                  if (($entry!=".")&&($entry!="..")) {
  68                      if (is_dir($dir.'/'.$entry)) {
  69                          $this->delDir($dir.'/'.$entry);    
  70                      } else {
  71                          $thumb=$dir.'/.thumb_'.$entry;
  72                          if (file_exists($thumb)) if (!unlink($thumb)) return false;
  73                          if (!unlink($dir.'/'.$entry)) return false;
  74                      }
  75                  }
  76              }    
  77              closedir($dh);
  78              return rmdir($dir);
  79          } else {
  80              return false;
  81          }
  82      }
  83  }
  84  
  85  ?>