0 and strlen($n) > 0) { if (substr($p, strlen($p) - 1, 1) == "/") { $return = $p . $n; } else { $return = $p . "/" . $n; } } else { $return = $p . $n; } //make sure return is above $path $realreturn = realpath($return); $realpath = realpath($path); if(strpos($realreturn, $realpath) !== 0) { //the returned path does not start with the given path. Default to path return $realpath; } else { return $realreturn; } } function xs_is_accepted_file_type($file_name) { $pos = strrpos($file_name, "."); $ext = ""; if ($pos !== false) { $ext = strtolower(substr($file_name, $pos + 1)); } $accepted_file_types = explode(" ", strtolower(XS_ACCEPTED_FILE_TYPES)); foreach ($accepted_file_types as $accepted_file_type) { if ($accepted_file_type == $ext or $accepted_file_type == "*") { return true; } } return false; } function xs_xhtml_escape($text) { return str_replace(array("&", "<", ">", "\""), array("&", "<", ">", """), $text); } function xs_urlencode($text) { $parts = explode("/", $text); $count = count($parts); for($i = 0; $i < $count; $i++) { $parts[$i] = str_replace("+", "%20", urlencode($parts[$i])); } return implode("/", $parts); } //Process request $rootFolderPath = ""; $rootFilePath = ""; //Get sub-folder to browse if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] == "") { $rootFolderPath = XS_LIBRARY_FOLDER; $rootFilePath = XS_LIBRARY_FOLDER; } else { $rootFolderPath = xs_build_path(XS_LIBRARY_FOLDER, $_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); $rootFilePath = xs_build_path(XS_LIBRARY_FOLDER, $_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); } } else { $rootFolderPath = XS_LIBRARY_FOLDER; $rootFilePath = XS_LIBRARY_FOLDER; } $hidden_folders = explode(",", XS_HIDDEN_FOLDERS); $hidden_files = explode(",", XS_HIDDEN_FILES); // Respond if (get_magic_quotes_runtime() != 0) { set_magic_quotes_runtime(0); } header("Content-Type: text/xml"); echo ""; echo ""; echo ""; // Process folders $folder_list = array(); if (file_exists($rootFolderPath)) { if (false !== ($handle = @opendir($rootFolderPath))) { while (false !== ($fs_object = readdir($handle))) { if ($fs_object != "." && $fs_object != "..") { $found = false; foreach($hidden_folders as $hidden_folder) { if(strtolower($fs_object) == strtolower(trim($hidden_folder))) { $found = true; } } if (is_dir(xs_build_path($rootFolderPath, $fs_object))) { if ($found === false) { $folder_list[] = $fs_object; } } } } closedir($handle); } } natcasesort($folder_list); reset($folder_list); foreach ($folder_list as $key => $fs_object) { echo ""; //Folder name echo "" . xs_xhtml_escape($fs_object) . ""; //Path to parent folder echo ""; if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] != "") { echo xs_xhtml_escape($_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); } } echo ""; //Display label echo ""; //Base URL to this folder echo ""; $temp = $fs_object; if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] != "") { $temp = $_SERVER["HTTP_X_CMS_LIBRARY_PATH"] . "/" . $fs_object; } } $url = xs_build_path(XS_BASE_URL, xs_urlencode($temp)) . "/"; echo $url; echo ""; //Is folder empty (not implemented yet) echo "false"; //Icon ID defined in icons.xml echo "folder"; //Reserved for future use echo ""; //Reserved for future use echo "0"; echo ""; } echo ""; echo ""; // Process files $file_list = array(); if (file_exists($rootFilePath)) { if (false !== ($handle = @opendir($rootFilePath))) { while (false !== ($fs_object = readdir($handle))) { if ($fs_object != "." && $fs_object != "..") { $found = false; foreach($hidden_files as $hidden_file) { if(strtolower($fs_object) == strtolower(trim($hidden_file))) { $found = true; } } if (is_file(xs_build_path($rootFilePath, $fs_object))) { if (xs_is_accepted_file_type($fs_object)) { if ($found === false) { $file_list[] = $fs_object; } } } } } closedir($handle); } } natcasesort($file_list); reset($file_list); foreach ($file_list as $key => $fs_object) { echo ""; //Folder name echo "" . xs_xhtml_escape($fs_object) . ""; //Path to parent folder echo ""; if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] != "") { echo xs_xhtml_escape($_SERVER["HTTP_X_CMS_LIBRARY_PATH"]); } } echo ""; //Display label echo ""; //Icon ID defined in icons.xml echo "image"; //Reserved for future use echo ""; //Reserved for future use echo "0"; //Attributes echo ""; //src attribute echo ""; echo "src"; echo ""; if (isset($_SERVER["HTTP_X_CMS_LIBRARY_PATH"])) { if ($_SERVER["HTTP_X_CMS_LIBRARY_PATH"] == "") { echo xs_build_path(XS_BASE_URL, xs_urlencode($fs_object)); } else { echo xs_build_path(xs_build_path(XS_BASE_URL, $_SERVER["HTTP_X_CMS_LIBRARY_PATH"]), xs_urlencode($fs_object)); } } else { echo xs_build_path(XS_BASE_URL, xs_urlencode($fs_object)); } echo ""; echo ""; //Image dimensions if (XS_GET_IMAGE_DIMENSIONS) { if (false === (list($width, $height) = @getimagesize(xs_build_path($rootFilePath, $fs_object)))) { } else { //Width echo ""; echo "width"; echo "" . $width . ""; echo ""; //Height echo ""; echo "height"; echo "" . $height . ""; echo ""; } } echo ""; //Properties echo ""; //File size if (XS_GET_FILE_SIZE) { echo ""; echo "size"; echo "" . filesize(xs_build_path($rootFilePath, $fs_object)) . ""; echo ""; } //Last modified date if (XS_GET_DATE_LAST_MODIFIED) { echo ""; echo "date"; echo "" . date("Y-m-d H:i:s", filemtime(xs_build_path($rootFilePath, $fs_object))) . ""; echo ""; } //Decorative image flag echo ""; echo "decorative"; echo ""; if (XS_DEFAULT_IMAGE_IS_DECORATIVE) { echo "true"; } else { echo "false"; } echo ""; echo ""; echo ""; echo ""; } echo ""; echo ""; ?>