Support » Plugin: Antispam Bee » [Plugin: Antispam Bee] Spam Reason: CSS Hack

Viewing 11 replies - 1 through 11 (of 11 total)
  • 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.

    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.

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

    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?

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

    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

    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.

    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).

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

    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

    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?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: Antispam Bee] Spam Reason: CSS Hack’ is closed to new replies.