コード例 #1
0
ファイル: luc_referrer.php プロジェクト: dtekcth/dns
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_visitors.php プロジェクト: newmight2015/psmpsm
function luc_visitors()
{
    global $wpdb, $StatPressV_Option;
    $table_name = STATPRESS_V_TABLE_NAME;
    $visitors_color = "#114477";
    $action = "visitors";
    $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} as t", "JOIN {$wpdb->posts} as p ON t.urlrequested LIKE CONCAT('%', p.post_name, '_' ) OR t.urlrequested =''", "(ip IS NOT NULL) AND p.post_status = 'publish' AND (post_type = 'page' OR post_type = 'post')", "date", $graphdays);
    $start_of_week = get_option('start_of_week');
    $strqry = "SELECT  count(distinct post_name)\n\t\t\t\t\tFROM {$wpdb->posts} as p\n\t\t\t\t\tJOIN {$table_name} as t\n\t\t\t\t\tON t.urlrequested LIKE CONCAT('" . $permalink . "', p.post_name, '_' )\n\t\t\t\t\tWHERE p.post_status = 'publish'\n\t\t\t\t\t\tAND t.feed=''\n\t\t\t\t\t\tAND (p.post_type = 'page' OR p.post_type = 'post')\n\t\t\t\t\t\tAND t.date BETWEEN {$limitdate} AND {$currentdate} ;\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  post_name, total, urlrequested\n\t\t\t\t\tFROM (\n\t\t\t\t\t(SELECT 'page_accueil' as post_name, count(DISTINCT ip) as total, urlrequested\n\t\t\t\t\t\tFROM {$wpdb->posts} as p\n\t\t\t\t\t\tJOIN {$table_name} as t ON urlrequested =''\n\t\t\t\t\t\tWHERE  p.post_status = 'publish'\n\t\t\t\t\t\t\tAND (p.post_type = 'page' OR p.post_type = 'post')\n\t\t\t\t\t\t\tAND t.spider=''\n\t\t\t\t\t\t\tAND t.feed=''\n\t\t\t\t\t\t\tAND (t.date BETWEEN {$limitdate} AND {$currentdate})\n\t\t\t\t\t\tGROUP BY post_name)\n\t\t\t\t\tUNION ALL\n\t\t\t\t\t(SELECT post_name, count(DISTINCT ip) as total, urlrequested\n\t\t\t\t\t\tFROM {$wpdb->posts} as p\n\t\t\t\t\t\tJOIN {$table_name} as t\n\t\t\t\t\t\tON t.urlrequested LIKE CONCAT('%', p.post_name, '_' )\n\t\t\t\t\t\tWHERE p.post_status = 'publish'\n\t\t\t\t\t\t\tAND (p.post_type = 'page' OR p.post_type = 'post')\n\t\t\t\t\t\t\tAND t.spider=''\n\t\t\t\t\t\t\tAND t.feed=''\n\t\t\t\t\t\t\tAND t.date BETWEEN {$limitdate} AND {$currentdate}\n\t\t\t\t\t\tGROUP BY post_name)\n\t\t\t\t\t) visitors\n\t\t\t\t\tGROUP BY post_name\n\t\t\t\t\tORDER BY total DESC LIMIT {$LimitValueArticles}, {$NumberDisplayPost} ;\n\t\t\t\t";
    $query = $wpdb->get_results($strqry);
    $spider = $StatPressV_Option['StatPressV_Dont_Collect_Spider'];
    echo "<div class='wrap'><h2>Most visitors these " . $graphdays . " days </h2>";
    luc_print_pp_pa_link($NP, $pp, $action, $NA, $pa);
    foreach ($query as $url) {
        $where1 = " (urlrequested LIKE '" . $permalink . "feed%' OR urlrequested LIKE '" . $permalink . "comment%') ";
        $where2 = " urlrequested LIKE '%" . $url->post_name . "%' AND spider='' ";
        if ($url->post_name == 'page_accueil') {
            //url == home
            $total = luc_count_graph(luc_init_count_graph($graphdays, $pp), $graphdays, $pp, " urlrequested ='' ", $where1, "feed=''", "feed<>''", $limitdate, $currentdate);
        } else {
            //url<> home
            $total = luc_count_graph(luc_init_count_graph($graphdays, $pp), $graphdays, $pp, $where2, $where2, "feed=''", "feed<>''", $limitdate, $currentdate);
        }
        $maxxday = luc_maxxday($total, $graphdays, $pp);
        $px = luc_pixel($total, $graphdays, $maxxday, $pp, $action);
        if ($url->urlrequested == '') {
            $out_url = "[Page]: Home";
        } else {
            $out_url = luc_post_title_Decode($permalink . $url->post_name);
        }
        // Overhead of the graph, display the name of the post/page and the average by day of the visitors
        echo "<div class='wrap' >\n\t\t\t\t<table class='widefat' >\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th scope='col' width='15%'>\n\t\t\t\t\t\t\t\t<div style='background:{$visitors_color};width:10px;height:10px;float:left;margin-top:2px;margin-right:5px;'></div>" . $total->totalvisitors . " visitors\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope='col' width='15%'>\n\t\t\t\t\t\t\t\t<div style='background:{$visitors_color};width:10px;height:10px;float:left;margin-top:2px;margin-right:5px;'></div>Average " . round($total->totalvisitors / $graphdays, 1) . " by day\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t<th scope='col' width='70%'>\n\t\t\t\t\t\t\t\t<font font-size='1'>" . $out_url . "</font>\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t</table>\n\t\t\t\t<table class='graph'>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr>";
        luc_graph($px, $total, $graphdays, $pp, $action);
        echo "\t\t\t</tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>";
    }
    luc_print_pp_pa_link($NP, $pp, $action, $NA, $pa);
    echo "</div>";
    luc_StatPressV_load_time();
}
コード例 #3
0
ファイル: luc_url_monitoring.php プロジェクト: dtekcth/dns
function luc_url_monitoring()
{
    global $wpdb, $StatPressV_Option;
    $table_name = STATPRESS_V_TABLE_NAME;
    $querylimit = 20;
    $pa = luc_page_posts();
    $action = "urlmonitoring";
    // Number of distinct "no author post or page URL"
    $Num = $wpdb->get_var("SELECT COUNT(*)\r\n\t\t\t\tFROM {$table_name}\r\n\t\t\t\tWHERE realpost=0 AND (spider ='' OR spider LIKE 'Unknown Spam Bot')\r\n\t\t\t\t");
    $NumPage = ceil($Num / $querylimit);
    echo "<div class='wrap'><h2>" . __('URL Monitoring', 'statpress') . "</h2>\r\n\t       </br> This page is designed to help you secure your website:<div title='Indeed this page shows all URLs that have access to your website or your blog and who are not posts or pages written by an author of your website.Some are legitimate as /category or the robots like Google. Nevertheless, they are all shown so you can secure your blog or your site by selecting the ones you want to block access to your site.'>Learn more</div>";
    luc_print_pp_pa_link(0, 0, $action, $NumPage, $pa);
    $LimitValue = $pa * $querylimit - $querylimit;
    ?>
	<table class='widefat' >
		<thead>
		<tr>
			<th scope='col'>Date</th>
			<th scope='col'>Time</th>
			<th scope='col'>IP</th>
			<th scope='col'>Country</th>
			<th scope='col' width="30%">URL requested</th>
			<th scope='col' width="30%">Agent</th>
			<th scope='col'>Spider</th>
			<th scope='col'>OS</th>
			<th scope='col'>Browser</th>
		</tr>
		</thead>
		<tbody>
	<?php 
    $qry = $wpdb->get_results("SELECT date,time,ip,urlrequested,agent,os,browser,spider,country,realpost\r\n\t\t\tFROM {$table_name}\r\n\t\t\tWHERE realpost=0 AND (spider ='' OR spider LIKE 'Unknown Spam Bot')\r\n\t\t\tORDER BY id DESC\r\n\t\t\tLIMIT {$LimitValue}, {$querylimit};");
    foreach ($qry as $rk) {
        echo "<tr>\r\n\t\t\t<td>" . luc_hdate($rk->date) . "</td>\r\n\t\t\t<td>" . $rk->time . "</td>\r\n\t\t\t<td>" . luc_create_href($rk->ip, 'ip') . "</td>\r\n\t\t\t<td>" . luc_HTML_IMG($rk->country, 'country', false) . "</td>\r\n\t\t\t<td>" . $rk->urlrequested . "</td>\r\n\t\t\t<td><a href='http://www.google.com/search?q=%22User+Agent%22+" . urlencode($rk->agent) . "' target='_blank' title='Search for User Agent string on Google...'> " . $rk->agent . "</a> </td>\r\n\t\t\t<td>" . luc_HTML_IMG($rk->spider, 'spider', false) . "</td>\r\n\t\t\t<td>" . luc_HTML_IMG($rk->os, 'os', $text_OS) . "</td>\r\n\t\t\t<td>" . luc_HTML_IMG($rk->browser, 'browser', $text_browser) . "</td>";
    }
    ?>
		</tbody>
	</table>
	
<?php 
    echo "</div>";
    luc_print_pp_pa_link(0, 0, $action, $NumPage, $pa);
    luc_StatPressV_load_time($start);
}
コード例 #4
0
ファイル: luc_yesterday.php プロジェクト: dtekcth/dns
function luc_yesterday()
{
    global $wpdb, $StatPressV_Option;
    $table_name = STATPRESS_V_TABLE_NAME;
    $action = "yesterday";
    $visitors_color = "#114477";
    $rss_visitors_color = "#FFF168";
    $pageviews_color = "#3377B6";
    $rss_pageviews_color = "#f38f36";
    $spider_color = "#83b4d8";
    $yesterday = gmdate('Ymd', current_time('timestamp') - 86400);
    $pa = luc_page_posts();
    $permalink = luc_permalink();
    $strqry = "SELECT post_name\r\n\t\t\t\tFROM {$wpdb->posts}\r\n\t\t\t\tWHERE post_status = 'publish'\r\n\t\t\t\t\tAND (post_type = 'page' OR post_type = 'post')\r\n\t\t\t\t\tAND  DATE_FORMAT(post_date_gmt, '%Y%m%d') <= {$yesterday};";
    $qry_posts = $wpdb->get_results($strqry);
    $NumberPosts = $wpdb->num_rows;
    $NumberDisplayPost = 100;
    $NA = ceil($NumberPosts / $NumberDisplayPost);
    $LimitValueArticles = ($pa - 1) * $NumberDisplayPost;
    foreach ($qry_posts as $p) {
        $posts[$p->post_name]['post_name'] = $p->post_name;
        $posts[$p->post_name]['visitors'] = NULL;
        $posts[$p->post_name]['visitors_feeds'] = NULL;
        $posts[$p->post_name]['pageviews'] = NULL;
        $posts[$p->post_name]['pageviews_feeds'] = NULL;
        $posts[$p->post_name]['spiders'] = NULL;
    }
    $posts['page_accueil']['post_name'] = 'page_accueil';
    $posts['page_accueil']['visitors'] = NULL;
    $posts['page_accueil']['visitors_feeds'] = NULL;
    $posts['page_accueil']['pageviews'] = NULL;
    $posts['page_accueil']['pageviews_feeds'] = NULL;
    $posts['page_accueil']['spiders'] = NULL;
    $qry_visitors = requete_yesterday("DISTINCT ip", "urlrequested = ''", "spider = '' AND feed = ''", $yesterday);
    foreach ($qry_visitors as $p) {
        $posts[$p->post_name]['visitors'] = $p->total;
        $total_visitors += $p->total;
    }
    $qry_visitors_feeds = requete_yesterday("DISTINCT ip", "(urlrequested LIKE '%" . $permalink . "feed%' OR urlrequested LIKE '%" . $permalink . "comment%') ", "spider='' AND feed<>''", $yesterday);
    foreach ($qry_visitors_feeds as $p) {
        $posts[$p->post_name]['visitors_feeds'] = $p->total;
        $total_visitors_feeds += $p->total;
    }
    $qry_pageviews = requete_yesterday("ip", "urlrequested = ''", "spider = '' AND feed = ''", $yesterday);
    foreach ($qry_pageviews as $p) {
        $posts[$p->post_name]['pageviews'] = $p->total;
        $total_pageviews += $p->total;
    }
    $qry_pageviews_feeds = requete_yesterday("ip", "(urlrequested LIKE '%" . $permalink . "feed%' OR urlrequested LIKE '%" . $permalink . "comment%')", " spider='' AND feed<>''", $yesterday);
    foreach ($qry_pageviews_feeds as $p) {
        $posts[$p->post_name]['pageviews_feeds'] = $p->total;
        $total_pageviews_feeds += $p->total;
    }
    $spider = $StatPressV_Option['StatPressV_Dont_Collect_Spider'];
    if ($spider == '') {
        $qry_spiders = requete_yesterday("ip", "urlrequested=''", "spider<>'' AND feed=''", $yesterday);
        foreach ($qry_spiders as $p) {
            $posts[$p->post_name]['spiders'] = $p->total;
            $total_spiders += $p->total;
        }
    }
    $total_visitors = $wpdb->get_var("SELECT count(DISTINCT ip) AS total\r\n\t\t\tFROM {$table_name}\r\n\t\t\tWHERE feed=''\r\n\t\t\t\tAND spider=''\r\n\t\t\t\tAND date = {$yesterday} ;");
    $total_visitors_feeds = $wpdb->get_var("SELECT count(DISTINCT ip) as total\r\n\t\t\tFROM {$table_name}\r\n\t\t\tWHERE feed<>''\r\n\t\t\t\tAND spider=''\r\n\t\t\t\tAND date = {$yesterday} ;");
    echo "<div class='wrap'><h2>" . __('Yesterday ', 'statpressV') . gmdate('d M, Y', current_time('timestamp') - 86400) . "</div></br>";
    luc_print_pp_pa_link(0, 0, $action, $NA, $pa);
    // Sort the results by total
    usort($posts, "luc_posts_pages_custom_sort");
    echo "<table class='widefat'>\r\n\t<thead><tr>\r\n\t<th scope='col'>" . __('URL', 'statpressV') . "</th>\r\n\t<th scope='col'><div style='background:{$visitors_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Visitors', 'statpressV') . "<br /><font size=1></font></th>\r\n\t<th scope='col'><div style='background:{$rss_visitors_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Visitors Feeds', 'statpressV') . "<br /><font size=1></font></th>\r\n\t<th scope='col'><div style='background:{$pageviews_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Views', 'statpressV') . "<br /><font size=1></font></th>\r\n\t<th scope='col'><div style='background:{$rss_pageviews_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Views Feeds', 'statpressV') . "<br /><font size=1></font></th>";
    if ($spider == '') {
        echo "<th scope='col'><div style='background:{$spider_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Spider', 'statpressV') . "<br /><font size=1></font></th>";
    }
    echo "</tr></thead>";
    echo "<tr>\r\n\t<th scope='col'>All URL</th>\r\n\t<th scope='col'>" . __($total_visitors, 'statpressV') . "</th>\r\n\t<th scope='col'>" . __($total_visitors_feeds, 'statpressV') . "</th>\r\n\t<th scope='col'>" . __($total_pageviews, 'statpressV') . "</th>\r\n\t<th scope='col'>" . __($total_pageviews_feeds, 'statpressV') . "</th>";
    if ($spider == '') {
        echo "<th scope='col'>" . __($total_spiders, 'statpressV') . "</th>\r\n\t\t\t</tr>";
    }
    $i = 0;
    foreach ($posts as $p) {
        if ($i >= $LimitValueArticles and $i < $LimitValueArticles + $NumberDisplayPost) {
            if ($p['post_name'] == 'page_accueil') {
                $out_url = "Page : Home";
            } else {
                $out_url = $permalink . $p['post_name'];
            }
            echo "<tr>\r\n\t\t\t<td>" . luc_post_title_Decode(urldecode($out_url)) . "</td>";
            echo "<td>" . $p['visitors'] . "</td>\r\n\t\t\t<td>" . $p['visitors_feeds'] . "</td>\r\n\t\t\t<td>" . $p['pageviews'] . "</td>\r\n\t\t\t<td>" . $p['pageviews_feeds'] . "</td>";
            if ($spider == '') {
                echo "<td>" . $p['spiders'] . "</td>";
            }
            echo "</tr>";
        }
        $i++;
    }
    echo "</table>";
    luc_print_pp_pa_link(0, 0, $action, $NA, $pa);
    luc_StatPressV_load_time();
}
コード例 #5
0
ファイル: luc_spybot.php プロジェクト: newmight2015/psmpsm
function luc_spybot()
{
    global $wpdb, $StatPressV_Option;
    $action = "spybot";
    $table_name = STATPRESS_V_TABLE_NAME;
    $LIMIT = $StatPressV_Option['StatPressV_SpyBot_Bots_Per_Page'];
    $LIMIT_PROOF = $StatPressV_Option['StatPressV_SpyBot_Visits_Per_Bot'];
    if ($LIMIT == 0) {
        $LIMIT = 10;
    }
    if ($LIMIT_PROOF == 0) {
        $LIMIT_PROOF = 30;
    }
    $pa = luc_page_posts();
    $LimitValue = $pa * $LIMIT - $LIMIT;
    // limit the search 7 days ago
    $day_ago = gmdate('Ymd', current_time('timestamp') - 7 * 86400);
    $MinId = $wpdb->get_var("SELECT min(id) as MinId\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE date > {$day_ago};");
    // Number of distinct spiders after $day_ago
    $Num = $wpdb->get_var("SELECT count(distinct spider)\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE spider<>''\n\t\t\t\t\tAND id >{$MinId};");
    $NA = ceil($Num / $LIMIT);
    echo "<div class='wrap'><h2>" . __('Bot Spy', 'statpress') . "</h2>";
    // selection of spider, group by spider, order by most recently visit (last id in the table)
    $sql = "SELECT *\n\t\t\t\t\tFROM {$table_name} as T1\n\t\t\t\t\tJOIN\n\t\t\t\t\t\t(SELECT spider,max(id) as MaxId\n\t\t\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\t\t\tWHERE spider<>''\n\t\t\t\t\t\t\tGROUP BY spider\n\t\t\t\t\t\t\tORDER BY MaxId\n\t\t\t\t\t\t\tDESC LIMIT {$LimitValue}, {$LIMIT}\n\t\t\t\t\t\t) as T2\n\t\t\t\t\tON T1.spider = T2.spider\n\t\t\t\t\tWHERE T1.id > {$MinId}\n\t\t\t\t\tORDER BY MaxId DESC, id DESC;\n\t\t\t\t";
    $qry = $wpdb->get_results($sql);
    echo '<div align="center">';
    luc_print_pp_pa_link(0, 0, $action, $NA, $pa);
    echo '</div><div align="left">';
    ?>
<script>
function ttogle(thediv){
if (document.getElementById(thediv).style.display=="inline") {
document.getElementById(thediv).style.display="none"
} else {document.getElementById(thediv).style.display="inline"}
}
</script>
<table class="widefat" id="mainspytab" name="mainspytab">
	<div align='left'>
		<?php 
    $spider = "robot";
    $num_row = 0;
    foreach ($qry as $rk) {
        // Bot Spy
        if ($robot != $rk->spider) {
            echo "<div align='left'>\n\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t<tr><th scope='colgroup' colspan='2'>";
            $img = str_replace(" ", "_", strtolower($rk->spider));
            $img = str_replace('.', '', $img) . ".png";
            $lines = file(STATPRESS_V_PLUGIN_PATH . '/def/spider.dat');
            foreach ($lines as $line_num => $spider) {
                list($title, $id) = explode("|", $spider);
                if ($title == $rk->spider) {
                    break;
                }
                // break, the tooltip ($title) is found
            }
            echo "<IMG style='border:0px;height:16px;align:left;' alt='" . $title . "' title='" . $title . "' SRC='" . STATPRESS_V_PLUGIN_URL . '/images/spider/' . $img . "'>\n\t\t\t\t\t\t\t\t\t<span style='color:#006dca;cursor:pointer;border-bottom:1px dotted #AFD5F9;font-size:8pt;' onClick=ttogle('" . $img . "');>(more information)</span>\n\t\t\t\t\t\t\t\t\t<div id='" . $img . "' name='" . $img . "'><br /><small>" . $rk->ip . "</small><br><small>" . $rk->agent . "<br /></small></div>\n\t\t\t\t\t\t\t\t\t<script>document.getElementById('" . $img . "').style.display='none';</script>\n\t\t\t\t\t\t\t\t\t</th></tr></thead><tbody>\n\t\t\t\t\t\t\t\t\t<tr><td>" . luc_hdate($rk->date) . " " . $rk->time . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . (isset($rk->post_title) ? $rk->post_title : luc_post_title_Decode(urldecode($rk->urlrequested))) . "</td></tr>";
            $robot = $rk->spider;
            $num_row = 1;
        } else {
            if ($num_row < $LIMIT_PROOF) {
                echo "<tr>\n\t\t\t\t\t\t<td>" . luc_hdate($rk->date) . " " . $rk->time . "</td>\n\t\t\t\t\t\t<td>" . (isset($rk->post_title) ? $rk->post_title : luc_post_title_Decode(urldecode($rk->urlrequested))) . "</td></tr>";
                $num_row += 1;
            }
        }
        echo "</div></td></tr>\n";
    }
    echo "</tbody></table>";
    luc_print_pp_pa_link(0, 0, $action, $NA, $pa);
    echo "</div>";
    luc_StatPressV_load_time();
}
コード例 #6
0
function luc_table_posts_pages()
{
    global $wpdb, $StatPressV_Option;
    $table_name = STATPRESS_V_TABLE_NAME;
    // action part of the slug
    $action = "postpage";
    // colors
    $visitors_color = "#114477";
    $rss_visitors_color = "#FFF168";
    $pageviews_color = "#3377B6";
    $rss_pageviews_color = "#f38f36";
    $spider_color = "#83b4d8";
    $pa = luc_page_posts();
    $permalink = luc_permalink();
    $collect_spider = $StatPressV_Option['StatPressV_Dont_Collect_Spider'];
    $day = isset($_POST['postspagesdate']) ? gmdate('Ymd', strtotime($_POST['postspagesdate'])) : gmdate('Ymd', current_time('timestamp') - 86400);
    // All WordPress posts and pages
    $sql_posts_pages = "SELECT post_date_gmt,post_title,post_name,post_type \n\t\t\tFROM {$wpdb->posts} \n\t\t\tWHERE post_status = 'publish' \n\t\t\t\tAND (post_type = 'page' OR post_type = 'post')\n\t\t\t\tAND DATE_FORMAT(post_date_gmt, '%Y%m%d') <= {$day};";
    // Get all posts and pages
    $qry_posts_pages = $wpdb->get_results($sql_posts_pages);
    $total_posts_pages = $wpdb->num_rows;
    $NumberDisplayPost = 100;
    $NA = ceil($total_posts_pages / $NumberDisplayPost);
    $LimitValueArticles = ($pa - 1) * $NumberDisplayPost;
    foreach ($qry_posts_pages as $p) {
        $posts[$p->post_name]['post_name'] = $p->post_name;
        $posts[$p->post_name]['post_title'] = $p->post_title;
        $posts[$p->post_name]['post_type'] = $p->post_type;
        $posts[$p->post_name]['visitors'] = NULL;
        $posts[$p->post_name]['visitors_feeds'] = NULL;
        $posts[$p->post_name]['pageviews'] = NULL;
        $posts[$p->post_name]['pageviews_feeds'] = NULL;
        $posts[$p->post_name]['spiders'] = NULL;
    }
    $posts['page_accueil']['post_name'] = 'page_accueil';
    $posts['page_accueil']['post_title'] = 'Home';
    $posts['page_accueil']['post_type'] = 'page';
    $posts['page_accueil']['visitors'] = NULL;
    $posts['page_accueil']['visitors_feeds'] = NULL;
    $posts['page_accueil']['pageviews'] = NULL;
    $posts['page_accueil']['pageviews_feeds'] = NULL;
    $posts['page_accueil']['spiders'] = NULL;
    $qry_visitors = requete_day("DISTINCT ip", "urlrequested = ''", "spider = '' AND feed = ''", $day);
    foreach ($qry_visitors as $p) {
        $posts[$p->post_name]['visitors'] = $p->total;
        $total_visitors += $p->total;
    }
    $qry_visitors_feeds = requete_day("DISTINCT ip", "(urlrequested LIKE '%" . $permalink . "feed%' OR urlrequested LIKE '%" . $permalink . "comment%') ", "spider='' AND feed<>''", $day);
    foreach ($qry_visitors_feeds as $p) {
        $posts[$p->post_name]['visitors_feeds'] = $p->total;
        $total_visitors_feeds += $p->total;
    }
    $qry_pageviews = requete_day("ip", "urlrequested = ''", "spider = '' AND feed = ''", $day);
    foreach ($qry_pageviews as $p) {
        $posts[$p->post_name]['pageviews'] = $p->total;
        $total_pageviews += $p->total;
    }
    $qry_pageviews_feeds = requete_day("ip", "(urlrequested LIKE '%" . $permalink . "feed%' OR urlrequested LIKE '%" . $permalink . "comment%')", " spider='' AND feed<>''", $day);
    foreach ($qry_pageviews_feeds as $p) {
        $posts[$p->post_name]['pageviews_feeds'] = $p->total;
        $total_pageviews_feeds += $p->total;
    }
    $spider = $StatPressV_Option['StatPressV_Dont_Collect_Spider'];
    if ($spider == '') {
        $qry_spiders = requete_day("ip", "urlrequested=''", "spider<>'' AND feed=''", $day);
        foreach ($qry_spiders as $p) {
            $posts[$p->post_name]['spiders'] = $p->total;
            $total_spiders += $p->total;
        }
    }
    $total_visitors = $wpdb->get_var("SELECT count(DISTINCT ip) AS total\n\t\t\tFROM {$table_name}\n\t\t\tWHERE feed=''\n\t\t\t\tAND spider=''\n\t\t\t\tAND date = {$day} ;");
    $total_visitors_feeds = $wpdb->get_var("SELECT count(DISTINCT ip) as total\n\t\t\tFROM {$table_name}\n\t\t\tWHERE feed<>''\n\t\t\t\tAND spider=''\n\t\t\t\tAND date = {$day} ;");
    echo "<strong>";
    _e("Displaying report for " . gmdate('d M, Y', strtotime($day)) . " (" . $total_posts_pages . " posts/pages)");
    echo " </strong>";
    luc_print_pp_pa_link(0, 0, $action, $NA, $pa);
    // Sort the results by total
    usort($posts, "luc_posts_pages_custom_sort");
    echo "<table class='widefat' >\n\t<thead><tr>\n\t<th scope='col'>" . __('URL', 'statpressV') . "</th>\n\t<th scope='col'><div style='background:{$visitors_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Visitors', 'statpressV') . "<br /><font size=1></font></th>\n\t<th scope='col'><div style='background:{$rss_visitors_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Visitors Feeds', 'statpressV') . "<br /><font size=1></font></th>\n\t<th scope='col'><div style='background:{$pageviews_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Views', 'statpressV') . "<br /><font size=1></font></th>\n\t<th scope='col'><div style='background:{$rss_pageviews_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Views Feeds', 'statpressV') . "<br /><font size=1></font></th>";
    if ($spider == '') {
        echo "<th scope='col'><div style='background:{$spider_color};width:10px;height:10px;float:left;margin-top:4px;margin-right:5px;'></div>" . __('Spider', 'statpressV') . "<br /><font size=1></font></th>";
    }
    echo "</tr></thead>";
    echo "<tr>\n\t<th scope='col'>All URL</th>\n\t<th scope='col'>" . __($total_visitors, 'statpressV') . "</th>\n\t<th scope='col'>" . __($total_visitors_feeds, 'statpressV') . "</th>\n\t<th scope='col'>" . __($total_pageviews, 'statpressV') . "</th>\n\t<th scope='col'>" . __($total_pageviews_feeds, 'statpressV') . "</th>";
    if ($spider == '') {
        echo "<th scope='col'>" . __($total_spiders, 'statpressV') . "</th>\n\t\t\t</tr>";
    }
    $i = 0;
    foreach ($posts as $p) {
        if ($i >= $LimitValueArticles and $i < $LimitValueArticles + $NumberDisplayPost) {
            echo "<td>" . ($p[post_type] == 'page' ? "[page]&#58;&nbsp;" . $p['post_title'] : $p['post_title']) . "</td>\n\t\t\t<td>" . $p['visitors'] . "</td>\n\t\t\t<td>" . $p['visitors_feeds'] . "</td>\n\t\t\t<td>" . $p['pageviews'] . "</td>\n\t\t\t<td>" . $p['pageviews_feeds'] . "</td>";
            if ($spider == '') {
                echo "<td>" . $p['spiders'] . "</td>";
            }
            echo "</tr>";
        }
        $i++;
    }
    echo "</table>";
    luc_print_pp_pa_link(0, 0, $action, $NA, $pa);
    if (isset($_POST['postspagesdate'])) {
        die;
    }
}