I have coded something that helps generate and automatically place .htpasswd file and .htaccess file to securely password-protect a folder (even a couch folder). If someone needs that, send email or PM.
For the sake of this post not being meaningless I will show my main function (calling others)
Code: Select all
<cms:func 'protect_folder' user='admin' password='admin' folder='couch'><cms:ignore>
    /**
    *   Password-protect a folder (writes .htaccess + .htpasswd to a folder)
    *   folder: No slash in the end!
    *
    *   @example <cms:call 'protect_folder' user='admin' password='admin' folder='couch' />
    *   @author Antony &lt;tony.smirnov@gmail.com&gt;
    *   @date   16.02.2019
    *   @last   22.06.2020
    */
    </cms:ignore>
    <cms:set folder = "<cms:concat folder '/' />" />
    <cms:write "<cms:show folder />.htpasswd" add_newline='0' truncate='1'><cms:call 'htpasswd_content' user=user password=password /></cms:write>
    <cms:write "<cms:show folder />.htaccess" add_newline='1' truncate='1'><cms:call 'htpasswd_htaccess' folder=folder /></cms:write>
</cms:func>