first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
.wpa-test-msg{background: #d1ecf1 !important; border: 1px solid #bee5eb !important; border-radius: 5px !important;color: #0c5460 !important; font-size: 14px !important; padding:.75rem 1.25rem !important; font-family: Arial !important; margin-top:5px !important;}
span.wpa-button{ display: inline-block !important; padding-top: 5px !important; color: #fff !important;background-color: #6c757d !important;border-color: #6c757d !important; padding: 5px 10px !important; border-radius: 5px !important; margin-top:5px !important; cursor: pointer !important; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,12 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
/* BB PRESS */
add_action( 'bbp_new_topic_pre_extras','wpa_bbp_extra_validation');
add_action( 'bbp_new_reply_pre_extras','wpa_bbp_extra_validation');
function wpa_bbp_extra_validation(){
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','bbpress', $_POST);
bbp_add_error( 'bbp_extra_email', __( $GLOBALS['wpa_error_message'], 'bbpress' ) );
}
}

View File

@@ -0,0 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
function wpa_calderaforms_extra_validation( ) {
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','calderaforms', $_POST);
die($GLOBALS['wpa_error_message']);
}
};
add_action( 'caldera_forms_pre_load_processors', 'wpa_calderaforms_extra_validation', 10, 0 );

View File

@@ -0,0 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_filter( 'wpcf7_validate', 'wpa_contactform7_extra_validation', 10, 2 );
function wpa_contactform7_extra_validation($result, $tags){
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','contactform7', $_POST);
$result->invalidate('', $GLOBALS['wpa_error_message']);
}
return $result;
}

View File

@@ -0,0 +1,16 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
foreach($_POST as $param => $value){
if(strpos($param, 'et_pb_contactform_submit') === 0){
$is_divi_form = 'true';
$divi_form_additional = str_replace('et_pb_contactform_submit', '', $param);
}
}
if(!empty($is_divi_form) && $is_divi_form == 'true'){
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','divi_form', $_POST);
echo "<div id='et_pb_contact_form{$divi_form_additional}'><p>".$GLOBALS['wpa_error_message']."</p><div></div></div>";
die();
}
}

View File

@@ -0,0 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
function wpa_elementor_extra_validation( $record, $ajax_handler ) {
if (wpa_check_is_spam($_POST)){
$all_fields = $record->get( 'fields' );
$firstField = array_key_first($all_fields);
do_action('wpa_handle_spammers','elementor', $_POST);
$ajax_handler->add_error($all_fields[$firstField]['id'], $GLOBALS['wpa_error_message']);
}
};
add_action( 'elementor_pro/forms/validation', 'wpa_elementor_extra_validation', 10, 2 );

View File

@@ -0,0 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
function wpa_fluent_form_extra_validation($insertData, $data, $form) {
if (wpa_check_is_spam($data)){
do_action('wpa_handle_spammers','fluent_forms', $data);
//die($GLOBALS['wpa_error_message']);
wp_send_json_error(['errors' => $GLOBALS['wpa_error_message']]);
wp_die();
}
};
add_action( 'fluentform_before_insert_submission', 'wpa_fluent_form_extra_validation', 10, 3 );

View File

@@ -0,0 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_filter( 'frm_validate_entry', 'wpa_formidable_extra_validation', 10, 2 );
function wpa_formidable_extra_validation($errors, $values){
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','formidable', $_POST);
$errors['my_error'] = $GLOBALS['wpa_error_message'];
}
return $errors;
}

View File

@@ -0,0 +1,20 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_action( 'gform_validation', 'wpa_gravityforms_extra_validation');
function wpa_gravityforms_extra_validation($validation_result ){
if (wpa_check_is_spam($_POST)){
$form = $validation_result['form'];
do_action('wpa_handle_spammers','gravityforms', $_POST);
$validation_result['is_valid'] = false;
foreach( $form['fields'] as &$field ) {
if ( $field->id == '1' ) {
$field->failed_validation = true;
$field->validation_message = $GLOBALS['wpa_error_message'];
break;
}
}
$validation_result['form'] = $form;
}
return $validation_result;
}

View File

@@ -0,0 +1,13 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_filter('cred_form_validate','wpa_toolsetform_extra_validation',20,2);
function wpa_toolsetform_extra_validation($error_fields, $form_data)
{
list($fields,$errors)=$error_fields;
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','toolset_form', $_POST);
die($GLOBALS['wpa_error_message']);
}
return array($fields,$errors);
}

View File

@@ -0,0 +1,12 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
// WP Comments
add_filter( 'preprocess_comment', 'wpa_wpcomment_extra_validation' );
function wpa_wpcomment_extra_validation( $commentdata ) {
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','wpcomment', $_POST);
wp_die( __( $GLOBALS['wpa_error_message'] ) );
}
return $commentdata;
}

View File

@@ -0,0 +1,10 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_filter( 'wpforms_process_before', 'wpa_wpforms_extra_validation', 10, 2 );
function wpa_wpforms_extra_validation($entry, $form_data){
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','wpforms', $_POST);
wpforms()->process->errors[ $form_data['id'] ][ '0' ] = $GLOBALS['wpa_error_message'];
}
}

View File

@@ -0,0 +1,17 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_action( 'register_form', 'wpa_wpregistration_add_initiator_field' );
function wpa_wpregistration_add_initiator_field() {
echo '<input type="hidden" id="wpa_initiator" class="wpa_initiator" name="wpa_initiator" value="" />';
}
add_filter( 'registration_errors', 'wpa_wpregistration_extra_validation', 10, 3 );
function wpa_wpregistration_extra_validation( $errors, $sanitized_user_login, $user_email ) {
if (wpa_check_is_spam($_POST)){
do_action('wpa_handle_spammers','wpregistration', $_POST);
$errors->add( 'wpa_extra_email', __($GLOBALS['wpa_error_message']) );
}
return $errors;
}

View File

@@ -0,0 +1,75 @@
var wpa_field_name, wpa_unique_id, wpa_add_test, wpa_hidden_field;
jQuery(document).ready(function(){
wpa_field_name = wpa_field_info.wpa_field_name;
wpa_unique_id = wpa_field_info.wpa_field_value;
wpa_add_test = wpa_field_info.wpa_add_test;
wpa_hidden_field = "<span class='wpa_hidden_field' style='display:none;height:0;width:0;'><input type='text' name='"+wpa_field_name+"' value='"+wpa_unique_id+"' /></span>";
wpa_add_honeypot_field();
if (typeof wpae_add_honeypot_field == 'function') { // IF EXTENDED version exists.
wpae_add_honeypot_field();
}
if (wpa_add_test == 'yes'){
wpa_add_test_block();
}
});
function wpa_act_as_spam(){
actiontype = jQuery('span.wpa-button').data('actiontype');
if (actiontype == 'remove'){
wpa_remove_honeypot_field();
jQuery('span.wpa-button').data('actiontype','add');
jQuery('span.wpa-button').html('Acting as Spam Bot');
} else {
wpa_add_honeypot_field();
jQuery('span.wpa-button').data('actiontype','remove');
jQuery('span.wpa-button').html('Act as Spam Bot');
}
}
function wpa_add_honeypot_field(){
jQuery('.bbp-topic-form form').append(wpa_hidden_field); // BBPRESS TOPIC
jQuery('.bbp-reply-form form').append(wpa_hidden_field); // BBPRESS REPLY
jQuery('form#commentform').append(wpa_hidden_field); // WP COMMENT
jQuery('form#ast-commentform').append(wpa_hidden_field); // Astra Comment Form
jQuery('form.wpcf7-form').append(wpa_hidden_field); // CONTACT FORM 7
jQuery('form.wpforms-form').append(wpa_hidden_field); // WPFFORMS
jQuery('.gform_wrapper form').append(wpa_hidden_field); // GRAVITY FORMS
jQuery('.frm_forms form').append(wpa_hidden_field); // Formidible forms
jQuery('.caldera-grid form').append(wpa_hidden_field); // Caldera forms
jQuery('.wp-block-toolset-cred-form form').append(wpa_hidden_field); // Toolset Forms
jQuery('form.et_pb_contact_form').append(wpa_hidden_field); // Divi Form
jQuery('form.elementor-form').append(wpa_hidden_field); // FOR Elementor
jQuery('form.form-contribution').append(wpa_hidden_field); //WooCommerce Reviews Pro
// FOR FLUENT FORMS
jQuery('form.frm-fluent-form').append(wpa_hidden_field); // FOR Fluent Forms
jQuery('.ff_conv_app').append(wpa_hidden_field); // FOR Fluent Convertional Forms
if (typeof fluent_forms_global_var_1 !== 'undefined') { // QUICK HACK FOR FLUENT FORMS CONVERSIONAL
fluent_forms_global_var_1.extra_inputs[wpa_field_name] = wpa_unique_id;
}
// EOF FLUENT FORMS
jQuery(wpa_hidden_field).insertAfter('input.wpa_initiator'); // FOR WPA INITIATOR (WP registration)
}
function wpa_add_test_block(){
checkingTest = '<div class="wpa-test-msg"><strong>WP Armour ( Only visible to site administrators. Not visible to other users. )</strong><br />This form has a honeypot trap enabled. If you want to act as spam bot for testing purposes, please click the button below.<br/><span class="wpa-button" onclick="wpa_act_as_spam()" data-actiontype="remove">Act as Spam Bot</span></div>';
jQuery('.wpa-test-msg').remove(); // Clear First
jQuery('span.wpa_hidden_field').after(checkingTest);
}
function wpa_remove_honeypot_field(){
jQuery('.wpa_hidden_field').remove();
if (typeof fluent_forms_global_var_1 !== 'undefined') {
delete fluent_forms_global_var_1.extra_inputs[wpa_field_name];
}
}

View File

@@ -0,0 +1,46 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<style type="text/css">
.why_extended{padding: 10px; font-size: 14px;}
.why_extended ul li{ padding-bottom: 20px; width: 285px; float: left; margin:10px 20px 10px 0px;border: 1px solid #d0d0d0; background: #d8d8d8; height: 150px; border-radius: 5px; padding: 10px; line-height: 1.5;}
.why_extended ul label{display: block;padding-bottom: 10px; font-size: 15px; color: #000; font-weight: 500;}
</style>
<div class="why_extended">
<h3>Extra Tools that WP Armour Extended offers to make WP Armour more powerfull.</h3>
<ul>
<li><label>Additional Support</label>
* WooCommerce & Easy Digital Downloads <br/>
* QuForm, MC4WP, HTMLform plugin<br/>
* BuddyPress, BuddyBoss<br/>
* NinjaForms, S2 Member, Avia Enfold Theme<br/>
* Gravity Forms (For Ajax enabled and multi page form) and more..
</li>
<li><label>2 Level Spam Check</label>
Our lite version should block most of the spam bot submission. But if you are still getting spam submission, you can enable 2 level spam check in Extended version from Extended Settings tab.
</li>
<li><label>Record Spammer IP</label>
Record spammers' IPs to block them from future submissions.
</li>
<li><label>View Spam Submission</label>
See what data spam bot was trying to submit.
</li>
<li><label>Auto Block Spam Bot IP</label>
Allows you to block the spam bot IP so that they can't visit your website.
</li>
<li><label>Get HoneyPot Extended Now !</label>
Get WP Armour Extended and make WP Armour more powerful.
<br/>
<a href="https://dineshkarki.com.np/buy-wp-armour-extended" target="_blank" class="button" style="float: right;">GET IT NOW</a>
</li>
<li><label>Don't need WP Armour Extended Tools ?</label>
In the long run, spam bots learn how to bypass antispam systems. Staying on top of new methodologies is key. You can motivate us to continue development of the plugin by getting a license for the WP Armour Extended.
</li>
</ul>
</div>

View File

@@ -0,0 +1,44 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if (isset($_POST['submit-wpa-general-settings'])){
$saveReturn = wpa_save_settings();
}
if (isset($_POST['submit-wpae-general-settings'])){
$saveReturn = wpae_save_settings();
}
if (isset($_GET['tab']) && array_key_exists($_GET['tab'],$wpa_tabs)){
$currentTab = $_GET['tab'];
} else {
$currentTab = 'settings';
}
?>
<?php if (isset($saveReturn)):?>
<div class="updated <?php echo $saveReturn['status']; ?>" id="message"><p><?php echo $saveReturn['body']; ?></p></div>
<?php endif; ?>
<div class="wrap">
<h1>WP Armour - HoneyPot Anti Spam</h1>
<nav class="nav-tab-wrapper">
<?php foreach ($wpa_tabs as $tabKey => $tabData) { ?>
<a href="?page=wp-armour&tab=<?php echo $tabKey; ?>" class="nav-tab <?php echo $currentTab == $tabKey?'nav-tab-active':''; ?>"><?php echo $tabData['name']; ?></a>
<?php } ?>
</nav>
<div class="tab-content">
<table width="100%">
<tr>
<td valign="top">
<?php include($wpa_tabs[$currentTab]['path']); ?>
</td>
<td width="15">&nbsp;</td>
<td width="250" valign="top"><?php include('wpa_sidebar.php'); ?></td>
</tr>
</table>
</div>
</div>

View File

@@ -0,0 +1,72 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_action('admin_notices', 'wpa_admin_notices');
if (isset($_GET['wpa_reviews_notice_hide']) == 1){
update_option('wpa_reviews_notice_hide','yes');
}
if (isset($_GET['wpa_extended_notice_hide']) == 1){
update_option('wpa_extended_notice_hide','yes');
}
function wpa_admin_notices(){
// FOR OLD EXTENDED VERSION
if(is_plugin_active( 'wp-armour-extended/wp-armour-extended.php' ) ) {
if ($GLOBALS['wpae_version'] < 1.17 ){
echo '<div class="notice notice-error is-dismissible">
<p><strong style="color:#900;">IMPORTANT : </strong> Your are using older version of WP Armour Extended. Please update to 1.17 or above for it to work properly.</p>
</div>';
}
}
// FOR REVIEWS
if (get_option('wpa_reviews_notice_hide') != 'yes'){
$installedDate = strtotime(get_option('wpa_installed_date'));
$todayDate = time();
$installedDays = round(($todayDate - $installedDate) / (60 * 60 * 24));
$wpa_stats = json_decode(get_option('wpa_stats'),true);
$all_spam_blocked = $wpa_stats['total']['all_time'];
if ($installedDays > 30 && $all_spam_blocked > 30){
echo '<div class="updated success" style="padding:10px; font-size:16px; line-height:1.6;color:#205225;">
Hey, WP Armour has blocked <strong>'.$all_spam_blocked.'</strong> spam submissions till date - thats awesome! Could you please do us a BIG favor and give it a 5-star rating on WordPress ? Just to help us spread the word and boost our motivation.<br/><br/>
<ul style="padding-left:50px;list-style-type: square;">
<li><a href="https://wordpress.org/support/plugin/honeypot/reviews/?filter=5" target="_blank">Ok, you deserve it</a></li>
<li><a href="https://dineshkarki.com.np/contact" target="_blank">I still have problem !!</a></li>
<li><a href="?wpa_reviews_notice_hide=1">I already did</a></li>
<li><a href="?wpa_reviews_notice_hide=1">Hide this message</a></li>
</ul>
</div>';
}
}
// UPSELLING EXTENDED VERSION
if (get_option('wpa_extended_notice_hide') != 'yes' && !is_plugin_active('wp-armour-extended/wp-armour-extended.php') ){
$installedDate = strtotime(get_option('wpa_installed_date'));
$todayDate = time();
$installedDays = round(($todayDate - $installedDate) / (60 * 60 * 24));
$wpa_stats = json_decode(get_option('wpa_stats'),true);
$all_spam_blocked = $wpa_stats['total']['all_time'];
if ($installedDays > 90 && $all_spam_blocked > 1000){
echo '<div class="updated success" style="padding:10px; font-size:16px; line-height:1.6;color:#205225;">
Hey, WP Armour has blocked <strong>'.$all_spam_blocked.'</strong> spam submissions till date - thats awesome!<br/><br/>
Can you help us by purchasing our Extended Version ? This will helps up maintain and support the plugin in upcoming days and make it even better. Our Extended version starts from 19.99 USD and comes with lifetime license (No monhtly or yearly recurring) and No API calls. <br/><br/>
Also, it has 2 level spam check and additionally works with WooCommerce, Ajax and Multi page Gravity Forms, Easy Digital Downloads, QuForm, MC4WP: Mailchimp for WordPress and have Spammer blocking based on IP, Record Spam Submission and so on.
<ul style="padding-left:50px;list-style-type: square;">
<li><a href="https://dineshkarki.com.np/buy-wp-armour-extended" target="_blank">I will help</a></li>
<li><a href="?wpa_extended_notice_hide=1">Hide this message</a></li>
</ul>
</div>';
}
}
}

View File

@@ -0,0 +1,67 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<br/>
<table class="wp-list-table widefat">
<thead>
<tr>
<th colspan="2"><strong>General Settings</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2"><strong>This plugin should work with default settings, however if you begin to get spam, update the field name below.</strong></td>
</tr>
<form method="post" action="">
<tr>
<td width="250">Honey Pot Field Name</td>
<td>
<input id="wpa_field_name" name="wpa_field_name" style="width:300px;" value="<?php echo esc_attr(get_option('wpa_field_name'));?>" type="text" readonly="readonly" />
<span class="dashicons dashicons-update" style="font-size: 28px; cursor: pointer;" onclick="wpa_unqiue_field_name()"></span>
<br/>
<em>Changing the field name regularly is a good idea. Please click on icon above to generate new field name.</em>
</td>
</tr>
<tr>
<td>Honey Pot Error Message</td>
<td>
<input name="wpa_error_message" style="width:300px;" value="<?php echo esc_attr(get_option('wpa_error_message'));?>" type="text" /><br/><em>Mesage for bots. No average human users will see though.</em>
</td>
</tr>
<tr>
<td>Disable Honeypot Test Widget</td>
<td>
<select name="wpa_disable_test_widget">
<option value="no" <?php echo get_option('wpa_disable_test_widget') == 'no'?'selected="selected"':''; ?> >No</option>
<option value="yes" <?php echo get_option('wpa_disable_test_widget') == 'yes'?'selected="selected"':''; ?> >Yes</option>
</select>
<em>Only visible when Admin user is logged in.</em>
</td>
</tr>
<tr>
<td colspan="2">
<?php wp_nonce_field( 'wpa_save_settings', 'wpa_nonce' ); ?>
<input type="submit" name="submit-wpa-general-settings" class="button-primary" value="Save General Settings" />
</td>
</tr>
</form>
</tbody>
</table><br/>
<script type="text/javascript">
function wpa_unqiue_field_name(){
var randomChars = 'abcdefghijklmnopqrstuvwxyz';
var length = 6;
var string = '';
for ( var i = 0; i < length; i++ ) {
string += randomChars.charAt(Math.floor(Math.random() * randomChars.length));
}
var number = Math.floor(1000 + Math.random() * 9000);
jQuery('#wpa_field_name').val(string+number);
}
</script>

View File

@@ -0,0 +1,49 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<style type="text/css">
ul.uaf_list{ list-style-type:square;margin-left: 2em;}
</style>
<br/>
<table class="wp-list-table widefat fixed bookmarks">
<thead>
<tr>
<th><strong>Quick Link</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<ul class="uaf_list">
<li><a href="https://wordpress.org/support/plugin/honeypot/" target="_blank">Support Forum</a></li>
<li><a href="https://www.facebook.com/Dnesscarkey-77553779916" target="_blank">Send Us Msg via Facebook</a></li>
<li><a href="https://dineshkarki.com.np/buy-wp-armour-extended" target="_blank">Get WP Armour Extended</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<br/>
<table class="wp-list-table widefat fixed bookmarks">
<thead>
<tr>
<th><strong>Plugins You May Like</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<ul class="uaf_list">
<li><a href="https://wordpress.org/plugins/use-any-font/" target="_blank">Use Any Font</a></li>
<li><a href="https://dineshkarki.com.np/jquery-validation-for-gravity-forms" target="_blank">Jquery Validation For Gravity Form</a></li>
<li><a href="http://wordpress.org/extend/plugins/any-mobile-theme-switcher/" target="_blank">Any Mobile Theme Switcher</a></li>
<li><a href="http://wordpress.org/extend/plugins/jquery-validation-for-contact-form-7/" target="_blank">Jquery Validation For Contact Form 7</a></li>
<li><a href="http://wordpress.org/extend/plugins/add-tags-and-category-to-page/" target="_blank">Add Tags And Category To Page</a></li>
<li><a href="http://wordpress.org/extend/plugins/block-specific-plugin-updates/" target="_blank">Block Specific Plugin Updates</a></li>
<li><a href="http://wordpress.org/extend/plugins/featured-image-in-rss-feed/" target="_blank">Featured Image In RSS Feed</a></li>
<li><a href="http://wordpress.org/extend/plugins/remove-admin-bar-for-client/" target="_blank">Remove Admin Bar</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<br/>

View File

@@ -0,0 +1,93 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
$currentStats = json_decode(get_option('wpa_stats'), true);
?>
<br/>
<table class="wp-list-table widefat fixed bookmarks">
<?php
/*
<thead>
<tr>
<th colspan="5"><strong>Quick Stats</strong></th>
</tr>
</thead>
*/ ?>
<thead>
<tr>
<th><strong>Source</strong></th>
<th><strong>Today</strong></th>
<th><strong>This Week</strong></th>
<th><strong>This Month</strong></th>
<th><strong>All Time</strong></th>
</tr>
<thead>
<tbody>
<?php
if (!empty($currentStats)){
foreach ($currentStats as $source=>$statData): ?>
<tr>
<td><strong><?php echo ucfirst($source); ?></strong></td>
<td><?php echo @wpa_check_date($statData['today']['date'],'today')?$statData['today']['count']:'0'; ?></td>
<td><?php echo @wpa_check_date($statData['week']['date'],'week')?$statData['week']['count']:'0'; ?></td>
<td><?php echo @wpa_check_date($statData['month']['date'],'month')?$statData['month']['count']:'0'; ?></td>
<td><?php echo $statData['all_time']; ?></td>
</tr>
<?php endforeach;
} else { ?>
<tr><td colspan="5">No Record Found</td></tr>
<?php } ?>
</tbody>
</table><br/>
<br/>
<?php /*
<table class="wp-list-table widefat fixed bookmarks">
<thead>
<tr>
<th colspan="2"><strong>Visualization </strong></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2">
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Source', 'Today', 'This Week','This Month', 'All Time'],
<?php foreach ($currentStats as $source=>$statData): ?>
[
'<?php echo ucfirst($source); ?>',
<?php echo wpa_check_date($todayDate,'today')?$statData['today']['count']:'0'; ?>,
<?php echo wpa_check_date($weekDate,'week')?$statData['week']['count']:'0'; ?>,
<?php echo wpa_check_date($monthDate,'month')?$statData['month']['count']:'0'; ?>,
<?php echo $statData['all_time']; ?>
],
<?php endforeach;?>
]);
var options = {
chart: {
title: 'Spam blocked by WP Armour',
hAxis: {title: 'Source', titleTextStyle: {color: 'red'}},
},
colors:['#bedcf5','#75b5e9','#2c8ddd','#19609b']
};
var chart = new google.charts.Bar(document.getElementById('wpae_chart_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
<div id="wpae_chart_div" style="width:100%; height:400px; margin-top:15px; margin-bottom:10px;">
</div>
</td>
</tr>
</tbody>
</table><br/>*/ ?>

View File

@@ -0,0 +1,28 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<style type="text/css">
.wpa_stat_table{max-width: 100%;filter: blur(2px);-webkit-filter: blur(2px);}
.wpa_stat_table_holder{position: relative;}
.wpa_stat_overlay{position: absolute; z-index: 10; width: 80%; height: 80%;top: 10%; left: 10%;box-shadow: 0 0 25px 10px rgba(0,0,0,0.08); background: #fff; border-radius: 5px; text-align:center;}
.wpa_stat_overlay .wpa_stat_headline{font-size: 20px; margin-top: 20px; padding: 5px;}
.wpa_stat_overlay .wpa_stat_content{padding: 5px;}
.wpa_stat_button a{ padding: 5px 30px !important; }
</style>
<div class="wpa_stat_table_holder">
<img class="wpa_stat_table" src="<?php echo plugin_dir_url( dirname( __FILE__ ) ) . 'img/dashboard_stats.png'; ?>" />
<div class="wpa_stat_overlay">
<div class="wpa_stat_headline">
View all spam statistics from dashboard
</div>
<div class="wpa_stat_content">
<p>Enable stats widgets with WP Armour Extended.</p>
<p>Also, it can auto block spammer's IP and record what spammer are trying to submit.</p>
</div>
<div class="wpa_stat_button">
<a href="https://dineshkarki.com.np/buy-wp-armour-extended" target="_blank" class="button button-primary">Get WP Armour Extended</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,6 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
$GLOBALS['wpa_version'] = '2.0.1';
$GLOBALS['wpa_field_name'] = get_option('wpa_field_name');
$GLOBALS['wpa_error_message'] = get_option('wpa_error_message');
$GLOBALS['wpa_disable_test_widget'] = get_option('wpa_disable_test_widget');

View File

@@ -0,0 +1,16 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
add_action("wp_dashboard_setup", "wpa_dashboard_widget");
function wpa_dashboard_widget()
{
add_meta_box( 'wpa_dashboard_widget', 'WP Armour Anti Spam Statistics', 'wpa_dashboard_widget_function', 'dashboard', 'side', 'high');
}
function wpa_dashboard_widget_function(){
ob_start();
include('views/wpa_stats_widget.php');
$widget_content = ob_get_contents();
ob_end_clean ();
$widget_content = apply_filters( 'wpa_widget_content', $widget_content);
echo $widget_content;
}

View File

@@ -0,0 +1,153 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
function wpa_load_scripts(){
wp_enqueue_script( 'wpascript', plugins_url( '/js/wpa.js', __FILE__ ), array ( 'jquery' ), $GLOBALS['wpa_version'], true);
wp_add_inline_script( 'wpascript', 'wpa_field_info = '.json_encode(wpa_field_info()));
wp_enqueue_style( 'wpa-css', plugins_url( '/css/wpa.css', __FILE__ ), array(), $GLOBALS['wpa_version']);
}
function wpa_plugin_menu(){
add_menu_page( 'WP Armour', 'WP Armour', 'manage_options', 'wp-armour', 'wpa_options','dashicons-shield');
}
function wpa_options(){
$wpa_tabs = array(
'settings' => array('name'=>'Settings','path'=>'wpa_settings.php'),
'stats' => array('name'=>'Statistics','path'=>'wpa_stats.php'),
'extended_version' => array('name'=>"What's in WP Armour Extended ?",'path'=>'wpa_extended_version.php')
);
$wpa_tabs = apply_filters( 'wpa_tabs_filter', $wpa_tabs);
include 'views/wpa_main.php';
}
function wpa_save_settings(){
if ( isset($_POST['wpa_nonce']) && wp_verify_nonce($_POST['wpa_nonce'], 'wpa_save_settings')) {
if (empty($_POST['wpa_field_name'])){
$return['status'] = 'error';
$return['body'] = "Honey Pot Field Name can't be empty";
} else {
update_option('wpa_field_name',sanitize_title_with_dashes($_POST['wpa_field_name']));
update_option('wpa_error_message',sanitize_text_field($_POST['wpa_error_message']));
update_option('wpa_disable_test_widget',sanitize_text_field($_POST['wpa_disable_test_widget']));
$GLOBALS['wpa_field_name'] = get_option('wpa_field_name');
$GLOBALS['wpa_error_message'] = get_option('wpa_error_message');
$return['status'] = 'ok';
$return['body'] = 'Settings Saved';
}
} else {
$return['status'] = 'error';
$return['body'] = 'Sorry, your nonce did not verify. Please try again.';
}
return $return;
}
function wpa_save_stats($wp_system, $data){
$currentStats = json_decode(get_option('wpa_stats'), true);
$timeArray = array('today','week','month');
if (!array_key_exists($wp_system,$currentStats)){
$currentStats[$wp_system]['today']['count'] = 0;
$currentStats[$wp_system]['week']['count'] = 0;
$currentStats[$wp_system]['month']['count'] = 0;
$currentStats[$wp_system]['today']['date'] = date('Ymd');
$currentStats[$wp_system]['week']['date'] = date('Ymd');
$currentStats[$wp_system]['month']['date'] = date('Ymd');
}
foreach ($timeArray as $key => $time) {
if (wpa_check_date($currentStats['total'][$time]['date'],$time)){
$currentStats['total'][$time]['count'] += 1;
} else {
$currentStats['total'][$time]['count'] = 1;
}
if (wpa_check_date($currentStats[$wp_system][$time]['date'],$time)){
$currentStats[$wp_system][$time]['count'] += 1;
} else {
$currentStats[$wp_system][$time]['count'] = 1;
}
$currentStats['total'][$time]['date'] = date('Ymd');
$currentStats[$wp_system][$time]['date'] = date('Ymd');
}
$currentStats['total']['all_time'] += 1;
@$currentStats[$wp_system]['all_time'] += 1;
update_option('wpa_stats', json_encode($currentStats));
}
function wpa_check_date($timestamp, $comparision){
switch ($comparision) {
case 'today':
if (date('Ymd') == $timestamp){
return true;
} else {
return false;
}
break;
case 'week':
$firstWeekDay = date("Ymd", strtotime('monday this week'));
$lastWeekDay = date("Ymd", strtotime('sunday this week'));
if($timestamp >= $firstWeekDay && $timestamp <= $lastWeekDay) {
return true;
} else {
return false;
}
break;
case 'month':
if(date('Ym',strtotime($timestamp)) == date('Ym')) {
return true;
} else {
return false;
}
break;
}
}
function wpa_unqiue_field_name(){
$permitted_chars = 'abcdefghijklmnopqrstuvwxyz';
return substr(str_shuffle($permitted_chars), 0, 6).rand(1,9999);
}
function wpa_unqiue_field_value(){
if (function_exists('wpae_unqiue_field_value')){ // IF EXTENDED VERSION AVAILABLE
return wpae_unqiue_field_value();
} else {
return rand(1111, 999999);
}
}
function wpa_check_is_spam($form_data){
if (isset($form_data[$GLOBALS['wpa_field_name']])){
if (function_exists('wpae_2level_spam_check')){
return wpae_2level_spam_check($form_data[$GLOBALS['wpa_field_name']]);
} else {
return false; // FALSE MEANS NOT SPAM
}
} else {
return true; // TRUE MEANS SPAM
}
}
function wpa_field_info(){
if (current_user_can('activate_plugins') && (get_option('wpa_disable_test_widget') != 'yes')){
$wpa_add_test = 'yes';
} else {
$wpa_add_test = 'no';
}
$return = array(
'wpa_field_name' => $GLOBALS['wpa_field_name'],
'wpa_field_value' => wpa_unqiue_field_value(),
'wpa_add_test' => $wpa_add_test
);
return $return;
}