Plugin Directory

Changeset 1215910


Ignore:
Timestamp:
08/08/2015 04:33:51 PM (11 years ago)
Author:
jtmorris
Message:

v3.3.0

Location:
ad-blocking-detector/trunk
Files:
2 added
1 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • ad-blocking-detector/trunk/ad-blocking-detector.php

    r1208754 r1215910  
    44 * Plugin URI: http://adblockingdetector.jtmorris.net
    55 * Description: A plugin for detecting ad blocking browser extensions, plugins, and add-ons. It allows you to display alternative content to site visitors who block your ads.
    6  * Version: 3.2.0
     6 * Version: 3.3.0
    77 * Author: John Morris
    88 * Author URI: http://cs.johnmorris.me
     
    4141 *     \/      \/      \/      \/                          */
    4242
    43 define( 'ABD_VERSION', '3.2.0' );
     43define( 'ABD_VERSION', '3.3.0' );
    4444
    4545/*     /\      /\      /\      /\
     
    5353$start_time = microtime( true );
    5454$start_mem = memory_get_usage( true );
    55 $start_peak_mem = memory_get_peak_usage( true );
    5655
    5756define ( 'ABD_ROOT_PATH', plugin_dir_path( __FILE__ ) );
     
    6564ABD_Setup::initialize();
    6665
    67 
    68 
    69 //      Start SESSION to facilitate data transfers
    70 //      Don't Forget Error Prevention: http://goo.gl/Acm9oY
    71 //      Don't Forget PHP 5.4.0+ changes: http://www.php.net/manual/en/function.session-status.php
    72 function abd_my_session_start()
    73 {
    74     if(abd_is_session_started() || !isset($_SESSION)) {
    75         if (isset($_COOKIE['PHPSESSID'])) {
    76                 $sessid = $_COOKIE['PHPSESSID'];
    77         }
    78         else if (isset($_GET['PHPSESSID'])) {
    79                 $sessid = $_GET['PHPSESSID'];
    80         }
    81         else {
    82                 session_start();
    83                 return false;
    84         }
    85         if (!preg_match('/^[a-z0-9]{32}$/', $sessid)) {
    86                 return false;
    87         }
    88         session_start();
    89         return true;
    90     }
    91 }
    92 function abd_is_session_started()
    93 {
    94     if ( php_sapi_name() !== 'cli' ) {
    95         if ( version_compare(phpversion(), '5.4.0', '>=') ) {
    96             return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
    97         } else {
    98             return session_id() === '' ? FALSE : TRUE;
    99         }
    100     }
    101     return FALSE;
    102 }
    103 abd_my_session_start();
    104 
    10566ABD_Log::perf_summary( 'Entire Plugin Init', $start_time, $start_mem );
    106 ABD_Log::perf( 'Entire Plugin Init -- Peak Memory = ' . ( memory_get_peak_usage( true ) - $start_peak_mem )/1048576 . 'MB' );
  • ad-blocking-detector/trunk/assets/anti-adblock/plugin-files/ad-blocking-detector-block-list-countermeasure.php

    r1208754 r1215910  
    44 * Plugin URI: http://adblockingdetector.johnmorris.me
    55 * Description: Provides fallback files in the event the main Ad Blocking Detector's assets are blocked.
    6  * Version: 3.2.0
     6 * Version: 3.3.0
    77 * Author: John Morris
    88 * Author URI: http://cs.johnmorris.me
     
    3939 *     \/      \/      \/      \/                          */
    4040
    41 define( 'ABDBLC_VERSION', '3.2.0' );
     41define( 'ABDBLC_VERSION', '3.3.0' );
    4242
    4343/*     /\      /\      /\      /\
  • ad-blocking-detector/trunk/assets/anti-adblock/zip-name.txt

    r1208754 r1215910  
    1 jolly-drink-manual
     1ok-things-manual
  • ad-blocking-detector/trunk/assets/css/admin.css

    r1206074 r1215910  
    107107    border-bottom: 3px solid #CCC;
    108108}   
    109     #abdwpsm_tab-manage-shortcodes form .abd-shortcode-get-button {
     109    .abdwpsm_tab_wrapper .abd-shortcode-get-button,
     110    .abdwpsm_tab_wrapper .abd-shortcode-get-button:hover {
    110111        background-color: #78d639;
    111112        font-size: 1.2em;
     
    115116        color: #222;
    116117    }
    117         #abdwpsm_tab-manage-shortcodes form .abd-shortcode-get-button:before {
     118        .abdwpsm_tab_wrapper .abd-shortcode-get-button:before {
    118119            content:'\2713 \0020';
    119120        }
    120     #abdwpsm_tab-manage-shortcodes form .abd-shortcode-delete-button {
     121    .abdwpsm_tab_wrapper .abd-delete-button,
     122    .abdwpsm_tab_wrapper .abd-delete-button:hover {
    121123        background-color: #FF7F7F;
    122124        font-size: 1.2em;
     
    126128        color: #222;
    127129    }
    128         #abdwpsm_tab-manage-shortcodes form .abd-shortcode-delete-button:before {
     130        .abdwpsm_tab_wrapper .abd-delete-button:before {
    129131            content:'\2717 \0020';
    130132        }
     
    255257
    256258
     259div.abd-stats-chart {
     260    width: 650px;
     261    height: 500px;
     262}
     263p.abd-stats-chart-caption {
     264    width: 650px;
     265    font-size: 1.1em;
     266
     267    padding-bottom: 20px;
     268    border-bottom: 3px solid #999;
     269}
     270
     271
    257272 /********************
    258273 * jQuery UI Fixes
  • ad-blocking-detector/trunk/assets/js/adblock-detector.js

    r1206106 r1215910  
    9393        //  Ad blockers can hide things in numerous ways. Check every way I
    9494        //  can think of.
    95         if(ABDSettings.enableIframe == 'yes' || ABDSettings.enableIframe == '') {
     95        if(ABDSettings.enableIframe != 'no') {
    9696            //  Check for the appended frame
    9797            //
     
    110110
    111111
    112         if( ABDSettings.enableDiv == 'yes' || ABDSettings.enableDiv == '' ) {
     112        if( ABDSettings.enableDiv != 'no' ) {
    113113            retVal = self.checkAdStatusDivHelper(div, divNoJq, retVal);
    114114        }
     
    118118
    119119
    120         if( ABDSettings.enableJsFile == 'yes' || ABDSettings.enableJsFile == '' ) {
     120        if(ABDSettings.enableJsFile != 'no') {
    121121            //  Check for bait javascript file (assets/js/advertisement.js) flags
    122122            if (window.abd_script_load_flag !== true) {
  • ad-blocking-detector/trunk/assets/js/admin-view.js

    r1208754 r1215910  
    382382
    383383
    384 
     384        //////////////////////////////////
     385        //  Statistics Charts & Buttons //
     386        //////////////////////////////////
     387        //  Load Google Charts
     388        //  We only need to do this on the statistics page... if the chart containers are
     389        //  present.  Let's check if the chart containers are present by picking one and
     390        //  seeing what we get.
     391        if( $('#abd-stats-chart-page-load').length ) {
     392            //  Yay!  We're on stats page and containers are present.       
     393            google.load('visualization', '1.0', {
     394                'packages':['corechart'],
     395                callback: function() {
     396                    //  This is here to keep page from being blank
     397                    //  http://stackoverflow.com/a/24980290
     398                }
     399            });
     400            google.setOnLoadCallback(drawCharts);
     401        }
     402
     403        //  Reset Statistics Button Handling
     404        $('#abd-statistics-reset-button').click(function(e) {
     405            e.preventDefault();
     406            var targetUrl = $(this).attr("href");
     407
     408            var warning = '<p>' + objectL10n.resetStatisticsWarning + '</p>';
     409
     410            var dsDialog = $("<div/>").html(warning).dialog( {
     411                modal: true,
     412                title: objectL10n.resetStatisticsTitle,
     413                width: 400,
     414                position: {my: 'right bottom', at: 'middle'},
     415                buttons: [
     416                    {
     417                        text: objectL10n.affirmative,
     418                        icons: {primary: 'ui-icon-check'},
     419                        click: function() {
     420                            window.location.href = targetUrl;
     421                        }
     422                    },
     423                    {
     424                        text: objectL10n.nevermind,
     425                        icons: {primary: 'ui-icon-closethick'},
     426                        click: function() {
     427                            $(this).dialog("destroy");
     428                        }
     429                    }
     430                ],
     431                open: function() {
     432                    //  Fix Random jQuery UI CSS Scoping Issues //
     433                    $('div.ui-widget-overlay, div.ui-dialog').wrap('<div class="ffs abd-jqui" />');
     434                }
     435            });
     436            dsDialog.parent('.ui-dialog').addClass('abd-jqui'); //  jQuery UI theme scope
     437        });
     438       
     439        function drawCharts() {
     440            drawPageLoadChart('#336699', '#a93912');
     441            drawUserChart('#336699', '#a93912');
     442            drawDisableChart('#33CC33', '#990099');
     443            drawEnableChart('#33CC33', '#990099');
     444        }
     445
     446        function drawPageLoadChart(goodColor, badColor, neutralColor) {
     447            var data = new google.visualization.DataTable();
     448            data.addColumn( 'string', 'Category' );
     449            data.addColumn( 'number', 'The Number' );
     450            data.addRows([
     451                ['Ad Blockers Enabled (' + ABDStats.pageLoadAdblocker + ')', ABDStats.pageLoadAdblocker],
     452                ['Ad Blockers Disabled (' + ABDStats.pageLoadNoAdblocker + ')', ABDStats.pageLoadNoAdblocker],
     453                ['Other (' + ABDStats.pageLoadOther + ')', ABDStats.pageLoadOther]
     454            ]);
     455
     456            var options = {
     457                'title': 'Ad Blockers By Page Loads',
     458                'colors': [badColor, goodColor, neutralColor],
     459                'backgroundColor': '#f1f1f1',
     460                'fontSize': 18,
     461                'fontName': 'sans-serif',
     462                'legend': {position: 'bottom', textStyle: {fontSize: 15}}
     463            };
     464
     465            var chart = new google.visualization.PieChart(document.getElementById('abd-stats-chart-page-load'));
     466            chart.draw(data, options);
     467        }
     468
     469        function drawUserChart(goodColor, badColor, neutralColor) {
     470            var data = new google.visualization.DataTable();
     471            data.addColumn( 'string', 'Category' );
     472            data.addColumn( 'number', 'The Number' );
     473            data.addRows([
     474                ['Ad Blockers Enabled (' + ABDStats.uniqueUsersAdBlocker + ')', ABDStats.uniqueUsersAdBlocker],
     475                ['Ad Blockers Disabled (' + ABDStats.uniqueUsersNoAdBlocker + ')', ABDStats.uniqueUsersNoAdBlocker],
     476                ['Other (' + ABDStats.uniqueUsersOther + ')', ABDStats.uniqueUsersOther]
     477            ]);
     478
     479            var options = {
     480                'title': 'Ad Blockers By Unique User',
     481                'colors': [badColor, goodColor, neutralColor],
     482                'backgroundColor': '#f1f1f1',
     483                'fontSize': 18,
     484                'fontName': 'sans-serif',
     485                'legend': {position: 'bottom', textStyle: {fontSize: 15}}
     486            };
     487
     488            var chart = new google.visualization.PieChart(document.getElementById('abd-stats-chart-unique-user'));
     489            chart.draw(data, options);
     490        }
     491
     492        function drawDisableChart(goodColor, badColor) {
     493            if( ABDStats.numUsersToDisable > 0 ) {
     494                var to = ABDStats.numUsersToDisable;
     495                var lo = ABDStats.uniqueUsersAdBlocker - ABDStats.numUsersToDisable;
     496            }
     497            else {
     498                var to = 0;
     499                var lo = 0;
     500            }
     501
     502            var data = new google.visualization.DataTable();
     503            data.addColumn( 'string', 'Category' );
     504            data.addColumn( 'number', 'The Number' );
     505            data.addRows([
     506                ['Turned Off Ad Blockers (' + to + ')', to],
     507                ['Left On Ad Blockers (' + lo + ')', lo]
     508            ]);
     509
     510            var options = {
     511                'title': 'Users Who Toggled Off Ad Blocker',
     512                'colors': [goodColor, badColor],
     513                'backgroundColor': '#f1f1f1',
     514                'fontSize': 18,
     515                'fontName': 'sans-serif',
     516                'legend': {position: 'bottom', textStyle: {fontSize: 15}}
     517            };
     518
     519            var chart = new google.visualization.PieChart(document.getElementById('abd-stats-chart-change-disable'));
     520            chart.draw(data, options);
     521        }
     522
     523        function drawEnableChart(goodColor, badColor) {
     524            if( ABDStats.numUsersToEnable > 0 ) {
     525                var to = ABDStats.numUsersToEnable;
     526                var lo = ABDStats.uniqueUsersNoAdBlocker - ABDStats.numUsersToEnable;
     527            }
     528            else {
     529                var to = 0;
     530                var lo = 0;
     531            }
     532
     533            var data = new google.visualization.DataTable();
     534            data.addColumn( 'string', 'Category' );
     535            data.addColumn( 'number', 'The Number' );
     536            data.addRows([
     537                ['Turned On Ad Blockers (' + to + ')', to],
     538                ['Left Off Ad Blockers (' + lo + ')', lo]
     539            ]);
     540
     541            var options = {
     542                'title': 'Users Who Toggled On Ad Blocker',
     543                'colors': [goodColor, badColor],
     544                'backgroundColor': '#f1f1f1',
     545                'fontSize': 18,
     546                'fontName': 'sans-serif',
     547                'legend': {position: 'bottom', textStyle: {fontSize: 15}}
     548            };
     549
     550            var chart = new google.visualization.PieChart(document.getElementById('abd-stats-chart-change-enable'));
     551            chart.draw(data, options);
     552        }
    385553
    386554
  • ad-blocking-detector/trunk/includes/ajax-actions.php

    r1203582 r1215910  
    88    class ABD_Ajax_Actions {
    99       
     10        public static function submit_stats() {
     11            check_ajax_referer( 'ad blocking detector stats ajax nonce', '_wpnonce' );
     12
     13            //  First, check ignore cases
     14            $enabled = ABD_Database::get_specific_setting( 'enable_statistics' );
     15            $ignore_registered = ABD_Database::get_specific_setting( 'stats_ignore_registered' );
     16            $ignore_ips = ABD_Database::get_specific_setting( 'stats_ignore_ips' );
     17
     18            if( $enabled == 'no' ) {
     19                echo 'Statistics recording disabled.';
     20                wp_die();
     21            }
     22
     23            if( $ignore_registered == 'yes' ) {
     24                if( is_user_logged_in() ) {
     25                    echo 'Skipping stastics update for logged in user.';
     26                    wp_die();   //  terminate immediately for proper AJAX response
     27                }
     28            }
     29
     30            if( !empty( $ignore_ips ) ) {
     31                //  This is results from textarea... one IP on each line... split it into array
     32                $ignore_ips = trim( $ignore_ips );
     33                $ips = explode( '\n', $ignore_ips );
     34                $ips = array_filter( $ips, 'trim' );    //  remove any \r characters
     35
     36                $cur_user_ip = $_SERVER['REMOTE_ADDR'];
     37
     38                foreach( $ips as $ip ) {
     39                    if( ABD_Perf_Tools::ip_in_range( $cur_user_ip, $ip ) ) {
     40                        echo 'Skipping statistics update for user\'s IP address: ' . $cur_user_ip;
     41                        wp_die();   //  terminate immediately for proper AJAX response
     42                    }
     43                }
     44            }
     45
     46
     47            //  If we're here, then we really are supposed to record this
     48            if( array_key_exists( 'adblocker', $_POST ) ) {
     49                $adblocker = intval( $_POST['adblocker'] );
     50                $blog_id = ABD_Multisite::get_current_blog_id();
     51                $user_ip = $_SERVER['REMOTE_ADDR'];
     52
     53                //  Check validity of value
     54                if( $adblocker != 1 && $adblocker != 0 && $adblocker != -1 ) {
     55                    echo 'Invalid adblocker status code submitted. (' . $adblocker . ')';
     56                    wp_die();   //  terminate immediately for proper AJAX response
     57                }
     58
     59                //  Add it to database
     60                $res = ABD_Database::insert_stat( $adblocker, $blog_id, $user_ip );
     61
     62                if( $res ) {
     63                    echo 'Statistics database updated.';
     64                }
     65                else {
     66                    echo 'Failed to update statistics database.';
     67                }
     68
     69                wp_die();   //  terminate immediately for proper AJAX response
     70            }
     71        }
     72
    1073    }   //  end class
    1174}   //  end if ( !class_exists( ...
  • ad-blocking-detector/trunk/includes/anti-adblock.php

    r1208754 r1215910  
    182182
    183183            return $retval;
    184 
    185 
    186 
    187 
    188 
    189 
    190 
    191 
    192             // $status = array( 'auto_plugin_exists' => 0, 'auto_plugin_activated' => 0, 'manual_plugin_exists' => -1, 'manual_plugin_activated' => 0 );
    193 
    194             // $dir_name = get_site_option( 'abd_blc_dir' );
    195             // $plugin_type = get_site_option( 'abd_blc_plugin_type' );
    196 
    197             // if( $dir_name ) {//  Plugin should exist             
    198             //  //  Let's make sure
    199             //  $plugin_path = ABD_ROOT_PATH . '../' . $dir_name;
    200                
    201             //  if( !is_dir( $plugin_path ) ) {
    202             //      ABD_Log::error( 'Block List Countermeasure plugin does not exist at the location it is expected to: ' . $plugin_path );
    203 
    204             //      //  The directory option is obviously out of sync...
    205             //      delete_site_option( 'abd_blc_dir' );
    206 
    207             //      //  The plugin does not exist... therefore it isn't activated either... so, return our vanilla $status
    208             //      return $status;
    209             //  }
    210 
    211             //  //  If we're here, the plugin exists.  Now we just need to know whether it's automatic or manual
    212             //  if( $plugin_type == 'auto' ) {
    213             //      //  It's automatic
    214             //      $status['auto_plugin_exists'] = 1;
    215             //      $status['manual_plugin_exists'] = 0;
    216             //  }
    217             //  else {
    218             //      //  It's manual
    219             //      $status['manual_plugin_exists'] = 1;
    220             //      $status['auto_plugin_exists'] = 0;
    221             //  }
    222 
    223             //  //  Let's check if the plugin is activated.  The simplest way to do that is check whether
    224             //  //  one of it's crucial constants is defined.
    225             //  if( defined( 'ABDBLC_ROOT_PATH' ) ) {
    226             //      //  Yes, it is activated
    227             //      if( $plugin_type == 'auto' ) {
    228             //          $status['auto_plugin_activated'] = 1;
    229             //          $status['manual_plugin_activated'] = 0;
    230             //      }
    231             //      else {
    232             //          $status['manual_plugin_activated'] = 1;
    233             //          $status['auto_plugin_activated'] = 0;
    234             //      }
    235             //  }
    236             // }
    237             // else {   //  Plugin does not exist
    238             //  $status['manual_plugin_exists'] = 0;
    239             //  $status['auto_plugin_exists'] = 0;
    240             // }
    241 
    242 
    243             // ABD_Log::perf_summary( 'ABD_Anti_Adblock::bcc_plugin_status()', $start_time, $start_mem );
    244 
    245             // return $status;
    246184        }
    247185
  • ad-blocking-detector/trunk/includes/click-handler.php

    r1208754 r1215910  
    111111
    112112
     113        public static function delete_all_statistics() {
     114            $start_time = microtime( true );
     115            $start_mem = memory_get_usage( true );
     116
     117            check_admin_referer( 'user instructed deletion of all statistics table rows' );
     118
     119            $res = ABD_Database::delete_all_stats();
     120
     121            ABD_Log::perf_summary( 'ABD_Click_Handler::send_usage_info()', $start_time, $start_mem );
     122
     123            self::redirect( 'delete_all_stats_success' );
     124        }
     125
     126
    113127       
    114128
  • ad-blocking-detector/trunk/includes/database.php

    r1208754 r1215910  
    88        protected static $our_shortcode_cache_option = 'abd_sc_cache'; 
    99        protected static $our_shortcode_cache = null;
     10        protected static $our_stats_table = 'abd_adblocker_stats';
     11
     12        protected static $our_list_of_options = array(
     13            'abd_event_log',
     14            'abd_blc_dir',
     15            'abd_blc_plugin_type',
     16            'abd_user_settings',
     17            'abd_list_of_shortcodes',
     18            'abd_feedback_nag_time',
     19            'abd_current_version'
     20        );
     21        protected static $our_list_of_transients = array(
     22            'abd_sc_cache',
     23            'abd_next_shortcode_id'
     24        );
    1025
    1126        /**
     
    7792                $options = self::$our_shortcode_cache;
    7893                $cache_status = true;
     94                $update_list_flag = false;
    7995            }
    8096            else { 
     
    286302        public static function get_settings( $json_array = false ) {
    287303            $abd_settings = get_option( 'abd_user_settings', array(
    288                     'user_defined_selectors' => '',
    289                     'enable_iframe'          => 'yes',
    290                     'enable_div'             => 'yes',
    291                     'enable_js_file'         => 'yes',
    292                     'enable_perf_logging'    => 'yes'
    293                 )
    294             );
    295 
    296             if( $json_array ) {
     304                //  Load in some default values that will throw dreadful errors in the middle
     305                //  of JavaScript code if somebody (*cough* John *cough*) forgets to run an
     306                //  array_key_exists(), or it is really ugly and inelegant to do so, when
     307                //  debug errors are enabled.
     308                // 
     309                //  See includes/setup.php > ABD_Setup::enqueue_helper_footer() for a really
     310                //  rough area for these errors at the time of this writing.
     311                'enable_iframe'          => 'yes',
     312                'enable_div'             => 'yes',
     313                'enable_js_file'         => 'yes',
     314                'user_defined_selectors' => '',
     315                'enable_statistics'      => 'yes',
     316                'stats_ignore_registered'=> 'no',
     317                'stats_ignore_ips'       => ''
     318            ) );
     319
     320            if( $json_array && array_key_exists( 'user_defined_selectors', $abd_settings ) ) {
    297321                //  Turn user defined selectors into JSON array
    298322                $abd_settings['user_defined_selectors'] = json_encode(
     
    300324                );
    301325            }
    302 
    303326            return $abd_settings;
    304327        }
    305328
     329        public static function get_specific_setting( $setting_name, $json_array = false ) {
     330            $abd_settings = self::get_settings( $json_array );
     331
     332            if( array_key_exists( $setting_name, $abd_settings ) ) {
     333                return $abd_settings[$setting_name];
     334            }
     335
     336            return null;
     337        }
     338
    306339
    307340        public static function nuke_all_options() {
    308             //      Collect start state for performance logging
    309             $start_time = microtime( true );
    310             $start_mem = memory_get_usage( true );
    311 
    312             $options = wp_load_alloptions();    //  Get all WP options
    313 
    314             foreach( $options as $key=>$o ) {
    315                 if( stristr( $key, 'abd_' ) ) {
    316                     delete_site_option( $key );                 
    317                 }               
    318             }
    319 
    320             //      Make sure we update the cache when we retrieve shortcodes next
    321             self::nuke_shortcode_cache();   
    322 
    323             //      Performance log
    324             ABD_Log::perf_summary( 'ABD_Database::nuke_all_options()', $start_time, $start_mem );       
     341            //      Do not collect start state for performance logging
     342            //      Performance logging gets put in database, and we're trying to delete that!
     343           
     344
     345            $sc_options = self::get_all_shortcodes();
     346
     347            foreach( $sc_options as $id=>$val ) {
     348                $oname = self::$our_shortcode_prefix . $id;
     349
     350                delete_option( $oname );
     351            }
     352            foreach( self::$our_list_of_options as $o ) {
     353                delete_option( $o );           
     354            }
     355            foreach( self::$our_list_of_transients as $t ) {
     356                delete_transient( $t );
     357            }
     358
     359            //      Do not log performance!
     360            //      Performance logging gets put in database, and we're trying to delete that! 
    325361        }
    326362
     
    336372            ABD_Log::perf_summary( 'ABD_Database::nuke_shortcode_cache()', $start_time, $start_mem );           
    337373        }
     374
     375        public static function drop_tables() {
     376            //      Collect start state for performance logging
     377            $start_time = microtime( true );
     378            $start_mem = memory_get_usage( true );
     379
     380            global $wpdb;
     381           
     382
     383            $prefix = $wpdb->base_prefix;
     384            $table1 = $prefix . 'abd_shortcodes';
     385
     386            $sql = "DROP TABLE IF EXISTS $table1;";
     387            $wpdb->query( $sql );
     388
     389            ABD_Log::info( 'Dropped version 2 table, abd_shortcodes, from the database.' );
     390
     391            $table2 = $prefix . 'abd_adblocker_stats';
     392
     393            $sql = "DROP TABLE IF EXISTS $table2;";
     394            $wpdb->query( $sql );
     395
     396            ABD_Log::info( 'Dropped version 3 table, abd_adblocker_stats, from the database.' );
     397
     398            //      Performance log
     399            ABD_Log::perf_summary( 'ABD_Database::drop_tables()', $start_time, $start_mem );
     400        }
     401
     402
     403
     404
     405
     406        ////////////////////////////
     407        //  Ad Blocker Statistics //
     408        ////////////////////////////
     409        /**
     410         * Unlike shortcodes, statistics are collected into their own database table.
     411         * This is because the Settings API, which makes certain tasks easier and faster,
     412         * is not suited for an every page load kind of interaction. To use the Settings API,
     413         * we'd need to have a new option for every page load, or build an array, which needs
     414         * to be retrieved, updated, and put back in the database. This is way too much
     415         * database traffic!
     416         *
     417         * However, we're only doing a handful of specific jobs for these stats, so a CRUD
     418         * setup for the custom table isn't too hard.
     419         */
     420        public static function update_stats_table_structure() {
     421            global $wpdb;
     422            $charset = $wpdb->get_charset_collate();
     423            $table = $wpdb->prefix . self::$our_stats_table;
     424
     425            $sql = "CREATE TABLE $table (
     426                id mediumint(9) NOT NULL AUTO_INCREMENT,
     427                blog_id mediumint(9) NOT NULL DEFAULT 1,
     428                adblocker tinyint(1) NOT NULL,
     429                date_time datetime NOT NULL,
     430                label text DEFAULT '',
     431                ip varchar(39),
     432                PRIMARY KEY  (id),
     433                KEY adblocker (adblocker),
     434                KEY blog_id (blog_id),
     435                KEY ip (ip)
     436            ) $charset;";
     437
     438            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     439            dbDelta( $sql );
     440        }
     441
     442        /**
     443         * Insert a row in the statistics database table.
     444         *
     445         * @param    int   $adblocker_code   The codified integer adblocker status (-1 = unknown, 0 = no adblocker, 1 = adblocker)
     446         * @param    int   $blog_id          The ID of the multisite blog this statistic is collected for. Defaults to 1.  Non-multisite is always 1.
     447         * @param    int   $user_ip          The IP address of the user.
     448         * @param    string   $date             The date and time this statistic is for. Ommitted = now. Should be a UNIX timestamp.
     449         * @param    string   $label            Some descriptive text for the entry.
     450         */
     451        public static function insert_stat( $adblocker_code, $blog_id = 1, $user_ip  = '', $date = 'now', $label = '' ) {
     452            global $wpdb;
     453
     454            $table = $wpdb->prefix . self::$our_stats_table;
     455
     456            //  Get date in right format
     457            if( is_string( $date ) ) {
     458                if( $date == 'now' ) {
     459                    $date = date( 'Y-m-d H:i:s' );
     460                }
     461                else {
     462                    $date = date( 'Y-m-d H:i:s', $date );
     463                }
     464            }
     465            else {
     466                ABD_Log::error( 'Invalid date/time value provided when inserting adblocker statistic. Using current date/time.' );
     467                $date = date( 'Y-m-d H:i:s' );
     468            }
     469
     470            //  Insert row
     471            $res = $wpdb->insert( $table,
     472                array( 'adblocker'=>$adblocker_code, 'ip'=> $user_ip, 'date_time'=>$date, 'label'=>$label, 'blog_id' => $blog_id )
     473             );
     474
     475            if( !$res ) {   //  no updated rows or fail
     476                ABD_Log::error( 'Unknown failure inserting adblocker statistic.' );
     477                self::log_last_query_debug_info();
     478            }
     479
     480            return $res;
     481        }
     482
     483        /**
     484         * Deletes rows from statistics database.
     485         */
     486        public static function delete_all_stats() {
     487            global $wpdb;
     488
     489            $table = $wpdb->prefix . self::$our_stats_table;
     490
     491            $sql = "DELETE FROM $table WHERE blog_id=" . ABD_Multisite::get_current_blog_id();
     492
     493            $res = $wpdb->query( $sql );
     494
     495            if( $res === false ) {
     496                ABD_Log::error( 'Unknown failure deleting adblocker statistics.' );
     497                self::log_last_query_debug_info();
     498            }
     499            else {
     500                ABD_Log::info( 'Deleted ' . $rows . ' rows from statistics table in database.' );               
     501            }
     502        }
     503
     504        /**
     505         * Returns all rows from statistics database that match provided WHERE and LIMIT clauses
     506         *
     507         * @param    string/array    $where   WHERE clause string, or named array of WHERE clauses (in column -> value pairs).  Defaults to empty WHERE clause thus not limiting SELECT query.
     508         * @param    integer   $limit   A limit on rows returned. 0 or negative number will not limit rows. Defaults to -1.
     509         *
     510         * @return   array             Associative array containing query results.  Array will be empty if query fails or no rows match query.
     511         */
     512        public static function select_all_stats( $where = '', $limit = -1 ) {
     513            global $wpdb;
     514
     515            $table = $wpdb->prefix . self::$our_stats_table;
     516
     517            //  Construct WHERE clause
     518            if( is_array( $where ) ) {
     519                if( !array_key_exists( 'blog_id', $where ) ) {
     520                    $where['blog_id'] = ABD_Multisite::get_current_blog_id();
     521                }
     522
     523                $where = self::where_from_array( $where );
     524            }
     525            else if( !is_string( $where ) ) {
     526                ABD_Log::error( 'Invalid $where parameter fed to ABD_Database::select_all_stats(). Defaulting to empty clause.' );
     527                ABD_Log::debug( '$where parameter data dump = ' . print_r( $where, true ), true );
     528                $where = ' WHERE blog_id=' . ABD_Multisite::get_current_blog_id();
     529            }
     530            else {
     531                if( empty( $where ) ) {
     532                    $where = ' WHERE blog_id=' . ABD_Multisite::get_current_blog_id();
     533                }
     534                else {
     535                    $where .= ' AND blog_id=' . ABD_Multisite::get_current_blog_id();
     536                }
     537            }
     538
     539            //  Construct LIMIT clause
     540            if( is_numeric( $limit) && $limit > 0 ) {
     541                $limit = ' LIMIT ' . $limit;
     542            }
     543            else {
     544                $limit = '';
     545            }
     546
     547            //  Run query
     548            $res = $wpdb->get_results( 'SELECT * FROM ' . $table . $where . $limit, ARRAY_A );
     549
     550            if( !is_array( $res ) || count( $res ) < 1 ) {
     551                ABD_Log::info( 'SELECT query on statistics database returned empty set.' );
     552                ABD_Log::debug( 'Empty set query = ' . $wpdb->last_query );
     553
     554                return array();
     555            }
     556
     557            return $res;
     558        }
     559
     560        /**
     561         * Returns all rows from statisitics database that fall in the date/time range specified. This is basically
     562         * a wrapper around ABD_Database::select_all_stats() which will add appropriate date range to WHERE clause
     563         * automatically.
     564         *
     565         * @param    string    $start_date   English textual datetime description of start date filter parsable by PHP's DateTime constructor.
     566         * @param    string    $end_date     English textual datetime description fo end date filter parsable by PHP's DateTime constructor.
     567         * @param    string/array    $where        WHERE clause string, or named array of WHERE clauses (in column -> value pairs).  Defaults to empty WHERE clause thus not limiting SELECT query.
     568         * @param    integer   $limit        A limit on rows returned. 0 or negative number will not limit rows. Defaults to -1.
     569         *
     570         * @return   array             Associative array containing query results.  Array will be empty if query fails or no rows match query.
     571         */
     572        public static function select_stats_by_date( $start_date, $end_date = 'now', $where = null, $limit = -1 ) {
     573            //  Get start and end dates in MySQL acceptable forms
     574            try {
     575                $start_date = new DateTime( $start_date );
     576                $end_date = new DateTime( $end_date );
     577
     578                $s = $start_date->format( 'Y-m-d H:i:s' );
     579                $e = $end_date->format( 'Y-m-d H:i:s' );
     580            }
     581            catch( Exception $e ) {
     582                ABD_Log::error( 'Invalid $start_date or $end_date parameter provided in ABD_Database::select_stats_by_date().' );
     583                ABD_Log::debug( 'DateTime exception = ' . $e->getMessage(), true );
     584
     585                return array();
     586            }
     587
     588
     589            //  Construct WHERE clause without start and end dates
     590            if( is_array( $where ) ) {
     591                if( !array_key_exists( 'blog_id', $where ) ) {
     592                    $where['blog_id'] = ABD_Multisite::get_current_blog_id();
     593                }
     594               
     595                $where = self::where_from_array( $where );
     596            }
     597            else if( !is_string( $where ) ) {
     598                ABD_Log::error( 'Invalid $where parameter fed to ABD_Database::select_stats_by_date(). Defaulting to empty clause.' );
     599                ABD_Log::debug( '$where parameter data dump = ' . print_r( $where, true ), true );
     600                $where = ' WHERE blog_id=' . ABD_Multisite::get_current_blog_id();
     601            }
     602            else {
     603                if( empty( $where ) ) {
     604                    $where = ' WHERE blog_id=' . ABD_Multisite::get_current_blog_id();
     605                }
     606                else {
     607                    $where .= ' AND blog_id=' . ABD_Multisite::get_current_blog_id();
     608                }
     609            }
     610
     611
     612            //  Add start and end dates
     613            if( empty( $where ) ) {
     614                $where = ' WHERE ';
     615            }
     616            else {
     617                $where .= ' AND ';
     618            }
     619
     620            $where .= 'date > "' . $s . '" AND date < "' . $e . '"';
     621
     622            return self::select_all_stats( $where, $limit );
     623        }
     624
     625        /**
     626         * Returns a count of rows in statistics database where the adblocker column contains the given $status_code.
     627         *
     628         * @param    integer   $status_code   adblocker column status code (adblocker=1, no adblocker=0, other=-1)
     629         * @param    string    $custom_query  A custom SQL query to run. The last clause must be a WHERE clause! If no WHERE clause, use "WHERE 1=1".  Use template tag {{table}} in place of table name.
     630         *
     631         * @return   integer                  A count of matching rows.
     632         */
     633        public static function stats_status_count( $status_code = 1, $custom_query = "SELECT adblocker FROM {{table}} WHERE 1=1" ) {
     634            global $wpdb;
     635
     636            $table = $wpdb->prefix . self::$our_stats_table;
     637
     638            $custom_query = str_replace( '{{table}}', $table, $custom_query );
     639
     640            $sql = $custom_query . " AND adblocker = $status_code AND blog_id=" . ABD_Multisite::get_current_blog_id();
     641            $wpdb->get_results( $sql );
     642
     643            return intval( $wpdb->num_rows );
     644        }
     645            public static function stats_status_count_blocker_change( $change_type = 'disable' ) {
     646                global $wpdb;
     647
     648                $table = $wpdb->prefix . self::$our_stats_table;
     649
     650                $count = 0;
     651
     652                //  Where multiple rows for distinct ip and multiple values in adblocker for some of those rows
     653                //  Row returned is first occurrence... meaning starting ad blocker state...
     654                $sql = "SELECT DISTINCT adblocker, date_time FROM $table WHERE blog_id=" . ABD_Multisite::get_current_blog_id() . " GROUP BY ip HAVING COUNT(DISTINCT adblocker) > 1";
     655                $res = $wpdb->get_results( $sql, ARRAY_A );
     656
     657                if( !is_array( $res ) ) {
     658                    ABD_Log::error( 'Unknown query failure in ABD_Database::stats_status_count_blocker_change(). Returning 0.' );
     659                    self::log_last_query_debug_info();
     660                    return 0;
     661                }
     662
     663                foreach( $res as $r ) {
     664                    //  Rows contain beginning adblocker state. If we want disabled type, we want
     665                    //  enabled ad blocker in row.  Otherwise, we want disabled type
     666                    if( $change_type == 'disable' && $r['adblocker'] == 1 ) {
     667                        $count++;
     668                    }
     669                    else if( $change_type == 'enable' && $r['adblocker'] == 0 ) {
     670                        $count++;
     671                    }
     672                }
     673
     674                return $count;
     675            }
     676
     677
     678        protected static function log_last_query_debug_info( $indented = true ) {
     679            global $wpdb;
     680
     681            ABD_Log::debug( 'Failed MYSQL Query = ' . $wpdb->last_query, $indented );
     682            ABD_Log::debug( 'Failed MYSQL Error = ' . $wpdb->last_error, $indented );
     683        }
     684
     685        protected static function where_from_array( $named_array_of_where_clauses ) {
     686            if( !is_array( $named_array_of_where_clauses ) ) {
     687                return false;
     688            }
     689
     690            $first = true;
     691            $wc = '';
     692            foreach( $named_array_of_where_clauses as $field=>$value ) {
     693                if( $first ) {
     694                    $wc .= ' WHERE ';
     695                    $first = false;
     696                }
     697                else {
     698                    $wc .= ' AND ';
     699                }
     700
     701                $wc .= $field . '="' . $value . '"';
     702            }
     703
     704            ABD_Log::debug( 'Constructed WHERE clause = ' . $wc );
     705
     706            return $wc;
     707        }
     708
     709
     710
     711
     712
     713
     714
     715
    338716
    339717        /**
     
    554932        }
    555933
    556         public static function drop_v2_table() {
    557             //      Collect start state for performance logging
    558             $start_time = microtime( true );
    559             $start_mem = memory_get_usage( true );
    560 
    561             global $wpdb;
    562            
    563 
    564             $prefix = $wpdb->base_prefix;
    565             $table = $prefix . 'abd_shortcodes';
    566 
    567             $sql = "DROP TABLE IF EXISTS abd_shortcodes;";
    568             $wpdb->query( $sql );
    569 
    570             ABD_Log::info( 'Dropped version 2 table, abd_shortcodes, from the database.' );
    571 
    572             //      Performance log
    573             ABD_Log::perf_summary( 'ABD_Database::drop_v2_table()', $start_time, $start_mem );
    574         }
     934       
    575935
    576936    }   //  end class ABD_Database
  • ad-blocking-detector/trunk/includes/log.php

    r1208754 r1215910  
    1010
    1111        public static function error( $msg, $indented = false ) {
    12             self::generic_log_entry( 'ERROR', $msg, $indented );
     12            $enable_errors = ABD_Database::get_specific_setting( 'enable_error_logging' );
     13
     14            if( $enable_errors != 'no' ) {
     15                self::generic_log_entry( 'ERROR', $msg, $indented );
     16            }
    1317        }
    1418
    1519        public static function info( $msg, $indented = false ) {
    16             self::generic_log_entry( 'INFO', $msg, $indented );
     20            $enable_info = ABD_Database::get_specific_setting( 'enable_info_logging' );
     21
     22            if( $enable_info != 'no' ) {
     23                self::generic_log_entry( 'INFO', $msg, $indented );
     24            }
    1725        }
    1826
    1927        public static function debug( $msg, $indented = false ) {
    20             self::generic_log_entry( 'DEBUG', $msg, $indented );
     28            $enable_debug = ABD_Database::get_specific_setting( 'enable_debug_logging' );
     29
     30            if( $enable_debug != 'no' ) {
     31                self::generic_log_entry( 'DEBUG', $msg, $indented );
     32            }
    2133        }
    2234
    2335        public static function perf( $msg, $indented = false ) {
    24             $settings = ABD_Database::get_settings();
    25 
    26             if( $settings['enable_perf_logging'] == 'yes' ) {
     36            $enable_perf_logging = ABD_Database::get_specific_setting( 'enable_perf_logging' );
     37
     38            if( $enable_perf_logging != 'no' ) {
    2739                self::generic_log_entry( 'PERF', $msg, $indented );
    2840            }
     
    4860
    4961        public static function get_readable_log( $num_entries = 0, $indentation = '    >>   ', $line_endings = '&#13;&#10;&#13;&#10;' ) {
     62            $enabled = ABD_Database::get_specific_setting( 'enable_logging' );
     63
     64            if( $enabled === 'no' ) {
     65                return ABD_L::__( '* Logging has been disabled in Advanced Settings.' );
     66            }
     67
    5068            $readable = '';
    5169            $es = self::get_all_log_entries();
     
    90108            }
    91109
     110            if( empty( $readable ) ) {
     111                $readable = ABD_L::__( '* No log entries at this time.' );
     112            }
     113
    92114            return $readable;
    93115        }
     
    99121
    100122        protected static function generic_log_entry( $type, $msg, $indented = false ) {
    101             $e = self::get_all_log_entries();
    102 
    103             $e[] = array(
    104                 'type' => $type,
    105                 'message' => $msg,
    106                 'time' => date( 'm/d/y @ H:i:s (P' ) . ' GMT)',
    107                 'indented' => $indented
    108             );
    109 
    110             update_site_option( self::get_option_name(), $e );
    111 
    112             self::prune_log();
    113         }
    114 
    115         protected static function prune_log( $max_entries = 500 ) {
    116             $es = self::get_all_log_entries();
    117 
    118             if( count( $es ) > $max_entries ) {
    119                 $es = array_slice( $es, -1*$max_entries );
    120             }
    121 
    122             update_option( self::$our_option_name, $es );
     123            $enable = ABD_Database::get_specific_setting( 'enable_logging' );
     124
     125            if( $enable != 'no' ) {
     126                $e = self::get_all_log_entries();
     127
     128                $e[] = array(
     129                    'type' => $type,
     130                    'message' => $msg,
     131                    'time' => date( 'm/d/y @ H:i:s (P' ) . ' GMT)',
     132                    'indented' => $indented
     133                );         
     134
     135                $e = self::prune_log( $e );
     136
     137                update_site_option( self::get_option_name(), $e );
     138            }
     139        }
     140
     141        protected static function prune_log( $value = null, $max_entries = 500 ) {
     142            if( $value == null ) {
     143                $value = self::get_all_log_entries();
     144            }
     145
     146
     147            if( count( $value ) > $max_entries ) {
     148                $value = array_slice( $value, -1*$max_entries );
     149            }
     150
     151            return $value;
    123152        }
    124153
     
    199228            //  Check for settings thresholds and filtration
    200229            $settings = ABD_Database::get_settings();
    201             if( isset( $settings['perf_logging_time_limit'] ) ) {
    202                 $time_alert_threshold = $settings['perf_logging_time_limit'];
    203             }
    204             if( isset( $settings['perf_logging_mem_limit'] ) ) {
    205                 $mem_alert_threshold = $settings['perf_logging_mem_limit'];
    206             }
    207             if( isset( $settings['perf_logging_only_above_limits'] ) && $settings['perf_logging_only_above_limits'] == 'yes' ) {
     230            $time_limit = ABD_Database::get_specific_setting( 'perf_logging_time_limit' );
     231            $mem_limit = ABD_Database::get_specific_setting( 'perf_logging_mem_limit' );
     232            $only_above_threshold = ABD_Database::get_specific_setting( 'perf_logging_only_above_limits' );
     233
     234            if( !is_null( $time_limit ) ) {
     235                $time_alert_threshold = $time_limit;
     236            }
     237            if( !is_null( $mem_limit ) ) {
     238                $mem_alert_threshold = $mem_limit;
     239            }
     240            if( $only_above_threshold != 'no' ) {
    208241                $only_above_threshold = true;
    209242            }
  • ad-blocking-detector/trunk/includes/multisite.php

    r1203582 r1215910  
    44 * class... because multisite is a pain-in-the-ass
    55 */
    6 
    7 abd_my_session_start(); //  Make sure we have a $_SESSION.  It's absolutely necessary for parts of this.
    8 
    9 
    106
    117
  • ad-blocking-detector/trunk/includes/perf-tools.php

    r1208754 r1215910  
    5454            //  Gather Data
    5555            $blcp_status = array(
    56                 'auto_plugin_activated'   => ABD_Anti_Adblock::bcc_plugin_status( 'auto_plugin_activated' ),
    57                 'manual_plugin_activated' => ABD_Anti_Adblock::bcc_plugin_status( 'manual_plugin_activated' ),
    58                 'auto_plugin_exists'      => ABD_Anti_Adblock::bcc_plugin_status( 'auto_plugin_exists' ),
    59                 'manual_plugin_exists'    => ABD_Anti_Adblock::bcc_plugin_status( 'manual_plugin_exists' ),
    6056                'plugin_activated'        => ABD_Anti_Adblock::bcc_plugin_status( 'plugin_activated' ),
    6157                'plugin_exists'           => ABD_Anti_Adblock::bcc_plugin_status( 'plugin_exists' )
     
    6561            if( !$blcdir ) { $blcdir = 'No BLC Plugin Directory'; }
    6662
    67             $mem_usage = memory_get_usage( true );
     63            $mem_usage = memory_get_peak_usage( true );
    6864            if( $mem_usage < 1024 ) { $mem_usage = $mem_usage . ' bytes'; }
    6965            else if( $mem_usage < 1048576 ) { $mem_usage = round( $mem_usage/1024, 2 ) . ' KB'; }
    7066            else { $mem_usage = round( $mem_usage/1048576, 2 ) . ' MB'; }
     67
     68            $aa2d_mem = memory_get_usage();
     69            $aa2d = array(
     70                'perftestentry1' => array( 'abcdefg', 'hijklmn' ),
     71                'perftestentry2' => array( 'opqrstu', 'vwxyz12' ),
     72                'perftestentry3' => array( '3456789', '0abcdef' ),
     73                'perftestentry4' => array( 'ghijklm', 'nopqrst' ),
     74                'perftestentry5' => array( 'uvwxyz1', '2345678' ),
     75                'perftestentry6' => array( '90abcde', 'fghijkl' ),
     76                'perftestentry7' => array( 'mnopqrs', 'tuvwxyz' ),
     77                'perftestentry8' => array( '1234567', '890abcd' ),
     78                'perftestentry9' => array( 'efghijk', 'lmnopqr' )
     79            );
     80            $aa2d_mem = ABD_Log::mem_diff( $aa2d_mem );
     81            unset( $aa2d );
     82
     83            $aa1d_mem = memory_get_usage();
     84            $aa1d = array(
     85                'perftestentry1' => 'abcdefg',
     86                'perftestentry2' => 'opqrstu',
     87                'perftestentry3' => '3456789',
     88                'perftestentry4' => '1234567',
     89                'perftestentry5' => 'hijklmn',
     90                'perftestentry6' => 'vwxyz12',
     91                'perftestentry7' => '4567890',
     92                'perftestentry8' => 'bcdefgh',
     93                'perftestentry9' => 'ijklmno'
     94            );
     95            $aa1d_mem = ABD_Log::mem_diff( $aa1d_mem );
     96            unset( $aa1d );
     97
    7198
    7299            ob_start();
     
    83110Plugin Version: <?php echo ABD_VERSION; ?><?php echo $line_endings; ?>
    84111Total # of shortcodes: <?php echo ABD_Database::count_shortcodes(); ?><?php echo $line_endings; ?>
    85 BLC Plugin Exists?: <?php echo $blcp_status['plugin_exists']; ?><?php echo $line_endings; ?>
    86 BLC Plugin Active?: <?php echo $blcp_statuc['plugin_activated']; ?><?php echo $line_endings; ?>
     112BLC Plugin Exists?: <?php echo $blcp_status['plugin_exists'] ? 'true' : 'false'; ?><?php echo $line_endings; ?>
     113BLC Plugin Active?: <?php echo $blcp_status['plugin_activated'] ? 'true' : 'false'; ?><?php echo $line_endings; ?>
    87114BLC Plugin Type?: <?php echo get_option( 'abd_blc_plugin_type' ); ?><?php echo $line_endings; ?>
    88 BLC Plugin Dir: <?php echo $blcdir; ?><?php echo $line_endings; ?>
     115BLC Plugin Dir: <?php echo $blcdir; ?><?php echo $line_endings . $line_endings; ?>
     1169 entry 1D Assoc. Array Used Memory: <?php echo $aa1d_mem; ?><?php echo $line_endings; ?>
     1179 entry 2D Assoc. Array Used Memory: <?php echo $aa2d_mem; ?><?php echo $line_endings; ?>
    89118            <?php
    90119           
    91120            return ob_get_clean();
    92121        }
     122
     123
     124
     125        /**
     126         * Determines whether the given IP address is within the given range.
     127         *
     128         * @param    string   $ip      IPV4 address to check in standard dot notation (e.g. 192.168.0.1)
     129         * @param    string   $range   IPV4 address with CIDR netmask. If no CIDR netmask given, /32 is assumed (exact match).  (e.g. 182.168.0.0/16)
     130         *
     131         * @return   boolean            true if $ip is in $range.  false if not.
     132         */
     133        public static function ip_in_range( $ip, $range ) {
     134            if ( strpos( $range, '/' ) == false ) {
     135                $range .= '/32';
     136            }
     137            // $range is in IP/CIDR format eg 127.0.0.1/24
     138            list( $range, $netmask ) = explode( '/', $range, 2 );
     139            $range_decimal = ip2long( $range );
     140            $ip_decimal = ip2long( $ip );
     141            $wildcard_decimal = pow( 2, ( 32 - $netmask ) ) - 1;
     142            $netmask_decimal = ~ $wildcard_decimal;
     143            return ( ( $ip_decimal & $netmask_decimal ) == ( $range_decimal & $netmask_decimal ) );
     144        }
    93145    }   //  end class
    94146}   //  end if( !class_exists( ...
  • ad-blocking-detector/trunk/includes/setup.php

    r1208754 r1215910  
    55 */
    66
    7 require_once( ABD_ROOT_PATH . 'includes/log.php' );
    8 require_once( ABD_ROOT_PATH . 'includes/wpsm/settings-manager.php' );
    9 require_once( ABD_ROOT_PATH . 'includes/anti-adblock.php' );
    10 require_once( ABD_ROOT_PATH . 'views/admin-views.php' );
    11 require_once( ABD_ROOT_PATH . 'views/public-views.php' );
    12 require_once( ABD_ROOT_PATH . "includes/widget.php" );
    13 require_once( ABD_ROOT_PATH . "includes/click-handler.php" );
    14 require_once( ABD_ROOT_PATH . "includes/perf-tools.php" );
     7$start_time = microtime( true );
     8$start_mem = memory_get_usage( true );
     9
     10require( ABD_ROOT_PATH . 'includes/database.php' );
     11require( ABD_ROOT_PATH . 'includes/log.php' );
     12require( ABD_ROOT_PATH . 'includes/wpsm/settings-manager.php' );
     13require( ABD_ROOT_PATH . 'includes/anti-adblock.php' );
     14require( ABD_ROOT_PATH . 'views/admin-views.php' );
     15require( ABD_ROOT_PATH . 'views/public-views.php' );
     16require( ABD_ROOT_PATH . "includes/widget.php" );
     17require( ABD_ROOT_PATH . "includes/click-handler.php" );
     18require( ABD_ROOT_PATH . "includes/perf-tools.php" );
     19require( ABD_ROOT_PATH . "includes/multisite.php" );
     20require( ABD_ROOT_PATH . "includes/localization.php" );
     21require( ABD_ROOT_PATH . "includes/ajax-actions.php" );
     22
     23ABD_Log::perf_summary( 'setup.php // require plugin files', $start_time, $start_mem );
     24
    1525
    1626if ( !class_exists( 'ABD_Setup' ) ) {
     
    118128                    'jquery' );
    119129
     130
     131                //  Google Charts
     132                wp_enqueue_script( 'google-jsapi', 'https://www.google.com/jsapi' );
     133
     134
    120135                wp_enqueue_script( 'abd-admin-view',
    121136                    $prefix . 'assets/js/admin-view.js', array('jquery') );
     
    141156                wp_enqueue_script( 'abd-fake-ad',
    142157                    $prefix . 'assets/js/advertisement.min.js' );
     158                wp_enqueue_script( 'abd-public-view',
     159                    $prefix . 'assets/js/public-view.js' );
    143160            }
    144161            public static function enqueue_helper_footer() {
     
    173190                //  it will come back as an JSON encoded array with one empty string... [""]
    174191                //  We don't want this... this should mean utterly blank
    175                 if( $abd_settings['user_defined_selectors'] == '[""]' ) {
     192                if( !array_key_exists( 'user_defined_selectors', $abd_settings ) ||  $abd_settings['user_defined_selectors'] == '[""]' ) {
    176193                    $abd_settings['user_defined_selectors'] = '';
    177194                }
     
    180197                <script type="text/javascript">
    181198                    <?php
    182                     if( $abd_settings['enable_iframe'] == 'yes' || $abd_settings['enable_iframe'] == '' ) {
     199                    if( !array_key_exists( 'enable_iframe', $abd_settings ) || $abd_settings['enable_iframe'] != 'no' ) {
    183200                        ?>
    184201                        (function() {
     
    208225                        enableIframe: "<?php echo $abd_settings['enable_iframe']; ?>",
    209226                        enableDiv:    "<?php echo $abd_settings['enable_div']; ?>",
    210                         enableJsFile: "<?php echo $abd_settings['enable_js_file']; ?>"
    211                     }
     227                        enableJsFile: "<?php echo $abd_settings['enable_js_file']; ?>",
     228                        statsAjaxNonce: "<?php echo wp_create_nonce( 'ad blocking detector stats ajax nonce' ); ?>",
     229                        ajaxUrl: "<?php echo admin_url( 'admin-ajax.php' ); ?>"
     230                    }
     231
     232                    <?php
     233                    if( is_admin() ) {
     234                        ?>
     235                        var ABDStats = {
     236                            pageLoadAdblocker: parseInt('<?php echo ABD_Database::stats_status_count( 1 ); ?>'),
     237                            pageLoadNoAdblocker: parseInt('<?php echo ABD_Database::stats_status_count( 0 ); ?>'),
     238                            pageLoadOther: parseInt('<?php echo ABD_Database::stats_status_count( -1 ); ?>'),
     239
     240                            uniqueUsersAdBlocker: parseInt('<?php echo ABD_Database::stats_status_count( 1, "SELECT DISTINCT ip FROM {{table}} WHERE 1=1" ); ?>'),
     241                            uniqueUsersNoAdBlocker: parseInt('<?php echo ABD_Database::stats_status_count( 0, "SELECT DISTINCT ip FROM {{table}} WHERE 1=1" ); ?>'),
     242                            uniqueUsersOther: parseInt('<?php echo ABD_Database::stats_status_count( -1, "SELECT DISTINCT ip FROM {{table}} WHERE 1=1" ); ?>'),
     243
     244                            numUsersToDisable: parseInt( '<?php echo ABD_Database::stats_status_count_blocker_change( "disable" ); ?>' ),
     245                            numUsersToEnable: parseInt( '<?php echo ABD_Database::stats_status_count_blocker_change( "enable" ); ?>' )
     246                        }
     247                        <?php
     248                    }
     249                    ?>
    212250
    213251                    //  Make sure ABDSettings.cssSelectors is an array... might be a string
     
    218256
    219257                <?php
    220                 if( $abd_settings['enable_div'] == 'yes' || $abd_settings['enable_div'] == '' ) {
     258                if( !array_key_exists( 'enable_div', $abd_settings ) || $abd_settings['enable_div'] != 'no' ) {
    221259                    ?>
    222260                    <div
     
    357395            add_action( 'admin_post_abd_send_usage_info',
    358396                array( 'ABD_Click_Handler', 'send_usage_info' ) );
     397            add_action( 'admin_post_abd_delete_stats',
     398                array( 'ABD_Click_Handler', 'delete_all_statistics' ) );
     399
     400
     401            //  AJAX Handlers
     402            add_action( 'wp_ajax_submit_stats',
     403                array( 'ABD_Ajax_Actions', 'submit_stats' ) );
    359404
    360405            //  Admin notices
     
    377422            }
    378423                protected static function nuke_plugin() {
     424                    ABD_Database::drop_tables();
    379425                    ABD_Database::nuke_all_options();
    380                     ABD_Database::drop_v2_table();  //  Compatibility for upgraded v2 installs
    381 
     426                   
    382427                    ABD_Anti_Adblock::delete_bcc_plugin();
    383428                    ABD_Anti_Adblock::delete_bcc_manual_plugin();
     
    419464            public static function menus_helper() {
    420465                //  We need the ABD_Admin_Views class
    421                 require_once (ABD_ROOT_PATH . 'views/admin-views.php');
     466                require (ABD_ROOT_PATH . 'views/admin-views.php');
    422467
    423468                add_menu_page(
     
    556601             */
    557602
    558             /**
    559              * An associative array where the key is a plugin version, and the value is
    560              * a function callback, passed to admin_notices WordPress action that outputs the content
    561              * of an upgrade message for that version.  This will be checked later on,
    562              * and if we are upgrading, and there is a mapped function, it will be tied
    563              * to an admin_notices action.
    564              */
    565             $notification_map = array(
    566                 '3.0.0'  => array( 'ABD_Admin_Views', 'v2_to_v3_migration_notice' )
    567             );  //  Maps a version number to a function to call with an upgrade notice.         
    568            
    569 
    570603            //  Does the stored plugin version equal the current version?
    571604            //  If so, then we shouldn't need to do anything.
     
    576609                $upgrading_version = '2.2.8';
    577610            }
    578 
    579             $upgrading_major_version = $upgrading_version[0];
    580611            $new_version = ABD_VERSION;
    581             $new_major_version = $new_version[0];
    582612
    583613            if (  $upgrading_version != $new_version ) {
    584614                ABD_Log::info( 'Running plugin update. Old version: ' . $upgrading_version . ', new version: ' . $new_version );
     615
     616                $upgrading_major_version = $upgrading_version[0];               
     617                $new_major_version = $new_version[0];
     618               
    585619                ///////////////////////////////
    586620                //  Do our updating here!!! ///
     
    647681                    }
    648682                }
     683
     684                //  Update Stats table structure
     685                ABD_Database::update_stats_table_structure();
    649686
    650687               
     
    674711             * site the first time somebody goes to that site's dashboard after the update.
    675712             */
     713           
     714            /**
     715             * An associative array where the key is a plugin version, and the value is
     716             * a function callback, passed to admin_notices WordPress action that outputs the content
     717             * of an upgrade message for that version.  This will be checked later on,
     718             * and if we are upgrading, and there is a mapped function, it will be tied
     719             * to an admin_notices action.
     720             */
     721            $notification_map = array(
     722                '3.0.0'  => array( 'ABD_Admin_Views', 'v2_to_v3_migration_notice' )
     723            );  //  Maps a version number to a function to call with an upgrade notice.
    676724            $last_notice_version = get_option( 'abd_last_upgrade_notice_seen', '0.0.0' );
    677725
  • ad-blocking-detector/trunk/includes/widget.php

    r1203582 r1215910  
    33 * This file contains the ABD widget declaration and handler functions.
    44 */
    5 
    6 require_once ( ABD_ROOT_PATH . 'views/public-views.php' );
    75
    86if( !class_exists( 'ABD_Widget' ) ) {
  • ad-blocking-detector/trunk/includes/wpsm/field.php

    r1206074 r1215910  
    167167            foreach( ABDWPSM_Settings_Manager::$fields as $Field ) {
    168168                if( $Field->get_field_name() == $my_fn &&
    169                     $Field->get_section()->get_options_group()->get_db_option_name == $my_fn &&
     169                    $Field->get_section()->get_options_group()->get_db_option_name() == $my_fn &&
    170170                    $Field                   != $this ) {
    171171
     
    311311                //  Start with read only.
    312312                ( array_key_exists( 'readonly', $fopt ) && $fopt['readonly'] ) ?
    313                     $readonly = 'readonly="readonly"' : '';
     313                    $readonly = 'readonly="readonly"' : $readonly = '';
    314314                //  Now disabled
    315315                ( array_key_exists( 'disabled', $fopt ) && $fopt['disabled'] ) ?
    316                     $disabled = 'disabled="disabled"' : '';
     316                    $disabled = 'disabled="disabled"' : $disabled = '';
    317317                //  Required
    318318                ( array_key_exists( 'required', $fopt ) && $fopt['required'] ) ?
    319                     $required = 'required="required"' : '';
     319                    $required = 'required="required"' : $required = '';
    320320                //  Now default value
    321321                array_key_exists('default', $fopt) ?
     
    344344                //  Unfortunately, there are several possibilities.
    345345                //  Possibility #1: Data persistence from a previous failed submission attempt.
    346                 if( !is_null( $this->data_persistence_value ) ) {
     346                if( isset( $this->data_persistence_value ) && !is_null( $this->data_persistence_value ) ) {
    347347                    $value = $this->data_persistence_value;
    348348
     
    412412                }
    413413
    414                 $fid = str_replace('[', '--', $fid);
    415                 $fid = str_replace(']', '--', $fid);
     414                $fid = str_replace('[', '--', $fname);
     415                $fid = str_replace(']', '', $fid);
    416416
    417417                //  Let's parse the field options a little to make life simpler
    418418                //  Start with read only.
    419419                ( array_key_exists( 'readonly', $fopt ) && $fopt['readonly'] ) ?
    420                     $readonly = 'readonly="readonly"' : '';
     420                    $readonly = 'readonly="readonly"' : $readonly = '';
    421421                //  Now disabled
    422422                ( array_key_exists( 'disabled', $fopt ) && $fopt['disabled'] ) ?
    423                     $disabled = 'disabled="disabled"' : '';
     423                    $disabled = 'disabled="disabled"' : $disabled = '';
    424424                //  Required
    425425                //  Now disabled
    426426                ( array_key_exists( 'required', $fopt ) && $fopt['required'] ) ?
    427                     $required = 'required="required"' : '';
     427                    $required = 'required="required"' : $required = '';
    428428                //  Now default value
    429429                array_key_exists('default', $fopt) ?
     
    445445                //  Unfortunately, there are several possibilities.
    446446                //  Possibility #1: Data persistence from a previous failed submission attempt.
    447                 if( !is_null( $this->data_persistence_value ) ) {
     447                if( isset( $this->data_persistence_value ) && !is_null( $this->data_persistence_value ) ) {
    448448                    $cur_val = $this->data_persistence_value;
    449449
  • ad-blocking-detector/trunk/readme.txt

    r1208754 r1215910  
    44Tags: adblock, adblocker, ad blocker, adblock plus, detector, advertisement, ads, ad blocking
    55Requires at least: 4.2
    6 Tested up to: 4.2.3
    7 Stable tag: 3.2.0
     6Tested up to: 4.2.4
     7Stable tag: 3.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    124124
    125125== Changelog ==
     126= 3.3.0 =
     127* NEW FEATURE: Statistics - Now includes ability to collect ad blocker statuses of your site visitors and view the aggregated data.
     128* Performance Improvement: Remove dependence on PHP sessions.
     129* Performance Improvement: Decrease memory usage in several functions by eliminating needless arrays and defining on demand only.
     130* Performance Improvement: Correct log pruning behavior, and reduce database access required for pruning.
     131* Performance Improvement: Replace PHP require_once() with require().
     132* Increased performance logging detail.
     133* Added more log customization settings.
     134* Minor bug fixes.
     135* Source code tidying.
    126136= 3.2.0 =
    127137* Performance Improvement: Counting shortcodes no longer retrieves all shortcodes and data from database (lower load times, less memory usage).
     
    267277
    268278== Upgrade Notice ==
     279= 3.3.0 =
     280* This update includes a new feature: statistics! Now see the ad blocker usage trends for your website by visiting the Ad Blocking Detector dashboard.
    269281= 3.1.2 =
    270282Dramatic performance improvements! If versions 3.0.0 through 3.0.2 were displaying errors, or was not functioning correctly, install this update!
  • ad-blocking-detector/trunk/views/admin-views.php

    r1208754 r1215910  
    44 * plugin.
    55 */
    6 
    7 require_once ( ABD_ROOT_PATH . 'includes/multisite.php' );
    8 require_once ( ABD_ROOT_PATH . 'includes/database.php' );
    9 require_once ( ABD_ROOT_PATH . 'includes/localization.php' );
    10 
    116
    127if ( !class_exists( 'ABD_Admin_Views' ) ) {
     
    133128                'send_usage_info_success' => array(
    134129                    'msg'   => ABD_L::__( 'Usage info submitted. Thanks for helping improve Ad Blocking Detector!' ),
     130                    'class' => 'updated'
     131                ),
     132
     133                //  Delete All Statistics Table Rows
     134                'delete_all_stats_success' => array(
     135                    'msg'   => ABD_L::__( 'Statistics table cleared successfully.' ),
    135136                    'class' => 'updated'
    136137                )
     
    389390                        $AS_Iframe_URL->add_to_section( $AS_Iframe_Section );
    390391
     392
     393                    $AS_Stats_Section = new ABDWPSM_Section( array(
     394                        'id'                  => 'as_uds-stats_management',
     395                        'display_name'        => ABD_L::__( 'Statistics Collection Options' ),
     396                        'display_description' => ABD_L::__( 'This plugin can collect basic statistics on how many of your visitors utilize ad blockers. The statistics collection behavior can be modified below.' )
     397                    ) );
     398                    $AS_Stats_Section->add_to_options_group( $AS_OG );
     399
     400                        $AS_Stats_enable_statistics = new ABDWPSM_Field( array(
     401                            'field_name'          => 'enable_statistics',
     402                            'type'                => 'radio',
     403                            'display_name'        => ABD_L::__( 'Enable Statistics Collection' ),
     404                            'display_description' => ABD_L::__( 'Whether to enable ad blocker detection statistics. Statistics results are viewable in the "Statistics" tab at the top of this page.' ),
     405                            'field_options_array' => array(
     406                                'choices' => array( 'Enabled'=>'yes', 'Disbaled'=>'no' ),
     407                                'default' => 'yes'
     408                            )
     409                        ) );
     410
     411                        $AS_Stats_ignore_ips = new ABDWPSM_Field( array(
     412                            'field_name'          => 'stats_ignore_ips',
     413                            'type'                => 'textarea',
     414                            'display_name'        => ABD_L::__( 'Ignored IP Addresses' ),
     415                            'display_description' => ABD_L::__( 'List of IP addresses for which statistics will not be collected. CIDR netmask ranges are acceptable. One IP address, or CIDR netmask, per line. Your detected IP address is: ' ) . $_SERVER['REMOTE_ADDR'],
     416                            'example_entry'       => '<br />' . $_SERVER['REMOTE_ADDR'] . '<br />192.168.0.0/16'
     417                        ) );
     418
     419                        $AS_Stats_ignore_registered = new ABDWPSM_Field( array(
     420                            'field_name'          => 'stats_ignore_registered',
     421                            'type'                => 'radio',
     422                            'display_name'        => ABD_L::__( 'Ignore Logged In Users' ),
     423                            'display_description' => ABD_L::__( 'If enabled, statistics will not be collected for logged in users.' ),
     424                            'field_options_array' => array(
     425                                'choices' => array( 'Enabled'=>'yes', 'Disbaled'=>'no' ),
     426                                'default' => 'no'
     427                            )
     428                        ) );
     429
     430                        $AS_Stats_enable_statistics->add_to_section( $AS_Stats_Section );
     431                        $AS_Stats_ignore_ips->add_to_section( $AS_Stats_Section );
     432                        $AS_Stats_ignore_registered->add_to_section( $AS_Stats_Section );
     433
     434
    391435                    $AS_Log_Section = new ABDWPSM_Section( array(
    392436                        'id'                  => 'as_uds-log_management',
     
    396440                    $AS_Log_Section->add_to_options_group( $AS_OG );
    397441
     442                        $AS_Log_enable_all = new ABDWPSM_Field( array(
     443                            'field_name'          => 'enable_logging',
     444                            'type'                => 'radio',
     445                            'display_name'        => ABD_L::__( 'Allow Logging' ),
     446                            'display_description' => ABD_L::__( 'Whether to log any events in the "Session Log." If this is disabled, no logging will occur.' ),
     447                            'field_options_array' => array(
     448                                'choices' => array( 'Enabled'=>'yes', 'Disbaled'=>'no' ),
     449                                'default' => 'yes'
     450                            )
     451                        ) );
     452
     453                        $AS_Log_enable_info = new ABDWPSM_Field( array(
     454                            'field_name'          => 'enable_info_logging',
     455                            'type'                => 'radio',
     456                            'display_name'        => ABD_L::__( 'Information Logging' ),
     457                            'display_description' => ABD_L::__( 'Whether to log noteworthy plugin actions in the "Session Log." Most Ad Blocking Detector Dashboard activities generates one or more of these log entries. Disabling this will improve plugin performance, but will drastically reduce the effectiveness of logging.' ),
     458                            'field_options_array' => array(
     459                                'choices' => array( 'Enabled'=>'yes', 'Disbaled'=>'no' ),
     460                                'default' => 'yes'
     461                            )
     462                        ) );
     463
     464                        $AS_Log_enable_debug = new ABDWPSM_Field( array(
     465                            'field_name'          => 'enable_debug_logging',
     466                            'type'                => 'radio',
     467                            'display_name'        => ABD_L::__( 'Debugging Data Logging' ),
     468                            'display_description' => ABD_L::__( 'Whether to log debugging data in the "Session Log." These entries are rarely generated outside of plugin updates and activation. They often accompany error log entries with contextual information. It is recommended to match this with error logging.  If error logging is on, debug logging should also be on.' ),
     469                            'field_options_array' => array(
     470                                'choices' => array( 'Enabled'=>'yes', 'Disbaled'=>'no' ),
     471                                'default' => 'yes'
     472                            )
     473                        ) );
     474
     475                        $AS_Log_enable_error = new ABDWPSM_Field( array(
     476                            'field_name'          => 'enable_error_logging',
     477                            'type'                => 'radio',
     478                            'display_name'        => ABD_L::__( 'Error Report Logging' ),
     479                            'display_description' => ABD_L::__( 'Whether to log encountered errors in the "Session Log." These are very rarely generated outside of plugin updates and activation.' ),
     480                            'field_options_array' => array(
     481                                'choices' => array( 'Enabled'=>'yes', 'Disbaled'=>'no' ),
     482                                'default' => 'yes'
     483                            )
     484                        ) );
     485
    398486                        $AS_Log_enable_perf = new ABDWPSM_Field( array(
    399487                            'field_name'          => 'enable_perf_logging',
    400488                            'type'                => 'radio',
    401489                            'display_name'        => ABD_L::__( 'Performance Statistics Logging' ),
    402                             'display_description' => ABD_L::__( 'Whether to record execution times and memory usage in the Session Log. This helps tracking down performance related plugin bugs, but generates a lot of log entries and uses slightly more overhead and database traffic.' ),             
     490                            'display_description' => ABD_L::__( 'Whether to record execution times and memory usage in the Session Log. This helps tracking down performance related plugin bugs, but generates a lot of log entries and generates significant database traffic.' ),               
    403491                            'field_options_array' => array(
    404492                                'choices' => array( 'Enabled'=>'yes', 'Disabled'=>'no' ),
     
    413501                            'field_options_array' => array(
    414502                                'choices' => array( 'Enabled'=>'yes', 'Disabled'=>'no' ),
    415                                 'default' => 'no'
     503                                'default' => 'yes'
    416504                            )
    417505                        ) );
     
    434522                            )
    435523                        ) );
     524                        $AS_Log_enable_all->add_to_section( $AS_Log_Section );
     525                        $AS_Log_enable_info->add_to_section( $AS_Log_Section );
     526                        $AS_Log_enable_debug->add_to_section( $AS_Log_Section );
     527                        $AS_Log_enable_error->add_to_section( $AS_Log_Section );
    436528                        $AS_Log_enable_perf->add_to_section( $AS_Log_Section );
    437529                        $AS_Log_perf_filtering->add_to_section( $AS_Log_Section );
     
    440532
    441533            //  Free memory
     534            unset( $AS_Log_enable_all );
     535            unset( $AS_Log_enable_info );
     536            unset( $AS_Log_enable_debug );
     537            unset( $AS_Log_enable_error );
    442538            unset( $AS_Log_enable_perf );
    443539            unset( $AS_Log_perf_filtering );
     
    456552            unset( $Settings_Tab );
    457553
     554
     555            $stats_enabled = ABD_Database::get_specific_setting( 'enable_statistics' );
     556            if( $stats_enabled != 'no' ) {
     557                new ABDWPSM_Tab( array(
     558                    'display_name'        => ABD_L::__( 'Statistics (Beta)' ),
     559                    'display_description' => self::statistics_tab_header(),
     560                    'url_slug'            => 'statistics',
     561                    'page'                => 'ad-blocking-detector'
     562                ) );
     563            }
    458564
    459565            new ABDWPSM_Tab( array(
     
    610716                'plugin_exists'           => ABD_Anti_Adblock::bcc_plugin_status( 'plugin_exists' )
    611717            );
    612             ABD_Log::perf_summary( 'ABD_Admin_Views::getting_started_tab_content // before $blcp_status = ABD_Anti_Adblock::bcc_plugin_status();', $bfs_time, $bfs_mem, true );
    613 
    614             $abd_settings = ABD_Database::get_settings();
     718            ABD_Log::perf_summary( 'ABD_Admin_Views::getting_started_tab_content // before $blcp_status = ABD_Anti_Adblock::bcc_plugin_status();', $bfs_time, $bfs_mem, true );         
    615719
    616720            ob_start();
     
    857961           
    858962
     963            <?php
     964            return ob_get_clean();
     965        }
     966
     967        protected static function statistics_tab_header() {
     968            ob_start();
     969            ?>
     970
     971            <h2><?php ABD_L::_e( 'Ad Blocker Statistics' ); ?></h2>
     972
     973            <?php
     974            echo self::statistics_tab_description();
     975
     976            return ob_get_clean();
     977        }
     978
     979        protected static function statistics_tab_description() {
     980            ob_start();
     981            ?>     
     982            <p><?php ABD_L::_e( 'The charts below aggregate ad blocker status statistics collected during visits to your website. The collected statistics are subject to any filtering and recording rules defined on the Advanced Settings tab, and accuracy is not guaranteed.  Charts with no relevant data will be blank until data is collected.' ); ?></p>
     983            <p style="color: #990000;"><strong><em><?php ABD_L::_e( 'The statistics feature of this plugin is currently in beta testing. The aggregated data below may be inaccurate and is subject to change. If flaws are discovered, all collected statistics during this beta may be reset without warning or prompting. Feedback on this feature is welcome.' ); ?></em></strong></p>
     984            <a href="<?php echo wp_nonce_url( admin_url( 'admin-post.php?action=abd_delete_stats' ), 'user instructed deletion of all statistics table rows' ); ?>" id="abd-statistics-reset-button" class="button abd-delete-button"><?php ABD_L::_e( 'Reset Statistics' ); ?></a>
     985
     986
     987            <div id='abd-stats-chart-page-load' class='abd-stats-chart'></div>
     988            <p class='abd-stats-chart-caption'><?php echo sprintf( ABD_L::__( 'This chart shows ad blocker status on every recorded page load. This metric is useful for assessing %simpressions%s.  It can be skewed by multiple page loads per visitor, or visitors who toggled on or off their ad blocker while on your website. ' ), '<a href="https://en.wikipedia.org/wiki/Impression_(online_media)" target="_blank">', '</a>' ); ?></p>
     989           
     990            <div id='abd-stats-chart-unique-user' class='abd-stats-chart'></div>
     991            <p class='abd-stats-chart-caption'><?php ABD_L::_e( 'This chart shows the ad blocker status for unique viewers.  This filters out the previous chart\'s skew, caused by page reloads, multiple page visits, and return views of your site.  Viewers are counted a maximum of once in each category.  Uniqueness is determined by IP address.  This metric is useful for assessing the ad blocker usage proclivity of your audience. It can be skewed by users who toggle their ad blocker on or off during their visit to your site, and by users whose IP address changes between page loads or site visits.' ); ?></p>
     992
     993            <div id="abd-stats-chart-change-disable" class="abd-stats-chart"></div>
     994            <p class='abd-stats-chart-caption'><?php ABD_L::_e( 'This chart shows how many users first visited your site with an ad blocker enabled, and who later disabled it.  This metric can be a rough estimation of the effectiveness of disable ad blocker pleas.  It can be skewed by returning visitors, who toggled ad blockers off on other websites, between visits to yours. It does not take into account multiple ad blocker state toggles per visitor. If the visitor ever had an ad blocker on, and turned it off on a later page load, they are counted.' ); ?></p>
     995
     996            <div id="abd-stats-chart-change-enable" class="abd-stats-chart"></div>
     997            <p class='abd-stats-chart-caption'><?php ABD_L::_e( 'This chart shows how many users first visited your site with an ad blocker disabled, and who later enabled it.  This metric can be a rough estimation of how many users felt the need to turn on an ad blocker on your site for some reason.  It can be skewed by returning visitors, who toggled on ad blockers on other websites, between visits to yours. It does not take into account multiple ad blocker state toggles per visitor. If the visitor ever had an ad blocker off, and turned it on, on a later page load, they are counted.' ); ?></p>
    859998            <?php
    860999            return ob_get_clean();
     
    16471786                    </a> &nbsp;
    16481787
    1649                     <a href="<?php echo wp_nonce_url( admin_url( 'admin-post.php?action=abd_delete_shortcode&id=' . $sc_id ), 'user instructed shortcode delete id equals ' . $sc_id ); ?>" class="abd-shortcode-delete-button button">
     1788                    <a href="<?php echo wp_nonce_url( admin_url( 'admin-post.php?action=abd_delete_shortcode&id=' . $sc_id ), 'user instructed shortcode delete id equals ' . $sc_id ); ?>" class="abd-shortcode-delete-button abd-delete-button button">
    16501789                        <?php ABD_L::_e( 'Delete This Shortcode' ); ?>
    16511790                    </a>
     
    18551994
    18561995                'submitLogToDevWarning'             => ABD_L::__( 'Ad Blocking Detector is about to send the contents of the Session Log and Plugin, WordPress, and Server Configuration Data boxes to the developer. If you wish to check the contents before sending, close this dialog box, and review the content in the appropriate boxes. No contact information is submitted with the log entries, so you will not be responded to. If you require or desire feedback, you will need to contact the developer personally as well.' ),
    1857                 'submitLogToDevTitle'               => ABD_L::__( 'Are you sure?' )
     1996                'submitLogToDevTitle'               => ABD_L::__( 'Are you sure?' ),
     1997
     1998                'resetStatisticsTitle'                 => ABD_L::__( 'Are you sure?' ),
     1999                'resetStatisticsWarning'               => ABD_L::__( 'This will delete all recorded statistical information, and can not be undone!' )
    18582000            );
    18592001
Note: See TracChangeset for help on using the changeset viewer.