Changeset 1540189
- Timestamp:
- 11/24/2016 10:24:36 PM (9 years ago)
- Location:
- antispam/trunk
- Files:
-
- 9 added
- 2 edited
-
admin (added)
-
admin/admin.php (added)
-
admin/antispam.js (added)
-
admin/canvasjs.min.js (added)
-
admin/install.php (added)
-
admin/jquery.canvasjs.min.js (added)
-
comments-antispam.php (modified) (10 diffs)
-
log-model-public.php (added)
-
readme.txt (modified) (3 diffs)
-
screenshot-1.png (added)
-
screenshot-2.png (added)
Legend:
- Unmodified
- Added
- Removed
-
antispam/trunk/comments-antispam.php
r1426913 r1540189 7 7 Plugin Name: Antispam 8 8 Plugin URI: http://wordpress.org/plugins/antispam/ 9 Description: Anti spam hack form comment form9 Description: Anti-spam check the robots by behavior. No captcha. Antispam let robots do so as a human can't do. 10 10 Author: Eugen Bobrowski 11 Version: 1. 311 Version: 1.4 12 12 Author URI: http://atf.li/ 13 13 */ … … 16 16 17 17 if (is_admin()) { 18 class Antispam_Admin 19 { 20 protected static $instance; 21 22 private function __construct() 23 { 24 add_action('admin_bar_menu', array($this, 'show_spam_count'), 99); 25 add_action('admin_print_styles', array($this, 'style')); 26 return true; 27 } 28 29 public static function get_instance() 30 { 31 if (null === self::$instance) { 32 self::$instance = new self(); 33 } 34 return self::$instance; 35 } 36 37 public function show_spam_count($wp_admin_bar) 38 { 39 $wp_admin_bar->add_node(array( 40 "id" => "antispam-plugin", 41 "title" => "Antispam:", 42 "parent" => "comments", 43 )); 44 45 $wp_admin_bar->add_node(array( 46 "id" => "antispam-plugin-counter", 47 "title" => get_option('spams_detected', 0) . ' rejected', 48 "parent" => "antispam-plugin", 49 )); 50 51 $wp_admin_bar->add_node(array( 52 'id' => 'antispam-github', 53 'href' => 'https://github.com/EugenBobrowski/antispam/issues', 54 "title" => 'Create Issue on GitHub', 55 "parent" => "antispam-plugin", 56 )); 57 58 59 } 60 61 public function style() 62 { 63 ?> 64 <style> 65 #wp-admin-bar-antispam-plugin > .ab-item:before { 66 content: "\f332" !important; 67 top: 4px; 68 } 69 </style><?php 70 } 71 } 72 73 if (apply_filters('antispam_counter', true)) 74 Antispam_Admin::get_instance(); 18 include_once 'admin/admin.php'; 19 include_once 'admin/install.php'; 20 add_action('plugins_loaded', array('Antispam_Activator', 'db_check')); 21 register_activation_hook( __FILE__, array('Antispam_Activator', 'db_check') ); 75 22 } else { 76 23 class Antispam … … 78 25 79 26 protected static $instance; 27 private $secret; 80 28 private $nonce; 81 29 private $localize_object; … … 84 32 private function __construct() 85 33 { 86 87 // add_filter('pre_comment_on_post', array($this, 'verify_spam')); 88 89 $this->nonce = hash('md5', ABSPATH); 34 $this->secret = apply_filters('antispam_s', ABSPATH); 35 36 $this->nonce = hash('md5', $this->secret); 90 37 91 38 $this->localize_object = 'veritas'; … … 96 43 //protect method (replace | add ) 97 44 'method' => 'add', 45 'request_method' => 'post', 98 46 //parent to copy and hide 99 47 'parent' => '.comment-form-comment', 48 'author' => 'author', 49 'email' => 'email', 100 50 ), 51 's' => array( 52 //protect method (replace | add ) 53 'method' => 'add', 54 'request_method' => 'get', 55 //parent to copy and hide 56 'parent' => 'label', 57 ), 58 101 59 )); 102 60 … … 104 62 $this->fields[$name]['ha'] = hash('md5', ABSPATH . $name); 105 63 } 106 107 add_filter('init', array($this, 'verify_spam') );64 // add_filter('pre_comment_on_post', array($this, 'verify_spam')); 65 add_filter('init', array($this, 'verify_spam'), 1); 108 66 add_action('wp_print_scripts', array($this, 'localize')); 109 67 add_filter('print_footer_scripts', array($this, 'javascript')); … … 128 86 public function localize() 129 87 { 130 131 132 88 wp_enqueue_script('jquery'); 133 89 wp_localize_script('jquery', $this->localize_object, $this->fields); … … 203 159 public function verify_spam($commentdata) 204 160 { 161 205 162 foreach ($this->fields as $name => $field) { 206 163 if ( 207 ('replace' == $field['method'] && isset($_POST['comment']) && !isset($_POST[$field['ha']])) 208 || 209 ('add' == $field['method'] && !empty($_POST['comment'])) 164 (('replace' == $field['method'] && isset($_REQUEST[$name]) && !isset($_REQUEST[$field['ha']])) 165 || 166 ('add' == $field['method'] && !empty($_REQUEST[$name]))) 167 && !isset($_COOKIE['antispam_verified']) 210 168 ) { 211 $this->die_die_die(); 212 213 } elseif (isset($_POST[$field['ha']])) { 214 $_POST['comment'] = $_POST[$field['ha']]; 169 $this->die_die_die($field); 170 } elseif (isset($_REQUEST[$field['ha']]) && 'post' == $field['request_method']) { 171 $_POST[$name] = $_POST[$field['ha']]; 172 } elseif (isset($_REQUEST[$field['ha']]) && 'get' == $field['request_method']) { 173 setcookie('antispam_verified', 'asd', time() + 60, '/'); 174 $_GET[$name] = $_GET[$field['ha']]; 175 wp_redirect(site_url('?s='.$_GET[$field['ha']])); exit; 215 176 } 216 177 } … … 220 181 } 221 182 222 public function die_die_die() 223 { 183 public function log_spam($field = array()) { 184 185 $spamdata = array( 186 'spam_date' => current_time( 'mysql' ), 187 'spam_IP' => '', 188 'spam_email' => '', 189 'spam_author' => '', 190 ); 191 192 193 $spamdata['spam_IP'] = $_SERVER['REMOTE_ADDR']; 194 $spamdata['spam_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $spamdata['spam_IP'] ); 195 196 if (isset($field['author']) && isset($_POST[$field['author']])) $spamdata['spam_author'] = sanitize_text_field($_POST[$field['author']]); 197 elseif (isset($_POST['author'])) $spamdata['spam_author'] = sanitize_text_field($_POST['author']); 198 199 if (isset($field['email']) && isset($_POST[$field['email']])) $spamdata['spam_email'] = sanitize_text_field($_POST[$field['email']]); 200 elseif (isset($_POST['email'])) $spamdata['spam_email'] = sanitize_text_field($_POST['email']); 201 202 global $wpdb; 203 $table = $wpdb->prefix . 'comments_antispam_log'; 204 205 $wpdb->insert($table, $spamdata); 206 207 } 208 209 public function die_die_die($field) 210 { 211 $this->log_spam($field); 224 212 $spam_detected = get_option('spams_detected', 0); 225 213 $spam_detected++; … … 228 216 } 229 217 230 231 218 } 232 219 -
antispam/trunk/readme.txt
r1426913 r1540189 3 3 Tags: comments, spam, antispam, anti-spam, anti spam, comment spam, spam comments 4 4 Requires at least: 3.2 5 Tested up to: 4. 5.26 Stable tag: 1. 35 Tested up to: 4.6.1 6 Stable tag: 1.4 7 7 License: GPLv2 or later 8 8 … … 13 13 Antispam let robots do so as a human can't do. 14 14 15 Features include: 15 = Features include: = 16 16 17 17 * No captcha 18 * Statistic 18 19 19 20 GitHub: https://github.com/EugenBobrowski/antispam … … 25 26 1, 2, 3: You're done! 26 27 28 == Screenshots == 27 29 30 1. Spam comment is rejected 31 2. Antispam statistic page 28 32 29 33 == Changelog ==
Note: See TracChangeset
for help on using the changeset viewer.