Ejemplo n.º 1
0
 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;
     }
 }