[ 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/ -> RenameFolder.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: RenameFolder.php
  13   *     Implements the DeleteFile command to delete a file
  14   *     in the current directory. Output is in XML
  15   * 
  16   * File Authors:
  17   *         Grant French (grant@mcpuk.net)
  18   */
  19  
  20  class RenameFolder {
  21      var $fckphp_config;
  22      var $type;
  23      var $cwd;
  24      var $actual_cwd;
  25      var $newfolder;
  26      
  27  	function RenameFolder($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("//","/",($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          if (isset($_GET['NewName'])) {
  39              $this->newname=str_replace(array("..","/"),"",$this->checkName($_GET['NewName']));
  40          } else {
  41              $this->newname='';
  42          }
  43      }
  44      
  45  	function checkName($name) {
  46          $newName="";
  47          for ($i=0;$i<strlen($name);$i++) {
  48              if (in_array($name[$i],$this->fckphp_config['DirNameAllowedChars'])) $newName.=$name[$i];
  49          }
  50          return $newName;
  51      }
  52      
  53  	function run() {
  54          $result1=false;
  55  
  56          
  57          if ($this->newname!='') {
  58              $result1=rename($this->real_cwd.'/'.$this->foldername,$this->real_cwd.'/'.$this->newname);
  59          }
  60          
  61          header ("content-type: text/xml");
  62          echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
  63          ?>
  64  <Connector command="RenameFolder" resourceType="<?php echo $this->type; ?>">
  65      <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  66      <?php
  67          if ($result1) {
  68              $err_no=0;
  69          } else {
  70              $err_no=602;
  71          }
  72          
  73      ?>
  74      <Error number="<?php echo "".$err_no; ?>" />
  75  </Connector>
  76          <?php
  77      }
  78  }
  79  
  80  ?>