예제 #1
0
        protected override void OnLoad(EventArgs e)
        {
            Config.LoadConfig();

            if (!Config.Enabled)
            {
                XmlResponseHandler.SendError(Response, 1, "This connector is disabled. Please check the \"editor/filemanager/connectors/aspx/config.ascx\" file.");
                return;
            }

            // Busca informações iniciais.
            string sCommand       = Request.QueryString["Command"];
            string sResourceType  = Request.QueryString["Type"];
            string sCurrentFolder = Request.QueryString["CurrentFolder"];

            if (sCommand == null || sResourceType == null || sCurrentFolder == null)
            {
                XmlResponseHandler.SendError(Response, 1, "Invalid request.");
                return;
            }

            // Verifica se é um tipo permitido.
            if (!Config.CheckIsTypeAllowed(sResourceType))
            {
                XmlResponseHandler.SendError(Response, 1, "Invalid resource type specified.");
                return;
            }

            // Verificar a sintaxe do caminho.
            if (!sCurrentFolder.EndsWith("/"))
            {
                sCurrentFolder += "/";
            }
            if (!sCurrentFolder.StartsWith("/"))
            {
                sCurrentFolder = "/" + sCurrentFolder;
            }

            // Verifica caminhos inválidos (..).
            if (sCurrentFolder.IndexOf("..") >= 0 || sCurrentFolder.IndexOf("\\") >= 0)
            {
                XmlResponseHandler.SendError(Response, 102, "");
                return;
            }

            // Upload de arquivo não tem que retornar o XML, por isso deve ser interceptados antes de qualquer coisa.
            if (sCommand == "FileUpload")
            {
                this.FileUpload(sResourceType, sCurrentFolder, false);
                return;
            }

            XmlResponseHandler oResponseHandler = new XmlResponseHandler(this, Response);
            XmlNode            oConnectorNode   = oResponseHandler.CreateBaseXml(sCommand, sResourceType, sCurrentFolder);

            // Execute comando.
            switch (sCommand)
            {
            case "GetFolders":
                this.GetFolders(oConnectorNode, sResourceType, sCurrentFolder);
                break;

            case "GetFoldersAndFiles":
                this.GetFolders(oConnectorNode, sResourceType, sCurrentFolder);
                this.GetFiles(oConnectorNode, sResourceType, sCurrentFolder);
                break;

            case "CreateFolder":
                this.CreateFolder(oConnectorNode, sResourceType, sCurrentFolder);
                break;
            }

            oResponseHandler.SendResponse();
        }
예제 #2
0
 private void SetupResponse()
 {
     XmlResponseHandler.SetupResponse(this.Response);
 }