OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / scripts / fckeditor2.6.6 / editor / plugins / FileBrowser_Thumbnail / connectors / php / Commands / RenameFolder.php
1 <?php
2 /*
3 PHP Connector for the FCKEditor v2 File Manager
4 Written By Grant French, UK, Sept 2004
5 http://www.mcpuk.net
6
7 FCKEditor - By Frederico Caldeira Knabben
8 http://www.fckeditor.net
9
10 File Description:
11 Implements the DeleteFile command to delete a file
12 in the current directory. Output is in XML
13
14 2009.2.10       mbstringなしでも実行できるように修正 by naoki hirata
15 */
16
17 class RenameFolder extends command {
18         var $foldername;
19         var $newname;
20         
21         function init() {
22                 $this->foldername = $_GET['FolderName'];
23                 $this->newname = $_GET['NewName'];
24         }
25         
26         function run() {
27                 $err_no = $this->_run();
28                 
29                 header ("content-type: text/xml");
30                 echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
31 ?>
32 <Connector command="RenameFolder" resourceType="<?php echo $this->XMLEncode($this->type); ?>">
33         <CurrentFolder path="<?php echo $this->XMLEncode($this->raw_cwd); ?>" url="<?php echo $this->XMLEncode($this->url($this->actual_cwd)); ?>" />
34         <Error number="<?php echo $err_no; ?>" />
35 </Connector>
36 <?php
37         }
38         
39         function _run() {
40                 if ($this->newname == '') {
41                         return 101;
42                 }
43                 
44                 if (function_exists('mb_ereg')){
45                         if (mb_ereg($this->fckphp_config['DisableName'], $this->newname)) {
46                                 return 101;
47                         }
48                 } else {
49                         if (ereg($this->fckphp_config['DisableName'], $this->newname)) {
50                                 return 101;
51                         }
52                 }
53                 if (function_exists('mb_ereg')){
54                         if (mb_ereg($this->fckphp_config['DisableChars'], $this->newname)) {
55                                 return 102;
56                         }
57                 } else {
58                         if (ereg($this->fckphp_config['DisableChars'], $this->newname)) {
59                                 return 102;
60                         }
61                 }
62                 
63                 //Check if we can create the directory here
64                 if (! is_writeable($this->path($this->actual_cwd))) {
65                         return 103;     //No permissions to rename
66                 }
67                 
68                 //Check if it already exists
69                 if (file_exists($this->path("{$this->actual_cwd}{$this->newname}"))) {
70                         return 104; //Folder or file already exists
71                 }
72                 
73                 if (! @rename($this->path("{$this->actual_cwd}{$this->foldername}"), $this->path("{$this->actual_cwd}/{$this->newname}"))) {
74                         return 110;
75                 }
76                 
77                 return 0;
78         }
79 }
80 ?>