public void SaveUploadedFiles(String path)
        {
            int fileCount = _process.HttpPage.Request.Files.Count;

            String[] files = new String[fileCount];

            for (int fileIndex = 0; fileIndex < fileCount; fileIndex++)
            {
                HttpPostedFile file = _process.HttpPage.Request.Files[fileIndex];

                if (path != null && file.ContentLength > 0)
                {
                    String prepend = _process.QueryOther["file_prepend"];
                    prepend = !String.IsNullOrEmpty(prepend)
                        ? prepend + "_"
                        : String.Empty;

                    String filename = String.Join("_", Common.CleanToSafeString(Path.GetFileName(file.FileName)).Split(' '));
                    String fullName = Common.CombinePaths(_rootFilesPath, path, prepend + filename);
                    if (Common.PathIsInSite(fullName) && filename != String.Empty)
                    {
                        file.SaveAs(fullName);
                        files[fileIndex] = fullName;
                    }
                }
                else if (path != null && file.ContentLength == 0 && file.FileName != String.Empty)
                {
                    _process.AddMessage(
                        String.Format("The file \"{0}\" was ignored because it was empty.", file.FileName),
                        MessageType.Error);
                }
            }
        }
示例#2
0
        public void CopyTo(string mainValue)
        {
            string[] parts        = mainValue.Split('¤');
            string   copyFromPath = parts[0];
            string   copyToPath   = parts[1];
            string   name         = parts[2];

            if (copyFromPath.Trim() == string.Empty || copyToPath.Trim() == string.Empty)
            {
                _process.AddMessage("An error occured while copying the page.");
            }
            else
            {
                Page copyFrom = GetPage(copyFromPath);
                Page copyTo   = GetPage(copyToPath);

                if (name.Trim() == string.Empty)
                {
                    name = string.Format("Copy of {0}", copyFrom.Name);
                }

                Page newPage = Create(copyTo.PageIdentifier, name, name);
                newPage.Containers.ParentNode.InnerXml = copyFrom.Containers.ParentNode.InnerXml;
                newPage.Save();

                Save();
            }
        }
        /// <summary>
        /// Handles the add page.
        /// </summary>
        private void HandleAddPage()
        {
            String mainvalue = Process.QueryEvents["mainvalue"];

            String[] pathSplit = mainvalue.Split('*');
            String   path      = pathSplit[0];
            String   pageName  = pathSplit[1];

            SiteTree siteTree = new SiteTree(Process);

            if (!siteTree.Exists(path + "/" + pageName))
            {
                siteTree.Create(path, pageName, pageName);
            }
            else
            {
                Process.AddMessage("A page with that name already exists.");
            }
        }
示例#4
0
        private void HandleIndex()
        {
            string rootPath = Process.Root;

            string[] s        = Process.CurrentProcess.Split('/');
            string   baseDir  = Process.Settings["search/index"];
            string   rules    = rootPath + @"\Custom\App_Data\rules.xml";
            string   filePath = rootPath + @"\Custom\App_Data\database";

            //jig: index only one section
            if (s.Length >= 2)
            {
                filePath = Path.Combine(Path.Combine(filePath, "site"), s[1]);
                baseDir  = Path.Combine(baseDir, s[1]);
            }

            string procMessage;

            Indexer indexer = new Indexer(baseDir);

            indexer.LoadRules(rules);

            try
            {
                indexer.AddDirectory(filePath, "*.xml");
                ArrayList fileList = indexer.IndexDocuments();
                fileList.Clear();
                procMessage  = indexer.ProcMessage;
                procMessage += "Indexed OK.";
            }
            catch (Exception)
            {
                procMessage = string.Format("Failed to index documents in '{0}'", filePath);
            }

            if (procMessage != string.Empty)
            {
                Process.AddMessage(procMessage);
            }
        }
        private void HandleSubmitForm()
        {
            StringBuilder reply = new StringBuilder();

            for (int i = 0; i < Process.QueryData.Count; i++)
            {
                Query current = Process.QueryData[i];
                if (current.Name.StartsWith("form"))
                {
                    string fieldName = current.Name.Replace("form_", string.Empty).Replace("_", " ").Trim();
                    reply.AppendFormat("{0}: {1}\n", fieldName, current.Value);
                }
            }

            MailMessage message = new MailMessage {
                From = new MailAddress(Process.Settings["mail/servermail"])
            };

            message.To.Add(Process.Settings["mail/user"]);
            message.Subject = Process.Settings["mail/subject"];
            message.Body    = reply.ToString();

            SmtpClient smtpClient = new SmtpClient(Process.Settings["mail/smtp"]);

            if (Process.Settings["mail/smtpuser"] != string.Empty)
            {
                smtpClient.Credentials = new NetworkCredential(Process.Settings["mail/smtpuser"], Process.Settings["mail/smtppass"]);
            }

            smtpClient.Send(message);

            string confirmMessage = Process.Settings["mail/confirm"];

            if (confirmMessage != string.Empty)
            {
                Process.AddMessage(confirmMessage);
            }
        }
示例#6
0
        private void LoopThroughProcess(string[] args, XmlNode xmlNode, Process process)
        {
            if (args[0] != string.Empty)
            {
                args[0] = CommonXml.RenameIntegerPath(args[0]);
                xmlNode = xmlNode.SelectSingleNode(args[0]);

                if (xmlNode != null)
                {
                    if (process.CheckGroups(CommonXml.GetAttributeValue(xmlNode, "rights")))
                    {
                        XmlNodeList contentNodes = xmlNode.SelectNodes("*");
                        foreach (XmlNode contentNode in contentNodes)
                        {
                            // Not very pretty, I know, but it seems to be the
                            // best way to allow for proper debugging
                            if (process.HttpPage.Request.ServerVariables["REMOTE_ADDR"] == "127.0.0.1")
                            {
                                switch (contentNode.Name)
                                {
                                case "load":
                                    HandlePlugin(contentNode, args, process);
                                    break;

                                case "handle":
                                    HandlePlugin(contentNode, args, process);
                                    break;

                                case "template":
                                    process.mainTemplate = process.Settings["templates/" + contentNode.Attributes["name"].Value];
                                    break;

                                case "redirect":
                                    process.HttpPage.Response.Redirect(process.GetUrl(contentNode.Attributes["href"].Value));
                                    break;
                                }
                            }
                            else
                            {
                                try
                                {
                                    switch (contentNode.Name)
                                    {
                                    case "load":
                                        HandlePlugin(contentNode, args, process);
                                        break;

                                    case "handle":
                                        HandlePlugin(contentNode, args, process);
                                        break;

                                    case "template":
                                        process.mainTemplate = process.Settings["templates/" + contentNode.Attributes["name"].Value];
                                        break;

                                    case "redirect":
                                        process.HttpPage.Response.Redirect(process.GetUrl(contentNode.Attributes["href"].Value));
                                        break;
                                    }
                                }
                                catch (Exception e)
                                {
                                    process.AddMessage(e);
                                }
                            }
                        }
                        args = Common.RemoveOne(args);

                        if (args != null)
                        {
                            LoopThroughProcess(args, xmlNode, process);
                        }
                    }
                    else
                    {
                        string redirectUrl = string.Format("login.aspx?redirect={0}", process.QueryOther["process"]);
                        process.HttpPage.Response.Redirect(redirectUrl); // todo: is this the way to do it
                    }
                }
            }
        }