public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { // adds to denylist - $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); $blist = $options['blist']; // add this ip to your Allow List if (!in_array($ip, $blist)) { $blist[] = $ip; } $options['blist'] = $blist; kpg_ss_set_options($options); // need to remove from caches $badips = $stats['badips']; if (array_key_exists($ip, $badips)) { unset($badips[$ip]); $stats['badips'] = $badips; } $goodips = $stats['goodips']; if (array_key_exists($ip, $goodips)) { unset($goodips[$ip]); $stats['goodips'] = $goodips; } kpg_ss_set_stats($stats); return false; }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { extract($stats); extract($options); $trash = KPG_SS_PLUGIN_URL . 'images/trash.png'; $tdown = KPG_SS_PLUGIN_URL . 'images/tdown.png'; $tup = KPG_SS_PLUGIN_URL . 'images/tup.png'; // fix this $whois = KPG_SS_PLUGIN_URL . 'images/whois.png'; // fix this $ajaxurl = admin_url('admin-ajax.php'); $show = ''; $nwlrequests = array(); //sfs_debug_msg('wlrequests '.print_r($wlrequests,true)); foreach ($wlrequests as $key => $value) { $sw = true; if (!empty($ip) && $ip != 'x') { if ($key == $ip) { //sfs_debug_msg("wlreq matched '$ip'"); $sw = false; } if ($ip == trim($value[0])) { // match ip //sfs_debug_msg("wlreq val 0 '$value[0]'"); $sw = false; } if ($ip == trim($value[1])) { // match email //sfs_debug_msg("wlreq val 1 '$value[1]'"); $sw = false; } } $container = 'wlreq'; if ($sw) { $nwlrequests[$key] = $value; $show .= "<tr style=\"background-color:white;\">"; $trsh = "<a href=\"\" onclick=\"sfs_ajax_process('{$key}','wlreq','delete_wl_row','{$ajaxurl}');return false;\" title=\"Delete row\" alt=\"Delete row\" ><img src=\"{$trash}\" width=\"16px\" /></a>"; $addtodeny = "<a href=\"\"onclick=\"sfs_ajax_process('{$value['0']}','{$container}','add_black','{$ajaxurl}');return false;\" title=\"Add {$value['0']} to Deny List\" alt=\"Add {$value['0']} to Deny List\" ><img src=\"{$tdown}\" width=\"16px\" /></a>"; $addtoallow = "<a href=\"\"onclick=\"sfs_ajax_process('{$value['0']}','{$container}','add_white','{$ajaxurl}');return false;\" title=\"Add {$value['0']} to allow List\" alt=\"Add {$value['0']} to allow List\" ><img src=\"{$tup}\" width=\"16px\" /></a>"; $show .= "<td>{$key} {$trsh} {$addtodeny} {$addtoallow}</td>"; $who = "<a title=\"whois\" target=\"_stopspam\" href=\"http://lacnic.net/cgi-bin/lacnic/whois?lg=EN&query={$value['0']}\"><img src=\"{$whois}\" width=\"16px\"/></a> "; $trsh = "<a href=\"\" onclick=\"sfs_ajax_process('{$value['0']}','wlreq','delete_wlip','{$ajaxurl}');return false;\" title=\"Delete all {$value['0']}\" alt=\"Delete all {$value['0']}\" ><img src=\"{$trash}\" width=\"16px\" /></a>"; $show .= "<td>{$value['0']} {$who} {$trsh}</td>"; $trsh = "<a href=\"\" onclick=\"sfs_ajax_process('{$value['1']}','wlreq','delete_wlem','{$ajaxurl}');return false;\" title=\"Delete all {$value['1']}\" alt=\"Delete all {$value['1']}\" ><img src=\"{$trash}\" width=\"16px\" /></a>"; $show .= "<td><a target=\"_stopspam\" href=\"mailto:{$value['1']}?subject=Website access\">{$value['1']} {$trsh}</td>"; $show .= "<td>{$value['3']}</td>"; $show .= "<td>{$value['4']}</td>"; $show .= "<tr>"; } } $stats['wlrequests'] = $nwlrequests; //sfs_debug_msg('nwlrequests '.print_r($nwlrequests,true)); if (array_key_exists('addon', $post)) { kpg_ss_set_stats($stats, $post['addon']); } else { kpg_ss_set_stats($stats); } return $show; }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { // gets the stats when reset or new version $stats = get_option('kpg_stop_sp_reg_stats'); if (empty($stats) || !is_array($stats)) { $stats = array(); } $defaults = array('badips' => array(), 'goodips' => array(), 'hist' => array(), 'wlrequests' => array(), 'addonstats' => array(), 'multi' => array()); $defaultsWL = array('cntchkaws' => 0, 'cntchkcloudflare' => 0, 'cntchkgcache' => 0, 'cntchkgenallowlist' => 0, 'cntchkgoogle' => 0, 'cntchkmiscallowlist' => 0, 'cntchkpaypal' => 0, 'cntchkscripts' => 0, 'cntchkvalidip' => 0, 'cntchkwlem' => 0, 'cntchkwluserid' => 0, 'cntchkwlist' => 0, 'cntchkyahoomerchant' => 0); // Deny List Y/N settiings $defaultsBL = array('cntchk404' => 0, 'cntchkaccept' => 0, 'cntchkadmin' => 0, 'cntchkadminlog' => 0, 'cntchkagent' => 0, 'cntchkamazon' => 0, 'cntchkakismet' => 0, 'cntchkbcache' => 0, 'cntchkblem' => 0, 'cntchkuserid' => 0, 'cntchkblip' => 0, 'cntchkbotscout' => 0, 'cntchkdisp' => 0, 'cntchkdnsbl' => 0, 'cntchkexploits' => 0, 'cntchkgooglesafe' => 0, 'cntchkhoney' => 0, 'cntchkhosting' => 0, 'cntchkinvalidip' => 0, 'cntchklong' => 0, 'cntchkbbcode' => 0, 'cntchkreferer' => 0, 'cntchksession' => 0, 'cntchksfs' => 0, 'cntchkspamwords' => 0, 'cntchktld' => 0, 'cntchkubiquity' => 0, 'cntchkmulti' => 0); $defaultsTOTALS = array('spcount' => 0, 'spmcount' => 0, 'cntcap' => 0, 'cntncap' => 0, 'cntpass' => 0, 'spmdate' => date('Y/m/d', time() + get_option('gmt_offset') * 3600), 'spdate' => date('Y/m/d', time() + get_option('gmt_offset') * 3600)); $defaultsCountries = array('cntchkAD' => 0, 'cntchkAE' => 0, 'cntchkAF' => 0, 'cntchkAL' => 0, 'cntchkAM' => 0, 'cntchkAR' => 0, 'cntchkAT' => 0, 'cntchkAU' => 0, 'cntchkAX' => 0, 'cntchkAZ' => 0, 'cntchkBA' => 0, 'cntchkBB' => 0, 'cntchkBD' => 0, 'cntchkBE' => 0, 'cntchkBG' => 0, 'cntchkBH' => 0, 'cntchkBN' => 0, 'cntchkBO' => 0, 'cntchkBR' => 0, 'cntchkBS' => 0, 'cntchkBY' => 0, 'cntchkBZ' => 0, 'cntchkCA' => 0, 'cntchkCD' => 0, 'cntchkCH' => 0, 'cntchkCL' => 0, 'cntchkCN' => 0, 'cntchkCO' => 0, 'cntchkCR' => 0, 'cntchkCU' => 0, 'cntchkCW' => 0, 'cntchkCY' => 0, 'cntchkCZ' => 0, 'cntchkDE' => 0, 'cntchkDK' => 0, 'cntchkDO' => 0, 'cntchkDZ' => 0, 'cntchkEC' => 0, 'cntchkEE' => 0, 'cntchkES' => 0, 'cntchkEU' => 0, 'cntchkFI' => 0, 'cntchkFJ' => 0, 'cntchkFR' => 0, 'cntchkGB' => 0, 'cntchkGE' => 0, 'cntchkGF' => 0, 'cntchkGI' => 0, 'cntchkGP' => 0, 'cntchkGR' => 0, 'cntchkGT' => 0, 'cntchkGU' => 0, 'cntchkGY' => 0, 'cntchkHK' => 0, 'cntchkHN' => 0, 'cntchkHR' => 0, 'cntchkHT' => 0, 'cntchkHU' => 0, 'cntchkID' => 0, 'cntchkIE' => 0, 'cntchkIL' => 0, 'cntchkIN' => 0, 'cntchkIQ' => 0, 'cntchkIR' => 0, 'cntchkIS' => 0, 'cntchkIT' => 0, 'cntchkJM' => 0, 'cntchkJO' => 0, 'cntchkJP' => 0, 'cntchkKE' => 0, 'cntchkKG' => 0, 'cntchkKH' => 0, 'cntchkKR' => 0, 'cntchkKW' => 0, 'cntchkKY' => 0, 'cntchkKZ' => 0, 'cntchkLA' => 0, 'cntchkLB' => 0, 'cntchkLK' => 0, 'cntchkLT' => 0, 'cntchkLU' => 0, 'cntchkLV' => 0, 'cntchkMD' => 0, 'cntchkME' => 0, 'cntchkMK' => 0, 'cntchkMM' => 0, 'cntchkMN' => 0, 'cntchkMO' => 0, 'cntchkMP' => 0, 'cntchkMQ' => 0, 'cntchkMT' => 0, 'cntchkMV' => 0, 'cntchkMX' => 0, 'cntchkMY' => 0, 'cntchkNC' => 0, 'cntchkNI' => 0, 'cntchkNL' => 0, 'cntchkNO' => 0, 'cntchkNP' => 0, 'cntchkNZ' => 0, 'cntchkOM' => 0, 'cntchkPA' => 0, 'cntchkPE' => 0, 'cntchkPG' => 0, 'cntchkPH' => 0, 'cntchkPK' => 0, 'cntchkPL' => 0, 'cntchkPR' => 0, 'cntchkPS' => 0, 'cntchkPT' => 0, 'cntchkPW' => 0, 'cntchkPY' => 0, 'cntchkQA' => 0, 'cntchkRO' => 0, 'cntchkRS' => 0, 'cntchkRU' => 0, 'cntchkSA' => 0, 'cntchkSC' => 0, 'cntchkSE' => 0, 'cntchkSG' => 0, 'cntchkSI' => 0, 'cntchkSK' => 0, 'cntchkSV' => 0, 'cntchkSX' => 0, 'cntchkSY' => 0, 'cntchkTH' => 0, 'cntchkTJ' => 0, 'cntchkTM' => 0, 'cntchkTR' => 0, 'cntchkTT' => 0, 'cntchkTW' => 0, 'cntchkUA' => 0, 'cntchkUK' => 0, 'cntchkUS' => 0, 'cntchkUY' => 0, 'cntchkUZ' => 0, 'cntchkVC' => 0, 'cntchkVE' => 0, 'cntchkVN' => 0, 'cntchkYE' => 0); $ansa = array_merge($defaults, $defaultsWL, $defaultsTOTALS, $defaultsBL, $defaultsCountries); // get rid of old values no longer used in this version_compare foreach ($ansa as $key => $val) { if (array_key_exists($key, $stats)) { $ansa[$key] = $stats[$key]; } } if (!is_array($ansa['wlrequests'])) { $ansa['wlrequests'] = array(); } if (!is_array($ansa['badips'])) { $ansa['badips'] = array(); } if (!is_array($ansa['hist'])) { $ansa['hist'] = array(); } if (!is_array($ansa['addonstats'])) { $ansa['addonstats'] = array(); } if (!is_array($ansa['goodips'])) { $ansa['goodips'] = array(); } if (!is_numeric($ansa['spcount'])) { $ansa['spcount'] = 0; } if (!is_numeric($ansa['spmcount'])) { $ansa['spmcount'] = 0; } if ($ansa['spcount'] == 0) { $ansa['spdate'] = date('Y/m/d', time() + get_option('gmt_offset') * 3600); } if ($ansa['spmcount'] == 0) { $ansa['spmdate'] = date('Y/m/d', time() + get_option('gmt_offset') * 3600); } $ansa['version'] = KPG_SS_VERSION; kpg_ss_set_stats($ansa); //sfs_debug_msg("in get ansa\r\n".print_r($ansa,true)); return $ansa; }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { // are we getting stats? extract($stats); extract($post); $sname = $this->getSname(); $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); // updates counters. Adds to log list. Adds to good cache. Then updates stats when done // start with the counters - does some extra checks in case the stats file gets corrupted if (array_key_exists('cntpass', $stats)) { $stats['cntpass']++; } else { $stats['cntpass'] = 1; } // now the cache - need to purge it for time and length $kpg_sp_good = $options['kpg_sp_good']; $goodips[$ip] = $now; asort($goodips); while (count($goodips) > $kpg_sp_good) { array_shift($goodips); } $nowtimeout = date('Y/m/d H:i:s', time() - 4 * 3600 + get_option('gmt_offset') * 3600); foreach ($goodips as $key => $data) { if ($data < $nowtimeout) { unset($goodips[$key]); } } $stats['goodips'] = $goodips; // now we need to log the ip and reason $blog = ''; if (function_exists('is_multisite') && is_multisite()) { global $blog_id; if (!isset($blog_id) || $blog_id != 1) { $blog = $blog_id; } } // $kpg_sp_hist = $options['kpg_sp_hist']; while (count($hist) > $kpg_sp_hist) { array_shift($hist); } $hist[$now] = array($ip, $email, $author, $sname, $reason, $blog); $stats['hist'] = $hist; if (array_key_exists('addon', $post)) { kpg_ss_set_stats($stats, $post['addon']); // from a plugin } else { // have to figure out why we are here - it is because registration did this - try to fix. } }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { if (function_exists('is_user_logged_in')) { if (is_user_logged_in()) { return false; // don't want to do this if just testing - could lock out sysop } } if (!array_key_exists('multi', $stats)) { return false; } $multi = $stats['multi']; if (!is_array($multi)) { $multi = array(); } $multitime = 3; $multicnt = 5; if (array_key_exists('multitime', $options)) { $multitime = $options['multitime']; } if (array_key_exists('multicnt', $options)) { $multicnt = $options['multicnt']; } // clean up multi $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); $nowtimeout = date('Y/m/d H:i:s', time() - 60 * $multitime + get_option('gmt_offset') * 3600); foreach ($multi as $key => $data) { // key is ip, data is array of time and count if ($data[0] < $nowtimeout) { unset($multi[$key]); } } $row = array($now, 0); if (array_key_exists($ip, $multi)) { $row = $multi[$ip]; } $row[0] = $now; $row[1]++; $multi[$ip] = $row; $stats['multi'] = $multi; kpg_ss_set_stats($stats); if ($row[1] >= $multicnt) { return "{$row['1']} Hits in last 3 minutes"; } return false; }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { extract($stats); extract($options); $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); while (count($badips) > $kpg_sp_cache) { array_shift($badips); } $nowtimeout = date('Y/m/d H:i:s', time() - 4 * 3600 + get_option('gmt_offset') * 3600); $badips[$ip] = $now; foreach ($badips as $key => $data) { if ($data < $nowtimeout) { unset($badips[$key]); } } $stats['badips'] = $badips; kpg_ss_set_stats($stats); return $badips; }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { extract($stats); extract($options); while (count($goodips) > $kpg_sp_good) { array_shift($goodips); } $nowtimeout = date('Y/m/d H:i:s', time() - 4 * 3600 + get_option('gmt_offset') * 3600); foreach ($goodips as $key => $data) { if ($data < $nowtimeout) { unset($goodips[$key]); } if ($key == $ip) { unset($goodips[$key]); } } $stats['goodips'] = $goodips; kpg_ss_set_stats($stats); return $goodips; // return the array so ajax can show it }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { extract($stats); extract($options); $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); while (count($goodips) > $kpg_sp_good) { array_shift($goodips); } $nowtimeout = date('Y/m/d H:i:s', time() - 4 * 3600 + get_option('gmt_offset') * 3600); $goodips[$ip] = $now; foreach ($goodips as $key => $data) { if ($data < $nowtimeout) { unset($goodips[$key]); } } $stats['goodips'] = $goodips; // if we add to good cache we need to delete from bad cache if (array_key_exists($ip, $goodips)) { unset($goodips[$ip]); $stats['goodips'] = $goodips; } kpg_ss_set_stats($stats); return goodips; }
public function process($ip, &$stats = array(), &$options = array(), &$post = array()) { extract($stats); extract($post); $sname = $this->getSname(); $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); // updates counters. Adds to log list. Adds to bad cache. Then updates stats when done // start with the counters - does some extra checks in case the stats file gets corrupted if (array_key_exists('spcount', $stats)) { $stats['spcount']++; } else { $stats['spcount'] = 1; } if (array_key_exists('spmcount', $stats)) { $stats['spmcount']++; } else { $stats['spmcount'] = 1; } if (array_key_exists('cnt' . $chk, $stats)) { $stats['cnt' . $chk]++; } else { $stats['cnt' . $chk] = 1; } // now the cache - need to purge it for time and length $kpg_sp_cache = $options['kpg_sp_cache']; $badips[$ip] = $now; asort($badips); while (count($badips) > $kpg_sp_cache) { array_shift($badips); } $nowtimeout = date('Y/m/d H:i:s', time() - 4 * 3600 + get_option('gmt_offset') * 3600); foreach ($badips as $key => $data) { if ($data < $nowtimeout) { unset($badips[$key]); } } $stats['badips'] = $badips; // now we need to log the ip and reason $blog = ''; if (function_exists('is_multisite') && is_multisite()) { global $blog_id; if (!isset($blog_id) || $blog_id != 1) { $blog = $blog_id; } } // $kpg_sp_hist = $options['kpg_sp_hist']; while (count($hist) > $kpg_sp_hist) { array_shift($hist); } if (!empty($pwd)) { $author = $author . '/' . $pwd; } $hist[$now] = array($ip, $email, $author, $sname, $reason, $blog); $stats['hist'] = $hist; if (array_key_exists('addon', $post)) { kpg_ss_set_stats($stats, $post['addon']); } else { kpg_ss_set_stats($stats); } // we can report the spam to addons here do_action('kpg_stop_spam_caught', $ip, $post); // post has the chk and reason in the array plus all the other info be_load('kpg_ss_challenge', $ip, $stats, $options, $post); exit; }
if (wp_verify_nonce($nonce, 'kpgstopspam_update')) { if (array_key_exists('clear', $_POST)) { foreach ($counters as $v1 => $v2) { $stats[$v1] = 0; } $addonstats = array(); $stats['addonstats'] = $addonstats; $msg = "Summary Cleared"; kpg_ss_set_stats($stats); extract($stats); // extract again to get the new options } if (array_key_exists('update_total', $_POST)) { $stats['spmcount'] = $_POST['spmcount']; $stats['spmdate'] = $_POST['spmdate']; kpg_ss_set_stats($stats); extract($stats); // extract again to get the new options } } $nonce = wp_create_nonce('kpgstopspam_update'); ?> <div class="wrap" style="position:relative;"> <h2>Stop Spammers Plugin Version <?php echo KPG_SS_VERSION; ?> </h2> <?php if (!empty($msg)) { echo "<h3>{$msg}</h3>";
public function kpg_ss_add_allow($ip, $options = array(), $stats = array(), $post = array(), $post = array()) { // add to the wlrequest option // time,ip,email,author,reasion,info,sname $sname = $this->getSname(); $now = date('Y/m/d H:i:s', time() + get_option('gmt_offset') * 3600); $ke = sanitize_text_field($_POST['ke']); // email //sfs_debug_msg("in add allow:'$ke'"); if (empty($ke)) { return false; } if (!is_email($ke)) { return false; } $km = really_clean(sanitize_text_field($_POST['km'])); //user message if (strlen($km) > 80) { $km = substr($km, 0, 77) . '...'; } $kr = really_clean(sanitize_text_field($_POST['kr'])); // reason $ka = really_clean(sanitize_text_field($_POST['ka'])); // author $req = array($ip, $ke, $ka, $kr, $km, $sname); // add to the request list $wlrequests = $stats['wlrequests']; if (empty($wlrequests) || !is_array($wlrequests)) { $wlrequests = array(); } $wlrequests[$now] = $req; // save stats $stats['wlrequests'] = $wlrequests; //sfs_debug_msg("added request:'$ke'"); kpg_ss_set_stats($stats); return true; }