More in this section

Forums / Developing with Sitefinity / Forum spam protector

Forum spam protector

7 posts, 0 answered
  1. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    24 Apr 2009
    Link to this post

    Hi!

    I want to use spam protector for forum module. I do this because in some part of my forums anonymous users can write messages. How can I do this?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Apr 2009
    Link to this post
    Hi Paul,

    You can add spamprotector control to the Forum templates ( depending on which mode you will use)

    Example:

    <sfweb:spamprotector id="SpamProtector2" runat="server" cssclass="commentsValidator hide" 
                    validationgroup="YOUR VALIDATION GROUP" 
                    enableautobotdiscovery="true" 
                    enablehiddentextboxstrategy="true" 
                    hiddentextboxerrormessage="Hidden TextBox has some text in it!" 
                    hiddentextboxlabel="Do not fill this textbox!" 
                    hiddentextboxlabelcssclass="hide" 
                    hiddentextboxinputcssclass="hide" 
                    enablemintimeoutstrategy="true" 
                    mintimeout="2" 
                    mintimeouterrormessage="Submission too fast!" /> 
                <asp:Button ID="Button1" runat="server" Text="<%$Resources:PostThisComment %>" 
                    ValidationGroup="YOUR VALIDATION GROUP" CssClass="sf_commentSubmit" /> 

    You need to specify ValidationGroup and the controls you want to validate.

    <asp:TextBox ID="Txt" runat="server" ValidationGroup="YOUR VALIDATION GROUP" size="30"></asp:TextBox> 
     

    I hope this helps.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    24 Apr 2009
    Link to this post

    Hi Ivan!

    When I am doing what you wrote all in my Edit Post Page dissapeared. What am I doing wrong?

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 Apr 2009
    Link to this post
    Hi Paul,

    Could you send us modified templates.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    24 Apr 2009
    Link to this post

    After your recomendations I get this for EditPost.ascx:

    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %>

    <sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Forums/forumsCommonLayout.css" Media="screen" runat="server" />
    <sfWeb:CssFileLink ID="CssFileLink2" FileName="~/Sitefinity/UserControls/Dialogs/Prometheus.css" Media="screen" runat="server" />

    <div class="sf_forumsWrapper">
    <p class="sf_mandatoryFields">* <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:MandatoryFields %>"></asp:Literal></p>


    <fieldset class="sf_forumsEditor">

    <h3><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:Quote %>" /></h3>
    <h4><asp:Literal ID="quoteAuthor" runat="server"></asp:Literal></h4>
    <telerik:RadEditor 
    ID="tbQuote" 
    runat="server"
    ToolsFile="~/Sitefinity/ControlTemplates/Forums/ToolsFile.xml"
    EnableEmbeddedSkins="True" 
    Skin="Default2006" 
    DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css"
    Height="200px"
    EditModes="Design,Html"
    Width="95%" ValidationGroup="ForumValidationGroup">
    <CssFiles>
    <telerik:EditorCssFile Value="~/Sitefinity/ControlTemplates/Forums/EditorCssFile.css" />
    </CssFiles> 
    </telerik:RadEditor>
    </fieldset>

    <fieldset class="sf_forumsEditor">
    <h3><asp:literal ID="Literal3" runat="server" Text="<%$Resources:Content %>" /> * <em id="contentEditorLabel" runat="server"></em></h3>  
    <telerik:RadEditor 
    runat="server" 
    ID="editor"
    ToolsFile="~/Sitefinity/ControlTemplates/Forums/ToolsFile.xml"
    EnableEmbeddedSkins="True" 
    Skin="Default2006" 
    DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css"
    Width="95%"
    EditModes="Design,Html" ValidationGroup="ForumValidationGroup">  
    <CssFiles>
    <telerik:EditorCssFile Value="~/Sitefinity/ControlTemplates/Forums/EditorCssFile.css" />
    </CssFiles>  
    </telerik:RadEditor>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="editor" Display="Dynamic" EnableViewState="False" CssClass="sf_validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:ContentEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>  

    </fieldset>

    <p class="sf_createNewItem"> 
    <sfweb:spamprotector id="SpamProtector2" runat="server" cssclass="commentsValidator hide" 
    validationgroup="ForumValidationGroup" 
    enableautobotdiscovery="true" 
    enablehiddentextboxstrategy="true" 
    hiddentextboxerrormessage="Hidden TextBox has some text in it!" 
    hiddentextboxlabel="Do not fill this textbox!" 
    hiddentextboxlabelcssclass="hide" 
    hiddentextboxinputcssclass="hide" 
    enablemintimeoutstrategy="true" 
    mintimeout="2" 
    mintimeouterrormessage="Submission too fast!" /> 
    <asp:Button ID="saveButton" runat="server" Text="<%$Resources:Publish %>" ValidationGroup="ForumValidationGroup"></asp:Button>
    <span id="separator1" runat="server"><asp:Literal ID="Literal6" runat="server" Text="<%$Resources:Or %>"></asp:Literal></span>
    <asp:LinkButton CssClass="sf_cancel" ID="cancelButton" Text="<%$Resources:Cancel %>" runat="server" causesvalidation="false"><asp:Literal ID="Literal7" runat="server" Text="<%$Resources:Cancel %>"></asp:Literal></asp:LinkButton>  
    </p>

    </div>

  6. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    27 Apr 2009
    Link to this post
    Hi!
    I can't attach zip archive to my post. I will write a code of my controls:
    EditPost.ascx:
    <%@ Register Assembly="Telerik.Cms.Web.UI" Namespace="Telerik.Cms.Web.UI" TagPrefix="sfWeb" %> 
     
    <sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Forums/forumsCommonLayout.css" Media="screen" runat="server" /> 
    <sfWeb:CssFileLink ID="CssFileLink2" FileName="~/Sitefinity/UserControls/Dialogs/Prometheus.css" Media="screen" runat="server" /> 
     
    <div class="sf_forumsWrapper"
    <class="sf_mandatoryFields">* <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:MandatoryFields %>"></asp:Literal></p
             
             
    <fieldset class="sf_forumsEditor"
         
        <h3><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:Quote %>" /></h3
        <h4><asp:Literal ID="quoteAuthor" runat="server"></asp:Literal></h4
        <telerik:RadEditor  
            ID="tbQuote"  
            runat="server" 
            ToolsFile="~/Sitefinity/ControlTemplates/Forums/ToolsFile.xml" 
            EnableEmbeddedSkins="True"  
            Skin="Default2006"  
            DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css" 
            Height="200px" 
            EditModes="Design,Html" 
            Width="95%"
            <CssFiles> 
                <telerik:EditorCssFile Value="~/Sitefinity/ControlTemplates/Forums/EditorCssFile.css" /> 
            </CssFiles>  
        </telerik:RadEditor> 
    </fieldset> 
             
    <fieldset class="sf_forumsEditor"
        <h3><asp:literal ID="Literal3" runat="server" Text="<%$Resources:Content %>" /> * <em id="contentEditorLabel" runat="server"></em></h3>    
            <telerik:RadEditor  
                runat="server"  
                ID="editor" 
                ToolsFile="~/Sitefinity/ControlTemplates/Forums/ToolsFile.xml" 
                EnableEmbeddedSkins="True"  
                Skin="Default2006"  
                DialogsCssFile ="~/Sitefinity/Admin/Themes/Default/AjaxControlsSkins/Sitefinity/EditorDialogs.css" 
                Width="95%" 
                EditModes="Design,Html" ValidationGroup="ForumValidationGroup" validationgroup="ForumValidationGroup">     
                <CssFiles> 
                    <telerik:EditorCssFile Value="~/Sitefinity/ControlTemplates/Forums/EditorCssFile.css" /> 
                </CssFiles>                         
            </telerik:RadEditor> 
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="editor" Display="Dynamic" EnableViewState="False" CssClass="sf_validMessage" SetFocusOnError="True"><strong><asp:Literal ID="Literal4" runat="server" Text="<%$Resources:ContentEmpty %>"></asp:Literal></strong></asp:RequiredFieldValidator>                             
     
    </fieldset> 
             
    <class="sf_createNewItem">  
    <sfweb:spamprotector id="SpamProtector2" runat="server" cssclass="commentsValidator hide"  
                    validationgroup="ForumValidationGroup"  
                    enableautobotdiscovery="true"  
                    enablehiddentextboxstrategy="true"  
                    hiddentextboxerrormessage="Hidden TextBox has some text in it!"  
                    hiddentextboxlabel="Do not fill this textbox!"  
                    hiddentextboxlabelcssclass="hide"  
                    hiddentextboxinputcssclass="hide"  
                    enablemintimeoutstrategy="true"  
                    mintimeout="2"  
                    mintimeouterrormessage="Submission too fast!" /> 
        <asp:Button ID="saveButton" runat="server" Text="<%$Resources:Publish %>" validationgroup="ForumValidationGroup"></asp:Button> 
        <span id="separator1" runat="server"><asp:Literal ID="Literal6" runat="server" Text="<%$Resources:Or %>"></asp:Literal></span
        <asp:LinkButton CssClass="sf_cancel" ID="cancelButton" Text="<%$Resources:Cancel %>" runat="server" causesvalidation="false"><asp:Literal ID="Literal7" runat="server" Text="<%$Resources:Cancel %>"></asp:Literal></asp:LinkButton>                 
    </p> 
      
    </div> 
    What I'm doing wrong?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    27 Apr 2009
    Link to this post
    Hello Paul,

    As I see it from your code it does not validate anything. Also, you cannot use SpamProtector control directly with the RadEditor, because it does not support ValidationGroup property. In your edit template you can add a TextBox control, where the user is supposed to enter any information. Then you can validate this control with Captcha( you should also set EnableCaptcha="true" for the spam protector).

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
7 posts, 0 answered