protected void LogBannedAttempt() { string to = FlexWikiWebApplication.ApplicationConfiguration.SendBanNotificationsToMailAddress; if (to == null || to == "") { return; } HtmlStringWriter w = new HtmlStringWriter(); w.WritePara(String.Format("{0} attempted to post a change with banned content to the topic {1} on the FlexWiki site at {2}.", HtmlStringWriter.Escape(VisitorIdentityString), HtmlStringWriter.Escape(TheTopic.DottedName), HtmlStringWriter.Escape((Request.Url.Host)))); w.WritePara("Banned content includes:"); w.WriteStartUnorderedList(); string proposed = PostedTopicText; foreach (string each in Federation.BlacklistedExternalLinkPrefixes) { if (proposed.ToUpper().IndexOf(each.ToUpper()) >= 0) { w.WriteListItem(HtmlStringWriter.Escape(each)); } } w.WriteEndUnorderedList(); string from = "noreply_spam_report@" + Request.Url.Host; MailMessage msg = new MailMessage(from, to); msg.Subject = "Banned content post attempt from " + VisitorIdentityString; msg.IsBodyHtml = true; msg.Body = w.ToString(); SendMail(msg); }
private static string WriteExampleWebConfig() { HtmlStringWriter w = new HtmlStringWriter(); w.Write("<blockquote><pre>"); w.Write(HtmlStringWriter.Escape(@"<?xml version=""1.0"" encoding=""utf-8"" ?> <configuration> <appSettings> <!-- PUT THE LOGICAL PATH TO THE FEDERATION CONFIGURATION FILE HERE --> <add key=""FederationNamespaceMapFile"" value=""/NamespaceMap.xml"" /> <!-- SET THE FOLLOWING KEY TO AN SMTP SERVER THAT WILL DELIVER MAIL. NEEDED IF YOU WANT YOUR WIKI SITE TO BE ABLE TO DELIVER NEWSLETTERS --> <add key=""SMTPServer"" value=""mail.my-server.com"" /> <!-- SET THE FOLLOWING KEY TO THE FULL FULLY-QUALIFIED ADDRESS OF THE USER NAME TO USE TO AUTHENTICATE AGAINST THE SMTP SERVER --> <add key=""SMTPUser"" value=""*****@*****.**"" /> <!-- SET THE FOLLOWING KEY IF THE SMTP SERVER NEEDS LOGIN AUTHENTICATION --> <add key=""SMTPPassword"" value=""password goes here"" /> <!-- SET THE FOLLOWING KEY TO THE DESIRED FROM ADDRESS FOR NEWSLETTERS --> <add key=""NewslettersFrom"" value=""*****@*****.**"" /> </appSettings> <system.web> <authentication mode=""Windows"" /> <authorization> <deny users=""?""/> </authorization> <pages validateRequest = ""false"" /> </system.web> </configuration>")); w.Write("</pre></blockquote>"); return w.ToString(); }
private string ExampleConfig() { HtmlStringWriter w = new HtmlStringWriter(); w.Write("<blockquote><pre>"); FlexWikiWebApplicationConfiguration appConfig = new FlexWikiWebApplicationConfiguration(); appConfig.FederationConfiguration = new FederationConfiguration(); appConfig.FederationConfiguration.AboutWikiString = "Text about the wiki here"; appConfig.FederationConfiguration.AuthorizationRules.Add( new WikiAuthorizationRule( new AuthorizationRule( new AuthorizationRuleWho(AuthorizationRuleWhoType.GenericAll), AuthorizationRulePolarity.Allow, AuthorizationRuleScope.Wiki, SecurableAction.Edit, 0) ) ); appConfig.FederationConfiguration.AuthorizationRules.Add( new WikiAuthorizationRule( new AuthorizationRule( new AuthorizationRuleWho(AuthorizationRuleWhoType.GenericAuthenticated), AuthorizationRulePolarity.Allow, AuthorizationRuleScope.Wiki, SecurableAction.ManageNamespace, 1) ) ); appConfig.FederationConfiguration.DefaultNamespace = "SampleNamespaceOne"; NamespaceProviderDefinition sampleNamespaceOne = new NamespaceProviderDefinition( typeof(FileSystemNamespaceProvider).Assembly.FullName, typeof(FileSystemNamespaceProvider).FullName, string.Empty); sampleNamespaceOne.Parameters.Add(new NamespaceProviderParameter("Root", @".\SampleNamespaceOne")); appConfig.FederationConfiguration.NamespaceMappings.Add(sampleNamespaceOne); appConfig.FederationConfiguration.WikiTalkVersion = 1; XmlSerializer serializer = new XmlSerializer(typeof(FlexWikiWebApplicationConfiguration)); XmlWriterSettings writerSettings = new XmlWriterSettings(); writerSettings.Indent = true; writerSettings.IndentChars = " "; StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = XmlWriter.Create(stringWriter, writerSettings); serializer.Serialize(xmlWriter, appConfig); xmlWriter.Close(); w.Write(HtmlStringWriter.Escape(stringWriter.ToString())); w.Write("</pre></blockquote>"); return w.ToString(); }
private static string ExampleConfig() { HtmlStringWriter w = new HtmlStringWriter(); w.Write("<blockquote><pre>"); w.Write(HtmlStringWriter.Escape(@"<?xml version=""1.0"" encoding=""utf-8""?> <FederationConfiguration> <DefaultNamespace>FlexWiki</DefaultNamespace> <Namespaces> <Namespace Id=""238f8774-a470-4f2e-93a0-07252e99fcb9"" Type=""FlexWiki.FileSystemStore"" Connection="".\wikibases\FlexWiki"" Namespace=""FlexWiki"" /> <Namespace Id=""890e8874-a470-4f2e-93a0-07252e99ed19"" Type=""FlexWiki.FileSystemStore"" Connection="".\wikibases\Some.Other.Namespace"" Namespace=""Some.Other.Namespace"" /> </Namespaces> <About>This site is the home of FlexWiki, an experimental collaboration tool.</About> </FederationConfiguration>")); w.Write("</pre></blockquote>"); return w.ToString(); }