Esempio n. 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.aspx\" file.");
                return;
            }

            // Get the main request information.
            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;
            }

            // Check if it is an allowed type.
            if (!Config.CheckIsTypeAllowed(sResourceType))
            {
                XmlResponseHandler.SendError(Response, 1, "Invalid resource type specified.");
                return;
            }

            // Check the current folder syntax (must begin and start with a slash).
            if (!sCurrentFolder.EndsWith("/"))
            {
                sCurrentFolder += "/";
            }
            if (!sCurrentFolder.StartsWith("/"))
            {
                sCurrentFolder = "/" + sCurrentFolder;
            }

            // Check for invalid folder paths (..).
            if (sCurrentFolder.IndexOf("..") >= 0)
            {
                XmlResponseHandler.SendError(Response, 102, "");
                return;
            }

            // File Upload doesn't have to return XML, so it must be intercepted before anything.
            if (sCommand == "FileUpload")
            {
                this.FileUpload(sResourceType, sCurrentFolder, false);
                return;
            }

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

            // Execute the required command.
            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();
        }
Esempio n. 2
0
 protected override void OnLoad(EventArgs e)
 {
     base.Config.LoadConfig();
     if (!base.Config.Enabled)
     {
         XmlResponseHandler.SendError(base.Response, 1, "This connector is disabled. Please check the \"editor/filemanager/connectors/aspx/config.ascx\" file.");
     }
     else
     {
         string command       = base.Request.QueryString["Command"];
         string typeName      = base.Request.QueryString["Type"];
         string currentFolder = base.Request.QueryString["CurrentFolder"];
         if (((command == null) || (typeName == null)) || (currentFolder == null))
         {
             XmlResponseHandler.SendError(base.Response, 1, "Invalid request.");
         }
         else if (!base.Config.CheckIsTypeAllowed(typeName))
         {
             XmlResponseHandler.SendError(base.Response, 1, "Invalid resource type specified.");
         }
         else
         {
             if (!currentFolder.EndsWith("/"))
             {
                 currentFolder = currentFolder + "/";
             }
             if (!currentFolder.StartsWith("/"))
             {
                 currentFolder = "/" + currentFolder;
             }
             if ((currentFolder.IndexOf("..") >= 0) || (currentFolder.IndexOf(@"\") >= 0))
             {
                 XmlResponseHandler.SendError(base.Response, 0x66, "");
             }
             else if (command == "FileUpload")
             {
                 base.FileUpload(typeName, currentFolder, false);
             }
             else
             {
                 XmlResponseHandler handler       = new XmlResponseHandler(this, base.Response);
                 XmlNode            connectorNode = handler.CreateBaseXml(command, typeName, currentFolder);
                 string             str4          = command;
                 if (str4 != null)
                 {
                     if (!(str4 == "GetFolders"))
                     {
                         if (str4 == "GetFoldersAndFiles")
                         {
                             this.GetFolders(connectorNode, typeName, currentFolder);
                             this.GetFiles(connectorNode, typeName, currentFolder);
                         }
                         else if (str4 == "CreateFolder")
                         {
                             this.CreateFolder(connectorNode, typeName, currentFolder);
                         }
                     }
                     else
                     {
                         this.GetFolders(connectorNode, typeName, currentFolder);
                     }
                 }
                 handler.SendResponse();
             }
         }
     }
 }