3
* FCKeditor - The text editor for internet
4
* Copyright (C) 2003-2005 Frederico Caldeira Knabben
6
* Licensed under the terms of the GNU Lesser General Public License:
7
* http://www.opensource.org/licenses/lgpl-license.php
9
* For further information visit:
10
* http://www.fckeditor.net/
12
* "Support Open Source software. What about a donation today?"
14
* File Name: CreateFolder.php
15
* Implements the CreateFolder command to make a new folder
16
* in the current directory. Output is in XML.
19
* Grant French (grant@mcpuk.net)
28
function CreateFolder($fckphp_config,$type,$cwd) {
29
$this->fckphp_config=$fckphp_config;
32
$this->actual_cwd=str_replace("//","/",($this->fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
33
$this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
34
$this->newfolder=str_replace(array("..","/"),"",$_GET['NewFolderName']);
37
function checkFolderName($folderName) {
39
//Check the name is not too long
40
if (strlen($folderName)>$this->fckphp_config['MaxDirNameLength']) return false;
42
//Check that it only contains valid characters
43
for($i=0;$i<strlen($folderName);$i++) if (!in_array(substr($folderName,$i,1),$this->fckphp_config['DirNameAllowedChars'])) return false;
45
//If it got this far all is ok
50
header ("content-type: text/xml");
51
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
53
<Connector command="CreateFolder" resourceType="<?php echo $this->type; ?>">
54
<CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
56
$newdir=str_replace("//","/",($this->real_cwd."/".$this->newfolder));
59
if ($this->checkFolderName($this->newfolder)) {
61
//Check if it already exists
62
if (is_dir($newdir)) {
63
$err_no=101; //Folder already exists
66
//Check if we can create the directory here
67
if (is_writeable($this->real_cwd)) {
70
if (mkdir($newdir,0777)) {
74
$err_no=110; //Unknown error
77
$err_no=103; //No permissions to create
81
$err_no=102; //Invalid Folder Name
85
<Error number="<?php echo "".$err_no; ?>" />
b'\\ No newline at end of file'