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: RenameFile.php
15
* Implements the DeleteFile command to delete a file
16
* in the current directory. Output is in XML
19
* Grant French (grant@mcpuk.net)
28
function RenameFile($fckphp_config,$type,$cwd) {
29
$this->fckphp_config=$fckphp_config;
32
$this->actual_cwd=str_replace("//","/",($fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd));
33
$this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd));
34
$this->filename=str_replace(array("..","/"),"",$_GET['FileName']);
35
$this->newname=str_replace(array("..","/"),"",$this->checkName($_GET['NewName']));
38
function checkName($name) {
40
for ($i=0;$i<strlen($name);$i++) {
41
if (in_array($name[$i],$this->fckphp_config['FileNameAllowedChars'])) $newName.=$name[$i];
50
if ($this->newname!='') {
52
if ($this->nameValid($this->newname)) {
53
//Remove thumbnail if it exists
55
$thumb=$this->real_cwd.'/.thumb_'.$this->filename;
56
if (file_exists($thumb)) $result2=unlink($thumb);
58
$result1=rename($this->real_cwd.'/'.$this->filename,$this->real_cwd.'/'.$this->newname);
64
header ("content-type: text/xml");
65
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
67
<Connector command="RenameFile" resourceType="<?php echo $this->type; ?>">
68
<CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" />
70
if ($result1&&$result2) {
76
<Error number="<?php echo "".$err_no; ?>" />
81
function nameValid($fname) {
82
$type_config=$this->fckphp_config['ResourceAreas'][$this->type];
84
$lastdot=strrpos($fname,".");
86
if ($lastdot!==false) {
87
$ext=substr($fname,($lastdot+1));
88
$fname=substr($fname,0,$lastdot);
90
if (in_array(strtolower($ext),$type_config['AllowedExtensions'])) {
b'\\ No newline at end of file'