/** * handle request and build XML * @access protected * */ protected function buildXml() { $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_VIEW)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); } // Map the virtual path to the local server path. $_sServerDir = $this->_currentFolder->getServerPath(); if (!is_dir($_sServerDir)) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND); } // Create the "Folders" node. $oFoldersNode = new Ckfinder_Connector_Utils_XmlNode("Folders"); $this->_connectorNode->addChild($oFoldersNode); $files = array(); if ($dh = @opendir($_sServerDir)) { while (($file = readdir($dh)) !== false) { if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) { $files[] = $file; } } closedir($dh); } else { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED); } $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); if (sizeof($files) > 0) { natcasesort($files); $i = 0; foreach ($files as $file) { $oAcl = $_config->getAccessControlConfig(); $aclMask = $oAcl->getComputedMask($this->_currentFolder->getResourceTypeName(), $this->_currentFolder->getClientPath() . $file . "/"); if (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) { continue; } if ($resourceTypeInfo->checkIsHiddenFolder($file)) { continue; } // Create the "Folder" node. $oFolderNode[$i] = new Ckfinder_Connector_Utils_XmlNode("Folder"); $oFoldersNode->addChild($oFolderNode[$i]); $oFolderNode[$i]->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($file)); $oFolderNode[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_sServerDir . $file) ? "true" : "false"); $oFolderNode[$i]->addAttribute("acl", $aclMask); $i++; } } }
/** * handle request and build XML * @access protected * */ function buildXml() { $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); // Create the "ConnectorInfo" node. $_oConnInfo = new Ckfinder_Connector_Utils_XmlNode("ConnectorInfo"); $this->_connectorNode->addChild($_oConnInfo); $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false"); if (!$_config->getIsEnabled()) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED); } $_ln = ''; $_lc = $_config->getLicenseKey() . ' '; $pos = strpos(CKFINDER_CHARS, $_lc[0]) % 5; if ($pos == 1 || $pos == 4) { $_ln = $_config->getLicenseName(); } $_oConnInfo->addAttribute("s", $_ln); $_oConnInfo->addAttribute("c", trim($_lc[11] . $_lc[0] . $_lc[8] . $_lc[12] . $_lc[26] . $_lc[2] . $_lc[3] . $_lc[25] . $_lc[1])); $_thumbnailsConfig = $_config->getThumbnailsConfig(); $_thumbnailsEnabled = $_thumbnailsConfig->getIsEnabled(); $_oConnInfo->addAttribute("thumbsEnabled", $_thumbnailsEnabled ? "true" : "false"); if ($_thumbnailsEnabled) { $_oConnInfo->addAttribute("thumbsUrl", $_thumbnailsConfig->getUrl()); $_oConnInfo->addAttribute("thumbsDirectAccess", $_thumbnailsConfig->getDirectAccess() ? "true" : "false"); } $_imagesConfig = $_config->getImagesConfig(); $_oConnInfo->addAttribute("imgWidth", $_imagesConfig->getMaxWidth()); $_oConnInfo->addAttribute("imgHeight", $_imagesConfig->getMaxHeight()); // Create the "ResourceTypes" node. $_oResourceTypes = new Ckfinder_Connector_Utils_XmlNode("ResourceTypes"); $this->_connectorNode->addChild($_oResourceTypes); // Create the "PluginsInfo" node. $_oPluginsInfo = new Ckfinder_Connector_Utils_XmlNode("PluginsInfo"); $this->_connectorNode->addChild($_oPluginsInfo); // Load the resource types in an array. $_aTypes = $_config->getDefaultResourceTypes(); if (!sizeof($_aTypes)) { $_aTypes = $_config->getResourceTypeNames(); } $_aTypesSize = sizeof($_aTypes); if ($_aTypesSize) { $phpMaxSize = 0; $max_upload = CKFinder_Connector_Utils_Misc::returnBytes(ini_get('upload_max_filesize')); if ($max_upload) { $phpMaxSize = $max_upload; } $max_post = CKFinder_Connector_Utils_Misc::returnBytes(ini_get('post_max_size')); if ($max_post) { $phpMaxSize = $phpMaxSize ? min($phpMaxSize, $max_post) : $max_post; } //ini_get('memory_limit') only works if compiled with "--enable-memory-limit" $memory_limit = CKFinder_Connector_Utils_Misc::returnBytes(@ini_get('memory_limit')); if ($memory_limit && $memory_limit != -1) { $phpMaxSize = $phpMaxSize ? min($phpMaxSize, $memory_limit) : $memory_limit; } $_oConnInfo->addAttribute("uploadMaxSize", $phpMaxSize); $_oConnInfo->addAttribute("uploadCheckImages", $_config->checkSizeAfterScaling() ? "false" : "true"); for ($i = 0; $i < $_aTypesSize; $i++) { $_resourceTypeName = $_aTypes[$i]; $_acl = $_config->getAccessControlConfig(); $_aclMask = $_acl->getComputedMask($_resourceTypeName, "/"); if (($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) { continue; } if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) { //print $_resourceTypeName; $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName); //print_r($_oTypeInfo); $_oResourceType[$i] = new Ckfinder_Connector_Utils_XmlNode("ResourceType"); $_oResourceTypes->addChild($_oResourceType[$i]); $_oResourceType[$i]->addAttribute("name", $_resourceTypeName); $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl()); $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions())); $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions())); $_oResourceType[$i]->addAttribute("hash", substr(md5($_oTypeInfo->getDirectory()), 0, 16)); $_oResourceType[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_oTypeInfo->getDirectory()) ? "true" : "false"); $_oResourceType[$i]->addAttribute("acl", $_aclMask); $maxSize = $_oTypeInfo->getMaxSize(); if ($phpMaxSize) { $maxSize = $maxSize ? min($maxSize, $phpMaxSize) : $phpMaxSize; } $_oResourceType[$i]->addAttribute("maxSize", $maxSize); } } } $config = $GLOBALS['config']; if (!empty($config['Plugins']) && is_array($config['Plugins'])) { $_oConnInfo->addAttribute("plugins", implode(",", $config['Plugins'])); } CKFinder_Connector_Core_Hooks::run('InitCommand', array(&$this->_connectorNode)); }
/** * handle request and build XML * @access protected * */ protected function buildXml() { $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); // if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_VIEW)) { // $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED); // } // Map the virtual path to the local server path. $_sServerDir = substr($this->_currentFolder->getServerPath(), 1); // if (!is_dir($_sServerDir)) { // $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND); // } // Create the "Folders" node. $oFoldersNode = new Ckfinder_Connector_Utils_XmlNode("Folders"); $this->_connectorNode->addChild($oFoldersNode); $files = array(); global $config; $s3 = s3_con(); $items = $s3->getBucket($config['AmazonS3']['Bucket'], $_sServerDir, null, null, '/', true); foreach ($items as $key => $val) { if (array_key_exists('prefix', $val)) { //TODO: Replace the base directory in this URL $files[] = substr(str_replace($_sServerDir, "", $key), 0, -1); //$files[] = substr($key, 3, strlen($key) - 4); } } $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); if (sizeof($files) > 0) { natcasesort($files); $i = 0; foreach ($files as $file) { $oAcl = $_config->getAccessControlConfig(); $folderPath = $this->_currentFolder->getClientPath() . $file . '/'; $aclMask = $oAcl->getComputedMask($this->_currentFolder->getResourceTypeName(), $folderPath); if (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) { continue; } if ($resourceTypeInfo->checkIsHiddenFolder($file)) { continue; } // Create the "Folder" node. $oFolderNode[$i] = new Ckfinder_Connector_Utils_XmlNode("Folder"); $oFoldersNode->addChild($oFolderNode[$i]); $oFolderNode[$i]->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($file)); $oFolderNode[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($folderPath, $resourceTypeInfo) ? "true" : "false"); $oFolderNode[$i]->addAttribute("acl", $aclMask); $i++; } } }
/** * handle request and build XML * @access protected * */ protected function buildXml() { $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); // Create the "ConnectorInfo" node. $_oConnInfo = new Ckfinder_Connector_Utils_XmlNode("ConnectorInfo"); $this->_connectorNode->addChild($_oConnInfo); $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false"); if (!$_config->getIsEnabled()) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED); } $_ln = ''; $_lc = $_config->getLicenseKey() . ' '; if (1 == strpos(CKFINDER_CHARS, $_lc[0]) % 5) { $_ln = $_config->getLicenseName(); } $_oConnInfo->addAttribute("s", $_ln); $_oConnInfo->addAttribute("c", trim($_lc[11] . $_lc[0] . $_lc[8] . $_lc[12] . $_lc[26] . $_lc[2] . $_lc[3] . $_lc[25] . $_lc[1])); $_thumbnailsConfig = $_config->getThumbnailsConfig(); $_thumbnailsEnabled = $_thumbnailsConfig->getIsEnabled(); $_oConnInfo->addAttribute("thumbsEnabled", $_thumbnailsEnabled ? "true" : "false"); if ($_thumbnailsEnabled) { $_oConnInfo->addAttribute("thumbsUrl", $_thumbnailsConfig->getUrl()); $_oConnInfo->addAttribute("thumbsDirectAccess", $_thumbnailsConfig->getDirectAccess() ? "true" : "false"); } $_imagesConfig = $_config->getImagesConfig(); $_oConnInfo->addAttribute("imgWidth", $_imagesConfig->getMaxWidth()); $_oConnInfo->addAttribute("imgHeight", $_imagesConfig->getMaxHeight()); // Create the "ResourceTypes" node. $_oResourceTypes = new Ckfinder_Connector_Utils_XmlNode("ResourceTypes"); $this->_connectorNode->addChild($_oResourceTypes); // Create the "PluginsInfo" node. $_oPluginsInfo = new Ckfinder_Connector_Utils_XmlNode("PluginsInfo"); $this->_connectorNode->addChild($_oPluginsInfo); // Load the resource types in an array. $_aTypes = $_config->getDefaultResourceTypes(); if (!sizeof($_aTypes)) { $_aTypes = $_config->getResourceTypeNames(); } $_aTypesSize = sizeof($_aTypes); if ($_aTypesSize) { for ($i = 0; $i < $_aTypesSize; $i++) { $_resourceTypeName = $_aTypes[$i]; $_acl = $_config->getAccessControlConfig(); $_aclMask = $_acl->getComputedMask($_resourceTypeName, "/"); if (($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) { continue; } if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) { //print $_resourceTypeName; $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName); //print_r($_oTypeInfo); $_oResourceType[$i] = new Ckfinder_Connector_Utils_XmlNode("ResourceType"); $_oResourceTypes->addChild($_oResourceType[$i]); $_oResourceType[$i]->addAttribute("name", $_resourceTypeName); $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl()); $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions())); $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions())); $_oResourceType[$i]->addAttribute("hash", substr(md5($_oTypeInfo->getDirectory()), 0, 16)); $_oResourceType[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_oTypeInfo->getDirectory()) ? "true" : "false"); $_oResourceType[$i]->addAttribute("acl", $_aclMask); } } } $config = $GLOBALS['config']; if (!empty($config['Plugins']) && is_array($config['Plugins'])) { $_oConnInfo->addAttribute("plugins", implode(",", $config['Plugins'])); } CKFinder_Connector_Core_Hooks::run('InitCommand', array(&$this->_connectorNode)); }
/** * handle request and build XML * @access protected * */ protected function buildXml() { $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config"); // Create the "ConnectorInfo" node. $_oConnInfo = new Ckfinder_Connector_Utils_XmlNode("ConnectorInfo"); $this->_connectorNode->addChild($_oConnInfo); $_oConnInfo->addAttribute("enabled", $_config->getIsEnabled() ? "true" : "false"); if (!$_config->getIsEnabled()) { $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED); } $_ln = ''; $_lc = $_config->getLicenseKey() . ' '; if (1 == strpos(CKFINDER_CHARS, $_lc[0]) % 5) { $_ln = $_config->getLicenseName(); } $_oConnInfo->addAttribute("s", $_ln); $_oConnInfo->addAttribute("c", trim($_lc[11] . $_lc[0] . $_lc[8] . $_lc[12])); $_thumbnailsConfig = $_config->getThumbnailsConfig(); $_oConnInfo->addAttribute("thumbsEnabled", $_thumbnailsConfig->getIsEnabled() ? "true" : "false"); // Create the "ResourceTypes" node. $_oResourceTypes = new Ckfinder_Connector_Utils_XmlNode("ResourceTypes"); $this->_connectorNode->addChild($_oResourceTypes); // Load the resource types in an array. $_aTypes = $_config->getDefaultResourceTypes(); if (!sizeof($_aTypes)) { $_aTypes = $_config->getResourceTypeNames(); } $_aTypesSize = sizeof($_aTypes); if ($_aTypesSize) { for ($i = 0; $i < $_aTypesSize; $i++) { $_resourceTypeName = $_aTypes[$i]; $_acl = $_config->getAccessControlConfig(); $_aclMask = $_acl->getComputedMask($_resourceTypeName, "/"); if (($_aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) { continue; } if (!isset($_GET['type']) || $_GET['type'] === $_resourceTypeName) { //print $_resourceTypeName; $_oTypeInfo = $_config->getResourceTypeConfig($_resourceTypeName); //print_r($_oTypeInfo); $_oResourceType[$i] = new Ckfinder_Connector_Utils_XmlNode("ResourceType"); $_oResourceTypes->addChild($_oResourceType[$i]); $_oResourceType[$i]->addAttribute("name", $_resourceTypeName); $_oResourceType[$i]->addAttribute("url", $_oTypeInfo->getUrl()); $_oResourceType[$i]->addAttribute("allowedExtensions", implode(",", $_oTypeInfo->getAllowedExtensions())); $_oResourceType[$i]->addAttribute("deniedExtensions", implode(",", $_oTypeInfo->getDeniedExtensions())); $_oResourceType[$i]->addAttribute("defaultView", $_oTypeInfo->getDefaultView()); $_oResourceType[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_oTypeInfo->getDirectory()) ? "true" : "false"); $_oResourceType[$i]->addAttribute("acl", $_aclMask); } } } }