| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
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 * File Name: RenameFile.php 13 * Implements the DeleteFile command to delete a file 14 * in the current directory. Output is in XML 15 * 16 * File Authors: 17 * Grant French (grant@mcpuk.net) 18 */ 19 20 class RenameFile { 21 var $fckphp_config; 22 var $type; 23 var $cwd; 24 var $actual_cwd; 25 var $newfolder; 26 27 function RenameFile($fckphp_config,$type,$cwd) { 28 $this->fckphp_config=$fckphp_config; 29 $this->type=$type; 30 $this->raw_cwd=$cwd; 31 $this->actual_cwd=str_replace("//","/",($fckphp_config['UserFilesPath']."/$type/".$this->raw_cwd)); 32 $this->real_cwd=str_replace("//","/",($this->fckphp_config['basedir']."/".$this->actual_cwd)); 33 34 if (isset($_GET['FileName'])) { 35 $this->filename=str_replace(array("..","/"),"",$_GET['FileName']); 36 } else { 37 $this->filename=''; 38 } 39 if (isset($_GET['NewName'])) { 40 $this->newname=str_replace(array("..","/"),"",$this->checkName($_GET['NewName'])); 41 } else { 42 $this->newname=''; 43 } 44 } 45 46 function checkName($name) { 47 $newName=""; 48 for ($i=0;$i<strlen($name);$i++) { 49 if (in_array($name[$i],$this->fckphp_config['FileNameAllowedChars'])) $newName.=$name[$i]; 50 } 51 return $newName; 52 } 53 54 function run() { 55 $result1=false; 56 $result2=true; 57 58 if ($this->newname!='') { 59 60 if ($this->nameValid($this->newname)) { 61 //Remove thumbnail if it exists 62 $result2=true; 63 $thumb=$this->real_cwd.'/.thumb_'.$this->filename; 64 if (file_exists($thumb)) { 65 $result2=unlink($thumb); 66 } 67 68 $result1=rename($this->real_cwd.'/'.$this->filename,$this->real_cwd.'/'.$this->newname); 69 } else { 70 $result1=false; 71 } 72 } 73 74 header ("content-type: text/xml"); 75 echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; 76 ?> 77 <Connector command="RenameFile" resourceType="<?php echo $this->type; ?>"> 78 <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->actual_cwd; ?>" /> 79 <?php 80 if ($result1&&$result2) { 81 $err_no=0; 82 } else { 83 $err_no=502; 84 } 85 ?> 86 <Error number="<?php echo "".$err_no; ?>" /> 87 </Connector> 88 <?php 89 } 90 91 function nameValid($fname) { 92 $type_config=$this->fckphp_config['ResourceAreas'][$this->type]; 93 94 $lastdot=strrpos($fname,"."); 95 96 if ($lastdot!==false) { 97 $ext=substr($fname,($lastdot+1)); 98 $fname=substr($fname,0,$lastdot); 99 100 if (in_array(strtolower($ext),$type_config['AllowedExtensions'])) { 101 return true; 102 } else { 103 return false; 104 } 105 } 106 } 107 } 108 109 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |