/** * Initalize class properties */ public static function init() { self::$screens_info = array('wp-slim-view-1' => __('Real-Time Log', 'wp-slimstat'), 'wp-slim-view-2' => __('Overview', 'wp-slimstat'), 'wp-slim-view-3' => __('Audience', 'wp-slimstat'), 'wp-slim-view-4' => __('Site Analysis', 'wp-slimstat'), 'wp-slim-view-5' => __('Traffic Sources', 'wp-slimstat'), 'wp-slim-view-6' => __('Map Overlay', 'wp-slimstat')); // Filters use the following format: browser equals Firefox&&&country contains gb $filters = array(); if (!empty($_REQUEST['fs']) && is_array($_REQUEST['fs'])) { foreach ($_REQUEST['fs'] as $a_request_filter_name => $a_request_filter_value) { $filters[] = "{$a_request_filter_name} {$a_request_filter_value}"; } } // Fields and drop downs if (!empty($_POST['f']) && !empty($_POST['o'])) { $filters[] = "{$_POST['f']} {$_POST['o']} " . (isset($_POST['v']) ? $_POST['v'] : ''); } foreach (array('minute', 'hour', 'day', 'month', 'year', 'interval_direction', 'interval', 'interval_hours', 'interval_minutes') as $a_date_time_filter_name) { if (!empty($_POST[$a_date_time_filter_name])) { $filters[] = "{$a_date_time_filter_name} equals {$_POST[$a_date_time_filter_name]}"; } } // Hidden Filters if (wp_slimstat::$options['restrict_authors_view'] == 'yes' && !current_user_can('manage_options')) { $filters[] = 'author equals ' . $GLOBALS['current_user']->user_login; self::$hidden_filters['author'] = 1; } if (!empty($filters)) { $filters = implode('&&&', $filters); } // Include and initialize the API to interact with the database include_once 'wp-slimstat-db.php'; wp_slimstat_db::init($filters); // Retrieve data that will be used by multiple reports self::$pageviews = wp_slimstat_db::count_records(); // Define all the reports // // Parameters // - title : report name // - callback : function to use to render the report // - callback_args : parameters to pass to the function // - classes : determine the look and feel of this report ( tall, normal, wide, hidden ) // - screens : where should the report appear ( wp-slim-view-1, .., wp-slim-view-4, dashboard, raw ). If 'raw' is used, it means that this report can return an array of rows for other uses ( export, email, etc ) // - tooltip : contextual help to be displayed on hover $chart_tooltip = '<strong>' . __('Chart controls', 'wp-slimstat') . '</strong><ul><li>' . __('Use your mouse wheel to zoom in and out', 'wp-slimstat') . '</li><li>' . __('While zooming in, drag the chart to move to a different area', 'wp-slimstat') . '</li><li>' . __('Double click on an empty region to reset the zoom level', 'wp-slimstat') . '</li></ul>'; self::$reports_info = array('slim_p7_02' => array('title' => __('Activity', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_activity_log'), 'callback_args' => array('type' => 'recent', 'columns' => 'id', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('full-width', 'tall'), 'screens' => array('wp-slim-view-1', 'raw'), 'tooltip' => __('Color codes', 'wp-slimstat') . '</strong><p><span class="little-color-box is-search-engine"></span> ' . __('From search result page', 'wp-slimstat') . '</p><p><span class="little-color-box is-known-visitor"></span> ' . __('Known Visitor', 'wp-slimstat') . '</p><p><span class="little-color-box is-known-user"></span> ' . __('Known Users', 'wp-slimstat') . '</p><p><span class="little-color-box is-direct"></span> ' . __('Other Humans', 'wp-slimstat') . '</p><p><span class="little-color-box"></span> ' . __('Bot or Crawler', 'wp-slimstat') . '</p>'), 'slim_p1_01' => array('title' => __('Pageviews', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_chart'), 'callback_args' => array('chart_data' => wp_slimstat_db::get_data_for_chart('COUNT(ip)', 'COUNT(DISTINCT(ip))'), 'chart_labels' => array(__('Pageviews', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat'))), 'classes' => array('wide', 'chart'), 'screens' => array('wp-slim-view-2', 'dashboard'), 'tooltip' => $chart_tooltip), 'slim_p1_02' => array('title' => __('About Slimstat', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_about_wpslimstat'), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-2')), 'slim_p1_03' => array('title' => __('At a Glance', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_overview_summary'), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2', 'dashboard')), 'slim_p1_04' => array('title' => __('Currently Online', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'username', 'where' => 'dt > ' . (date_i18n('U') - 300), 'use_date_filters' => false, 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2', 'dashboard', 'raw'), 'tooltip' => __('When visitors leave a comment on your blog, WordPress assigns them a cookie. Slimstat leverages this information to identify returning visitors. Please note that visitors also include registered users.', 'wp-slimstat')), 'slim_p1_06' => array('title' => __('Recent Search Terms', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'searchterms', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2', 'wp-slim-view-5', 'raw'), 'tooltip' => __('Keywords used by your visitors to find your website on a search engine.', 'wp-slimstat')), 'slim_p1_08' => array('title' => __('Top Pages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'SUBSTRING_INDEX(resource, "' . (!get_option('permalink_structure') ? '&' : '?') . '", 1)', 'as_column' => 'resource', 'filter_op' => 'contains', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2', 'dashboard', 'raw'), 'tooltip' => __('Here a "page" is not just a WordPress page type, but any web page on your website, including posts, products, categories, and so on.', 'wp-slimstat')), 'slim_p1_10' => array('title' => __('Top Traffic Sources', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'referer', 'where' => 'referer NOT LIKE "%' . home_url() . '%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2', 'wp-slim-view-5', 'dashboard', 'raw')), 'slim_p1_11' => array('title' => __('Top Known Visitors', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'username', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-2', 'dashboard', 'raw')), 'slim_p1_12' => array('title' => __('Top Search Terms', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'searchterms', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2', 'wp-slim-view-4', 'wp-slim-view-5', 'dashboard', 'raw')), 'slim_p1_13' => array('title' => __('Top Countries', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'country', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-2', 'wp-slim-view-3', 'wp-slim-view-5', 'dashboard', 'raw'), 'tooltip' => __('You can configure Slimstat to ignore a specific Country by setting the corresponding filter under Settings > Slimstat > Filters.', 'wp-slimstat')), 'slim_p1_15' => array('title' => __('Rankings', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_rankings'), 'classes' => array('normal'), 'screens' => array('wp-slim-view-2'), 'tooltip' => __("Slimstat retrieves live information from Alexa, Facebook and Google, to measures your site's rankings. Values are updated every 12 hours. Filters set above don't apply to this report.", 'wp-slimstat')), 'slim_p1_17' => array('title' => __('Top Language Families', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'SUBSTRING(language, 1, 2)', 'as_column' => 'language', 'filter_op' => 'contains', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-2', 'raw')), 'slim_p2_01' => array('title' => __('Human Visits', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_chart'), 'callback_args' => array('chart_data' => wp_slimstat_db::get_data_for_chart('COUNT(DISTINCT visit_id)', 'COUNT(DISTINCT ip)', '(visit_id > 0 AND browser_type <> 1)'), 'chart_labels' => array(__('Visits', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')), 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('wide', 'chart'), 'screens' => array('wp-slim-view-3'), 'tooltip' => $chart_tooltip), 'slim_p2_02' => array('title' => __('Audience Overview', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_visitors_summary'), 'classes' => array('normal'), 'screens' => array('wp-slim-view-3', 'dashboard'), 'tooltip' => __('Where not otherwise specified, the metrics in this report are referred to human visitors.', 'wp-slimstat')), 'slim_p2_03' => array('title' => __('Top Languages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'language', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_04' => array('title' => __('Top Browsers', 'wp-slimstat', 'dashboard'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'browser, browser_version', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_05' => array('title' => __('Top Service Providers', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'ip', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('wide', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw'), 'tooltip' => __('Internet Service Provider: a company which provides other companies or individuals with access to the Internet. Your DSL or cable internet service is provided to you by your ISP.<br><br>You can ignore specific IP addresses by setting the corresponding filter under Settings > Slimstat > Filters.', 'wp-slimstat')), 'slim_p2_06' => array('title' => __('Top Operating Systems', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'platform', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw'), 'tooltip' => __('Internet Service Provider: a company which provides other companies or individuals with access to the Internet. Your DSL or cable internet service is provided to you by your ISP.<br><br>You can ignore specific IP addresses by setting the corresponding filter under Settings > Slimstat > Filters.', 'wp-slimstat')), 'slim_p2_07' => array('title' => __('Top Screen Resolutions', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'resolution', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-3', 'dashboard', 'raw')), 'slim_p2_09' => array('title' => __('Browser Capabilities', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_plugins'), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3')), 'slim_p2_12' => array('title' => __('Visit Duration', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_visit_duration'), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3')), 'slim_p2_13' => array('title' => __('Recent Countries', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'country', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'wp-slim-view-5', 'raw')), 'slim_p2_14' => array('title' => __('Recent Screen Resolutions', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resolution', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_15' => array('title' => __('Recent Operating Systems', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'platform', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_16' => array('title' => __('Recent Browsers', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'browser, browser_version', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_17' => array('title' => __('Recent Languages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'language', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_18' => array('title' => __('Top Browser Families', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'browser', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'raw'), 'tooltip' => __('This report shows you what user agent families (no version considered) are popular among your visitors.', 'wp-slimstat')), 'slim_p2_19' => array('title' => __('Top OS Families', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'CONCAT("p-", SUBSTRING(platform, 1, 3))', 'as_column' => 'platform', 'filter_op' => 'contains', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-3', 'raw'), 'tooltip' => __('This report shows you what operating system families (no version considered) are popular among your visitors.', 'wp-slimstat')), 'slim_p2_20' => array('title' => __('Recent Users', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'username', 'where' => 'notes LIKE "%user:%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-3', 'raw')), 'slim_p2_21' => array('title' => __('Top Users', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'username', 'where' => 'notes LIKE "%user:%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-3', 'dashboard', 'raw')), 'slim_p3_01' => array('title' => __('Traffic Sources', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_chart'), 'callback_args' => array('chart_data' => wp_slimstat_db::get_data_for_chart('COUNT(DISTINCT(referer))', 'COUNT(DISTINCT(ip))', '(referer IS NOT NULL AND referer NOT LIKE "%' . home_url() . '%")'), 'chart_labels' => array(__('Domains', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat'))), 'classes' => array('wide', 'chart'), 'screens' => array('wp-slim-view-5'), 'tooltip' => $chart_tooltip), 'slim_p3_02' => array('title' => __('Summary', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_traffic_sources_summary'), 'classes' => array('normal'), 'screens' => array('wp-slim-view-5')), 'slim_p3_06' => array('title' => __('Top Referring Search Engines', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'referer', 'where' => "searchterms IS NOT NULL AND referer NOT LIKE '%" . home_url() . "%'", 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-5', 'dashboard', 'raw')), 'slim_p3_11' => array('title' => __('Recent Exit Pages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'visit_id', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-5', 'raw')), 'slim_p4_01' => array('title' => __('Recent Outbound Links', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'outbound_resource', 'raw' => array(__CLASS__, 'get_raw_results')), 'callback_raw' => array(__CLASS__, 'get_raw_results'), 'classes' => array('wide'), 'screens' => array('wp-slim-view-4', 'raw'), 'tooltip' => ''), 'slim_p4_02' => array('title' => __('Recent Posts', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resource', 'where' => 'content_type = "post"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_03' => array('title' => __('Recent Bounce Pages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resource', 'where' => 'content_type <> "404"', 'having' => 'HAVING COUNT(visit_id) => 1', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw'), 'tooltip' => __('A <em>bounce page</em> is a single-page visit, or visit in which the person left your site from the entrance (landing) page.', 'wp-slimstat')), 'slim_p4_04' => array('title' => __('Recent Feeds', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resource', 'where' => '(resource LIKE "%/feed%" OR resource LIKE "%?feed=>%" OR resource LIKE "%&feed=>%" OR content_type LIKE "%feed%")', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_05' => array('title' => __('Recent Pages Not Found', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resource', 'where' => '(resource LIKE "[404]%" OR content_type LIKE "%404%")', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_06' => array('title' => __('Recent Internal Searches', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'searchterms', 'where' => 'content_type LIKE "%search%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw'), 'tooltip' => __("Searches performed using WordPress' built-in search functionality.", 'wp-slimstat')), 'slim_p4_07' => array('title' => __('Top Categories', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'category', 'where' => 'content_type LIKE "%category%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'raw'), 'screens' => array('wp-slim-view-4', 'dashboard')), 'slim_p4_09' => array('title' => __('Top Downloads', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'resource', 'where' => 'content_type = "download"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('wide', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw'), 'tooltip' => __('You can configure Slimstat to track specific file extensions as downloads.', 'wp-slimstat')), 'slim_p4_11' => array('title' => __('Top Posts', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'resource', 'where' => 'content_type = "post"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_13' => array('title' => __('Top Internal Searches', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'searchterms', 'where' => 'content_type LIKE "%search%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_15' => array('title' => __('Recent Categories', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resource', 'where' => '(content_type => "category" OR content_type => "tag")', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_16' => array('title' => __('Top Pages Not Found', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'resource', 'where' => 'content_type LIKE "%404%"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_18' => array('title' => __('Top Authors', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'author', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal'), 'screens' => array('wp-slim-view-4', 'dashboard', 'raw')), 'slim_p4_19' => array('title' => __('Top Tags', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'category', 'where' => '(content_type LIKE "%tag%")', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_20' => array('title' => __('Recent Downloads', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'recent', 'columns' => 'resource', 'where' => 'content_type = "download"', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('wide', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_21' => array('title' => __('Top Outbound Links', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'outbound_resource', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_22' => array('title' => __('Your Website', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_your_blog'), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4'), 'tooltip' => __('Your content at a glance: posts, comments, pingbacks, etc. Please note that this report is not affected by the filters set here above.', 'wp-slimstat')), 'slim_p4_23' => array('title' => __('Top Bounce Pages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top', 'columns' => 'resource', 'where' => 'content_type <> "404"', 'having' => 'HAVING COUNT(visit_id) => 1', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_24' => array('title' => __('Top Exit Pages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top_aggr', 'columns' => 'visit_id', 'outer_select_column' => 'resource', 'aggr_function' => 'MAX', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p4_25' => array('title' => __('Top Entry Pages', 'wp-slimstat'), 'callback' => array(__CLASS__, 'raw_results_to_html'), 'callback_args' => array('type' => 'top_aggr', 'columns' => 'visit_id', 'outer_select_column' => 'resource', 'aggr_function' => 'MIN', 'raw' => array(__CLASS__, 'get_raw_results')), 'classes' => array('normal', 'hidden'), 'screens' => array('wp-slim-view-4', 'raw')), 'slim_p6_01' => array('title' => __('World Map', 'wp-slimstat'), 'callback' => array(__CLASS__, 'show_world_map'), 'classes' => array('tall'), 'screens' => array('wp-slim-view-6'), 'tooltip' => '')); // Allow third party tools to manipulate this list here above: please use unique report IDs that don't interfere with built-in ones, if you add your own custom report self::$reports_info = apply_filters('slimstat_reports_info', self::$reports_info); // Define what reports have been deprecated over time, to remove them from the user's settings $deprecated_reports = array('slim_p1_05', 'slim_p1_18', 'slim_p2_10', 'slim_p3_03', 'slim_p3_04', 'slim_p3_05', 'slim_p3_08', 'slim_p3_09', 'slim_p3_10', 'slim_p4_08', 'slim_p4_10', 'slim_p4_12', 'slim_p4_14', 'slim_p4_17'); // Retrieve this user's list of active reports, $user = wp_get_current_user(); $page_location = wp_slimstat::$options['use_separate_menu'] == 'yes' ? 'slimstat' : 'admin'; // Do this only if we are in one of our screens (no dashboard!) if (!empty($_REQUEST['page']) && strpos($_REQUEST['page'], 'wp-slim-view') !== false) { $user_reports = get_user_option("meta-box-order_{$page_location}_page_{$_REQUEST['page']}", $user->ID); // If this list is not empty, we rearrange the order of our reports if (!empty($user_reports[0])) { $user_reports = array_flip(explode(',', $user_reports[0])); self::$reports_info = array_intersect_key(array_merge($user_reports, self::$reports_info), $user_reports); } // Remove deprecated reports self::$reports_info = array_diff_key(self::$reports_info, $deprecated_reports); $hidden_reports = get_user_option("metaboxhidden_{$page_location}_page_{$_REQUEST['page']}", $user->ID); // If this list is not empty, use it instead of the predefined visibility if (!empty($hidden_reports) && is_array($hidden_reports)) { foreach (self::$reports_info as $a_report_id => $a_report_info) { if (in_array($a_report_id, $hidden_reports)) { if (is_array(self::$reports_info[$a_report_id]['classes']) && !in_array('hidden', $a_report_info['classes'])) { self::$reports_info[$a_report_id]['classes'][] = 'hidden'; } } else { if (is_array(self::$reports_info[$a_report_id]['classes'])) { self::$reports_info[$a_report_id]['classes'] = array_diff(self::$reports_info[$a_report_id]['classes'], array('hidden')); } } } } } else { foreach (self::$reports_info as $a_report_id => $a_report_info) { if (is_array(self::$reports_info[$a_report_id]['classes'])) { self::$reports_info[$a_report_id]['classes'] = array_diff(self::$reports_info[$a_report_id]['classes'], array('hidden')); } } } }
public static function show_chart($_args = array()) { wp_slimstat_db::$debug_message = ''; switch ($_args['type']) { case 'p1_01': $chart_data = wp_slimstat_db::get_data_for_chart('COUNT(ip)', 'COUNT(DISTINCT(ip))'); $chart_labels = array(__('Pageviews', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')); break; case 'p2_01': $chart_data = wp_slimstat_db::get_data_for_chart('COUNT(DISTINCT visit_id)', 'COUNT(DISTINCT ip)', '(visit_id > 0 AND browser_type <> 1)'); $chart_labels = array(__('Visits', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')); break; case 'p3_01': $chart_data = wp_slimstat_db::get_data_for_chart('COUNT(DISTINCT(referer))', 'COUNT(DISTINCT(ip))', '(referer IS NOT NULL AND referer NOT LIKE "%' . home_url() . '%")'); $chart_labels = array(__('Domains', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')); break; default: $chart_data = array(); $chart_labels = array('', ''); break; } echo wp_slimstat_db::$debug_message; ?> <div id="chart-placeholder"></div><div id="chart-legend"></div> <script type="text/javascript"> SlimStatAdmin.chart_data = []; <?php if (!empty($chart_data['previous']['label'])) { ?> SlimStatAdmin.chart_data.push({ label: '<?php echo $chart_labels[0] . ' ' . $chart_data['previous']['label']; ?> ', data: [<?php $tmp_serialize = array(); $j = 0; foreach ($chart_data['previous']['first_metric'] as $a_value) { $tmp_serialize[] = "[{$j}, {$a_value}]"; $j++; } echo implode(',', $tmp_serialize); ?> ], points: { show: true, symbol: function(ctx, x, y, radius, shadow){ ctx.arc(x, y, 2, 0, Math.PI * 2, false) } } }); SlimStatAdmin.chart_data.push({ label: '<?php echo $chart_labels[1] . ' ' . $chart_data['previous']['label']; ?> ', data: [<?php $tmp_serialize = array(); $j = 0; foreach ($chart_data['previous']['second_metric'] as $a_value) { $tmp_serialize[] = "[{$j}, {$a_value}]"; $j++; } echo implode(',', $tmp_serialize); ?> ], points: { show: true, symbol: function(ctx, x, y, radius, shadow){ ctx.arc(x, y, 2, 0, Math.PI * 2, false) } } }); <?php } ?> SlimStatAdmin.chart_data.push({ label: '<?php echo $chart_labels[0] . ' ' . $chart_data['current']['label']; ?> ', data: [<?php $tmp_serialize = array(); $j = 0; foreach ($chart_data['current']['first_metric'] as $a_value) { $tmp_serialize[] = "[{$j}, {$a_value}]"; $j++; } echo implode(',', $tmp_serialize); ?> ], points: { show: true, symbol: function(ctx, x, y, radius, shadow){ ctx.arc(x, y, 2, 0, Math.PI * 2, false) } } }); SlimStatAdmin.chart_data.push({ label: '<?php echo $chart_labels[1] . ' ' . $chart_data['current']['label']; ?> ', data: [<?php $tmp_serialize = array(); $j = 0; foreach ($chart_data['current']['second_metric'] as $a_value) { $tmp_serialize[] = "[{$j}, {$a_value}]"; $j++; } echo implode(',', $tmp_serialize); ?> ], points: { show: true, symbol: function(ctx, x, y, radius, shadow){ ctx.arc(x, y, 2, 0, Math.PI * 2, false) } } }); SlimStatAdmin.ticks = [<?php $tmp_serialize = array(); $max_ticks = max(count($chart_data['current']['first_metric']), count($chart_data['previous']['first_metric'])); if (!empty(wp_slimstat_db::$filters_normalized['date']['interval'])) { for ($i = 0; $i < $max_ticks; $i++) { $tmp_serialize[] = "[{$i},'" . date('d/m', wp_slimstat_db::$filters_normalized['utime']['start'] + $i * 86400) . "']"; } } else { $min_idx = min(array_keys($chart_data['current']['first_metric'])); for ($i = $min_idx; $i < $max_ticks + $min_idx; $i++) { $tmp_serialize[] = '[' . ($i - $min_idx) . ',"' . $i . '"]'; } } echo implode(',', $tmp_serialize); ?> ]; </script> <?php if (defined('DOING_AJAX') && DOING_AJAX) { die; } }
public static function show_report_wrapper($_report_id = 'p0') { $is_ajax = false; if (!empty($_POST['report_id'])) { // Let's make sure the request is coming from the right place check_ajax_referer('meta-box-order', 'security'); $_report_id = $_POST['report_id']; $is_ajax = true; } if (!$is_ajax && (in_array($_report_id, self::$hidden_reports) || wp_slimstat::$options['async_load'] == 'yes')) { return; } // Some boxes need extra information if (in_array($_report_id, array('slim_p1_03', 'slim_p1_08', 'slim_p1_10', 'slim_p1_13', 'slim_p1_17', 'slim_p2_03', 'slim_p2_04', 'slim_p2_05', 'slim_p2_06', 'slim_p2_18', 'slim_p2_19', 'slim_p2_10', 'slim_p3_02', 'slim_p3_04', 'slim_p3_05'))) { $current_pageviews = wp_slimstat_db::count_records(); } switch ($_report_id) { case 'slim_p1_01': case 'slim_p1_03': $chart_data = wp_slimstat_db::get_data_for_chart('COUNT(t1.ip)', 'COUNT(DISTINCT(t1.ip))'); $chart_labels = array(__('Pageviews', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')); break; case 'slim_p2_01': $chart_data = wp_slimstat_db::get_data_for_chart('COUNT(DISTINCT t1.visit_id)', 'COUNT(DISTINCT t1.ip)', 'AND (tb.type = 0 OR tb.type = 2)'); $chart_labels = array(__('Visits', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')); break; case 'slim_p3_01': $chart_data = wp_slimstat_db::get_data_for_chart('COUNT(DISTINCT(`domain`))', 'COUNT(DISTINCT(ip))', "AND domain <> '' AND domain <> '{$_SERVER['SERVER_NAME']}'"); $chart_labels = array(__('Domains', 'wp-slimstat'), __('Unique IPs', 'wp-slimstat')); break; case 'slim_p4_01': $sql_from_where = " FROM (SELECT t1.visit_id, count(t1.ip) counthits, MAX(t1.dt) dt FROM [from_tables] WHERE [where_clause] GROUP BY t1.visit_id) AS ts1"; $chart_data = wp_slimstat_db::get_data_for_chart('ROUND(AVG(ts1.counthits),2)', 'MAX(ts1.counthits)', 'AND t1.visit_id > 0', $sql_from_where); $chart_labels = array(__('Avg Pageviews', 'wp-slimstat'), __('Longest visit', 'wp-slimstat')); break; default: } switch ($_report_id) { case 'slim_p1_01': case 'slim_p2_01': case 'slim_p3_01': case 'slim_p4_01': self::show_chart($_report_id, $chart_data, $chart_labels); break; case 'slim_p1_02': self::show_about_wpslimstat($_report_id); break; case 'slim_p1_03': self::show_overview_summary($_report_id, $current_pageviews, $chart_data); break; case 'slim_p1_04': self::show_results('recent', $_report_id, 'user', array('custom_where' => 't1.user <> "" AND t1.dt > ' . (date_i18n('U') - 300), 'use_date_filters' => false)); break; case 'slim_p1_05': case 'slim_p3_08': self::show_spy_view($_report_id); break; case 'slim_p1_06': case 'slim_p3_09': self::show_results('recent', $_report_id, 'searchterms'); break; case 'slim_p1_08': self::show_results('popular', $_report_id, 'resource', array('total_for_percentage' => $current_pageviews)); break; case 'slim_p1_10': case 'slim_p3_05': $self_domain = parse_url(site_url()); $self_domain = $self_domain['host']; //self::show_results('popular_complete', $_report_id, 'domain', array('total_for_percentage' => wp_slimstat_db::count_records('t1.referer <> ""'), 'custom_where' => 't1.domain <> "'.$self_domain.'" AND t1.domain <> ""')); self::show_results('popular', $_report_id, 'referer', array('total_for_percentage' => $current_pageviews, 'custom_where' => 't1.domain <> "' . $self_domain . '" AND t1.domain <> ""')); break; case 'slim_p1_11': // self::show_results('popular_complete', $_report_id, 'user', array('total_for_percentage' => wp_slimstat_db::count_records('t1.user <> ""'))); self::show_results('popular', $_report_id, 'user', array('total_for_percentage' => wp_slimstat_db::count_records('t1.user <> ""'))); break; case 'slim_p1_12': case 'slim_p3_03': case 'slim_p4_14': self::show_results('popular', $_report_id, 'searchterms', array('total_for_percentage' => wp_slimstat_db::count_records('t1.searchterms <> ""'))); break; case 'slim_p1_13': case 'slim_p2_10': case 'slim_p3_04': self::show_results('popular', $_report_id, 'country', array('total_for_percentage' => $current_pageviews)); break; case 'slim_p1_15': self::show_rankings($_report_id); break; case 'slim_p1_17': self::show_results('popular', $_report_id, 'SUBSTRING(t1.language, 1, 2)', array('total_for_percentage' => $current_pageviews, 'as_column' => 'language', 'filter_op' => 'contains')); break; case 'slim_p2_02': self::show_visitors_summary($_report_id, wp_slimstat_db::count_records_having('visit_id > 0', 'ip'), wp_slimstat_db::count_records('t1.visit_id > 0 AND tb.type <> 1', 'visit_id')); break; case 'slim_p2_03': self::show_results('popular', $_report_id, 'language', array('total_for_percentage' => $current_pageviews)); break; case 'slim_p2_04': self::show_results('popular', $_report_id, 'browser', array('total_for_percentage' => $current_pageviews, 'more_columns' => ',tb.version' . (wp_slimstat::$options['show_complete_user_agent_tooltip'] == 'yes' ? ',tb.user_agent' : ''))); break; case 'slim_p2_05': self::show_results('popular', $_report_id, 'ip', array('total_for_percentage' => $current_pageviews)); break; case 'slim_p2_06': self::show_results('popular', $_report_id, 'platform', array('total_for_percentage' => $current_pageviews)); break; case 'slim_p2_07': self::show_results('popular', $_report_id, 'resolution', array('total_for_percentage' => wp_slimstat_db::count_records('tss.resolution <> ""'))); break; case 'slim_p2_09': self::show_plugins($_report_id, wp_slimstat_db::count_records('t1.visit_id > 0 AND tb.type <> 1')); break; case 'slim_p2_12': self::show_visit_duration($_report_id, wp_slimstat_db::count_records('visit_id > 0 AND tb.type <> 1', 'visit_id')); break; case 'slim_p2_13': case 'slim_p3_10': self::show_results('recent', $_report_id, 'country'); break; case 'slim_p2_14': self::show_results('recent', $_report_id, 'resolution', array('join_tables' => 'tss.*')); break; case 'slim_p2_15': self::show_results('recent', $_report_id, 'platform', array('join_tables' => 'tb.*')); break; case 'slim_p2_16': self::show_results('recent', $_report_id, 'browser', array('join_tables' => 'tb.*')); break; case 'slim_p2_17': self::show_results('recent', $_report_id, 'language'); break; case 'slim_p2_18': self::show_results('popular', $_report_id, 'browser', array('total_for_percentage' => $current_pageviews)); break; case 'slim_p2_19': self::show_results('popular', $_report_id, 'CONCAT("p-", SUBSTRING(tb.platform, 1, 3))', array('total_for_percentage' => $current_pageviews, 'as_column' => 'platform')); break; case 'slim_p2_20': self::show_results('recent', $_report_id, 'user', array('custom_where' => 'notes LIKE "%user:%"')); break; case 'slim_p2_21': // self::show_results('popular_complete', $_report_id, 'user', array('total_for_percentage' => wp_slimstat_db::count_records('notes LIKE "%user:%"'), 'custom_where' => 'notes LIKE "%user:%"')); self::show_results('popular', $_report_id, 'user', array('total_for_percentage' => wp_slimstat_db::count_records('notes LIKE "%user:%"'), 'custom_where' => 'notes LIKE "%user:%"')); break; case 'slim_p3_02': self::show_traffic_sources_summary($_report_id, $current_pageviews); break; case 'slim_p3_06': //self::show_results('popular_complete', $_report_id, 'domain', array('total_for_percentage' => wp_slimstat_db::count_records("t1.searchterms <> '' AND t1.domain <> '{$_SERVER['SERVER_NAME']}' AND t1.domain <> ''", 't1.id'), 'custom_where' => "t1.searchterms <> '' AND t1.domain <> '{$_SERVER['SERVER_NAME']}'")); self::show_results('popular', $_report_id, 'domain', array('total_for_percentage' => wp_slimstat_db::count_records("t1.searchterms <> '' AND t1.domain <> '{$_SERVER['SERVER_NAME']}' AND t1.domain <> ''", 't1.id'), 'custom_where' => "t1.searchterms <> '' AND t1.domain <> '{$_SERVER['SERVER_NAME']}'")); break; case 'slim_p3_11': case 'slim_p4_17': self::show_results('popular', $_report_id, 'resource', array('total_for_percentage' => wp_slimstat_db::count_records('t1.domain <> ""'), 'custom_where' => 't1.domain <> ""')); break; case 'slim_p4_02': self::show_results('recent', $_report_id, 'resource', array('custom_where' => 'tci.content_type = "post"')); break; case 'slim_p4_03': self::show_results('recent', $_report_id, 'resource', array('custom_where' => 'tci.content_type <> "404"', 'having_clause' => 'HAVING COUNT(visit_id) = 1')); break; case 'slim_p4_04': self::show_results('recent', $_report_id, 'resource', array('custom_where' => '(t1.resource LIKE "%/feed%" OR t1.resource LIKE "%?feed=%" OR t1.resource LIKE "%&feed=%" OR tci.content_type LIKE "%feed%")')); break; case 'slim_p4_05': self::show_results('recent', $_report_id, 'resource', array('custom_where' => '(t1.resource LIKE "[404]%" OR tci.content_type LIKE "%404%")')); break; case 'slim_p4_06': self::show_results('recent', $_report_id, 'searchterms', array('custom_where' => '(t1.resource = "__l_s__" OR t1.resource = "" OR tci.content_type LIKE "%search%")')); break; case 'slim_p4_07': self::show_results('popular', $_report_id, 'category', array('total_for_percentage' => wp_slimstat_db::count_records('(tci.content_type LIKE "%category%")'), 'custom_where' => '(tci.content_type LIKE "%category%")')); break; case 'slim_p4_08': self::show_spy_view($_report_id, 0); break; case 'slim_p4_10': self::show_spy_view($_report_id, -1); break; case 'slim_p4_11': self::show_results('popular', $_report_id, 'resource', array('total_for_percentage' => wp_slimstat_db::count_records('tci.content_type = "post"'), 'custom_where' => 'tci.content_type = "post"')); break; case 'slim_p4_12': self::show_results('popular', $_report_id, 'resource', array('total_for_percentage' => wp_slimstat_db::count_records('(t1.resource LIKE "%/feed%" OR t1.resource LIKE "%?feed=%" OR t1.resource LIKE "%&feed=%" OR tci.content_type LIKE "%feed%")'), 'custom_where' => '(t1.resource LIKE "%/feed%" OR t1.resource LIKE "%?feed=%" OR t1.resource LIKE "%&feed=%" OR tci.content_type LIKE "%feed%")')); break; case 'slim_p4_13': self::show_results('popular', $_report_id, 'searchterms', array('total_for_percentage' => wp_slimstat_db::count_records('(t1.resource = "__l_s__" OR t1.resource = "" OR tci.content_type LIKE "%search%")'), 'custom_where' => '(t1.resource = "__l_s__" OR t1.resource = "" OR tci.content_type LIKE "%search%")')); break; case 'slim_p4_15': self::show_results('recent', $_report_id, 'resource', array('custom_where' => '(tci.content_type = "category" OR tci.content_type = "tag")', 'join_tables' => 'tci.*')); break; case 'slim_p4_16': self::show_results('popular', $_report_id, 'resource', array('total_for_percentage' => wp_slimstat_db::count_records('(t1.resource LIKE "[404]%" OR tci.content_type LIKE "%404%")'), 'custom_where' => '(t1.resource LIKE "[404]%" OR tci.content_type LIKE "%404%")')); break; case 'slim_p4_18': self::show_results('popular', $_report_id, 'author', array('total_for_percentage' => wp_slimstat_db::count_records('tci.author <> ""'))); break; case 'slim_p4_19': self::show_results('popular', $_report_id, 'category', array('total_for_percentage' => wp_slimstat_db::count_records('(tci.content_type LIKE "%tag%")'), 'custom_where' => '(tci.content_type LIKE "%tag%")', 'more_columns' => ',tci.category')); break; case 'slim_p4_20': self::show_spy_view($_report_id, 1); break; case 'slim_p4_21': self::show_results('popular_outbound', $_report_id, 'resource', array('total_for_percentage' => wp_slimstat_db::count_outbound())); break; case 'slim_p4_22': self::show_your_blog($_report_id); break; case 'slim_p6_01': self::show_world_map($_report_id); break; case 'slim_p7_02': include_once WP_PLUGIN_DIR . "/wp-slimstat/admin/view/right-now.php"; break; default: } if (!empty($_POST['report_id'])) { die; } }
public static function slim_p1_03() { wp_slimstat_reports::show_overview_summary('slim_p1_03', wp_slimstat_db::count_records(), wp_slimstat_db::get_data_for_chart('COUNT(t1.ip)', 'COUNT(DISTINCT(t1.ip))')); }