~stormdragon2976/bashtml

286d5a042d6181ef1c86b29cbbb7279c5b70cfd8 — Storm Dragon 10 months ago f5a6d48
Added  email protection using base64 and javascript. I know it won't stop all spam, but it should cut down on it.
1 files changed, 19 insertions(+), 3 deletions(-)

M bashtml.sh
M bashtml.sh => bashtml.sh +19 -3
@@ 975,9 975,25 @@ create_includes() {

    if [[ -f $footer_file ]]; then cp "$footer_file" .footer.html
    else {
        protected_mail=${global_email//@/@}
        protected_mail=${protected_mail//./.}
        echo "<div id=\"footer\">$global_license <a href=\"$global_author_url\">$global_author</a> &mdash; <a href=\"mailto:$protected_mail\">$protected_mail</a><br/>"
        protected_mail="$(echo "$global_email" | base64)"
        echo "<script type='text/javascript'>"
        echo "// <!--"
        echo "decodeBase64 = function(s) {"
        echo "var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;"
        echo "var A=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";"
        echo "for(i=0;i<64;i++){e[A.charAt(i)]=i;}"
        echo "for(x=0;x<L;x++){"
        echo "c=e[s.charAt(x)];b=(b<<6)+c;l+=6;"
        echo "while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));}"
        echo -e "}\nreturn r;\n};"
        echo "document.write('<div id=\"footer\">$global_license <a href=\"$global_author_url\">$global_author</a> &mdash; <a href=\"mailto://' + decodeBase64('$protected_mail') + '\">' + decodeBase64('$protected_mail') + '</a><br/>');"
        echo "// -->"
        echo "</script>"
        echo "<noscript>"
        echo "<div id=\"footer\">Javascript is disabled. To get the email address, enable javascript or run this string through base64 -d<br />"
        echo "<b>$protected_mail</b><br />"
        echo "$global_license <a href=\"$global_author_url\">$global_author</a> &mdash; <b>email protected</b><br/>"
        echo "</noscript>"
        echo 'Generated with <a href="https://gitlab.com/stormdragon2976/bashtml">BasHTML</a>, a bash script to easily create blogs like this one</div>'
        } >> ".footer.html"
    fi