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