<?php // Avoid direct access to this piece of code if (!function_exists('add_action')) { exit(0); } $is_dashboard = empty($_REQUEST['page']) || $_REQUEST['page'] != 'wp-slim-view-1'; // Available icons $supported_browser_icons = array('Android', 'Anonymouse', 'Baiduspider', 'BlackBerry', 'BingBot', 'CFNetwork', 'Chrome', 'Chromium', 'Default Browser', 'Exabot/BiggerBetter', 'FacebookExternalHit', 'FeedBurner', 'Feedfetcher-Google', 'Firefox', 'Internet Archive', 'Googlebot', 'Google Bot', 'Google Feedfetcher', 'Google Web Preview', 'IE', 'IEMobile', 'iPad', 'iPhone', 'iPod Touch', 'Maxthon', 'Mediapartners-Google', 'Microsoft-WebDAV', 'msnbot', 'Mozilla', 'NewsGatorOnline', 'Netscape', 'Nokia', 'Opera', 'Opera Mini', 'Opera Mobi', 'Python', 'PycURL', 'Safari', 'W3C_Validator', 'WordPress', 'Yahoo! Slurp', 'YandexBot'); $supported_os_icons = array('android', 'blackberry os', 'cellos', 'chromeos', 'ios', 'iphone osx', 'java', 'linux', 'macosx', 'rim os', 'symbianos', 'win7', 'win8', 'win8.1', 'winphone7', 'winphone7.5', 'winphone8', 'winphone8.1', 'winvista', 'winxp', 'unknown'); $supported_browser_types = array(__('Human', 'wp-slimstat'), __('Bot/Crawler', 'wp-slimstat'), __('Mobile Device', 'wp-slimstat'), __('Syndication Reader', 'wp-slimstat')); $plugin_url = plugins_url('', dirname(__FILE__)); // Get the data wp_slimstat_db::$debug_message = ''; $all_results = wp_slimstat_db::get_recent(wp_slimstat_reports::$reports_info['slim_p7_02']['callback_args']); $results = array_slice($all_results, wp_slimstat_db::$filters_normalized['misc']['start_from'], wp_slimstat::$options['number_results_raw_data']); // Echo the debug message echo wp_slimstat_db::$debug_message; // Return the results if we are not echoing them (export, email, etc) if (isset($_args['echo']) && $_args['echo'] === false) { return $results; } $count_all_results = count($all_results); $count_page_results = count($results); if ($count_page_results == 0) { echo '<p class="nodata">' . __('No data to display', 'wp-slimstat') . '</p>'; } else { // Pagination echo wp_slimstat_reports::report_pagination($count_page_results, $count_all_results, true, wp_slimstat::$options['number_results_raw_data']); // Show delete button? (only those who can access the settings can see it) $current_user_can_delete = current_user_can(wp_slimstat::$options['capability_can_admin']);
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; } }