get_setting('antispamzp_enable_credits') === false) $ret = $this->add_setting('antispamzp_enable_credits', 0); if($this->get_setting('antispamzp_enable_blacklist') === false) $ret = $this->add_setting('antispamzp_enable_blacklist', 1); if($this->get_setting('antispamzp_install_date') === false) $ret = $this->add_setting('antispamzp_install_date', date('Y-m-d h:i:s')); if($this->get_setting('antispamzp_rating_div') === false) $ret = $this->add_setting('antispamzp_rating_div', 'no'); } } $GLOBALS['AntiSpamZapper'] = new AntiSpamZapper(); // Load the lists function antispamzp_load_lists() { if(!$GLOBALS['antispamzp_blacklist_loaded']) { $GLOBALS['antispamzp_blacklist_loaded'] = true; $GLOBALS['antispamzp_blacklist_comments'] = file(dirname(__FILE__).'/lists/comments.txt'); $GLOBALS['antispamzp_blacklist_urls'] = file(dirname(__FILE__).'/lists/urls.txt'); } } //admin dashboard request, not secure, perms not checked if(is_admin()) { function antispamzp_admin_notices() { // Ask user for a review after 1 week $install_date = $GLOBALS['AntiSpamZapper']->get_setting('antispamzp_install_date'); $display_date = date( 'Y-m-d h:i:s' ); $datetime1 = new DateTime( $install_date ); $datetime2 = new DateTime( $display_date ); $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) ); if( $diff_intrval >= 7 && ($GLOBALS['AntiSpamZapper']->get_setting('antispamzp_rating_div') == "no") ) { echo '

'.__('You\'ve been using Anti-Spam Zapper for over a week, and I just wanted to know if it solved your spam problem?
If so, is there any chance you\'d be able to give it a review on WordPress?', 'anti-spam-zapper').'

'.__('This would be extremely helpful to me and many others, and would encourage people to try out the plugin.
If there were any bugs or issues, just let me know and I can fix them!', 'anti-spam-zapper' ).'

'; } } add_action( 'admin_notices', 'antispamzp_admin_notices' ); } // Ajax callback, hides the rating div and has no parameters or options function antispamzp_hide_rating() { $GLOBALS['AntiSpamZapper']->update_setting('antispamzp_rating_div', 'hide'); wp_send_json_success('success'); die(); } add_action('wp_ajax_antispamzp_hide_rating', 'antispamzp_hide_rating'); // Add rate-this plugin link function antispamzp_row_meta( $links, $file ) { if ( plugin_basename( __FILE__ ) == $file ) { $row_meta = array( 'rate-plugin' => ''.__('Rate This Plugin','anti-spam-zapper').'»' ); return array_merge( $links, $row_meta ); } return (array) $links; } add_filter( 'plugin_row_meta', 'antispamzp_row_meta', 10, 2 ); // Add settings page link on left function antispamzp_action_links( $links ) { $links[] = ''.__('Settings','anti-spam-zapper').''; $links[] = ''.__('Upgrade to Pro','anti-spam-zapper').''; return $links; } add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'antispamzp_action_links' ); function antispamzp_contains($str, $term, $nocase=false) { if($nocase) { $str = strtolower($str); $term = strtolower($term); } return strpos($str, $term) !== false; } function antispamzp_random_text($len=8) { //Not cryptographically secure $val = ''; for( $i=0; $i<$len; $i++ ) { $val .= chr( rand( 65, 90 ) ); } return $val; } function antispamzp_get_secret_key() { $val = get_option('antispamzp_secret_key'); if ($val === false) { $val = strtolower(antispamzp_random_text(16)); update_option('antispamzp_secret_key', $val); } return $val; } function antispamzp_check_blacklisted($phrase, $blarray, $nocase=true) { foreach ($blarray as $ib) { $b = trim($ib); if(strlen($b) == 0) continue; //blank if($b[0] === '/') if($b[1] === '/') continue; //comment if($b[0] === "*") { //encoded for potentially harmful/offensive terms if(antispamzp_contains($phrase, base64_decode(substr($b,1)), $nocase)) return true; //blacklisted phrase, b64-encoded } else { if(antispamzp_contains($phrase, $b, $nocase)) return true; //blacklisted phrase } } return false; } // Hook comments before inserting into DB function antispamzp_pre_comment_approved($approved, $commentdata) { // Todo: comment_author_IP check blacklist antispamzp_load_lists(); // Ensure loaded! global $antispamzp_blacklist_comments, $antispamzp_blacklist_urls; // Load up the globals $antispamzp_super_secret_key = antispamzp_get_secret_key(); // Load/Create the Secret if((!isset($_POST[$antispamzp_super_secret_key])) && (!isset($_GET[$antispamzp_super_secret_key]))) { // Doesn't have our "secret" key! D: return 'spam'; // spam } if($GLOBALS['AntiSpamZapper']->get_setting('antispamzp_enable_blacklist')) { if(antispamzp_check_blacklisted( $commentdata['comment_content'] .' '.$commentdata['comment_author'] .' '. $commentdata['comment_author_email'] .' '. $commentdata['comment_author_url'], $antispamzp_blacklist_comments, true )) return 'spam'; // mark spam if(strlen($commentdata['comment_author_url']) > 250) return 'spam'; //URL too long if(antispamzp_check_blacklisted($commentdata['comment_author_url'], $antispamzp_blacklist_urls, true)) return 'spam'; //blacklisted URL } return $approved; // don't modify anything } add_filter('pre_comment_approved', 'antispamzp_pre_comment_approved', '99', 2); function antispamzp_get_fake_atob($name4) { // make it harder for bots to parse return " var ".'c'.antispamzp_random_text(6)." = Function('".$name4."',\"return atob(".$name4.")\")('".base64_encode(antispamzp_random_text(16))."');"; } function antispamzp_comment_form_after() { // Block Useragents: if(strlen($_SERVER['HTTP_USER_AGENT']) <= 5) { return; } if(antispamzp_check_blacklisted(strtolower($_SERVER['HTTP_USER_AGENT']), array('phantomjs','baidu','python-','curl/','backlink','node','zbot') ,true)) { return; } $name1 = 'a'.antispamzp_random_text(6); //hidden class $name2 = 'b'.antispamzp_random_text(6); //hidden value $name3 = 'c'.antispamzp_random_text(6); //key var name $name4 = antispamzp_random_text(6); //atob function name ?> get_setting('antispamzp_enable_credits')): ?>
This comment form is protected with Anti-Spam Zapper