示例#1
0
function luc_referrer()
{
    global $wpdb, $StatPressV_Option;
    $table_name = STATPRESS_V_TABLE_NAME;
    $action = "referrer";
    $referrer_color = "#419E0C";
    $graphdays = $StatPressV_Option['StatPressV_Graph_Days'];
    if ($graphdays == 0) {
        $graphdays = 7;
    }
    // $pa = pa and $pp = pp in the slug
    $pa = luc_page_posts();
    $pp = luc_page_periode();
    $today = gmdate('Ymd', current_time('timestamp'));
    $limitdate = gmdate('Ymd', current_time('timestamp') - 86400 * $graphdays * $pp + 86400);
    $currentdate = gmdate('Ymd', current_time('timestamp') - 86400 * $graphdays * ($pp - 1));
    $permalink = luc_permalink();
    $NP = luc_count_periode("date", "FROM {$table_name}", "", "referrer<>'' AND referrer NOT LIKE '%" . get_bloginfo('url') . "%' AND searchengine=''", "date", $graphdays);
    $start_of_week = get_option('start_of_week');
    $strqry = "SELECT  count(distinct referrer)\r\n\t\t\t\t\tFROM {$table_name}\r\n\t\t\t\t\tWHERE referrer<>''\r\n\t\t\t\t\t\tAND referrer NOT LIKE '%" . get_bloginfo('url') . "%'\r\n\t\t\t\t\t\tAND searchengine=''\r\n\t\t\t\t\t\tAND date BETWEEN {$limitdate} AND {$currentdate};\r\n\t\t\t\t";
    $NumberPosts = $wpdb->get_var($strqry);
    $NumberDisplayPost = $StatPressV_Option['StatPressV_Graph_Per_Page'];
    if ($NumberDisplayPost == 0) {
        $NumberDisplayPost = 20;
    }
    $NA = ceil($NumberPosts / $NumberDisplayPost);
    $LimitValueArticles = $pa * $NumberDisplayPost - $NumberDisplayPost;
    // sort post or page by most unique visitors
    $strqry = "SELECT count(*) as total, referrer, urlrequested\r\n\t\t\t\t\tFROM {$table_name}\r\n\t\t\t\t\tWHERE referrer<>''\r\n\t\t\t\t\t\tAND referrer NOT LIKE '" . get_bloginfo('url') . "%'\r\n\t\t\t\t\t\tAND searchengine=''\r\n\t\t\t\t\t\tAND date BETWEEN {$limitdate} AND {$currentdate}\r\n\t\t\t\t\tGROUP BY referrer\r\n\t\t\t\t\tORDER by total DESC LIMIT {$LimitValueArticles}, {$NumberDisplayPost};\r\n\t\t\t\t";
    $query = $wpdb->get_results($strqry);
    echo "<div class='wrap'><h2>Most referrer these " . $graphdays . " days </h2>";
    luc_print_pp_pa_link($NP, $pp, $action, $NA, $pa);
    foreach ($query as $url) {
        for ($i = 0; $i < $graphdays; $i++) {
            $Date = gmdate('Ymd', current_time('timestamp') - 86400 * ($graphdays * $pp - $i - 1));
            $total->visitors[$Date] = 0;
        }
        $total->totalvisitors = 0;
        //TOTAL VISITORS
        if ($url->post_name == 'page_accueil') {
            //url == home
            $qry_visitors = luc_query_graph("DISTINCT ip", "urlrequested ='' AND spider='' AND feed=''", $limitdate, $currentdate);
        } else {
            $qry_visitors = luc_query_graph("*", "referrer = '" . $url->referrer . "'", $limitdate, $currentdate);
        }
        foreach ($qry_visitors as $row) {
            $total->visitors[$row->date] = $row->total;
            $total->totalvisitors += $row->total;
        }
        $maxxday = luc_maxxday($total, $graphdays, $pp);
        $px = luc_pixel($total, $graphdays, $maxxday, $pp, $action);
        // Overhead of the graph, display the name of the post/page and the average by day of the feeds
        echo "<div class='wrap'>\r\n\t\t\t\t<table class='widefat'>\r\n\t\t\t\t\t<thead>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<th scope='col' width='15%'>\r\n\t\t\t\t\t\t\t\t<div style='background:{$referrer_color};width:10px;height:10px;float:left;margin-top:2px;margin-right:5px;'></div>" . $total->totalvisitors . " visits\r\n\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t<th scope='col' width='15%'>\r\n\t\t\t\t\t\t\t\t<div style='background:{$referrer_color};width:10px;height:10px;float:left;margin-top:2px;margin-right:5px;'></div>Average " . round($total->totalvisitors / $graphdays, 1) . " by day\r\n\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t<th scope='col' width='70%'>\r\n\t\t\t\t\t\t\t\t<font font-size='1'>" . $url->referrer . "</font>\r\n\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</thead>\r\n\t\t\t\t</table>\r\n\t\t\t\t<table class='graph'>\r\n\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t<tr>";
        luc_graph($px, $total, $graphdays, $pp, $action);
        echo "\t\t\t</tr>\r\n\t\t\t\t\t</tbody>\r\n\t\t\t\t</table>\r\n\t\t\t</div>";
    }
    luc_print_pp_pa_link($NP, $pp, $action, $NA, $pa);
    echo "</div>";
    luc_StatPressV_load_time();
}
示例#2
0
文件: luc_admin.php 项目: dtekcth/dns
function luc_count_graph($total, $graphdays, $pp, $where1, $where2, $feed1, $feed2, $limitdate, $currentdate)
{
    //TOTAL VISITORS
    $qry_visitors = luc_query_graph("DISTINCT ip", $where1 . " AND " . $feed1 . " AND spider='' ", $limitdate, $currentdate);
    // SQL query count of the uniques visitors for all days of the graph ($graphdays)
    foreach ($qry_visitors as $row) {
        $total->visitors[$row->date] = $row->total;
        $total->totalvisitors += $row->total;
    }
    //TOTAL VISITORS FEEDS
    $qry_visitors_feeds = luc_query_graph("DISTINCT ip", $where2 . " AND " . $feed2 . " AND spider='' ", $limitdate, $currentdate);
    // SQL query count of the visitors feeds for all days of the graph ($graphdays)
    foreach ($qry_visitors_feeds as $row) {
        $total->visitors_feeds[$row->date] = $row->total;
        $total->totalvisitors_feeds += $row->total;
    }
    //TOTAL PAGEVIEWS (we do not delete the uniques, this is falsing the info.. uniques are not different visitors!)
    $qry_pageviews = luc_query_graph("*", $where1 . " AND " . $feed1 . " AND spider='' ", $limitdate, $currentdate);
    // SQL count of the pageviews for all days of the graph ($graphdays)
    foreach ($qry_pageviews as $row) {
        $total->pageviews[$row->date] = $row->total;
        $total->totalpageviews += $row->total;
    }
    //TOTAL PAGEVIEWS FEEDS
    $qry_pageviews_feeds = luc_query_graph("*", $where2 . " AND " . $feed2 . " AND spider='' ", $limitdate, $currentdate);
    // SQL query count of the pageviews feeds for all days of the graph ($graphdays)
    foreach ($qry_pageviews_feeds as $row) {
        $total->pageviews_feeds[$row->date] = $row->total;
        $total->totalpageviews_feeds += $row->total;
    }
    //TOTAL SPIDERS
    if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') {
        $qry_spiders = luc_query_graph("*", $where2 . " AND " . $feed1 . " AND spider<>'' ", $limitdate, $currentdate);
        // SQL query count of the spiders for all days of the graph ($graphdays)
        foreach ($qry_spiders as $row) {
            $total->spiders[$row->date] = $row->total;
            $total->totalspiders += $row->total;
        }
    }
    return $total;
}