__construct();
}
function __construct () {
add_action ('comment_form', array(&$this, 'comment_form'), 0);
add_action ('comment_post', array(&$this, 'comment_post'));
add_action ('admin_menu', array(&$this, 'admin_menu'));
// set unique string (makes some random strings different among websites)
$this->unique_string = get_option('siteurl');
// set $dir_name
$dir_name = str_replace('\\', '/', dirname(__FILE__));
$dir_name = trim(substr($dir_name, strpos($dir_name, '/plugins/')+9), '/');
// enable localization
load_plugin_textdomain($this->abbr, 'wp-content/plugins/' . $dir_name . '/languages/');
$this->default_template_code = '
';
}
// improves comment-form
function comment_form ($form) {
global $user_ID;
$this->name = $this->GenerateName();
$this->answer = $this->GenerateAnswer();
$this->name2 = $this->GenerateName2();
$this->answer2 = $this->GenerateAnswer2();
// split correct answer into two parts - because of more complicated parsing for spambots
$answer_len = strlen($this->answer);
$answer_splitpoint = rand(1, $answer_len-1);
$answer_array[0] = substr($this->answer, 0, $answer_splitpoint);
$answer_array[1] = substr($this->answer, $answer_splitpoint);
// for camino & seamonkey browsers (problems reported) display
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
// logged user don't need to be tested
if ($user_ID) {
?>
GetTemplateCode(); ?>
} else {
?>
temp_template_code)) {
return $this->temp_template_code;
} else {
// load settings
if (($_own_template_code = get_option($this->abbr . '_own_template_code')) == 1) {
$_template_code = get_option($this->abbr . '_template_code');
}
// get raw template code
$template_code = ($_own_template_code) ? $_template_code : $this->default_template_code;
// make the final template code
$template_code = str_replace(
array('%name%', '%answer%', '%name2%', '%answer2%'),
array($this->name, $this->answer, $this->name2, $this->answer2),
$template_code);
// cache the code for this instance
$this->temp_template_code = $template_code;
return $template_code;
}
}
// Checks user's answer
function comment_post ($post_ID) {
global $comment_content, $comment_type, $user_ID;
$this->name = $this->GenerateName();
$this->answer = $this->GenerateAnswer();
$this->name2 = $this->GenerateName2();
$this->answer2 = $this->GenerateAnswer2();
$this->answer_yesterday = $this->GenerateAnswer('yesterday');
$user_answer = trim($_POST[$this->name]);
$user_answer2 = trim($_POST[$this->name2]);
$errors['empty'] = __('You didn\'t answer the antispam question, your comment was not saved. Press "Back" and answer the question. Just to be sure that your message won\'t be lost - copy it now to the clipboard.', $this->abbr);
$errors['wrong'] = __('You didn\'t answer the antispam question correctly, your comment was not saved. Press "Back" and answer the question better. Just to be sure that your message won\'t be lost - copy it now to the clipboard.', $this->abbr);
// not a trackback
if ( $comment_type === '' AND !$user_ID) {
// not filled
if ( $user_answer == '' ) {
$this->Flashback ($post_ID);
wp_die($errors['empty'] .'