WordPress.org

Ready to get started?Download WordPress

Forums

Antispam Bee
Spam Reason: CSS Hack (12 posts)

  1. Marcel Bokhorst
    Member
    Posted 3 years ago #

    Since I don't know when, all comments got deleted, including legitimate.
    Enabling marking as spam revealed a reason: "Spam Reason: CSS Hack".
    But why? And how can I fix this? Is there a conflicting plugin?
    My site is http://blog.bokhorst.biz/

    http://wordpress.org/extend/plugins/antispam-bee/

  2. Marcel Bokhorst
    Member
    Posted 3 years ago #

    I found out the comment textarea isn't replaced as it should, but I didn't found out why yet. On another similar site (same theme at least) it is just working.

  3. Marcel Bokhorst
    Member
    Posted 3 years ago #

    Okay, I fixed the problem this way:

    First I added a new action hook:

    add_filter('comment_form_field_comment', array($this, 'alt_replace_comment_field'));

    Below this one:

    add_action('template_redirect', array($this, 'replace_comment_field'));

    Then I added this function below 'replace_comment_field':

    function alt_replace_comment_field($field) {
    	return preg_replace("#<textarea(.*?)name=([\"\'])comment([\"\'])(.+?)</textarea>#s", "<textarea$1name=$2" .$this->md5_sign. "$3$4</textarea><textarea name=\"comment\" rows=\"1\" cols=\"1\" style=\"display:none\"></textarea>", $field, 1);
    }

    I believe this solution is better and more compatible than the original one. Furthermore I believe there is an error in de preg_replace in the original function.

  4. Marcel Bokhorst
    Member
    Posted 3 years ago #

    Important note: this will only work for WordPress version 3.0 or newer.

  5. stalkerX
    Member
    Posted 3 years ago #

    I believe this solution is better and more compatible than the original one.

    See Plugin Details: Requires WordPress Version: 2.7 or higher

    Furthermore I believe there is an error in de preg_replace in the original function.

    Where?

  6. stalkerX
    Member
    Posted 3 years ago #

    comment_form_field_comment is a theme specific filter. Not every theme (with wp 3.0) has/use it.

  7. Marcel Bokhorst
    Member
    Posted 3 years ago #

    I was aware that the comment_form_field_comment filter is only available in WP 3.0+, but not that it is theme specific.

    About the preg_replace error, the single quotes of this fragment should be replaced by double quotes:

    $2' .$this->md5_sign. '$3

  8. stalkerX
    Member
    Posted 3 years ago #

    but not that is is theme specific.

    Please read: http://devpress.com/blog/using-the-wordpress-comment-form/
    Only if the theme supports the wordpress comment form.

    About the preg_replace error, the single quotes of this fragment should be replaced by double quotes:

    Please see the code:
    'return preg_replace("#<textarea(.*?)name=([\"\'])comment([\"\'])(.+?)</textarea>#s", "<textarea$1name=$2' .$this->md5_sign.

  9. Marcel Bokhorst
    Member
    Posted 3 years ago #

    I still think the closing quote is wrong:

    "<textarea$1name=$2' .$this->md5_sign.

    Opening quote: " (just before <textarea)
    Closing quote: ' (just after $2)

    I discovered this because I copied the pre_replace function call to my alternate replace function and it didn't work correctly (the single quotes ended up in the HTML).

  10. Marcel Bokhorst
    Member
    Posted 3 years ago #

    BTW, do you have any idea why the original code didn't replace the textarea as it should?

  11. stalkerX
    Member
    Posted 3 years ago #

    Original:

    create_function(
    '$input',
    'return preg_replace("#<textarea(.*?)name=([\"\'])comment([\"\'])(.+?)</textarea>#s", "<textarea$1name=$2' .$this->md5_sign. '$3$4</textarea><textarea name=\"comment\" rows=\"1\" cols=\"1\" style=\"display:none\"></textarea>", $input, 1);'
    )

    Please read the manual, ok? bye.
    http://www.php.net/manual/en/function.create-function.php

  12. Marcel Bokhorst
    Member
    Posted 3 years ago #

    Let's break down the preg_replace of the original code:

    preg_replace(
    	"#<textarea(.*?)name=([\"\'])comment([\"\'])(.+?)</textarea>#s",
     	STARTING QUOTE-> "<textarea$1name=$2' <-ENDING QUOTE
    	.$this->md5_sign.
    	STARTING QUOTO-> '$3$4</textarea><textarea name=\"comment\" rows=\"1\" cols=\"1\" style=\"display:none\">
    	</textarea>", <-ENDING QUOTE
    	$input,
    	1);'

    I don't see why the documentation of create_function matters, but maybe you can explain it?

    Apart from this discussion, my original problem is still not solved. Somehow, and I really looked hard to find out why, the comment textarea is not replaced. Do you have any idea about what could be wrong?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic