/**
  * Init -- Sets things up.
  */
 public static function init()
 {
     if (wp_slimstat::$options['enable_ads_network'] == 'yes' || wp_slimstat::$options['enable_ads_network'] == 'no') {
         self::$admin_notice = "A few weeks ago we started hitting the limits imposed on our site by our existing hosting provider. It was clearly time to find a new home for Slimstat. We've been working on migrating our web platform (website and add-on repository API) to a new more powerful server, and a new domain: <a href='http://www.wp-slimstat.com' target='_blank'>wp-slimstat.com</a>. Our dev team has also released updates for our premium add-ons Export to Excel, Email Reports and User Overview, which are now fully compatible with Slimstat 4. Go get your copy today.";
         self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">I got it, thanks</a>';
     } else {
         self::$admin_notice = "\n\t\t\t<div class='fixed-height'>\n\t\t\t\t<p>In order to protect our intellectual property rights (<a href='http://www.youtube.com/watch?v=OeU-RrjolCw' target='_blank'>Keyword Swarm</a>, anyone?), we are asking you to review the following terms of use.</p>\n\t\t\t\t<p><strong>GNU General Public License v2</strong></p>\n\t\t\t\t<ol>\n\t\t\t\t\t<li>You may copy and distribute verbatim copies of Slimstat's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of Slimstat a copy of this License along with Slimstat. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.</li>\n\t\t\t\t\t<li>You may modify your copy or copies of Slimstat or any portion of it, thus forming a work based on Slimstat, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:\n\t\t\t\t\t\t<ol>\n\t\t\t\t\t\t\t<li>You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.</li>\n\t\t\t\t\t\t\t<li>You must cause any work that you distribute or publish, <strong>that in whole or in part contains or is derived from Slimstat or any part thereof, to be licensed as a whole at no charge</strong> to all third parties under the terms of this License.</li>\n\t\t\t\t\t\t\t<li>If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute Slimstat under these conditions, and telling the user how to view a copy of this License.</li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t\tThese requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from Slimstat, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on Slimstat, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.\n\t\t\t\t\t\tThus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on Slimstat.\n\t\t\t\t\t\tIn addition, mere aggregation of another work not based on Slimstat with Slimstat (or with a work based on Slimstat) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.</li>\n\t\t\t\t\t<li>You may copy and distribute Slimstat (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:\n\t\t\t\t\t\t<ol>\n\t\t\t\t\t\t\t<li>Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,</li>\n\t\t\t\t\t\t\t<li>Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,</li>\n\t\t\t\t\t\t\t<li>Accompany it with the information you received as to the offer to distribute corresponding source code.</li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t\tThe source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.\n\t\t\t\t\t\tIf distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.</li>\n\t\t\t\t\t<li>You may not copy, modify, sublicense, or distribute Slimstat except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute Slimstat is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.</li>\n\t\t\t\t\t<li>You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute Slimstat or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing Slimstat (or any work based on Slimstat), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying Slimstat or works based on it.</li>\n\t\t\t\t\t<li>Each time you redistribute Slimstat (or any work based on Slimstat), the recipient automatically receives a license from the original licensor to copy, distribute or modify Slimstat subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.</li>\n\t\t\t\t\t<li>If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, <strong>then as a consequence you may not distribute Slimstat at all</strong>. For example, if a patent license would not permit royalty-free redistribution of Slimstat by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of Slimstat.\n\t\t\t\t\t\tIf any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.\n\t\t\t\t\t\tIt is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.\n\t\t\t\t\t\tThis section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.</li>\n\t\t\t\t\t<li>If the distribution and/or use of Slimstat is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places Slimstat under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.</li>\n\t\t\t\t\t<li>The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.\n\t\t\t\t\t\tEach version is given a distinguishing version number.</li>\n\t\t\t\t\t<li>If you wish to incorporate parts of Slimstat into other free programs whose distribution conditions are different, <strong>write to the author to ask for permission</strong>. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.</li>\n\t\t\t\t\t<li><strong>NO WARRANTY</strong> - BECAUSE WP SLIMSTAT IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR WP SLIMSTAT, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE WP SLIMSTAT \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF WP SLIMSTAT IS WITH YOU. SHOULD WP SLIMSTAT PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</li>\n\t\t\t\t\t<li>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE WP SLIMSTAT AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE WP SLIMSTAT (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF WP SLIMSTAT TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</li>\n\t\t\t\t</ol>\n\t\t\t\t\n\t\t\t\t<p><strong>Third Party Text Links</strong></p>\n\t\t\t\t<p>Third party text networks supply text for display in Slimstat. These networks may collect your visitors' IP addresses, in native or hashed forms, for purposes of controlling the distribution of text links. Slimstat collects anonymous aggregated usage statistics.</p>\n\t\t\t\t<p>By clicking the button here below, you agree to the terms and conditions and give permission to place text links on your website when search engine crawlers access it. Your website's layout, performance and interaction with human visitors should not be altered or affected in any way. Please note that this feature can be deactivated at any time under Setting > Advanced > UAN Netword, without affecting any other feature available in Slimstat.</p>\n\t\t\t\t<p>WP Slimstat - Copyright &copy; " . date('Y') . " Get Used to IT.</p>\n\t\t\t</div>\n\t\t\t\n\t\t\t<div>\n\t\t\t\t<a id='slimstat-accept-terms' href='#' class='button-primary'>I accept</a>\n\t\t\t\t<a id='slimstat-hide-admin-notice' href='#' class='button-secondary'>I do not accept</a>\n\t\t\t</div>";
     }
     // Settings URL
     self::$config_url = 'admin.php?page=wp-slim-config&amp;tab=';
     // Load language files
     load_plugin_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang', '/wp-slimstat/admin/lang');
     // If a localization does not exist, use English
     if (!isset($l10n['wp-slimstat'])) {
         load_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang/wp-slimstat-en_US.mo');
     }
     // WPMU - New blog created
     $active_sitewide_plugins = get_site_option('active_sitewide_plugins');
     if (!empty($active_sitewide_plugins['wp-slimstat/wp-slimstat.php'])) {
         add_action('wpmu_new_blog', array(__CLASS__, 'new_blog'));
     }
     // WPMU - Blog Deleted
     add_filter('wpmu_drop_tables', array(__CLASS__, 'drop_tables'), 10, 2);
     // Screen options: hide/show panels to customize your view
     add_filter('screen_settings', array(__CLASS__, 'screen_settings'), 10, 2);
     // Display a notice that hightlights this version's features
     if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false && !empty(self::$admin_notice) && wp_slimstat::$options['show_admin_notice'] != wp_slimstat::$version && current_user_can('manage_options')) {
         add_action('admin_notices', array(__CLASS__, 'show_admin_notice'));
     }
     // Remove spammers from the database
     if (wp_slimstat::$options['ignore_spammers'] == 'yes') {
         add_action('transition_comment_status', array(__CLASS__, 'remove_spam'), 15, 3);
     }
     if (function_exists('is_network_admin') && !is_network_admin()) {
         // Add the appropriate entries to the admin menu, if this user can view/admin WP SlimStats
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_view_menu'));
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_config_menu'));
         // Display the column in the Edit Posts / Pages screen
         if (wp_slimstat::$options['add_posts_column'] == 'yes') {
             add_filter('manage_posts_columns', array(__CLASS__, 'add_column_header'));
             add_filter('manage_pages_columns', array(__CLASS__, 'add_column_header'));
             add_action('manage_posts_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('manage_pages_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
         }
         // Add some inline CSS to customize the icon associated to SlimStat in the sidebar
         add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet_icon'));
         // Update the table structure and options, if needed
         if (!empty(wp_slimstat::$options['version']) && wp_slimstat::$options['version'] != wp_slimstat::$version) {
             add_action('admin_init', array(__CLASS__, 'update_tables_and_options'));
         }
     }
     // Load the library of functions to generate the reports
     if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false || !empty($_POST['action']) && $_POST['action'] == 'slimstat_load_report') {
         include_once dirname(__FILE__) . '/view/wp-slimstat-reports.php';
         wp_slimstat_reports::init();
         if (!empty($_POST['report_id'])) {
             $report_id = sanitize_title($_POST['report_id'], 'slim_p0_00');
             if (!empty(wp_slimstat_reports::$reports_info[$report_id])) {
                 add_action('wp_ajax_slimstat_load_report', array('wp_slimstat_reports', 'callback_wrapper'), 10, 2);
             }
         }
     }
     // Dashboard Widgets
     if (wp_slimstat::$options['add_dashboard_widgets'] == 'yes') {
         $temp = strlen($_SERVER['REQUEST_URI']) - 10;
         if (strpos($_SERVER['REQUEST_URI'], 'index.php') !== false || $temp >= 0 && strpos($_SERVER['REQUEST_URI'], '/wp-admin/', $temp) !== false) {
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
         }
         add_action('wp_dashboard_setup', array(__CLASS__, 'add_dashboard_widgets'));
     }
     // WordPress Widget
     // FIX ME: To be implemented
     // AJAX Handlers
     if (defined('DOING_AJAX') && DOING_AJAX) {
         add_action('wp_ajax_slimstat_hide_admin_notice', array(__CLASS__, 'hide_admin_notice'));
         add_action('wp_ajax_slimstat_hide_geolite_notice', array(__CLASS__, 'hide_geolite_notice'));
         add_action('wp_ajax_slimstat_manage_filters', array(__CLASS__, 'manage_filters'));
         add_action('wp_ajax_slimstat_delete_pageview', array(__CLASS__, 'delete_pageview'));
         add_action('wp_ajax_slimstat_enable_ads_feature', array(__CLASS__, 'enable_ads_feature'));
     }
 }
Example #2
0
        ?>
		<input type="hidden" name="fs[<?php 
        echo $a_key;
        ?>
]" class="slimstat-post-filter" value="equals <?php 
        echo htmlspecialchars($a_value);
        ?>
"/>
		<?php 
    }
}
?>
	</form>
	<?php 
if (!file_exists(wp_slimstat::$maxmind_path) && wp_slimstat::$options['no_maxmind_warning'] != 'yes') {
    wp_slimstat_admin::show_alert_message(sprintf(__("Install MaxMind's <a href='%s'>GeoLite DB</a> to determine your visitors' country of origin.", 'wp-slimstat'), self::$config_url . '6') . '<a id="slimstat-hide-geolite-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-notification below-h2');
}
$filters_html = wp_slimstat_reports::get_filters_html(wp_slimstat_db::$filters_normalized['columns']);
if (!empty($filters_html)) {
    echo "<div id='slimstat-current-filters'>{$filters_html}</div>";
}
?>

	<div class="meta-box-sortables">
		<form method="get" action=""><input type="hidden" id="meta-box-order-nonce" name="meta-box-order-nonce" value="<?php 
echo wp_create_nonce('meta-box-order');
?>
" /></form><?php 
foreach (wp_slimstat_reports::$reports_info as $a_report_id => $a_report_info) {
    if (empty($a_report_info['screens']) || !in_array($_GET['page'], $a_report_info['screens'])) {
        continue;
Example #3
0
        }
        break;
    case __('Advanced', 'wp-slimstat'):
        $this_domain = parse_url(get_bloginfo('url'));
        $encoded_ci = 'YTo0OntzOjEyOiJjb250ZW50X3R5cGUiO3M6ODoiZXh0ZXJuYWwiO3M6ODoiY2F0ZWdvcnkiO3M6MDoiIjtzOjEwOiJjb250ZW50X2lkIjtpOjA7czo2OiJhdXRob3IiO3M6MTM6ImV4dGVybmFsLXBhZ2UiO30=';
        $encoded_ci = $encoded_ci . '.' . md5($encoded_ci . wp_slimstat::$options['secret']);
        $options_on_this_page = array('advanced_tracker_header' => array('description' => __('Tracker', 'wp-slimstat'), 'type' => 'section_header'), 'detect_smoothing' => array('description' => __('Detect Smoothing', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Detect if your visitors' browsers support anti-aliasing (font smoothing). This option required Spy Mode to be enabled.", 'wp-slimstat')), 'enable_outbound_tracking' => array('description' => __('Track Outbound Clicks', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Track when your visitors click on link to external websites. This option required Spy Mode to be enabled.', 'wp-slimstat')), 'session_duration' => array('description' => __('Session Duration', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('How many seconds should a human session last? Google Analytics sets it to 1800 seconds.', 'wp-slimstat'), 'after_input_field' => __('seconds', 'wp-slimstat')), 'extend_session' => array('description' => __('Extend Session', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Extend the duration of a session each time the user visits a new page.', 'wp-slimstat')), 'enable_cdn' => array('description' => __('Enable CDN', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Use <a href='http://www.jsdelivr.com/' target='_blank'>JSDelivr</a>'s CDN, by serving our tracking code from their fast and reliable network (free service).", 'wp-slimstat')), 'extensions_to_track' => array('description' => __('Extensions to Track', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the file extensions that you want to be treated as Downloads. Please note that links pointing to external resources (i.e. PDFs on a different website) are considered Downloads and not Outbound Links (and tracked as such), if their extension matches one of the ones listed here below.", 'wp-slimstat')), 'advanced_external_pages_header' => array('description' => __('External Pages', 'wp-slimstat'), 'type' => 'section_header'), 'external_pages_script' => array('type' => 'static', 'skip_update' => 'yes', 'description' => __('Add the following code to all the non-WP pages you want to track', 'wp-slimstat'), 'long_description' => '&lt;script type="text/javascript"&gt;
/* &lt;![CDATA[ */
var SlimStatParams = {
	ajaxurl: "' . admin_url('admin-ajax.php') . '",
	ci: "' . $encoded_ci . '",
	extensions_to_track: "' . wp_slimstat::$options['extensions_to_track'] . '"
};
/* ]]&gt; */
&lt;/script&gt;
&lt;script type="text/javascript" src="http://cdn.jsdelivr.net/wp-slimstat/' . wp_slimstat::$version . '/wp-slimstat.js"&gt;&lt;/script&gt;'), 'advanced_misc_header' => array('description' => __('Miscellaneous', 'wp-slimstat'), 'type' => 'section_header'), 'show_sql_debug' => array('description' => __('Debug Mode', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Display the SQL queries used to retrieve the data.', 'wp-slimstat')), 'ip_lookup_service' => array('description' => __('IP Lookup', 'wp-slimstat'), 'type' => 'text', 'long_description' => __('Customize the Geolocation service to be used in the reports.', 'wp-slimstat')), 'custom_css' => array('description' => __('Custom CSS', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Paste here your custom stylesheet to personalize the way your reports look. <a href='http://wordpress.org/plugins/wp-slimstat/faq/' target='_blank'>Check the FAQ</a> for more information on how to use this setting.", 'wp-slimstat')), 'enable_ads_network' => array('description' => __('Enable UAN', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Send anonymous data about user agents to our server for analysis. This allows us to contribute to the <a href='http://browscap.org/' target='_blank'>BrowsCap opensource project</a>, and improve the accuracy of Slimstat's browser detection functionality. It also enables our transparent ads network. No worries, your site will not be affected in any way.", 'wp-slimstat')));
        break;
    case __('Maintenance', 'wp-slimstat'):
        include_once dirname(__FILE__) . '/maintenance.php';
        break;
    default:
        break;
}
if (has_filter('slimstat_options_on_page')) {
    $options_on_this_page = apply_filters('slimstat_options_on_page', $options_on_this_page, $current_tab);
}
if (isset($options_on_this_page)) {
    wp_slimstat_admin::update_options($options_on_this_page);
    wp_slimstat_admin::display_options($options_on_this_page, $current_tab);
}
echo '</div>';
Example #4
0
            $GLOBALS['wpdb']->query("DELETE FROM {$GLOBALS['wpdb']->prefix}usermeta WHERE meta_key LIKE '%slim%'");
            wp_slimstat_admin::show_alert_message(__('Your reports were successfully restored to their default arrangement.', 'wp-slimstat'), 'updated below-h2');
            break;
        case 'activate-indexes':
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats ADD INDEX stats_resource_idx(resource(20))");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats ADD INDEX stats_browser_idx(browser_id)");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->base_prefix}slim_browsers ADD INDEX browser_all_idx(browser,version,platform,css_version,type)");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->base_prefix}slim_screenres ADD INDEX screenres_all_idx(resolution,colordepth,antialias)");
            wp_slimstat_admin::show_alert_message(__('Congrats! Slimstat is now optimized for <a href="http://www.youtube.com/watch?v=ygE01sOhzz0" target="_blank">ludicrous speed</a>.', 'wp-slimstat'), 'updated below-h2');
            break;
        case 'deactivate-indexes':
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats DROP INDEX stats_resource_idx");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats DROP INDEX stats_browser_idx");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->base_prefix}slim_browsers DROP INDEX browser_all_idx");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->base_prefix}slim_screenres DROP INDEX screenres_all_idx");
            wp_slimstat_admin::show_alert_message(__('Indexing has been successfully disabled. Enjoy the extra database space you just gained!', 'wp-slimstat'), 'updated below-h2');
            break;
        case 'import-settings':
            $new_options = @unserialize(stripslashes($_POST['import-slimstat-settings']));
            $new_options = array_intersect_key($new_options, wp_slimstat::$options);
            if (!empty($new_options)) {
                foreach ($new_options as $a_option_name => $a_option_value) {
                    wp_slimstat::$options[$a_option_name] = $a_option_value;
                }
            }
            break;
        default:
    }
}
// Retrieve some information about the tables used by Slimstat
$check_index = wp_slimstat::$wpdb->get_results("SHOW INDEX FROM {$GLOBALS['wpdb']->prefix}slim_stats WHERE Key_name = 'stats_resource_idx'");
Example #5
0
}
$current_tab = empty($_GET['tab']) ? 1 : intval($_GET['tab']);
// Define all the options
$options = array(1 => array('title' => __('General', 'wp-slimstat'), 'rows' => array('general_tracking_header' => array('description' => __('Tracker', 'wp-slimstat'), 'type' => 'section_header'), 'is_tracking' => array('description' => __('Tracking', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Turn the tracker on or off, but keep the reports accessible.', 'wp-slimstat'), 'custom_label_yes' => __('On', 'wp-slimstat'), 'custom_label_no' => __('Off', 'wp-slimstat')), 'track_admin_pages' => array('description' => __('Admin Pages', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Enable this option to track your users' activity within the admin.", 'wp-slimstat'), 'custom_label_yes' => __('Track', 'wp-slimstat'), 'custom_label_no' => __('Do not track', 'wp-slimstat')), 'enable_javascript' => array('description' => __('Stealth Mode', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Collect information about screen resolutions, outbound links, downloads, etc. If Tracking Mode is set to Javascript, this data will be tracked regardless of which value you set for this option. In Accurate mode, this option will remove the tracking code from your pages' source code.", 'wp-slimstat'), 'custom_label_yes' => __('Off', 'wp-slimstat'), 'custom_label_no' => __('On', 'wp-slimstat')), 'javascript_mode' => array('description' => __('Tracking Mode', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Select <strong>Client</strong> if you are using a caching plugin (W3 Total Cache, WP SuperCache, HyperCache, etc). Slimstat will behave pretty much like Google Analytics, and visitors whose browser does not support Javascript will be ignored. A nice side effect is that <strong>most spammers, search engines and other crawlers</strong> will not be tracked.', 'wp-slimstat'), 'custom_label_yes' => __('Client', 'wp-slimstat'), 'custom_label_no' => __('Server', 'wp-slimstat')), 'general_integration_header' => array('description' => __('WordPress Integration', 'wp-slimstat'), 'type' => 'section_header'), 'use_separate_menu' => array('description' => __('Menu Position', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Choose between a standalone admin menu for Slimstat or a drop down in the admin bar (if visible).', 'wp-slimstat'), 'custom_label_yes' => __('Side Menu', 'wp-slimstat'), 'custom_label_no' => __('Admin Bar', 'wp-slimstat')), 'add_posts_column' => array('description' => __('Posts and Pages', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Add a new column to the Edit Posts/Pages screens, with the number of hits per post in the last 365 days.', 'wp-slimstat')), 'add_dashboard_widgets' => array('description' => __('Dashboard Widgets', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Choose if you want to have the most important reports on your WordPress Dashboard. Use the Screen Options dropdown to select which ones to display.', 'wp-slimstat')), 'posts_column_day_interval' => array('description' => __('Report Interval', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('Enter the time range, in days, that should be used to calculate the value here above.', 'wp-slimstat')), 'posts_column_pageviews' => array('description' => __('Report Type', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Select what kind of information you would like to see displayed on the Posts admin screen. Pageviews include all the hits regardless of the user, Unique IPs consider only one hit per user in the given time range.', 'wp-slimstat'), 'custom_label_yes' => __('Pageviews', 'wp-slimstat'), 'custom_label_no' => __('Unique IPs', 'wp-slimstat')), 'hide_addons' => array('description' => __('Hide Add-ons', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable this option to hide all your <strong>active</strong> premium add-ons from the list of plugins in WordPress. Please note that you will still receive updates for hidden add-ons.', 'wp-slimstat')), 'general_database_header' => array('description' => __('Database', 'wp-slimstat'), 'type' => 'section_header'), 'auto_purge' => array('description' => __('Retain data for', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __("Clean-up log entries older than the number of days specified here above. Enter <strong>0</strong> (number zero) if you want to preserve your data regardless of its age.", 'wp-slimstat') . (wp_slimstat::$options['auto_purge'] > 0 ? ' ' . __('Next clean-up on', 'wp-slimstat') . ' <strong>' . date_i18n(get_option('date_format') . ', ' . get_option('time_format'), wp_next_scheduled('wp_slimstat_purge')) . '</strong>. ' . sprintf(__('Entries logged on or before %s will be archived or deleted according to the option here below.', 'wp-slimstat'), date_i18n(get_option('date_format'), strtotime('-' . wp_slimstat::$options['auto_purge'] . ' days'))) : ''), 'after_input_field' => __('days', 'wp-slimstat')), 'auto_purge_delete' => array('description' => __('Delete records', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('If DB space is not an issue, you can decide to archive older records in another table, instead of deleting them. This way performance is preserved, but you will still be able to access your data at a later time, if needed. Please note that the archive table (<code>wp_slim_stats_archive</code>) will be <strong>deleted</strong> along with all the other tables, when Slimstat is uninstalled. Make sure to backup your data before you proceed.', 'wp-slimstat')))), 2 => array('title' => __('Reports', 'wp-slimstat'), 'rows' => array('reports_basic_header' => array('description' => __('Formats and Conversions', 'wp-slimstat'), 'type' => 'section_header'), 'use_european_separators' => array('description' => __('Number Format', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Choose the number format you want to use for your reports.', 'wp-slimstat'), 'custom_label_yes' => '1.234,56', 'custom_label_no' => '1,234.56'), 'date_format' => array('description' => __('Date Format', 'wp-slimstat'), 'type' => 'text', 'long_description' => __("<a href='http://php.net/manual/en/function.date.php' target='_blank'>PHP Format</a> to use when displaying a pageview's date.", 'wp-slimstat')), 'time_format' => array('description' => __('Time Format', 'wp-slimstat'), 'type' => 'text', 'long_description' => __("<a href='http://php.net/manual/en/function.date.php' target='_blank'>PHP Format</a> to use when displaying a pageview's time.", 'wp-slimstat')), 'show_display_name' => array('description' => __('Use Display Name', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('By default, users are listed by their usernames. Use this option to visualize their display names instead.', 'wp-slimstat')), 'convert_resource_urls_to_titles' => array('description' => __('Use Titles', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Slimstat converts your permalinks into post, page and category titles. Disable this feature if you need to see the URL in your reports.', 'wp-slimstat')), 'convert_ip_addresses' => array('description' => __('Convert IP Addresses', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Display provider names instead of IP addresses.', 'wp-slimstat')), 'reports_functionality_header' => array('description' => __('Functionality', 'wp-slimstat'), 'type' => 'section_header'), 'use_slimscroll' => array('description' => __('SlimScroll', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable SlimScroll, a slick jQuery library that replaces the built-in browser scrollbar.', 'wp-slimstat')), 'expand_details' => array('description' => __('Expand Details', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Expand each row's details by default, insted of on mousehover.", 'wp-slimstat')), 'rows_to_show' => array('description' => __('Rows to Display', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('Specify the number of items in each report.', 'wp-slimstat')), 'limit_results' => array('description' => __('Max Results', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('Decide how many records should be retrieved from the database in total. Depending on your server configuration, you may want to fine tune this value to avoid exceeding your PHP memory limit.', 'wp-slimstat')), 'reports_right_now_header' => array('description' => __('Activity Log', 'wp-slimstat'), 'type' => 'section_header'), 'refresh_interval' => array('description' => __('Live Stream', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('Enable the Live view, which refreshes the Activity Log every X seconds. Enter <strong>0</strong> (number zero) to deactivate this feature.', 'wp-slimstat'), 'after_input_field' => __('seconds', 'wp-slimstat')), 'number_results_raw_data' => array('description' => __('Rows to Display', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('Specify the number of items in the Activity Log.', 'wp-slimstat')), 'reports_miscellaneous_header' => array('description' => __('Miscellaneous', 'wp-slimstat'), 'type' => 'section_header'), 'show_complete_user_agent_tooltip' => array('description' => __('Show User Agent', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Choose if you want to see the browser name or a complete user agent string when hovering on browser icons.', 'wp-slimstat')), 'enable_sov' => array('description' => __('Enable SOV', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('In linguistic typology, a subject-object-verb (SOV) language is one in which the subject, object, and verb of a sentence appear in that order, like in Japanese.', 'wp-slimstat')), 'enable_getsocial' => array('description' => __('Social Analytics', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Thanks to a <a href='http://getsocial.io/enterprise' target='_blank'>partnership with GetSocial.io</a>, you can access a powerful set of analytics for social media where you can identify top performing posts. Track social sharing to understand which of your posts are generating more engagement. When this option is enabled, Slimstat sends a list of all your posts's URLs to their service for analysis once daily.", 'wp-slimstat')))), 3 => array('title' => __('Filters', 'wp-slimstat'), 'rows' => array('filters_users_header' => array('description' => __('Visitors and Known Users', 'wp-slimstat'), 'type' => 'section_header'), 'track_users' => array('description' => __('Track Registered Users', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable this option to track logged in users.', 'wp-slimstat')), 'ignore_users' => array('description' => __('Blacklist by Username', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the usernames you don't want to track, separated by commas. Please be aware that spaces are <em>not</em> ignored and that usernames are case sensitive.", 'wp-slimstat'), 'skip_update' => true), 'ignore_ip' => array('description' => __('Blacklist by IP Address', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the IP addresses you don't want to track, separated by commas. Each network <strong>must</strong> be defined using the <a href='http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing' target='_blank'>CIDR notation</a> (i.e. <em>192.168.0.0/24</em>). This filter applies both to the public IP and the originating IP, if available.", 'wp-slimstat')), 'ignore_capabilities' => array('description' => __('Blacklist by Capability', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Users having at least one of the <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capabilities</a> listed here below will not be tracked. Capabilities are case-insensitive.", 'wp-slimstat'), 'skip_update' => true), 'filters_categories_header' => array('description' => __('Profiling', 'wp-slimstat'), 'type' => 'section_header'), 'ignore_spammers' => array('description' => __('Ignore Spammers', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Enable this option if you don't want to track visits from users identified as spammers by third-party tools like Akismet. Pageviews generated by users whose comments are later marked as spam, will also be removed from the database.", 'wp-slimstat')), 'ignore_bots' => array('description' => __('Ignore Bots', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Turn on this feature if you want to have the accuracy level of server-side tracking, but not the inconvenience of getting your database clogged with pageviews generated by crawlers, spiders, search engine bots, etc. Please note that in Client mode, bots are ignored regardless of this setting.", 'wp-slimstat')), 'ignore_resources' => array('description' => __('Permalinks', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the URLs on your website that you don't want to track, separated by commas. Don't include the domain name: <em>/about, ?p=1</em>, etc. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>/abou*</code> will match /about and /abound, <code>/abo*t</code> will match /aboundant and /about, <code>/abo!t</code> will match /about and /abort. Strings are case-insensitive.", 'wp-slimstat')), 'ignore_countries' => array('description' => __('Countries', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Country codes (i.e.: <code>en-us, it, es</code>) that you don't want to track, separated by commas.", 'wp-slimstat')), 'ignore_browsers' => array('description' => __('User Agents', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Browsers (user agents) you don't want to track, separated by commas. You can specify the browser's version adding a slash after the name  (i.e. <em>Firefox/3.6</em>). Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>Chr*</code> will match Chrome and Chromium, <code>IE/!.0</code> will match IE/7.0 and IE/8.0. Strings are case-insensitive.", 'wp-slimstat')), 'ignore_referers' => array('description' => __('Referring Sites', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Referring URLs that you don't want to track, separated by commas: <code>http://mysite.com*</code>, <code>*/ignore-me-please</code>, etc. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. Strings are case-insensitive. Please include either a wildcard or the protocol you want to filter (http://, https://).", 'wp-slimstat')), 'filters_outbound_header' => array('description' => __('Internal and Outbound Links', 'wp-slimstat'), 'type' => 'section_header'), 'enable_outbound_tracking' => array('description' => __('Track Outbound Clicks', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Track when your visitors click on link to external websites. This option required Spy Mode to be enabled.', 'wp-slimstat')), 'track_internal_links' => array('description' => __('Track Coordinates', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Collect mouse coordinates and other information for clicks on internal links. Strongly recommended if you're using the heatmap add-on. By default, this information is only collected for external links.", 'wp-slimstat')), 'ignore_outbound_classes_rel_href' => array('description' => __('No Callback', 'wp-slimstat'), 'type' => 'text', 'long_description' => __("Track the event but do not invoke the callback function on links marked with one of these class names, <em>rel</em> attribute or whose <em>href</em> attribute contains one of these strings (separated by comma). Useful to prevent conflicts with lightbox and similar libraries.", 'wp-slimstat')), 'do_not_track_outbound_classes_rel_href' => array('description' => __('Do Not Track', 'wp-slimstat'), 'type' => 'text', 'long_description' => __("Do not track links marked with one of these class names, <em>rel</em> attributes or whose <em>href</em> attribute contains one of these strings (separated by comma).", 'wp-slimstat')), 'filters_miscellaneous_header' => array('description' => __('Miscellaneous', 'wp-slimstat'), 'type' => 'section_header'), 'anonymize_ip' => array('description' => __('Enable Privacy Mode', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Mask your visitors' IP addresses to comply with European Privacy Laws.", 'wp-slimstat')), 'ignore_prefetch' => array('description' => __('Ignore Prefetch Requests', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Prevent Slimstat from tracking pageviews generated by Firefox's <a href='https://developer.mozilla.org/en/Link_prefetching_FAQ' target='_blank'>Link Prefetching functionality</a>.", 'wp-slimstat')))), 4 => array('title' => __('Permissions', 'wp-slimstat'), 'rows' => array('permissions_reports_header' => array('description' => __('Reports', 'wp-slimstat'), 'type' => 'section_header'), 'restrict_authors_view' => array('description' => __('Restrict Authors', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable this option if you want your authors to only see stats related to their own content.', 'wp-slimstat')), 'capability_can_view' => array('description' => __('Capability', 'wp-slimstat'), 'type' => 'text', 'long_description' => __("Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> needed to access the reports (default: <code>activate_plugins</code>). If this field is empty, <strong>all your users</strong> (including subscribers) will have access to the reports, unless a 'Read access' whitelist has been specified here below. In this case, the list has precedence over the capability.", 'wp-slimstat')), 'can_view' => array('description' => __('Whitelist', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the users who should have access to the reports, separated by commas. Administrators are implicitly allowed, so you don't need to list them in here. Usernames are case sensitive.", 'wp-slimstat'), 'skip_update' => true), 'permissions_config_header' => array('description' => __('Settings', 'wp-slimstat'), 'type' => 'section_header'), 'capability_can_admin' => array('description' => __('Capability', 'wp-slimstat'), 'type' => 'text', 'long_description' => __("Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> required to configure Slimstat (default: <code>activate_plugins</code>). The whitelist here below can be used to override this option for specific users.", 'wp-slimstat')), 'can_admin' => array('description' => __('Whitelist', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the users who can edit these options, separated by commas. Please be advised that admins <strong>are not</strong> implicitly allowed, so do not forget to include yourself! Usernames are case sensitive.", 'wp-slimstat'), 'skip_update' => true))), 5 => array('title' => __('Advanced', 'wp-slimstat'), 'rows' => array('advanced_tracker_header' => array('description' => __('Tracker', 'wp-slimstat'), 'type' => 'section_header'), 'detect_smoothing' => array('description' => __('Detect Smoothing', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Detect if your visitors' browsers support anti-aliasing (font smoothing). This option requires Stealth Mode to be turned off.", 'wp-slimstat')), 'session_duration' => array('description' => __('Session Duration', 'wp-slimstat'), 'type' => 'integer', 'long_description' => __('How many seconds should a human session last? Google Analytics sets it to 1800 seconds.', 'wp-slimstat'), 'after_input_field' => __('seconds', 'wp-slimstat')), 'extend_session' => array('description' => __('Extend Session', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Extend the duration of a session each time the user visits a new page.', 'wp-slimstat')), 'enable_cdn' => array('description' => __('Enable CDN', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Use <a href='http://www.jsdelivr.com/' target='_blank'>JSDelivr</a>'s CDN, by serving our tracking code from their fast and reliable network (free service).", 'wp-slimstat')), 'extensions_to_track' => array('description' => __('Extensions to Track', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the file extensions that you want to be treated as Downloads. Please note that links pointing to external resources (i.e. PDFs on a different website) are considered Downloads and not Outbound Links (and tracked as such), if their extension matches one of the ones listed here below.", 'wp-slimstat')), 'advanced_external_pages_header' => array('description' => __('External Pages', 'wp-slimstat'), 'type' => 'section_header'), 'external_pages_script' => array('type' => 'static', 'skip_update' => 'yes', 'description' => __('Add the following code to all the non-WP pages you want to track, right before the closing BODY tag', 'wp-slimstat'), 'long_description' => '&lt;script type="text/javascript"&gt;
	/* &lt;![CDATA[ */
	var SlimStatParams = {
		ajaxurl: "' . admin_url('admin-ajax.php') . '",
		ci: "YTo0OntzOjEyOiJjb250ZW50X3R5cGUiO3M6ODoiZXh0ZXJuYWwiO3M6ODoiY2F0ZWdvcnkiO3M6MDoiIjtzOjEwOiJjb250ZW50X2lkIjtpOjA7czo2OiJhdXRob3IiO3M6MTM6ImV4dGVybmFsLXBhZ2UiO30=.' . md5('YTo0OntzOjEyOiJjb250ZW50X3R5cGUiO3M6ODoiZXh0ZXJuYWwiO3M6ODoiY2F0ZWdvcnkiO3M6MDoiIjtzOjEwOiJjb250ZW50X2lkIjtpOjA7czo2OiJhdXRob3IiO3M6MTM6ImV4dGVybmFsLXBhZ2UiO30=' . wp_slimstat::$options['secret']) . '",
		extensions_to_track: "' . wp_slimstat::$options['extensions_to_track'] . '"
	};
	/* ]]&gt; */
	&lt;/script&gt;
	&lt;script type="text/javascript" src="http://cdn.jsdelivr.net/wp/wp-slimstat/trunk/wp-slimstat.js"&gt;&lt;/script&gt;'), 'external_domains' => array('description' => __('Allow External Domains', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("If you are getting an error saying that no 'Access-Control-Allow-Origin' header is present on the requested resource, when using the external tracking code here above, list the domains (complete with scheme, separated by commas) you would like to allow. For example: <code>http://my.domain.ext</code> (no trailing slash). Please see <a href='http://www.w3.org/TR/cors/#security' target='_blank'>this W3 resource</a> for more information on the security implications of allowing CORS requests.", 'wp-slimstat')), 'advanced_misc_header' => array('description' => __('Miscellaneous', 'wp-slimstat'), 'type' => 'section_header'), 'show_sql_debug' => array('description' => __('Debug Mode', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Display the SQL queries used to retrieve the data.', 'wp-slimstat')), 'ip_lookup_service' => array('description' => __('IP Lookup', 'wp-slimstat'), 'type' => 'text', 'long_description' => __('Customize the Geolocation service to be used in the reports.', 'wp-slimstat')), 'custom_css' => array('description' => __('Custom CSS', 'wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Paste here your custom stylesheet to personalize the way your reports look. <a href='https://slimstat.freshdesk.com/support/solutions/articles/5000528528-how-can-i-change-the-colors-associated-to-color-coded-pageviews-known-user-known-visitors-search-e' target='_blank'>Check the FAQ</a> for more information on how to use this setting.", 'wp-slimstat')), 'enable_ads_network' => array('description' => __('Enable UAN', 'wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Send anonymous data about user agents to our server for analysis. This allows us to contribute to the <a href='http://browscap.org/' target='_blank'>BrowsCap opensource project</a>, and improve the accuracy of Slimstat's browser detection functionality. It also enables our transparent ads network. No worries, your site will not be affected in any way. Please note, this option is enabled only when the setting is explicitly set to YES.", 'wp-slimstat')))), 6 => array('title' => __('Maintenance', 'wp-slimstat'), 'include' => dirname(__FILE__) . '/maintenance.php'), 7 => array('title' => __('Add-ons', 'wp-slimstat')));
$options = apply_filters('slimstat_options_on_page', $options);
$tabs_html = '';
foreach ($options as $a_tab_id => $a_tab_info) {
    if (!empty($a_tab_info['rows']) || !empty($a_tab_info['include'])) {
        $tabs_html .= "<li class='nav-tab nav-tab" . ($current_tab == $a_tab_id ? '-active' : '-inactive') . "'><a href='" . wp_slimstat_admin::$config_url . $a_tab_id . "'>{$a_tab_info['title']}</a></li>";
    }
}
echo '<div class="wrap slimstat"><h2>' . __('Settings', 'wp-slimstat') . '</h2><ul class="nav-tabs">' . $tabs_html . '</ul>';
// The maintenance tab has its own separate file
if (!empty($options[$current_tab]['include'])) {
    include_once $options[$current_tab]['include'];
} else {
    if (!empty($options[$current_tab]['rows'])) {
        wp_slimstat_admin::update_options($options[$current_tab]['rows']);
        wp_slimstat_admin::display_options($options[$current_tab]['rows'], $current_tab);
    }
}
echo '</div>';
 /**
  * Core tracking functionality
  */
 public static function slimtrack($_argument = '')
 {
     // Don't track
     self::$stat['dt'] = date_i18n('U');
     self::$stat['notes'] = '';
     $referer = array();
     if (self::$options['javascript_mode'] != 'yes' && !empty($_SERVER['HTTP_REFERER']) || !empty(self::$data_js['ref'])) {
         if (!empty(self::$data_js['ref'])) {
             self::$stat['referer'] = base64_decode(self::$data_js['ref']);
         } else {
             self::$stat['referer'] = $_SERVER['HTTP_REFERER'];
         }
         $referer = parse_url(self::$stat['referer']);
         // This must be a 'seriously malformed' URL
         if (!$referer) {
             self::$stat['id'] = -208;
             return $_argument;
         }
         if (isset($referer['host'])) {
             self::$stat['domain'] = $referer['host'];
             // Fix Google Images referring domain
             if (strpos(self::$stat['domain'], 'www.google') !== false && strpos(self::$stat['referer'], '/imgres?') !== false) {
                 self::$stat['domain'] = str_replace('www.google', 'images.google', self::$stat['domain']);
             }
         }
     }
     // Is this referer blacklisted?
     if (!empty(self::$stat['referer'])) {
         foreach (self::string_to_array(self::$options['ignore_referers']) as $a_filter) {
             $pattern = str_replace(array('\\*', '\\!'), array('(.*)', '.'), preg_quote($a_filter, '/'));
             if (preg_match("@^{$pattern}\$@i", self::$stat['referer'])) {
                 self::$stat['id'] = -207;
                 return $_argument;
             }
         }
     }
     // We want to record both hits and searches (performed through the site search form)
     if (is_array(self::$data_js) && isset(self::$data_js['res'])) {
         $parsed_permalink = parse_url(base64_decode(self::$data_js['res']));
         self::$stat['searchterms'] = self::_get_search_terms($referer);
         // Was this an internal search?
         if (empty(self::$stat['searchterms'])) {
             self::$stat['searchterms'] = self::_get_search_terms($parsed_permalink);
         }
         self::$stat['resource'] = !is_array($parsed_permalink) ? self::$data_js['res'] : $parsed_permalink['path'] . (!empty($parsed_permalink['query']) ? '?' . urldecode($parsed_permalink['query']) : '');
     } elseif (empty($_REQUEST['s'])) {
         self::$stat['searchterms'] = self::_get_search_terms($referer);
         if (isset($_SERVER['REQUEST_URI'])) {
             self::$stat['resource'] = urldecode($_SERVER['REQUEST_URI']);
         } elseif (isset($_SERVER['SCRIPT_NAME'])) {
             self::$stat['resource'] = isset($_SERVER['QUERY_STRING']) ? $_SERVER['SCRIPT_NAME'] . "?" . $_SERVER['QUERY_STRING'] : $_SERVER['SCRIPT_NAME'];
         } else {
             self::$stat['resource'] = isset($_SERVER['QUERY_STRING']) ? $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'] : $_SERVER['PHP_SELF'];
         }
     } else {
         self::$stat['searchterms'] = str_replace('\\', '', $_REQUEST['s']);
         self::$stat['resource'] = '';
         // Mark the resource to remember that this is a 'local search'
     }
     if (strpos(self::$stat['resource'], 'wp-admin/admin-ajax.php') !== false || !empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-') !== false) {
         return $_argument;
     }
     // Is this resource blacklisted?
     if (!empty(self::$stat['resource'])) {
         foreach (self::string_to_array(self::$options['ignore_resources']) as $a_filter) {
             $pattern = str_replace(array('\\*', '\\!'), array('(.*)', '.'), preg_quote($a_filter, '/'));
             if (preg_match("@^{$pattern}\$@i", self::$stat['resource'])) {
                 self::$stat['id'] = -209;
                 return $_argument;
             }
         }
     }
     // User's IP address
     list(self::$stat['ip'], $long_other_ip) = self::_get_ip2long_remote_ip();
     if (empty(self::$stat['ip'])) {
         self::$stat['id'] = -203;
         return $_argument;
     }
     // Should we ignore this user?
     if (!empty($GLOBALS['current_user']->ID)) {
         // Don't track logged-in users, if the corresponding option is enabled
         if (self::$options['track_users'] == 'no') {
             self::$stat['id'] = -214;
             return $_argument;
         }
         // Don't track users with given capabilities
         foreach (self::string_to_array(self::$options['ignore_capabilities']) as $a_capability) {
             if (array_key_exists(strtolower($a_capability), $GLOBALS['current_user']->allcaps)) {
                 self::$stat['id'] = -200;
                 return $_argument;
             }
         }
         if (is_string(self::$options['ignore_users']) && strpos(self::$options['ignore_users'], $GLOBALS['current_user']->data->user_login) !== false) {
             self::$stat['id'] = -201;
             return $_argument;
         }
         self::$stat['user'] = $GLOBALS['current_user']->data->user_login;
         self::$stat['notes'] .= 'user:'******'current_user']->data->ID . ';';
         $not_spam = true;
     } elseif (isset($_COOKIE['comment_author_' . COOKIEHASH])) {
         // Is this a spammer?
         $spam_comment = self::$wpdb->get_row("SELECT comment_author, COUNT(*) comment_count FROM {$GLOBALS['wpdb']->prefix}comments WHERE INET_ATON(comment_author_IP) = '" . sprintf("%u", self::$stat['ip']) . "' AND comment_approved = 'spam' GROUP BY comment_author LIMIT 0,1", ARRAY_A);
         if (isset($spam_comment['comment_count']) && $spam_comment['comment_count'] > 0) {
             if (self::$options['ignore_spammers'] == 'yes') {
                 self::$stat['id'] = -202;
                 return $_argument;
             } else {
                 self::$stat['notes'] .= 'spam:yes;';
                 self::$stat['user'] = $spam_comment['comment_author'];
             }
         } else {
             self::$stat['user'] = $_COOKIE['comment_author_' . COOKIEHASH];
         }
     }
     // Should we ignore this IP address?
     foreach (self::string_to_array(self::$options['ignore_ip']) as $a_ip_range) {
         $mask = 32;
         $ip_to_ignore = $a_ip_range;
         if (strpos($ip_to_ignore, '/') !== false) {
             list($ip_to_ignore, $mask) = @explode('/', trim($ip_to_ignore));
             if (empty($mask) || !is_numeric($mask)) {
                 $mask = 32;
             }
         }
         $long_ip_to_ignore = ip2long($ip_to_ignore);
         $long_mask = bindec(str_pad('', $mask, '1') . str_pad('', 32 - $mask, '0'));
         $long_masked_user_ip = self::$stat['ip'] & $long_mask;
         $long_masked_other_ip = $long_other_ip & $long_mask;
         $long_masked_ip_to_ignore = $long_ip_to_ignore & $long_mask;
         if ($long_masked_user_ip == $long_masked_ip_to_ignore || $long_masked_other_ip == $long_masked_ip_to_ignore) {
             self::$stat['id'] = -204;
             return $_argument;
         }
     }
     // Country and Language
     self::$stat['language'] = self::_get_language();
     self::$stat['country'] = self::_get_country(self::$stat['ip']);
     // Anonymize IP Address?
     if (self::$options['anonymize_ip'] == 'yes') {
         self::$stat['ip'] = self::$stat['ip'] & 4294967040;
         $long_other_ip = $long_other_ip & 4294967040;
     }
     // Is this country blacklisted?
     if (is_string(self::$options['ignore_countries']) && stripos(self::$options['ignore_countries'], self::$stat['country']) !== false) {
         self::$stat['id'] = -206;
         return $_argument;
     }
     // Mark or ignore Firefox/Safari prefetching requests (X-Moz: Prefetch and X-purpose: Preview)
     if (isset($_SERVER['HTTP_X_MOZ']) && strtolower($_SERVER['HTTP_X_MOZ']) == 'prefetch' || isset($_SERVER["HTTP_X_PURPOSE"]) && strtolower($_SERVER['HTTP_X_PURPOSE']) == 'preview') {
         if (self::$options['ignore_prefetch'] == 'yes') {
             self::$stat['id'] = -210;
             return $_argument;
         } else {
             self::$stat['notes'] .= 'pre:yes;';
         }
     }
     // Information about this resource
     $content_info = is_array(self::$data_js) && isset(self::$data_js['ci']) ? unserialize(base64_decode(self::$data_js['ci'])) : self::_get_content_info();
     if (!is_array($content_info)) {
         $content_info = array('content_type' => 'unknown');
     }
     // Detect user agent
     $browser = self::_get_browser();
     // Are we ignoring bots?
     if (self::$options['javascript_mode'] == 'yes' && $browser['type'] % 2 != 0) {
         self::$stat['id'] = -211;
         return $_argument;
     }
     // Is this browser blacklisted?
     foreach (self::string_to_array(self::$options['ignore_browsers']) as $a_filter) {
         $pattern = str_replace(array('\\*', '\\!'), array('(.*)', '.'), preg_quote($a_filter, '/'));
         if (preg_match("~^{$pattern}\$~i", $browser['browser'] . '/' . $browser['version']) || preg_match("~^{$pattern}\$~i", $browser['browser']) || preg_match("~^{$pattern}\$~i", $browser['user_agent'])) {
             self::$stat['id'] = -212;
             return $_argument;
         }
     }
     // Do we need to assign a visit_id to this user?
     $cookie_has_been_set = self::_set_visit_id(false);
     // Allow third-party tools to modify all the data we've gathered so far
     self::$stat = apply_filters('slimstat_filter_pageview_stat', self::$stat, $browser, $content_info);
     $browser = apply_filters('slimstat_filter_pageview_browser', $browser, self::$stat, $content_info);
     $content_info = apply_filters('slimstat_filter_pageview_content_info', $content_info, self::$stat, $browser);
     do_action('slimstat_track_pageview', self::$stat, $browser, $content_info);
     // Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
     if (empty(self::$stat) || empty(self::$stat['dt'])) {
         self::$stat['id'] = -213;
         return $_argument;
     }
     // Because PHP's integer type is signed, and many IP addresses will result in negative integers on 32-bit architectures, we need to use the "%u" formatter
     self::$stat['ip'] = sprintf("%u", self::$stat['ip']);
     if (!empty($long_other_ip) && $long_other_ip != self::$stat['ip']) {
         self::$stat['other_ip'] = sprintf("%u", $long_other_ip);
     }
     // Now let's save this information in the database
     if (!empty($content_info)) {
         self::$stat['content_info_id'] = self::maybe_insert_row($content_info, $GLOBALS['wpdb']->base_prefix . 'slim_content_info', 'content_info_id', array());
     }
     self::$stat['browser_id'] = self::maybe_insert_row($browser, $GLOBALS['wpdb']->base_prefix . 'slim_browsers', 'browser_id', array('user_agent' => $browser['user_agent']));
     self::$stat['id'] = self::insert_row(self::$stat, $GLOBALS['wpdb']->prefix . 'slim_stats');
     // Something went wrong during the insert
     if (empty(self::$stat['id'])) {
         self::$stat['id'] = -215;
         // Attempt to init the environment (new blog in a MU network?)
         include_once WP_PLUGIN_DIR . '/wp-slimstat/admin/wp-slimstat-admin.php';
         wp_slimstat_admin::init_environment(true);
         return $_argument;
     }
     // Is this a new visitor?
     $is_set_cookie = apply_filters('slimstat_set_visit_cookie', true);
     if ($is_set_cookie) {
         if (empty(self::$stat['visit_id']) && !empty(self::$stat['id'])) {
             // Set a cookie to track this visit (Google and other non-human engines will just ignore it)
             @setcookie('slimstat_tracking_code', self::$stat['id'] . 'id.' . md5(self::$stat['id'] . 'id' . self::$options['secret']), time() + 2678400, COOKIEPATH);
             // one month
         } elseif (!$cookie_has_been_set && self::$options['extend_session'] == 'yes' && self::$stat['visit_id'] > 0) {
             @setcookie('slimstat_tracking_code', self::$stat['visit_id'] . '.' . md5(self::$stat['visit_id'] . self::$options['secret']), time() + self::$options['session_duration'], COOKIEPATH);
         }
     }
     return $_argument;
 }
 /**
  * Init -- Sets things up.
  */
 public static function init()
 {
     // This option requires a special treatment
     if (!empty($_POST['options']['use_separate_menu'])) {
         wp_slimstat::$options['use_separate_menu'] = in_array($_POST['options']['use_separate_menu'], array('yes', 'no')) ? $_POST['options']['use_separate_menu'] : '';
     }
     // Current screen
     if (!empty($_GET['page'])) {
         self::$current_tab = intval(str_replace('wp-slim-view-', '', $_GET['page']));
     } else {
         if (!empty($_POST['current_tab'])) {
             self::$current_tab = intval($_POST['current_tab']);
         }
     }
     // Settings URL
     self::$config_url = (wp_slimstat::$options['use_separate_menu'] == 'yes' ? 'admin.php' : 'options.php') . '?page=wp-slim-config&amp;tab=';
     self::$view_url = (wp_slimstat::$options['use_separate_menu'] == 'yes' ? 'admin.php' : 'options.php') . '?page=wp-slim-view-' . self::$current_tab;
     // Load language files
     load_plugin_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang', '/wp-slimstat/admin/lang');
     // If a localization does not exist, use English
     if (!isset($l10n['wp-slimstat'])) {
         load_textdomain('wp-slimstat', WP_PLUGIN_DIR . '/wp-slimstat/admin/lang/wp-slimstat-en_US.mo');
     }
     // WPMU - New blog created
     $active_sitewide_plugins = get_site_option('active_sitewide_plugins');
     if (!empty($active_sitewide_plugins['wp-slimstat/wp-slimstat.php'])) {
         add_action('wpmu_new_blog', array(__CLASS__, 'new_blog'));
     }
     // WPMU - Blog Deleted
     add_filter('wpmu_drop_tables', array(__CLASS__, 'drop_tables'), 10, 2);
     // Screen options: hide/show panels to customize your view
     add_filter('screen_settings', array(__CLASS__, 'screen_settings'), 10, 2);
     // Display a notice that hightlights this version's features
     //if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim') !== false && !empty(self::$admin_notice) && wp_slimstat::$options['show_admin_notice'] != wp_slimstat::$version) {
     //	add_action('admin_notices', array(__CLASS__, 'show_admin_notice'));
     //}
     // Remove spammers from the database
     if (wp_slimstat::$options['ignore_spammers'] == 'yes') {
         add_action('transition_comment_status', array(__CLASS__, 'remove_spam'), 15, 3);
     }
     if (function_exists('is_network_admin') && !is_network_admin()) {
         // Add the appropriate entries to the admin menu, if this user can view/admin WP SlimStats
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_view_menu'));
         add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_config_menu'));
         // Display the column in the Edit Posts / Pages screen
         if (wp_slimstat::$options['add_posts_column'] == 'yes') {
             add_filter('manage_posts_columns', array(__CLASS__, 'add_column_header'));
             add_filter('manage_pages_columns', array(__CLASS__, 'add_column_header'));
             add_action('manage_posts_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('manage_pages_custom_column', array(__CLASS__, 'add_post_column'), 10, 2);
             add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
         }
         // Add some inline CSS to customize the icon associated to SlimStat in the sidebar
         add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet_icon'));
         // Update the table structure and options, if needed
         if (!empty(wp_slimstat::$options['version']) && wp_slimstat::$options['version'] != wp_slimstat::$version) {
             self::update_tables_and_options();
         } else {
             $admin_filemtime = @filemtime(__FILE__);
             if ($admin_filemtime < date('U') - 864000 && wp_slimstat::$options['enable_ads_network'] == 'null') {
                 wp_slimstat::$options['enable_ads_network'] = 'yes';
             }
         }
     }
     // Load the library of functions to generate the reports
     if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false || !empty($_POST['action']) && $_POST['action'] == 'slimstat_load_report') {
         include_once dirname(__FILE__) . '/view/wp-slimstat-reports.php';
         wp_slimstat_reports::init();
     }
     // AJAX Handlers
     if (defined('DOING_AJAX') && DOING_AJAX) {
         add_action('wp_ajax_slimstat_load_report', array('wp_slimstat_reports', 'show_report_wrapper'));
         add_action('wp_ajax_slimstat_hide_admin_notice', array(__CLASS__, 'hide_admin_notice'));
     }
 }
            }
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats ENGINE = InnoDB");
            wp_slimstat::$wpdb->query("ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_events ENGINE = InnoDB");
            wp_slimstat_admin::show_alert_message(__('Your Slimstat tables have been successfully converted to InnoDB.', 'wp-slimstat'), 'wp-ui-highlight below-h2');
            break;
        case 'truncate-archive':
            wp_slimstat::$wpdb->query("DELETE tsa FROM {$GLOBALS['wpdb']->prefix}slim_stats_archive tsa");
            wp_slimstat::$wpdb->query("OPTIMIZE TABLE {$GLOBALS['wpdb']->prefix}slim_stats_archive");
            wp_slimstat_admin::show_alert_message(__('All the archived records were successfully deleted.', 'wp-slimstat'), 'wp-ui-highlight below-h2');
            break;
        case 'truncate-table':
            wp_slimstat::$wpdb->query("DELETE te FROM {$GLOBALS['wpdb']->prefix}slim_events te");
            wp_slimstat::$wpdb->query("OPTIMIZE TABLE {$GLOBALS['wpdb']->prefix}slim_events");
            wp_slimstat::$wpdb->query("DELETE t1 FROM {$GLOBALS['wpdb']->prefix}slim_stats t1");
            wp_slimstat::$wpdb->query("OPTIMIZE TABLE {$GLOBALS['wpdb']->prefix}slim_stats");
            wp_slimstat_admin::show_alert_message(__('All the records were successfully deleted.', 'wp-slimstat'), 'wp-ui-highlight below-h2');
            break;
        default:
            break;
    }
}
// Retrieve some information about the tables used by Slimstat
$check_index = wp_slimstat::$wpdb->get_results("SHOW INDEX FROM {$GLOBALS['wpdb']->prefix}slim_stats WHERE Key_name = 'stats_resource_idx'");
$details_wp_slim_tables = array_merge(wp_slimstat::$wpdb->get_results("SHOW TABLE STATUS LIKE '{$GLOBALS['wpdb']->prefix}slim_stats'", ARRAY_A), wp_slimstat::$wpdb->get_results("SHOW TABLE STATUS LIKE '{$GLOBALS['wpdb']->prefix}slim_events'", ARRAY_A), wp_slimstat::$wpdb->get_results("SHOW TABLE STATUS LIKE '{$GLOBALS['wpdb']->prefix}slim_stats_archive'", ARRAY_A));
$have_innodb = wp_slimstat::$wpdb->get_results("SHOW VARIABLES LIKE 'have_innodb'", ARRAY_A);
$suffixes = array('bytes', 'KB', 'MB', 'GB', 'TB');
?>

<table class="form-table widefat">
<tbody>
	<tr>
 /**
  * Core tracking functionality
  */
 public static function slimtrack($_argument = '')
 {
     self::$stat['dt'] = date_i18n('U');
     self::$stat['notes'] = array();
     // Allow third-party tools to initialize the stat array
     self::$stat = apply_filters('slimstat_filter_pageview_stat_init', self::$stat);
     // Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
     if (empty(self::$stat) || empty(self::$stat['dt'])) {
         self::$stat['id'] = -213;
         self::_set_error_array(__('Pageview filtered by third-party code', 'wp-slimstat'));
         return $_argument;
     }
     if (!empty(self::$data_js['ref'])) {
         self::$stat['referer'] = base64_decode(self::$data_js['ref']);
     } else {
         if (!empty($_SERVER['HTTP_REFERER'])) {
             self::$stat['referer'] = $_SERVER['HTTP_REFERER'];
         }
     }
     if (!empty(self::$stat['referer'])) {
         // Is this a 'seriously malformed' URL?
         $referer = parse_url(self::$stat['referer']);
         if (!$referer) {
             self::$stat['id'] = -208;
             self::_set_error_array(__('Malformed URL', 'wp-slimstat'));
             return $_argument;
         }
         // Fix Google Images referring domain
         if (strpos(self::$stat['referer'], 'www.google') !== false) {
             if (strpos(self::$stat['referer'], '/imgres?') !== false) {
                 self::$stat['referer'] = str_replace('www.google', 'images.google', self::$stat['referer']);
             }
             if (strpos(self::$stat['referer'], '/url?') !== false) {
                 self::$stat['referer'] = str_replace('/url?', '/search?', self::$stat['referer']);
             }
         }
         // Is this referer blacklisted?
         foreach (self::string_to_array(self::$options['ignore_referers']) as $a_filter) {
             $pattern = str_replace(array('\\*', '\\!'), array('(.*)', '.'), preg_quote($a_filter, '/'));
             if (preg_match("@^{$pattern}\$@i", self::$stat['referer'])) {
                 self::$stat['id'] = -207;
                 self::_set_error_array(__('Referrer is blacklisted', 'wp-slimstat'));
                 return $_argument;
             }
         }
     }
     $content_info = self::_get_content_info();
     // Did we receive data from an Ajax request?
     if (!empty(self::$data_js['id'])) {
         // Are we tracking a new pageview? (pos is empty = no event was triggered)
         if (empty(self::$data_js['pos'])) {
             $content_info = unserialize(base64_decode(self::$data_js['id']));
             if ($content_info === false || empty($content_info['content_type'])) {
                 $content_info = array();
             }
         } else {
             if (!empty(self::$data_js['res'])) {
                 $download_url = base64_decode(self::$data_js['res']);
                 if (is_string($download_url)) {
                     $download_extension = pathinfo($download_url, PATHINFO_EXTENSION);
                     if (in_array($download_extension, self::string_to_array(self::$options['extensions_to_track']))) {
                         unset(self::$stat['id']);
                         $content_info = array('content_type' => 'download');
                     }
                 }
             }
         }
     }
     self::$stat = self::$stat + $content_info;
     // We want to record both hits and searches (performed through the site search form)
     if (self::$stat['content_type'] == 'external') {
         self::$stat['resource'] = $_SERVER['HTTP_REFERER'];
         self::$stat['referer'] = '';
     } else {
         if (is_array(self::$data_js) && isset(self::$data_js['res'])) {
             $parsed_permalink = parse_url(base64_decode(self::$data_js['res']));
             self::$stat['searchterms'] = self::_get_search_terms($referer);
             // Was this an internal search?
             if (empty(self::$stat['searchterms'])) {
                 self::$stat['searchterms'] = self::_get_search_terms($parsed_permalink);
             }
             self::$stat['resource'] = !is_array($parsed_permalink) ? self::$data_js['res'] : $parsed_permalink['path'] . (!empty($parsed_permalink['query']) ? '?' . urldecode($parsed_permalink['query']) : '');
         } elseif (empty($_REQUEST['s'])) {
             if (!empty($referer)) {
                 self::$stat['searchterms'] = self::_get_search_terms($referer);
             }
             self::$stat['resource'] = self::get_request_uri();
         } else {
             self::$stat['searchterms'] = str_replace('\\', '', $_REQUEST['s']);
         }
     }
     // Don't store empty values in the database
     if (empty(self::$stat['searchterms'])) {
         unset(self::$stat['searchterms']);
     }
     // Do not track report pages in the admin
     if (!empty(self::$stat['resource']) && strpos(self::$stat['resource'], 'wp-admin/admin-ajax.php') !== false || !empty($_GET['page']) && strpos($_GET['page'], 'wp-slim-view') !== false) {
         return $_argument;
     }
     // Is this resource blacklisted?
     if (!empty(self::$stat['resource'])) {
         foreach (self::string_to_array(self::$options['ignore_resources']) as $a_filter) {
             $pattern = str_replace(array('\\*', '\\!'), array('(.*)', '.'), preg_quote($a_filter, '/'));
             if (preg_match("@^{$pattern}\$@i", self::$stat['resource'])) {
                 self::$stat['id'] = -209;
                 self::_set_error_array(__('Permalink is blacklisted', 'wp-slimstat'));
                 return $_argument;
             }
         }
     }
     // User's IP address
     list(self::$stat['ip'], self::$stat['other_ip']) = self::_get_remote_ip();
     if (empty(self::$stat['ip']) || self::$stat['ip'] == '0.0.0.0') {
         self::$stat['id'] = -203;
         self::_set_error_array(__('Empty or not supported IP address format (IPv6)', 'wp-slimstat'));
         return $_argument;
     }
     // Should we ignore this user?
     if (!empty($GLOBALS['current_user']->ID)) {
         // Don't track logged-in users, if the corresponding option is enabled
         if (self::$options['track_users'] == 'no') {
             self::$stat['id'] = -214;
             self::_set_error_array(__('Logged in user not tracked', 'wp-slimstat'));
             return $_argument;
         }
         // Don't track users with given capabilities
         foreach (self::string_to_array(self::$options['ignore_capabilities']) as $a_capability) {
             if (array_key_exists(strtolower($a_capability), $GLOBALS['current_user']->allcaps)) {
                 self::$stat['id'] = -200;
                 self::_set_error_array(__('User with given capability not tracked', 'wp-slimstat'));
                 return $_argument;
             }
         }
         if (is_string(self::$options['ignore_users']) && strpos(self::$options['ignore_users'], $GLOBALS['current_user']->data->user_login) !== false) {
             self::$stat['id'] = -201;
             self::_set_error_array(sprintf(__('User %s is blacklisted', 'wp-slimstat'), $GLOBALS['current_user']->data->user_login));
             return $_argument;
         }
         self::$stat['username'] = $GLOBALS['current_user']->data->user_login;
         self::$stat['notes'][] = 'user:'******'current_user']->data->ID;
         $not_spam = true;
     } elseif (isset($_COOKIE['comment_author_' . COOKIEHASH])) {
         // Is this a spammer?
         $spam_comment = self::$wpdb->get_row(self::$wpdb->prepare("\n\t\t\t\tSELECT comment_author, COUNT(*) comment_count\n\t\t\t\tFROM {$GLOBALS['wpdb']->prefix}comments\n\t\t\t\tWHERE comment_author_IP = %s AND comment_approved = 'spam'\n\t\t\t\tGROUP BY comment_author\n\t\t\t\tLIMIT 0,1", self::$stat['ip']), ARRAY_A);
         if (!empty($spam_comment['comment_count'])) {
             if (self::$options['ignore_spammers'] == 'yes') {
                 self::$stat['id'] = -202;
                 self::_set_error_array(sprintf(__('Spammer %s not tracked', 'wp-slimstat'), $spam_comment['comment_author']));
                 return $_argument;
             } else {
                 self::$stat['notes'][] = 'spam:yes';
                 self::$stat['username'] = $spam_comment['comment_author'];
             }
         } else {
             self::$stat['username'] = $_COOKIE['comment_author_' . COOKIEHASH];
         }
     }
     // Should we ignore this IP address?
     foreach (self::string_to_array(self::$options['ignore_ip']) as $a_ip_range) {
         $ip_to_ignore = $a_ip_range;
         if (strpos($ip_to_ignore, '/') !== false) {
             list($ip_to_ignore, $cidr_mask) = explode('/', trim($ip_to_ignore));
         } else {
             $cidr_mask = self::get_mask_length($ip_to_ignore);
         }
         $long_masked_ip_to_ignore = substr(self::dtr_pton($ip_to_ignore), 0, $cidr_mask);
         $long_masked_user_ip = substr(self::dtr_pton(self::$stat['ip']), 0, $cidr_mask);
         $long_masked_user_other_ip = substr(self::dtr_pton(self::$stat['other_ip']), 0, $cidr_mask);
         if ($long_masked_user_ip === $long_masked_ip_to_ignore || $long_masked_user_other_ip === $long_masked_ip_to_ignore) {
             self::$stat['id'] = -204;
             self::_set_error_array(sprintf(__('IP address %s is blacklisted', 'wp-slimstat'), self::$stat['ip'] . (!empty(self::$stat['other_ip']) ? ' (' . self::$stat['other_ip'] . ')' : '')));
             return $_argument;
         }
     }
     // Country and Language
     self::$stat['language'] = self::_get_language();
     self::$stat['country'] = self::get_country(self::$stat['ip']);
     // Anonymize IP Address?
     if (self::$options['anonymize_ip'] == 'yes') {
         // IPv4 or IPv6
         $needle = '.';
         $replace = '.0';
         if (self::get_mask_length(self::$stat['ip']) == 128) {
             $needle = ':';
             $replace = ':0000';
         }
         self::$stat['ip'] = substr(self::$stat['ip'], 0, strrpos(self::$stat['ip'], $needle)) . $replace;
         if (!empty(self::$stat['other_ip'])) {
             self::$stat['other_ip'] = substr(self::$stat['other_ip'], 0, strrpos(self::$stat['other_ip'], $needle)) . $replace;
         }
     }
     // Is this country blacklisted?
     if (is_string(self::$options['ignore_countries']) && stripos(self::$options['ignore_countries'], self::$stat['country']) !== false) {
         self::$stat['id'] = -206;
         self::_set_error_array(sprintf(__('Country %s is blacklisted', 'wp-slimstat'), self::$stat['country']));
         return $_argument;
     }
     // Mark or ignore Firefox/Safari prefetching requests (X-Moz: Prefetch and X-purpose: Preview)
     if (isset($_SERVER['HTTP_X_MOZ']) && strtolower($_SERVER['HTTP_X_MOZ']) == 'prefetch' || isset($_SERVER['HTTP_X_PURPOSE']) && strtolower($_SERVER['HTTP_X_PURPOSE']) == 'preview') {
         if (self::$options['ignore_prefetch'] == 'yes') {
             self::$stat['id'] = -210;
             self::_set_error_array(__('Prefetch requests are ignored', 'wp-slimstat'));
             return $_argument;
         } else {
             self::$stat['notes'][] = 'pre:yes';
         }
     }
     // Detect user agent
     if (empty(self::$browser)) {
         self::$browser = self::_get_browser();
     }
     // Are we ignoring bots?
     if ((self::$options['javascript_mode'] == 'yes' || self::$options['ignore_bots'] == 'yes') && self::$browser['browser_type'] % 2 != 0) {
         self::$stat['id'] = -211;
         self::_set_error_array(__('Bot not tracked', 'wp-slimstat'));
         return $_argument;
     }
     // Is this browser blacklisted?
     foreach (self::string_to_array(self::$options['ignore_browsers']) as $a_filter) {
         $pattern = str_replace(array('\\*', '\\!'), array('(.*)', '.'), preg_quote($a_filter, '/'));
         if (preg_match("~^{$pattern}\$~i", self::$browser['browser'] . '/' . self::$browser['version']) || preg_match("~^{$pattern}\$~i", self::$browser['browser']) || preg_match("~^{$pattern}\$~i", self::$browser['user_agent'])) {
             self::$stat['id'] = -212;
             self::_set_error_array(sprintf(__('Browser %s is blacklisted', 'wp-slimstat'), self::$browser['browser']));
             return $_argument;
         }
     }
     self::$stat = self::$stat + self::$browser;
     // Do we need to assign a visit_id to this user?
     $cookie_has_been_set = self::_set_visit_id(false);
     // Allow third-party tools to modify all the data we've gathered so far
     self::$stat = apply_filters('slimstat_filter_pageview_stat', self::$stat);
     do_action('slimstat_track_pageview', self::$stat);
     // Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
     if (empty(self::$stat) || empty(self::$stat['dt'])) {
         self::$stat['id'] = -213;
         self::_set_error_array(__('Pageview filtered by third-party code', 'wp-slimstat'));
         return $_argument;
     }
     // Implode the notes
     self::$stat['notes'] = implode(';', self::$stat['notes']);
     // Now let's save this information in the database
     self::$stat['id'] = self::insert_row(self::$stat, $GLOBALS['wpdb']->prefix . 'slim_stats');
     // Something went wrong during the insert
     if (empty(self::$stat['id'])) {
         self::$stat['id'] = -215;
         self::_set_error_array(self::$wpdb->last_error);
         // Attempt to init the environment (new blog in a MU network?)
         include_once WP_PLUGIN_DIR . '/wp-slimstat/admin/wp-slimstat-admin.php';
         wp_slimstat_admin::init_environment(true);
         return $_argument;
     }
     // Is this a new visitor?
     $is_set_cookie = apply_filters('slimstat_set_visit_cookie', true);
     if ($is_set_cookie) {
         $unique_id = get_current_user_id();
         if (empty($unique_id)) {
             $unique_id = '';
         } else {
             $unique_id = '_' . $unique_id;
         }
         if (empty(self::$stat['visit_id']) && !empty(self::$stat['id'])) {
             // Set a cookie to track this visit (Google and other non-human engines will just ignore it)
             @setcookie('slimstat_tracking_code' . $unique_id, self::$stat['id'] . 'id.' . md5(self::$stat['id'] . 'id' . self::$options['secret']), time() + 2678400, COOKIEPATH);
         } elseif (!$cookie_has_been_set && self::$options['extend_session'] == 'yes' && self::$stat['visit_id'] > 0) {
             @setcookie('slimstat_tracking_code' . $unique_id, self::$stat['visit_id'] . '.' . md5(self::$stat['visit_id'] . self::$options['secret']), time() + self::$options['session_duration'], COOKIEPATH);
         }
     }
     return $_argument;
 }