Esempio n. 1
0
 /**
  * send response
  * @access public
  *
  */
 public function sendResponse()
 {
     $xml =& QFinder_Connector_Core_Factory::getInstance("Core_Xml");
     $this->_connectorNode =& $xml->getConnectorNode();
     $this->checkConnector();
     if ($this->mustCheckRequest()) {
         $this->checkRequest();
     }
     $resourceTypeName = $this->_currentFolder->getResourceTypeName();
     if (!empty($resourceTypeName)) {
         $this->_connectorNode->addAttribute("resourceType", $this->_currentFolder->getResourceTypeName());
     }
     if ($this->mustAddCurrentFolderNode()) {
         $_currentFolder = new Qfinder_Connector_Utils_XmlNode("CurrentFolder");
         $this->_connectorNode->addChild($_currentFolder);
         $_currentFolder->addAttribute("path", QFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($this->_currentFolder->getClientPath()));
         $this->_errorHandler->setCatchAllErros(true);
         $_url = $this->_currentFolder->getUrl();
         $_currentFolder->addAttribute("url", is_null($_url) ? "" : QFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($_url));
         $this->_errorHandler->setCatchAllErros(false);
         $_currentFolder->addAttribute("acl", $this->_currentFolder->getAclMask());
     }
     $this->buildXml();
     $_oErrorNode =& $xml->getErrorNode();
     $_oErrorNode->addAttribute("number", "0");
     echo $this->_connectorNode->asXML();
     exit;
 }
Esempio n. 2
0
 /**
  * Send error message to the browser. If error number is set to 1, $text (custom error message) will be displayed
  * Don't call this function directly
  *
  * @access public
  * @param int $number error number
  * @param string $text Custom error message (optional)
  */
 public function raiseError($number, $text = false)
 {
     $this->_errorNode->addAttribute("number", intval($number));
     if (false != $text) {
         $this->_errorNode->addAttribute("text", $text);
     }
     echo $this->_connectorNode->asXML();
 }
Esempio n. 3
0
 /**
  * handle request and build XML
  * @access protected
  *
  */
 function buildXml()
 {
     $this->checkConnector();
     $this->checkRequest();
     if (!$this->_currentFolder->checkAcl(QFINDER_CONNECTOR_ACL_FILE_VIEW)) {
         $this->_errorHandler->throwError(QFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
     }
     $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
     if (!isset($_GET["fileName"])) {
         $this->_errorHandler->throwError(QFINDER_CONNECTOR_ERROR_INVALID_NAME);
     }
     $fileName = QFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
     if (!QFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
         $this->_errorHandler->throwError(QFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
     }
     if (!$resourceTypeInfo->checkExtension($fileName, false)) {
         $this->_errorHandler->throwError(QFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
     }
     $filePath = QFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
     if (!file_exists($filePath) || !is_file($filePath)) {
         $this->_errorHandler->throwError(QFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
     }
     list($width, $height) = getimagesize($filePath);
     $oNode = new Qfinder_Connector_Utils_XmlNode("ImageInfo");
     $oNode->addAttribute("width", $width);
     $oNode->addAttribute("height", $height);
     $this->_connectorNode->addChild($oNode);
 }