Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 jpm 1
<?php 
/*
2
 * FCKeditor - The text editor for internet
3
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
4
 *
5
 * Licensed under the terms of the GNU Lesser General Public License:
6
 * 		http://www.opensource.org/licenses/lgpl-license.php
7
 *
8
 * For further information visit:
9
 * 		http://www.fckeditor.net/
10
 *
11
 * File Name: CreateFolder.php
12
 * 	Implements the CreateFolder command to make a new folder
13
 * 	in the current directory. Output is in XML.
14
 *
15
 * File Authors:
16
 * 		Grant French (grant@mcpuk.net)
17
 */
18
class CreateFolder {
19
	var $fckphp_config;
20
	var $type;
21
	var $cwd;
22
	var $actual_cwd;
23
	var $newfolder;
24
25
 
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
34
 
35
36
 
37
		if (strlen($folderName)>$this->fckphp_config['MaxDirNameLength']) return false;
38
39
 
40
		for($i=0;$i<strlen($folderName);$i++) if (!in_array(substr($folderName,$i,1),$this->fckphp_config['DirNameAllowedChars'])) return false;
41
42
 
43
		return true;
44
	}
45
46
 
47
		header ("content-type: text/xml");
48
		echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
49
		?>
50
<Connector command="CreateFolder" resourceType="<?php echo $this->type; ?>">
51
	<CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
52
	<?php
53
		$newdir=str_replace("//","/",($this->real_cwd."/".$this->newfolder));
54
55
 
56
		if ($this->checkFolderName($this->newfolder)) {
57
58
 
59
			if (is_dir($newdir)) {
60
				$err_no=101; //Folder already exists
61
			} else {
62
63
 
64
				if (is_writeable($this->real_cwd)) {
65
66
 
67
					if (mkdir($newdir,0777)) {
68
						$err_no=0; //Success
69
					} else {
70
71
 
72
					}
73
				} else {
74
					$err_no=103; //No permissions to create
75
				}
76
			}
77
		} else {
78
			$err_no=102; //Invalid Folder Name
79
		}
80
81
 
82
	<Error number="<?php echo "".$err_no; ?>" />
83
</Connector>
84
		<?php
85
	}
86
}
87
88