~ubuntu-branches/ubuntu/intrepid/moin/intrepid-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/applets/FCKeditor/editor/filemanager/browser/mcpuk/connectors/php/Commands/CreateFolder.php

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-02-14 16:09:24 UTC
  • mfrom: (0.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20060214160924-fyrx3gvknzqvt4vj
Tags: 1.5.2-1ubuntu1
Drop python2.3 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 * "Support Open Source software. What about a donation today?"
13
 
 * 
14
 
 * File Name: CreateFolder.php
15
 
 *      Implements the CreateFolder command to make a new folder
16
 
 *      in the current directory. Output is in XML.
17
 
 * 
18
 
 * File Authors:
19
 
 *              Grant French (grant@mcpuk.net)
20
 
 */
21
 
class CreateFolder {
22
 
        var $fckphp_config;
23
 
        var $type;
24
 
        var $cwd;
25
 
        var $actual_cwd;
26
 
        var $newfolder;
27
 
        
28
 
        function CreateFolder($fckphp_config,$type,$cwd) {
29
 
                $this->fckphp_config=$fckphp_config;
30
 
                $this->type=$type;
31
 
                $this->raw_cwd=$cwd;
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']);
35
 
        }
36
 
        
37
 
        function checkFolderName($folderName) {
38
 
                
39
 
                //Check the name is not too long
40
 
                if (strlen($folderName)>$this->fckphp_config['MaxDirNameLength']) return false;
41
 
                
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;
44
 
                
45
 
                //If it got this far all is ok
46
 
                return true;
47
 
        }
48
 
        
49
 
        function run() {
50
 
                header ("content-type: text/xml");
51
 
                echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
52
 
                ?>
53
 
<Connector command="CreateFolder" resourceType="<?php echo $this->type; ?>">
54
 
        <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
55
 
        <?php
56
 
                $newdir=str_replace("//","/",($this->real_cwd."/".$this->newfolder));
57
 
                
58
 
                //Check the new name
59
 
                if ($this->checkFolderName($this->newfolder)) {
60
 
                        
61
 
                        //Check if it already exists
62
 
                        if (is_dir($newdir)) {
63
 
                                $err_no=101; //Folder already exists
64
 
                        } else {
65
 
                                
66
 
                                //Check if we can create the directory here
67
 
                                if (is_writeable($this->real_cwd)) {
68
 
                                        
69
 
                                        //Make the directory
70
 
                                        if (mkdir($newdir,0777)) {
71
 
                                                $err_no=0; //Success
72
 
                                        } else {
73
 
                                        
74
 
                                                $err_no=110; //Unknown error
75
 
                                        }       
76
 
                                } else {
77
 
                                        $err_no=103; //No permissions to create
78
 
                                }
79
 
                        }
80
 
                } else {
81
 
                        $err_no=102; //Invalid Folder Name
82
 
                }
83
 
                
84
 
        ?>
85
 
        <Error number="<?php echo "".$err_no; ?>" />
86
 
</Connector>
87
 
                <?php
88
 
        }
89
 
}
90
 
 
91
 
?>
 
 
b'\\ No newline at end of file'