CreateFolder.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: CreateFolder.php
  13.  *  Implements the CreateFolder command to make a new folder
  14.  *  in the current directory. Output is in XML.
  15.  * 
  16.  * File Authors:
  17.  *  Grant French (grant@mcpuk.net)
  18.  */
  19. class CreateFolder {
  20. var $fckphp_config;
  21. var $type;
  22. var $cwd;
  23. var $actual_cwd;
  24. var $newfolder;
  25. function CreateFolder($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->newfolder=str_replace(array("..","/"),"",$_GET['NewFolderName']);
  32. }
  33. function checkFolderName($folderName) {
  34. //Check the name is not too long
  35. if (strlen($folderName)>$this->fckphp_config['MaxDirNameLength']) return false;
  36. //Check that it only contains valid characters
  37. for($i=0;$i<strlen($folderName);$i++) if (!in_array(substr($folderName,$i,1),$this->fckphp_config['DirNameAllowedChars'])) return false;
  38. //If it got this far all is ok
  39. return true;
  40. }
  41. function run() {
  42. header ("content-type: text/xml");
  43. echo "<?xml version="1.0" encoding="utf-8" ?>n";
  44. ?>
  45. <Connector command="CreateFolder" resourceType="<?php echo $this->type; ?>">
  46. <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
  47. <?php
  48. $newdir=str_replace("//","/",($this->real_cwd."/".$this->newfolder));
  49. //Check the new name
  50. if ($this->checkFolderName($this->newfolder)) {
  51. //Check if it already exists
  52. if (is_dir($newdir)) {
  53. $err_no=101; //Folder already exists
  54. } else {
  55. //Check if we can create the directory here
  56. if (is_writeable($this->real_cwd)) {
  57. //Make the directory
  58. if (mkdir($newdir,0777)) {
  59. $err_no=0; //Success
  60. } else {
  61. $err_no=110; //Unknown error
  62. }
  63. } else {
  64. $err_no=103; //No permissions to create
  65. }
  66. }
  67. } else {
  68. $err_no=102; //Invalid Folder Name
  69. }
  70. ?>
  71. <Error number="<?php echo "".$err_no; ?>" />
  72. </Connector>
  73. <?php
  74. }
  75. }
  76. ?>