As an experienced website operations expert, I am happy to elaborate in detail on how to independently configure留言验证码for each site in the AnQiCMS multi-site management environment.AnQiCMS with its flexible and efficient features provides great convenience for content operators, especially in terms of multi-site management. Its architectural design cleverly balances the needs of unified management and independent customization, and the configuration of comment captcha is one of the typical application scenarios.


How to independently configure the留言验证码in AnQiCMS multi-site environment?

AnQiCMS as an enterprise-level content management system, its 'multi-site management' feature is one of its core highlights.This not only means that you can manage the basic information of multiple websites under one backend interface, but also implies that each sub-site hosted by AnQiCMS has a relatively independent running environment and configuration options.This design philosophy is particularly important in handling functions such as message verification codes, allowing operators to finely tune protective strategies according to the specific traffic, user groups, and security needs of each site, rather than simply taking a one-size-fits-all approach.

Overview of the AnQiCMS multi-site mechanism

To understand how to independently configure the留言验证码, you first need to understand the AnQiCMS multi-site operation mechanism.In AnQiCMS, even if multiple sites are deployed on the same server, through reverse proxy and the multi-site management feature of the background for unified entry management, but each site is highly independent in logic.They can have their own domain, their own database (or a shared database but with isolated data), their own template files, and even independent backend management permissions.This is the characteristic of 'physical coexistence and logical isolation' that provides the basis for us to independently configure the留言验证码留言验证码.

This means that when you log in to the backend of a specific site, all the settings you operate, including feature enablement, template modification, etc., will only take effect on the current site and will not affect other sister sites.Whether or not the留言 verification code is enabled, as well as its display method on the front end, also follows this principle.

The core idea of independently configuring the留言验证码

Under the multi-site management context of AnQiCMS, the independent configuration of the留言验证码 is not dependent on a super switch spanning all sites.On the contrary, each site has the right to decide whether to enable this security measure and how to present it on its own frontend page.The core idea can be summarized into two points:

  1. Backend switch independent control:Each site's AnQiCMS backend provides independent options for enabling/disabling comment verification code.
  2. Flexible integration of front-end templates:The display logic of the captcha and the form submission method need to be implemented by modifying the corresponding template file of the site, and different sites can use different templates or make differentiated modifications to the same template.

Next, we will detail the specific configuration process.

Detailed configuration process.

To configure the independent message captcha for a specific site in the AnQiCMS multi-site environment, you need to follow several steps:

Step 1: Enter the target site's backend management interface

First, you need to access the back end of the specific site where you want to configure the message verification code. Each site usually has its independent back-end access address, such ashttp://your-site-one.com/system/orhttp://your-site-two.com/system/Please log in with the administrator account of this site.

Step two: Enable the comment captcha function of the target site.

Log in to the target site's backend and navigate to the "Function Management" module.Here, you will find an entry named 'Website Message Management' or a similar one.Click to enter, and there will usually be a dedicated settings page that allows you to configure options related to leaving messages.Among them, you should see a clear option, such as whether to enable the verification code function for leaving comments.Please check or select "Yes" to enable this feature and then save your settings.

This is a crucial step, it activates the captcha generation and verification logic on the backend for the current site.

Step three: modify the website template to integrate the captcha.

It is not enough to enable the feature only in the background, you also need to integrate the display element and submission logic of the captcha into your website's front-end message or comment form.AnQiCMS supports Django template engine syntax, allowing you to flexibly customize the front-end display.

  1. Locate the template file:The comment or message form is usually located in a specific file in your site template directory, such asguestbook/index.html(used for the message page) or in the comment area template of the article detail page. You candesign-director.mdThe document introduces the template directory structure to locate these files.

  2. Insert captcha code:After finding the corresponding form, you need to insert the HTML and JavaScript code related to the captcha at an appropriate position (usually before the submit button).AnQiCMS provides convenient template tags and API interfaces.Here is the standard integrated code example, you can directly copy and paste it into your template:

    <div style="display: flex; clear: both">
      <input type="hidden" name="captcha_id" id="captcha_id">
      <input type="text" name="captcha" required placeholder="请填写验证码" class="layui-input" style="flex: 1">
      <img src="" id="get-captcha" style="width: 150px;height: 56px;cursor: pointer;" />
      <script>
        document.getElementById('get-captcha').addEventListener("click", function (e) {
          fetch('/api/captcha')
                  .then(response => {
                    return response.json()
                  })
                  .then(res => {
                    document.getElementById('captcha_id').setAttribute("value", res.data.captcha_id)
                    document.getElementById('get-captcha').setAttribute("src", res.data.captcha)
                  }).catch(err =>{console.log(err)})
        });
        document.getElementById('get-captcha').click(); // 页面加载时自动获取一次验证码
      </script>
    </div>
    

    If your current site's frontend template is integrated with the jQuery library, you can also use a more concise jQuery syntax:

    <div style="display: flex; clear: both">
      <input type="hidden" name="captcha_id" id="captcha_id">
      <input type="text" name="captcha" required placeholder="请填写验证码" class="layui-input" style="flex: 1">
      <img src="" id="get-captcha" style="width: 150px;height: 56px;cursor: pointer;" />
      <script>
        $('#get-captcha').on("click", function (e) {
          $.get('/api/captcha', function(res) {
            $('#captcha_id').attr("value", res.data.captcha_id)
            $('#get-captcha').attr("src", res.data.captcha)
          }, 'json')
        })
        $('#get-captcha').click(); // 页面加载时自动获取一次验证码
      </script>
    </div>
    

    The key to this code is:

    • captcha_idA hidden field used to store the unique identifier of the captcha for backend verification.
    • captchaThe text box for entering the captcha by the user.
    • get-captchaA<img>The label used to display the captcha image and dynamically load and refresh it via JavaScript.
    • JavaScript code: responsible for obtaining the initial captcha at page load and refreshing the captcha image when clicked. It goes through/api/captchaInterface communicates with AnQiCMS backend.

Step four: Test and verification

After completing the above configuration, please make sure to clear the site cache (if applicable) and test the message or comment feature on the front-end page.You should be able to see the captcha image displayed normally, and the system will强制 require filling in the correct captcha when submitting the form.If the captcha image does not display or cannot be refreshed, please check the browser console for JavaScript errors and confirm the backend API interface (/api/captcha) Is the data returned normally.

Actual application and thinking

This independent configuration capability of AnQiCMS gives website operators great flexibility.For example, a sub-site mainly publishing news and information may need to enable captcha due to its high traffic and potential risk of spam comments;And another internal knowledge base site, due to the limited user group and high trust level, may choose to disable the captcha to optimize the user experience.

In addition, since the template is an independent asset of each site, even if multiple sites use the same basic template, you can customize the captcha for a specific site by copying the template and fine-tuning it.