| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 ** - Copyright (c) 2006 Belus Technology Inc. 4 ** - 5 ** - By using the software and documentation, the user expressly agrees that 6 ** - the use of the software documentation is at its sole risk. The software 7 ** - and documentation is made available on an "as is" basis. Copyright owner 8 ** - does not warrant that the software and documentation will meet the user's 9 ** - requirements, or that the operation of the software will be uninterrupted 10 ** - or error-free and does not make any warranty whatsoever regarding the 11 ** - software and documentation, any information, services or products provided 12 ** - through or in connection with the software and documentation, or any 13 ** - results to be obtained through the use thereof, and hereby expressly 14 ** - disclaims on behalf of itself and all suppliers any and all warranties, 15 ** - including without limitation: any express or implied warranties of: 16 ** - 1) merchantability; 2) fitness for a particular purpose; 3) effort to 17 ** - achieve purpose; 4) quality; 5) accuracy; 6) non-infringement. Copyright 18 ** - owner shall not be liable to the user, or to any third party, for any loss 19 ** - of data, profits, loss of use, interruption of business, error, omission, 20 ** - deletion, defect, delay in operation or transmission, computer virus, 21 ** - communications line failure, theft or destruction or unauthorized access to, 22 ** - alteration of, or use of records, whether for breach of contract, tortious 23 ** - behavior, negligence, or under any other cause of action. 24 ** - 25 ** - All right, title and interest including, but not limited to, copyright and 26 ** - other intellectual property rights in and to the software and documentation 27 ** - are owned by Copyright owner and the use of or modification to the software 28 ** - and documentation does not pass to the user any title to or any proprietary 29 ** - rights in the software and documentation. 30 ** - 31 ** - Permission is granted to copy, modify and distribute the software and 32 ** - documentation for any purpose and royalty-free, subject to the following: 33 ** - copyright and other intellectual property rights in and to the software and 34 ** - documentation must not be misrepresented and this notice may not be removed 35 ** - from any source distribution of the software or documentation. 36 *************************************************************************************/ 37 38 /**************************************************************************************** 39 ** - Purpose: Image Library 40 ** - Version: 1.00 41 ** - Date: 2006-01-30 42 ** - Documentation: http://xstandard.com/xstandard-lite-for-partner-cms/ 43 ****************************************************************************************/ 44 45 // Do not allow direct access 46 defined( '_JEXEC' ) or die( 'Restricted access' ); 47 48 $base_path = "../../../"; 49 require_once( $base_path . 'configuration.php' ); 50 51 /*************************** OPTIONAL - CHANGE THESE SETTINGS **************************/ 52 define("XS_LIBRARY_FOLDER", $base_path . 'images/stories/'); // Root library folder 53 define("XS_BASE_URL", 'images/stories/'); // Base URL to create for files. Relative URLs are okay, for example: "images/". 54 define("XS_ACCEPTED_FILE_TYPES", "gif jpeg jpg png bmp"); // A list of accepted file extensions. 55 define("XS_GET_DATE_LAST_MODIFIED", true); //Provide the last modified date for files. For large libraries, turning this off can improve performance. 56 define("XS_GET_FILE_SIZE", true); //Provide file size. For large libraries, turning this off can improve performance. 57 define("XS_GET_IMAGE_DIMENSIONS", true); //Provide image dimensions. For large libraries, turning this off can improve performance. 58 define("XS_DEFAULT_IMAGE_IS_DECORATIVE", false); //Flag to indicate if images should be treated as decorative by default. 59 define("XS_HIDDEN_FOLDERS", "CVS,_vti_cnf"); //Comma delimited list of hidden folders 60 define("XS_HIDDEN_FILES", ""); //Comma delimited list of hidden files 61 /*************************** OPTIONAL - CHANGE THESE SETTINGS ***************************/ 62 63 64 function xs_build_path($path, $name) { 65 $p = str_replace("\\", "/", trim($path)); 66 $n = trim($name); 67 68 $return = ''; 69 if (strlen($p) > 0 and strlen($n) > 0) { 70 if (substr($p, strlen($p) - 1, 1) == "/") { 71 $return = $p . $n; 72 } else { 73 $return = $p . "/" . $n; 74 } 75 } else { 76 $return = $p . $n; 77 } 78 79 //make sure return is above $path 80 $realreturn = realpath($return); 81 $realpath = realpath($path); 82 if(strpos($realreturn, $realpath) !== 0) { 83 //the returned path does not start with the given path. Default to path 84 return $realpath; 85 } else { 86 return $realreturn; 87 } 88 } 89 90 function xs_is_accepted_file_type($file_name) { 91 $pos = strrpos($file_name, "."); 92 $ext = ""; 93 if ($pos !== false) { 94 $ext = strtolower(substr($file_name, $pos + 1)); 95 } 96 97 $accepted_file_types = explode(" ", strtolower(XS_ACCEPTED_FILE_TYPES)); 98 foreach ($accepted_file_types as $accepted_file_type) { 99 if ($accepted_file_type == $ext or $accepted_file_type == "*") { 100 return true; 101 } 102 } 103 104 return false; 105 } 106 107 108 function xs_xhtml_escape($text) { 109 return str_replace(array("&", "<", ">", "\""), array("&", "<", ">", """), $text); 110 } 111 112 function xs_urlencode($text) { 113 $parts = explode("/", $text); 114 $count = count($parts); 115 116 for($i = 0; $i < $count; $i++) { 117 $parts[$i] = str_replace("+", "%20", urlencode($parts[$i])); 118 } 119 120 return implode("/", $parts); 121 } 122 123 124 125 //Process request 126 $rootFolderPath = ""; 127 $rootFilePath = ""; 128 129 //Get sub-folder to browse 130 if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { 131 if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] == "") { 132 $rootFolderPath = XS_LIBRARY_FOLDER; 133 $rootFilePath = XS_LIBRARY_FOLDER; 134 } else { 135 $rootFolderPath = xs_build_path(XS_LIBRARY_FOLDER, $_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); 136 $rootFilePath = xs_build_path(XS_LIBRARY_FOLDER, $_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); 137 } 138 } else { 139 $rootFolderPath = XS_LIBRARY_FOLDER; 140 $rootFilePath = XS_LIBRARY_FOLDER; 141 } 142 143 144 $hidden_folders = explode(",", XS_HIDDEN_FOLDERS); 145 $hidden_files = explode(",", XS_HIDDEN_FILES); 146 147 148 149 // Respond 150 if (get_magic_quotes_runtime() != 0) { 151 set_magic_quotes_runtime(0); 152 } 153 154 header("Content-Type: text/xml"); 155 echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; 156 echo "<library>"; 157 echo "<containers>"; 158 // Process folders 159 $folder_list = array(); 160 if (file_exists($rootFolderPath)) { 161 if (false !== ($handle = @opendir($rootFolderPath))) { 162 while (false !== ($fs_object = readdir($handle))) { 163 if ($fs_object != "." && $fs_object != "..") { 164 $found = false; 165 foreach($hidden_folders as $hidden_folder) { 166 if(strtolower($fs_object) == strtolower(trim($hidden_folder))) { 167 $found = true; 168 } 169 } 170 171 if (is_dir(xs_build_path($rootFolderPath, $fs_object))) { 172 if ($found === false) { 173 $folder_list[] = $fs_object; 174 } 175 } 176 } 177 } 178 closedir($handle); 179 } 180 } 181 natcasesort($folder_list); 182 reset($folder_list); 183 foreach ($folder_list as $key => $fs_object) { 184 echo "<container>"; 185 //Folder name 186 echo "<objectName>" . xs_xhtml_escape($fs_object) . "</objectName>"; 187 188 //Path to parent folder 189 echo "<path>"; 190 if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { 191 if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] != "") { 192 echo xs_xhtml_escape($_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); 193 } 194 } 195 echo "</path>"; 196 197 //Display label 198 echo "<label>" . xs_xhtml_escape($fs_object) . "</label>"; 199 200 //Base URL to this folder 201 echo "<baseURL>"; 202 $temp = $fs_object; 203 204 if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { 205 if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] != "") { 206 $temp = $_SERVER["HTTP_X_CMS_LIBRARY_PATH"] . "/" . $fs_object; 207 } 208 } 209 210 $url = xs_build_path(XS_BASE_URL, xs_urlencode($temp)) . "/"; 211 212 echo $url; 213 echo "</baseURL>"; 214 215 //Is folder empty (not implemented yet) 216 echo "<empty>false</empty>"; 217 218 //Icon ID defined in icons.xml 219 echo "<icon>folder</icon>"; 220 221 //Reserved for future use 222 echo "<metadata></metadata>"; 223 224 //Reserved for future use 225 echo "<options>0</options>"; 226 echo "</container>"; 227 } 228 echo "</containers>"; 229 echo "<objects>"; 230 // Process files 231 $file_list = array(); 232 if (file_exists($rootFilePath)) { 233 if (false !== ($handle = @opendir($rootFilePath))) { 234 while (false !== ($fs_object = readdir($handle))) { 235 if ($fs_object != "." && $fs_object != "..") { 236 $found = false; 237 foreach($hidden_files as $hidden_file) { 238 if(strtolower($fs_object) == strtolower(trim($hidden_file))) { 239 $found = true; 240 } 241 } 242 243 if (is_file(xs_build_path($rootFilePath, $fs_object))) { 244 if (xs_is_accepted_file_type($fs_object)) { 245 if ($found === false) { 246 $file_list[] = $fs_object; 247 } 248 } 249 } 250 } 251 } 252 closedir($handle); 253 } 254 } 255 natcasesort($file_list); 256 reset($file_list); 257 foreach ($file_list as $key => $fs_object) { 258 echo "<object>"; 259 //Folder name 260 echo "<objectName>" . xs_xhtml_escape($fs_object) . "</objectName>"; 261 262 //Path to parent folder 263 echo "<path>"; 264 if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { 265 if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] != "") { 266 echo xs_xhtml_escape($_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); 267 } 268 } 269 echo "</path>"; 270 271 //Display label 272 echo "<label>" . xs_xhtml_escape($fs_object) . "</label>"; 273 274 //Icon ID defined in icons.xml 275 echo "<icon>image</icon>"; 276 277 //Reserved for future use 278 echo "<metadata></metadata>"; 279 280 //Reserved for future use 281 echo "<options>0</options>"; 282 283 //Attributes 284 echo "<attrs>"; 285 //src attribute 286 echo "<attr>"; 287 echo "<name>src</name>"; 288 echo "<value>"; 289 if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { 290 if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] == "") { 291 echo xs_build_path(XS_BASE_URL, xs_urlencode($fs_object)); 292 } else { 293 echo xs_build_path(xs_build_path(XS_BASE_URL, $_SERVER["HTTP_X_CMS_LIBRARY_PATH"]), xs_urlencode($fs_object)); 294 } 295 } else { 296 echo xs_build_path(XS_BASE_URL, xs_urlencode($fs_object)); 297 } 298 echo "</value>"; 299 echo "</attr>"; 300 301 //Image dimensions 302 if (XS_GET_IMAGE_DIMENSIONS) { 303 if (false === (list($width, $height) = @getimagesize(xs_build_path($rootFilePath, $fs_object)))) { 304 305 } else { 306 //Width 307 echo "<attr>"; 308 echo "<name>width</name>"; 309 echo "<value>" . $width . "</value>"; 310 echo "</attr>"; 311 312 //Height 313 echo "<attr>"; 314 echo "<name>height</name>"; 315 echo "<value>" . $height . "</value>"; 316 echo "</attr>"; 317 } 318 319 } 320 echo "</attrs>"; 321 322 //Properties 323 echo "<props>"; 324 //File size 325 if (XS_GET_FILE_SIZE) { 326 echo "<prop>"; 327 echo "<name>size</name>"; 328 echo "<value>" . filesize(xs_build_path($rootFilePath, $fs_object)) . "</value>"; 329 echo "</prop>"; 330 } 331 332 //Last modified date 333 if (XS_GET_DATE_LAST_MODIFIED) { 334 echo "<prop>"; 335 echo "<name>date</name>"; 336 echo "<value>" . date("Y-m-d H:i:s", filemtime(xs_build_path($rootFilePath, $fs_object))) . "</value>"; 337 echo "</prop>"; 338 } 339 340 //Decorative image flag 341 echo "<prop>"; 342 echo "<name>decorative</name>"; 343 echo "<value>"; 344 if (XS_DEFAULT_IMAGE_IS_DECORATIVE) { 345 echo "true"; 346 } else { 347 echo "false"; 348 } 349 echo "</value>"; 350 echo "</prop>"; 351 echo "</props>"; 352 echo "</object>"; 353 } 354 echo "</objects>"; 355 echo "</library>"; 356 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |