| [ 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: GetFoldersAndFiles.php 13 * Implements the GetFoldersAndFiles command, to list 14 * files and folders in the current directory. 15 * Output is in XML 16 * 17 * File Authors: 18 * Grant French (grant@mcpuk.net) 19 */ 20 21 class GetFoldersAndFiles { 22 var $fckphp_config; 23 var $type; 24 var $cwd; 25 var $actual_cwd; 26 27 function GetFoldersAndFiles($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 35 function run() { 36 37 header ("Content-Type: application/xml; charset=utf-8"); 38 echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"; 39 ?> 40 <!DOCTYPE Connector [ 41 42 <?php include "dtd/iso-lat1.ent";?> 43 44 <!ELEMENT Connector (CurrentFolder,Folders,Files)> 45 <!ATTLIST Connector command CDATA "noname"> 46 <!ATTLIST Connector resourceType CDATA "0"> 47 48 <!ELEMENT CurrentFolder (#PCDATA)> 49 <!ATTLIST CurrentFolder path CDATA "noname"> 50 <!ATTLIST CurrentFolder url CDATA "0"> 51 52 <!ELEMENT Folders (#PCDATA)> 53 54 <!ELEMENT Folder (#PCDATA)> 55 <!ATTLIST Folder name CDATA "noname_dir"> 56 57 <!ELEMENT Files (#PCDATA)> 58 59 <!ELEMENT File (#PCDATA)> 60 <!ATTLIST File name CDATA "noname_file"> 61 <!ATTLIST File size CDATA "0"> 62 ] > 63 64 <Connector command="GetFoldersAndFiles" resourceType="<?php echo $this->type; ?>"> 65 <CurrentFolder path="<?php echo $this->raw_cwd; ?>" url="<?php echo $this->fckphp_config['urlprefix'] . $this->actual_cwd; ?>" /> 66 <Folders> 67 <?php 68 $files=array(); 69 if (is_dir($this->real_cwd)) { 70 if ($dh=opendir($this->real_cwd)) { 71 while (($filename=readdir($dh))!==false) { 72 if (($filename!=".")&&($filename!="..")) { 73 if (is_dir($this->real_cwd."/$filename")) { 74 //check if $fckphp_configured not to show this folder 75 $hide=false; 76 for($i=0;$i<sizeof($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders']);$i++) 77 $hide=(ereg($this->fckphp_config['ResourceAreas'][$this->type]['HideFolders'][$i],$filename)?true:$hide); 78 79 if (!$hide) echo "\t\t<Folder name=\"$filename\" />\n"; 80 81 } else { 82 array_push($files,$filename); 83 } 84 } 85 } 86 closedir($dh); 87 } 88 } 89 90 echo "\t</Folders>\n"; 91 echo "\t<Files>\n"; 92 93 for ($i=0;$i<sizeof($files);$i++) { 94 95 $lastdot=strrpos($files[$i],"."); 96 $ext=(($lastdot!==false)?(substr($files[$i],$lastdot+1)):""); 97 98 if (in_array(strtolower($ext),$this->fckphp_config['ResourceAreas'][$this->type]['AllowedExtensions'])) { 99 100 //check if$fckphp_configured not to show this file 101 $editable=$hide=false; 102 for($j=0;$j<sizeof($this->fckphp_config['ResourceAreas'][$this->type]['HideFiles']);$j++) 103 $hide=(ereg($this->fckphp_config['ResourceAreas'][$this->type]['HideFiles'][$j],$files[$i])?true:$hide); 104 105 if (!$hide) { 106 if ($this->fckphp_config['ResourceAreas'][$this->type]['AllowImageEditing']) 107 $editable=$this->isImageEditable($this->real_cwd."/".$files[$i]); 108 109 echo "\t\t<File name=\"".htmlentities($files[$i])."\" size=\"".ceil(filesize($this->real_cwd."/".$files[$i])/1024)."\" editable=\"" . ( $editable?"1":"0" ) . "\" />\n"; 110 } 111 112 } 113 114 } 115 116 echo "\t</Files>\n"; 117 echo "</Connector>\n"; 118 } 119 120 121 function isImageEditable($file) { 122 $fh=fopen($file,"r"); 123 if ($fh) { 124 $start4=fread($fh,4); 125 fclose($fh); 126 127 $start3=substr($start4,0,3); 128 129 if ($start4=="\x89PNG") { //PNG 130 return (function_exists("imagecreatefrompng") && function_exists("imagepng")); 131 132 } elseif ($start3=="GIF") { //GIF 133 return (function_exists("imagecreatefromgif") && function_exists("imagegif")); 134 135 } elseif ($start3=="\xFF\xD8\xFF") { //JPEG 136 return (function_exists("imagecreatefromjpeg")&& function_exists("imagejpeg")); 137 138 } elseif ($start4=="hsi1") { //JPEG 139 return (function_exists("imagecreatefromjpeg")&& function_exists("imagejpeg")); 140 141 } else { 142 return false; 143 } 144 145 } else { 146 return false; 147 } 148 } 149 150 151 } 152 153 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 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 |