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(); }
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(); }
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); }
function luc_statistics() { global $wpdb; $table_name = STATPRESS_V_TABLE_NAME; $querylimit = "LIMIT 10"; # Top days luc_ValueTable("date", "Top days", 5, "", "", "WHERE spider NOT LIKE '%Spam Bot'"); # O.S. luc_ValueTable("os", "O.S.", 10, "", "", "WHERE feed='' AND spider='' AND os<>'' AND agent<>''"); # Browser luc_ValueTable("browser", "Browser", 10, "", "", "WHERE feed='' AND spider='' AND browser<>'' AND agent<>''"); # Feeds luc_ValueTable("feed", "Feeds", 10, "", "", "WHERE feed<>'' AND spider NOT LIKE '%spam bot'"); # SE luc_ValueTable("searchengine", "Search engines", 10, "", "", "WHERE searchengine<>'' AND spider NOT LIKE '%spam bot'"); # Search terms luc_ValueTable("search", "Top search terms", 20, "", "", "WHERE search<>'' AND spider NOT LIKE '%spam bot'"); # Top referrer luc_ValueTable("referrer", "Top referrer", 20, "", "", "WHERE referrer<>'' AND referrer NOT LIKE '%" . get_bloginfo('url') . "%' AND spider NOT LIKE '%spam bot'"); # Countries luc_ValueTable("country", "Countries", 20, "", "", "WHERE country<>'' AND spider='' AND agent<>''"); # Languages luc_ValueTable("language", "Languages", 20, "", "", "WHERE language<>'' AND spider='' AND agent<>''"); # Spider if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') { // chek if collect or not spider luc_ValueTable("spider", "Spiders", 10, "", "", "WHERE spider<>'' AND spider NOT LIKE '%spam bot'"); } # Top Pages luc_ValueTable("urlrequested", "Top pages", 10, "", "urlrequested", "WHERE feed='' and spider='' AND agent<>''"); # Top Days - Unique visitors luc_ValueTable("date", "Top Days - Unique visitors", 5, "distinct", "ip", "WHERE feed='' and spider='' AND agent<>''"); /* Maddler 04112007: required patching luc_ValueTable */ # Top Days - Pageviews luc_ValueTable("date", "Top Days - Pageviews", 5, "", "urlrequested", "WHERE feed='' AND spider='' AND agent<>''"); /* Maddler 04112007: required patching luc_ValueTable */ # Top IPs - Pageviews luc_ValueTable("ip", "Top IPs - Pageviews", 10, "", "urlrequested", "WHERE feed='' AND spider='' AND agent<>'' "); /* Maddler 04112007: required patching luc_ValueTable */ luc_StatPressV_load_time(); }
function luc_posts_pages() { $start = microtime(true); ?> <div class='wrap'> <form id=postspagesdateForm> <table style="width:100%"> <tr> <td> <div id="postspagestitle"> <h2><?php _e(__('Post & Page Summary', 'statpressV')); ?> </h2> </div> </td> <td align="right"> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="postspagesdateLoader" style="display: none;" /> <input type=text name=postspagesdate id=postspagesdate class='datepicker'> <input type="hidden" name="action" value="table_posts_pages" /> </td> </tr> </table> </form> <div id="postspages"> <?php luc_table_posts_pages(); ?> </div> <?php _e(luc_StatPressV_load_time($start)); ?> </div> <?php }
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(); }
function luc_spyvisitors() { global $wpdb; global $StatPressV_Option; $action = "spyvisitors"; $table_name = STATPRESS_V_TABLE_NAME; // number of IP or bot by page $LIMIT = $StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] ? $StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] : 20; $LIMIT_PROOF = $StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] ? $StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] : 20; $pp = luc_page_periode(); // Number of distinct ip (unique visitors) $NumIP = $wpdb->get_var("SELECT count(distinct ip)\n\t\t\t\t\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\t\t\t\t\tWHERE spider='' ;"); $NP = ceil($NumIP / $LIMIT); $LimitValue = $pp * $LIMIT - $LIMIT; $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 max(id) as MaxId,ip\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 ip\n\t\t\t\t\t\t\tORDER BY MaxId DESC LIMIT {$LimitValue}, {$LIMIT}\n\t\t\t\t\t\t) as T2\n\t\t\t\t\tON T1.ip = T2.ip\n\t\t\t\t\tORDER BY MaxId DESC, id DESC;\n\t\t\t\t"; $qry = $wpdb->get_results($sql); if ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked' & function_exists('geoip_open')) { // Open the database to read and save info if (file_exists(luc_GeoIP_dbname('city'))) { $gic = geoip_open(luc_GeoIP_dbname('city'), GEOIP_STANDARD); $geoip_isok = true; } } echo "<div class='wrap'><h2>" . __('Visitor Spy', 'statpress') . "</h2>"; ?> <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> <?php $MaxId = 0; $num_row = 0; // Add pagination luc_insert_pagination_options("spyvisitors", $NumIP, $LIMIT); luc_print_pp_link($NP, $pp, $action); echo '<table class="widefat" id="mainspytab" name="mainspytab" width="99%" border="0" cellspacing="0" cellpadding="4">'; foreach ($qry as $rk) { // Visitor Spy if ($MaxId != $rk->MaxId) { if ($geoip_isok === true) { $gir = GeoIP_record_by_addr($gic, $rk->ip); } echo "<thead><tr><th scope='colgroup' colspan='2'>"; if ($rk->country != '') { echo "HTTP country " . luc_HTML_IMG($rk->country, 'country', false); } else { echo "Hostip country <IMG SRC='http://api.hostip.info/flag.php?ip=" . $rk->ip . "' border=0 width=18 height=12> "; } if ($geoip_isok === true) { $lookupsvc = "GeoIP details"; } else { $lookupsvc = "Hostip details"; } echo "\t<strong><span><font size='2' color='#7b7b7b'> " . $rk->ip . " </font></span></strong>\n\t\t\t\t\t<span style='color:#006dca;cursor:pointer;border-bottom:1px dotted #AFD5F9;font-size:8pt;'\n\t\t\t\t\t\tonClick=ttogle('" . $rk->ip . "');>" . $lookupsvc . "</span></div>\n\t\t\t\t\t<div id='" . $rk->ip . "' name='" . $rk->ip . "'>"; if ($geoip_isok === true) { echo "\t<small><br>\n\t\t\t\t\t\t\tCountry: " . utf8_encode($gir->country_name) . " (" . $gir->country_code . ")<br>\n\t\t\t\t\t\t\tCity: " . utf8_encode($gir->city) . "<br>\n\t\t\t\t\t\t\tLatitude/Longitude: <a href='http://maps.google.com/maps?q=" . $gir->latitude . "+" . $gir->longitude . "' target='_blank' title='Lookup latitude/longitude location on Google Maps...'>" . $gir->latitude . " " . $gir->longitude . "</a>\n\t\t\t\t\t\t</small>"; } else { echo "\t<iframe style='overflow:hide;border:0px;width:100%;height:35px;font-family:helvetica;paddng:0;'\n\t\t\t\t\t\t\tscrolling='no' marginwidth=0 marginheight=0 src=http://api.hostip.info/get_html.php?ip=" . $rk->ip . ">\n\t\t\t\t\t\t</iframe>"; } echo "\t<small>\n\t\t\t\t\t\t<br>" . $rk->os . "\n\t\t\t\t\t\t<br>" . $rk->browser . "\n\t\t\t\t\t\t<br>" . gethostbyaddr($rk->ip) . "\n\t\t\t\t\t\t<br>" . $rk->agent . "\n\t\t\t\t\t</small></div></th></tr></thead><tbody>\n\t\t\t\t\t<script> document.getElementById('" . $rk->ip . "').style.display='none';</script>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td>" . luc_hdate($rk->date) . " " . $rk->time . "</td>\n\t\t\t\t\t<td>" . (isset($rk->post_title) ? $rk->post_title : luc_post_title_Decode(urldecode($rk->urlrequested))) . ""; if ($rk->searchengine != '') { echo "<br><small>arrived from <b>" . $rk->searchengine . "</b> searching <a target='_blank' href='" . $rk->referrer . "' >" . urldecode($rk->search) . "</a></small>"; } elseif ($rk->referrer != '' && strpos($rk->referrer, $home) === false) { echo "<br><small>arrived from <a target='_blank' href='" . $rk->referrer . "' >" . $rk->referrer . "</a></small>"; } echo "</div></td></tr>\n"; $MaxId = $rk->MaxId; $num_row = 1; } elseif ($num_row < $LIMIT_PROOF) { echo "<tr><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))) . ""; if ($rk->searchengine != '') { echo "<br><small>arrived from <b>" . $rk->searchengine . "</b> searching <a target='_blank' href='" . $rk->referrer . "' >" . urldecode($rk->search) . "</a></small>"; } elseif ($rk->referrer != '' && strpos($rk->referrer, $home) === false) { echo "<br><small>arrived from <a target='_blank' href='" . $rk->referrer . "' >" . $rk->referrer . "</a></small>"; } $num_row += 1; echo "</td></tr></tbody>"; } } echo "</div></td></tr>\n</table>"; luc_print_pp_link($NP, $pp, $action); echo "</div>"; luc_StatPressV_load_time(); }
function luc_main() { $start = microtime(true); if (isset($_GET['ip'])) { // This is a query for an IP address luc_Lookup("ip", $_GET['ip']); return true; } if (isset($_GET['pageid'])) { // This is a query for a post or page luc_Lookup("pageid", $_GET['pageid']); return true; } global $StatPressV_Option; $overview = luc_main_table_overview_array(1); ?> <div class='wrap' > <div class="tabbed"> <!-- The tabs --> <ul> <li><strong><a href="#tabs-1">Overview</a></strong></li> <li><strong><a href="#tabs-2">Latest Hits</a></strong></li> <li><strong><a href="#tabs-3">Latest Search Terms</a></strong></li> <li><strong><a href="#tabs-4">Latest Referrers</a></strong></li> <li><strong><a href="#tabs-5">Latest Feeds</a></strong></li> <?php if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') { ?> <li><strong><a href="#tabs-6">Latest Spiders</a></strong></li> <li><strong><a href="#tabs-7">Latest Spams Bots</a></strong></li> <?php } ?> <li><strong><a href="#tabs-8">Latest Undefined Agents</a></strong></li> </ul> <!-- tab 1 --> <div id="tabs-1"> <div id="overview"> <?php luc_main_table_overview($overview['total']); ?> </div> <div id="bargraph"> <?php luc_main_table_bargraph($overview); ?> </div> <?php luc_insert_pagination_options("bargraph", $overview['numdays'], $StatPressV_Option['StatPressV_Graph_Days'] == 0 ? 7 : $StatPressV_Option['StatPressV_Graph_Days']); ?> <form id='bargraphForm'> <table class='main'> <tr> <td align='center'> <div id="pagination"></div> </td> <td> <img src="<?php echo STATPRESS_V_PLUGIN_URL; ?> /images/ajax-loader.gif" id="bargraphLoader" style="display: none;" /> <input type="hidden" name="action" value="table_bargraph" /> </td> </tr> </table> </form> </div> <!-- tab 2 --> <div id="tabs-2"> <table> <form id='latesthitsForm'> <table class='main'> <tr> <td>Rows:</td> <td align='right'> <select name='hitsrows' id='hitsrows'> <option value='0'>--Select--</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> <option value='250'>250</option> <option value='500'>500</option> </select> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="latesthitsLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_hits" /> </td> </tr> </table> </form> </table> <div id="latesthits"> <?php luc_main_table_latest_hits(); ?> </div> </div> <!-- tab 3 --> <div id="tabs-3"> <table> <form id='latestsearchForm'> <table class='main'> <tr> <td>Rows:</td> <td align='right'> <select name='searchrows' id='searchrows'> <option value='0'>--Select--</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> <option value='250'>250</option> <option value='500'>500</option> </select> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="latestsearchLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_search" /> </td> </tr> </table> </form> </table> <div id="latestsearch"> <?php luc_main_table_latest_search(); ?> </div> </div> <!-- tab 4 --> <div id="tabs-4"> <table> <form id='latestreferrersForm'> <table class='main'> <tr> <td>Rows:</td> <td align='right'> <select name='referrersrows' id='referrersrows'> <option value='0'>--Select--</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> <option value='250'>250</option> <option value='500'>500</option> </select> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="latestreferrersLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_referrers" /> </td> </tr> </table> </form> </table> <div id="latestreferrers"> <?php luc_main_table_latest_referrers(); ?> </div> </div> <!-- tab 5 --> <div id="tabs-5"> <table> <form id='latestfeedsForm'> <table class='main'> <tr> <td>Rows:</td> <td align='right'> <select name='feedsrows' id='feedsrows'> <option value='0'>--Select--</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> <option value='250'>250</option> <option value='500'>500</option> </select> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="latestfeedsLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_feeds" /> </td> </tr> </table> </form> </table> <div id="latestfeeds"> <?php luc_main_table_latest_feeds(); ?> </div> </div> <!-- tab 6 --> <?php if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') { ?> <div id="tabs-6"> <table> <form id='latestspidersForm'> <table class='main'> <tr> <td>Rows:</td> <td align='right'> <select name='spidersrows' id='spidersrows'> <option value='0'>--Select--</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> <option value='250'>250</option> <option value='500'>500</option> </select> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="latestspidersLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_spiders" /> </td> </tr> </table> </form> </table> <div id="latestspiders"> <?php luc_main_table_latest_spiders(); ?> </div> </div> <!-- tab 7 --> <div id="tabs-7"> <table> <form id='latestspambotsForm'> <table class='main'> <tr> <td width=270px><h2>Latest Spambots</h2></td> <td align='right'> <select name='spambotsrows' id='spambotsrows'> <option value='0'>Rows:</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> </select> <img src="<?php echo STATPRESS_V_PLUGIN_URL; ?> /images/ajax-loader.gif" id="latestspambotsLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_spambots" /> </td> </tr> </table> </form> </table> <div id="latestspambots"> <?php luc_main_table_latest_spambots(); ?> </div> </div> <?php } ?> <!-- tab 8 --> <div id="tabs-8"> <table> <form id='latestundefagentsForm'> <table class='main'> <tr> <td>Rows:</td> <td align='right'> <select name='undefagentsrows' id='undefagentsrows'> <option value='0'>--Select--</option> <option value='5'>5</option> <option value='10'>10</option> <option value='25'>25</option> <option value='50'>50</option> <option value='100'>100</option> <option value='250'>250</option> <option value='500'>500</option> </select> <img src="<?php _e(STATPRESS_V_PLUGIN_URL); ?> /images/ajax-loader.gif" id="latestundefagentsLoader" style="display: none;" /> <input type="hidden" name="action" value="table_latest_undefagents" /> </td> </tr> </table> </form> </table> <div id="latestundefagents"> <?php luc_main_table_latest_undefagents(); ?> </div> </div> </div> <!-- End tabbed div --> <!-- end of the tab --> <br> <table style="width:100%;"> <tbody> <tr> <td width="200px"><font size="1"><b>StatPress Visitors table size</b></font></td> <td><font size="1"><?php _e(luc_tablesize()); ?> </font></td> </tr> <tr> <td><font size="1"><b>StatPress Visitors current time</b></font></td> <td><font size="1"><?php _e(current_time('mysql')); ?> </font></td> </tr> <tr> <td><font size="1"><b>RSS2 URL</b></font></td> <td><font size="1"><?php _e(get_bloginfo('rss2_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('rss2_url')) . ")"); ?> </font></td> </tr> <tr> <td><font size="1"><b>ATOM URL</b></font></td> <td><font size="1"><?php _e(get_bloginfo('atom_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('atom_url')) . ")"); ?> </font></td> </tr> <tr> <td><font size="1"><b>RSS URL</b></font></td> <td><font size="1"><?php _e(get_bloginfo('rss_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('rss_url')) . ")"); ?> </font></td> </tr> <tr> <td><font size="1"><b>RSS2 Comments URL</b></font></td> <td><font size="1"><?php _e(get_bloginfo('comments_rss2_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('comments_rss2_url')) . ")"); ?> </font></td> </tr> <tr> <td><font size="1"><b>ATOM Comments URL</b></font></td> <td><font size="1"><?php _e(get_bloginfo('comments_atom_url') . " (" . luc_StatPress_extractfeedreq(get_bloginfo('comments_atom_url')) . ")"); ?> </font></td> </tr> </tbody> </table> <?php _e(luc_StatPressV_load_time($start)); ?> </div> <?php }
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(); }
function luc_display_by_IP($ip) { global $wpdb; $table_name = STATPRESS_V_TABLE_NAME; $qry_s = "SELECT *\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE ip = '{$ip}'\n\t\t\t\tORDER BY id DESC\n\t\t\t\t"; $qry = $wpdb->get_results($qry_s); $num = $wpdb->num_rows; $qry_sa = "SELECT DISTINCT agent\n\t\t\t\tFROM {$table_name}\n\t\t\t\tWHERE ip = '{$ip}'\n\t\t\t\tORDER BY agent ASC ;\n\t\t\t\t"; $qrya = $wpdb->get_results($qry_sa); if ($_POST['markbot'] == 'Mark as spambot') { luc_BanBot('ip', $ip); } if ($_POST['banip'] == 'Ban IP address') { luc_BanIP($ip); } $text_OS = $StatPressV_Option['StatPressV_Dont_Show_OS_name'] != 'checked' ? true : false; $text_browser = $StatPressV_Option['StatPressV_Dont_Show_Browser_name'] != 'checked' ? true : false; $text = "Report for " . $ip . " "; ?> <form method=post> <div class='wrap'><table style="width:100%"><tr><td><h2> <?php _e($text); ?> </h2></td> <td width=50px align='right'> <input type=submit name=banip value='Ban IP address' > </td> </tr> </table> <table class='widefat'> <thead> <tr> <th scope='col' colspan='2'></th> </thead> <tbody> <tr> <td>Records in database:</td> <td> <?php _e($num); ?> </td> </tr> <tr> <td>Latest hit:</td> <td> <?php _e(luc_hdate($qry[0]->date) . " " . $qry[0]->time); ?> </td> </tr> <tr> <td>First hit:</td> <td> <?php _e(luc_hdate($qry[$num - 1]->date) . " " . $qry[$num - 1]->time); ?> </td> </tr> <tr> <td>User agent(s):</td> <td> <?php _e(luc_print_uas($qrya)); ?> </td> </tr> </tbody> </table> <?php $geoip = luc_GeoIP_get_data($ip); if ($geoip !== false) { ?> <table class='widefat'> <thead><tr><th scope='col' colspan='4'>GeoIP Information</th></tr></thead> <tbody> <tr> <td><strong>Country:</strong></td> <td> <?php _e($geoip['cn'] . " (" . $geoip['cc'] . ")"); ?> <IMG style='border:0px;height:16px;' alt='$cn' title='$cn' SRC=' <?php _e(STATPRESS_V_PLUGIN_URL . "/images/domain/" . strtolower($geoip['cc']) . '.png'); ?> '></td> <td><strong>Continent Code:</strong></td> <td> <?php _e($geoip['continent_code']); ?> </td> </tr> <tr> <td><strong>Region:</strong></td> <td> <?php _e($geoip['region']); ?> </td> <td><strong>Area Code: (USA Only)</strong></td> <td> <?php _e($geoip['area_code']); ?> </td> </tr> <tr> <td><strong>City:</strong></td> <td> <?php _e($geoip['city']); ?> </td> <td><strong>Postal Code: (USA Only)</strong></td> <td> <?php _e($geoip['postal_code']); ?> </td> </tr> <tr> <td><strong>Latitude/Longitude</strong></td> <td> <a href='http://maps.google.com/maps?q=<?php _e($geoip['latitude'] . "+" . $geoip['longitude']); ?> ' target='_blank' title='Lookup latitude/longitude location on Google Maps...'><?php _e($geoip['latitude'] . " " . $geoip['longitude']); ?> </a></td> <td><strong>Metro Code: (USA Only)</strong></td> <td> <?php _e($geoip['metro_code']); ?> </td> </tr> </tbody> </table> <?php } ?> <table class='widefat'> <thead> <tr> <th scope='col' colspan='6'>URLs Requested</th> </tr> </thead> <thead> <tr> <th scope='col'>Date</th> <th scope='col'>Time</th> <th scope='col'>OS</th> <th scope='col'>Browser</th> <th scope='col'>Agent</th> <th scope='col'>Referrer</th> <th scope='col'>URL Requested</th> </tr> </thead> <tbody> <?php foreach ($qry as $rk) { ?> <tr> <td> <?php _e(luc_hdate($rk->date)); ?> </td> <td> <?php _e($rk->time); ?> </td> <td> <?php _e(luc_HTML_IMG($rk->os, 'os', $text_OS)); ?> </td> <td> <?php _e(luc_HTML_IMG($rk->browser, 'browser', $text_browser)); ?> </td> <td> <?php _e($rk->agent); ?> </td> <td> <?php _e($rk->referrer); ?> </td> <td> <?php _e(luc_post_title_Decode($rk->urlrequested)); ?> </td> </tr> </tbody> <?php } ?> </table> </div> </form> <?php luc_StatPressV_load_time(); }
function luc_options() { global $wpdb, $StatPressV_Option; $table_name = STATPRESS_V_TABLE_NAME; if ($_POST['saveit'] == 'yes') { // General Tab $StatPressV_Option['StatPressV_Hide_Page_Feeds'] = isset($_POST['StatPressV_Hide_Page_Feeds']) ? $_POST['StatPressV_Hide_Page_Feeds'] : ''; $StatPressV_Option['StatPressV_Hide_Page_Referrer'] = isset($_POST['StatPressV_Hide_Page_Referrer']) ? $_POST['StatPressV_Hide_Page_Referrer'] : ''; $StatPressV_Option['StatPressV_Hide_Page_SpyBot'] = isset($_POST['StatPressV_Hide_Page_SpyBot']) ? $_POST['StatPressV_Hide_Page_SpyBot'] : ''; $StatPressV_Option['StatPressV_Hide_Page_SpyVisitors'] = isset($_POST['StatPressV_Hide_Page_SpyVisitors']) ? $_POST['StatPressV_Hide_Page_SpyVisitors'] : ''; $StatPressV_Option['StatPressV_Hide_Page_Stats'] = isset($_POST['StatPressV_Hide_Page_Stats']) ? $_POST['StatPressV_Hide_Page_Stats'] : ''; $StatPressV_Option['StatPressV_Hide_Page_Update'] = isset($_POST['StatPressV_Hide_Page_Update']) ? $_POST['StatPressV_Hide_Page_Update'] : ''; $StatPressV_Option['StatPressV_Hide_Page_View'] = isset($_POST['StatPressV_Hide_Page_View']) ? $_POST['StatPressV_Hide_Page_View'] : ''; $StatPressV_Option['StatPressV_Hide_Page_Visitors'] = isset($_POST['StatPressV_Hide_Page_Visitors']) ? $_POST['StatPressV_Hide_Page_Visitors'] : ''; $StatPressV_Option['StatPressV_Hide_Page_Posts_Pages'] = isset($_POST['StatPressV_Hide_Page_Posts_Pages']) ? $_POST['StatPressV_Hide_Page_Posts_Pages'] : ''; $StatPressV_Option['StatPressV_Use_Widget_Dashboard'] = isset($_POST['StatPressV_Use_Widget_Dashboard']) ? $_POST['StatPressV_Use_Widget_Dashboard'] : ''; $StatPressV_Option['StatPressV_MinPermit'] = isset($_POST['StatPressV_MinPermit']) ? $_POST['StatPressV_MinPermit'] : $StatPressV_Option['StatPressV_MinPermit']; // Data Collection and Retention $StatPressV_Option['StatPressV_Dont_Collect_Logged_User'] = isset($_POST['StatPressV_Dont_Collect_Logged_User']) ? $_POST['StatPressV_Dont_Collect_Logged_User'] : ''; $StatPressV_Option['StatPressV_Dont_Collect_Logged_User_MinPermit'] = isset($_POST['StatPressV_Dont_Collect_Logged_User_MinPermit']) ? $_POST['StatPressV_Dont_Collect_Logged_User_MinPermit'] : ''; $StatPressV_Option['StatPressV_Dont_Collect_Spider'] = isset($_POST['StatPressV_Dont_Collect_Spider']) ? $_POST['StatPressV_Dont_Collect_Spider'] : ''; $StatPressV_Option['StatPressV_AutoDelete'] = isset($_POST['StatPressV_AutoDelete']) ? $_POST['StatPressV_AutoDelete'] : ''; $StatPressV_Option['StatPressV_AutoDelete_Spider'] = isset($_POST['StatPressV_AutoDelete_Spider']) ? $_POST['StatPressV_AutoDelete_Spider'] : ''; // Pages Options $StatPressV_Option['StatPressV_Rows_Per_Latest'] = isset($_POST['StatPressV_Rows_Per_Latest']) ? $_POST['StatPressV_Rows_Per_Latest'] : $StatPressV_Option['StatPressV_Rows_Per_Latest']; $StatPressV_Option['StatPressV_Graph_Days'] = isset($_POST['StatPressV_Graph_Days']) ? $_POST['StatPressV_Graph_Days'] : $StatPressV_Option['StatPressV_Graph_Days']; $StatPressV_Option['StatPressV_Graph_Height_Overview'] = isset($_POST['StatPressV_Graph_Height_Overview']) ? $_POST['StatPressV_Graph_Height_Overview'] : $StatPressV_Option['StatPressV_Graph_Height_Overview']; $StatPressV_Option['StatPressV_Graph_Height_Subpages'] = isset($_POST['StatPressV_Graph_Height_Subpages']) ? $_POST['StatPressV_Graph_Height_Subpages'] : $StatPressV_Option['StatPressV_Graph_Height_Subpages']; $StatPressV_Option['StatPressV_Graphs_Per_Page'] = isset($_POST['StatPressV_Graphs_Per_Page']) ? $_POST['StatPressV_Graphs_Per_Page'] : $StatPressV_Option['StatPressV_Graphs_Per_Page']; $StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] = isset($_POST['StatPressV_SpyVisitor_IP_Per_Page']) ? $_POST['StatPressV_SpyVisitor_IP_Per_Page'] : $StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page']; $StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] = isset($_POST['StatPressV_SpyVisitor_Visits_Per_IP']) ? $_POST['StatPressV_SpyVisitor_Visits_Per_IP'] : $StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP']; $StatPressV_Option['StatPressV_SpyBot_Bots_Per_Page'] = isset($_POST['StatPressV_SpyBot_Bots_Per_Page']) ? $_POST['StatPressV_SpyBot_Bots_Per_Page'] : $StatPressV_Option['StatPressV_SpyBot_Bots_Per_Page']; $StatPressV_Option['StatPressV_SpyBot_Visits_Per_Bot'] = isset($_POST['StatPressV_SpyBot_Visits_Per_Bot']) ? $_POST['StatPressV_SpyBot_Visits_Per_Bot'] : $StatPressV_Option['StatPressV_SpyBot_Visits_Per_Bot']; $StatPressV_Option['StatPressV_Dont_Show_Browser_name'] = isset($_POST['StatPressV_Dont_Show_Browser_name']) ? $_POST['StatPressV_Dont_Show_Browser_name'] : ''; $StatPressV_Option['StatPressV_Dont_Show_OS_name'] = isset($_POST['StatPressV_Dont_Show_OS_name']) ? $_POST['StatPressV_Dont_Show_OS_name'] : ''; // GeoIP $StatPressV_Option['StatPressV_Use_GeoIP'] = isset($_POST['StatPressV_Use_GeoIP']) ? $_POST['StatPressV_Use_GeoIP'] : ''; $StatPressV_Option['StatPressV_locate_IP'] = isset($_POST['StatPressV_locate_IP']) ? $_POST['StatPressV_locate_IP'] : $StatPressV_Option['StatPressV_locate_IP']; update_option('StatPressV_Option', $StatPressV_Option); echo "<div class='updated fade'><p>Options saved.</p></div>"; } ?> <div class='wrap'> <h2>Options</h2> <form method=post> <div class="tabbed"> <!-- The tabs --> <ul> <li><a href="#tabs-1">General</a></li> <li><a href="#tabs-2">Data Collection and Retention</a></li> <li><a href="#tabs-3">Pages Options</a></li> <li><a href="#tabs-4">GeoIP</a></li> </ul> <!-- tab 1 --> <div id="tabs-1"> <table class=widefat> <thead><tr> <th scope='col' colspan='2'>Hide pages in admin interface (reduces memory use)</th> </tr></thead> <tbody> <tr> <td> <input type=checkbox name='StatPressV_Hide_Page_Posts_Pages' id='StatPressV_Hide_Page_Posts_Pages' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_Posts_Pages']; ?> /> <label for='StatPressV_Hide_Page_Posts_Pages'>Yesterday </label><br /> <input type=checkbox name='StatPressV_Hide_Page_SpyVisitors' id='StatPressV_Hide_Page_SpyVisitors' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_SpyVisitors']; ?> /> <label for='StatPressV_Hide_Page_SpyVisitors'>Visitor Spy </label><br /> <input type=checkbox name='StatPressV_Hide_Page_SpyBot' id='StatPressV_Hide_Page_SpyBot' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_SpyBot']; ?> /> <label for='StatPressV_Hide_Page_SpyBot'>Bot Spy </label><br /> <input type=checkbox name='StatPressV_Hide_Page_Visitors' id='StatPressV_Hide_Page_Visitors' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_Visitors']; ?> /> <label for='StatPressV_Hide_Page_Visitors'>Visitors </label><br /> <input type=checkbox name='StatPressV_Hide_Page_View' id='StatPressV_Hide_Page_View' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_View']; ?> /> <label for='StatPressV_Hide_Page_View'>View </label><br /> <input type=checkbox name='StatPressV_Hide_Page_Feeds' id='StatPressV_Hide_Page_Feeds' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_Feeds']; ?> /> <label for='StatPressV_Hide_Page_Feeds'>Feeds </label><br /> <input type=checkbox name='StatPressV_Hide_Page_Referrer' id='StatPressV_Hide_Page_Referrer' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_Referrer']; ?> /> <label for='StatPressV_Hide_Page_Referrer'>Referrer </label><br /> <input type=checkbox name='StatPressV_Hide_Page_Stats' id='StatPressV_Hide_Page_Stats' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_Stats']; ?> /> <label for='StatPressV_Hide_Page_Stats'>Statistics </label><br /> <input type=checkbox name='StatPressV_Hide_Page_Update' id='StatPressV_Hide_Page_Update' value='checked' <?php echo $StatPressV_Option['StatPressV_Hide_Page_Update']; ?> /> <label for='StatPressV_Hide_Page_Update'>Update database </label><br /> </td> <td> </td> </tr> </tbody> <thead><tr> <th scope='col' colspan='2'>Dashboard widget</th> </tr></thead> <tbody> <tr> <td> <input type=checkbox name='StatPressV_Use_Widget_Dashboard' id='StatPressV_Use_Widget_Dashboard' value='checked' <?php echo $StatPressV_Option['StatPressV_Use_Widget_Dashboard']; ?> /> <label for='StatPressV_Use_Widget_Dashboard'>Enable</label><br /> </td> <td> </td> </tr> </tbody> <thead><tr> <th scope='col' colspan='2'>Access Control</th> </tr></thead> <tbody> <tr> <td width=200px>Minimum capability to view statistics</td> <td> <select name="StatPressV_MinPermit"> <?php luc_dropdown_caps($StatPressV_Option['StatPressV_MinPermit']); ?> </select> <a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">more info</a> </td> </tr> </table> </div> <!-- tab 2 --> <div id="tabs-2"> <table class=widefat> <thead><tr> <th scope='col' colspan='2'>Data Collection</th> </tr></thead> <tbody> <tr> <td colspan='2'> <input type=checkbox name='StatPressV_Dont_Collect_Logged_User' id='StatPressV_Dont_Collect_Logged_User' value='checked' <?php echo $StatPressV_Option['StatPressV_Dont_Collect_Logged_User']; ?> > <label for='StatPressV_Dont_Collect_Logged_User'>Do not collect data about logged users who have at least these capability</label> <select name="StatPressV_Dont_Collect_Logged_User_MinPermit"><?php luc_dropdown_caps($StatPressV_Option['StatPressV_Dont_Collect_Logged_User_MinPermit']); ?> </select> <a href="http://codex.wordpress.org/Roles_and_Capabilities" target='_blank'>more info</a> <br> <input type=checkbox name='StatPressV_Dont_Collect_Spider' id='StatPressV_Dont_Collect_Spider' value='checked' <?php echo $StatPressV_Option['StatPressV_Dont_Collect_Spider']; ?> > <label for='StatPressV_Dont_Collect_Spider'>Do not collect spiders visits</label> </td> </tr> </tbody> <thead><tr> <th scope='col' colspan='2'>Data Retention</th> </tr></thead> <tbody> <tr> <td width=200px>Automatically delete visits older than </td> <td> <select name="StatPressV_AutoDelete"> <option value="" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == '') { print "selected"; } ?> >Never delete !</option> <option value="1 week" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == "1 week") { print "selected"; } ?> >1 week</option> <option value="2 week" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == "2 weeks") { print "selected"; } ?> >2 weeks</option> <option value="1 month" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == "1 month") { print "selected"; } ?> >1 month</option> <option value="3 months" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == "3 months") { print "selected"; } ?> >3 months</option> <option value="6 months" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == "6 months") { print "selected"; } ?> >6 months</option> <option value="1 year" <?php if ($StatPressV_Option['StatPressV_AutoDelete'] == "1 year") { print "selected"; } ?> >1 year</option> </select> </td> </tr> <td width=200px>Automatically delete spider visits older than </td> <td> <select name="StatPressV_AutoDelete_spider"> <option value="" <?php if ($StatPressV_Option['StatPressV_AutoDelete_Spider'] == '') { print "selected"; } ?> >Never delete !</option> <option value="1 day" <?php if ($StatPressV_Option['StatPressV_AutoDelete_Spider'] == "1 day") { print "selected"; } ?> >1 day</option> <option value="1 week" <?php if ($StatPressV_Option['StatPressV_AutoDelete_Spider'] == "1 week") { print "selected"; } ?> >1 week</option> <option value="1 month" <?php if ($StatPressV_Option['StatPressV_AutoDelete_Spider'] == "1 month") { print "selected"; } ?> >1 month</option> <option value="1 year" <?php if ($StatPressV_Option['StatPressV_AutoDelete_Spider'] == "1 year") { print "selected"; } ?> >1 year</option> </select> </td> </tr> </tbody> </table> </div> <!-- tab 3 --> <div id="tabs-3"> <table class=widefat> <thead><tr> <th scope='col' colspan='3'>Main page :</th> </tr> </thead> <tbody> <tr><td colspan='2'> <input type=checkbox name='StatPressV_Dont_Show_OS_name' id='StatPressV_Dont_Show_OS_name' value='checked' <?php echo $StatPressV_Option['StatPressV_Dont_Show_OS_name']; ?> > <label for='StatPressV_Dont_Show_OS_name'>Dont show the name of OS</label> <br> <input type=checkbox name='StatPressV_Dont_Show_Browser_name' id='StatPressV_Dont_Show_Browser_name' value='checked' <?php echo $StatPressV_Option['StatPressV_Dont_Show_Browser_name']; ?> > <label for='StatPressV_Dont_Show_Browser_name'>Dont show the name of browsers</label> <br> </td><td></td></tr> <tr> <td >'Latest' Reports : Default number of rows</td> <td> <select name="StatPressV_Rows_Per_Latest"> <option value="5" <?php if ($StatPressV_Option['StatPressV_Rows_Per_Latest'] == 5) { echo "selected"; } ?> >5</option> <option value="10" <?php if ($StatPressV_Option['StatPressV_Rows_Per_Latest'] == 10) { echo "selected"; } ?> >10</option> <option value="25" <?php if ($StatPressV_Option['StatPressV_Rows_Per_Latest'] == 25) { echo "selected"; } ?> >25</option> <option value="50" <?php if ($StatPressV_Option['StatPressV_Rows_Per_Latest'] == 50) { echo "selected"; } ?> >50</option> </select> </td><td></td> </tr> </tbody> <thead><tr> <th scope='col' colspan='2'>Overview, Visitors, Views, Feeds and Referrer graphs</th> </tr></thead> <tbody> <tr> <td width=200px>Days in graphs</td> <td> <select name="StatPressV_Graph_Days"> <option value="7" <?php if ($StatPressV_Option['StatPressV_Graph_Days'] == 7) { echo "selected"; } ?> >7</option> <option value="15" <?php if ($StatPressV_Option['StatPressV_Graph_Days'] == 15) { echo "selected"; } ?> >15</option> <option value="21" <?php if ($StatPressV_Option['StatPressV_Graph_Days'] == 21) { echo "selected"; } ?> >21</option> <option value="31" <?php if ($StatPressV_Option['StatPressV_Graph_Days'] == 31) { echo "selected"; } ?> >31</option> <option value="62" <?php if ($StatPressV_Option['StatPressV_Graph_Days'] == 62) { echo "selected"; } ?> >62</option> </select> </td> </tr> </tbody> <thead><tr> <th scope='col' colspan='2'>Visitors, views, feeds and referrer graphs</th> </tr></thead> <tbody> <tr> <td width=200px>Graphs per page</td> <td> <select name="StatPressV_Graphs_Per_Page"> <option value="20" <?php if ($StatPressV_Option['StatPressV_Graphs_Per_Page'] == 20) { echo "selected"; } ?> >20</option> <option value="50" <?php if ($StatPressV_Option['StatPressV_Graphs_Per_Page'] == 50) { echo "selected"; } ?> >50</option> <option value="100" <?php if ($StatPressV_Option['StatPressV_Graphs_Per_Page'] == 100) { echo "selected"; } ?> >100</option> </select> </td> </tr> </tbody> <?php if ($StatPressV_Option['StatPressV_Hide_Page_SpyVisitors'] != 'checked' and file_exists(STATPRESS_V_PLUGIN_PATH . 'admin/pages/luc_spyvisitors.php')) { ?> <thead><tr> <th scope='col' colspan='2'>Visitor Spy</th> </tr></thead> <tbody> <tr> <td width=200px>Visitors per page</td> <td> <select name="StatPressV_SpyVisitor_IP_Per_Page"> <option value="20" <?php if ($StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] == 20) { print "selected"; } ?> >20</option> <option value="50" <?php if ($StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] == 50) { print "selected"; } ?> >50</option> <option value="100" <?php if ($StatPressV_Option['StatPressV_SpyVisitor_IP_Per_Page'] == 100) { print "selected"; } ?> >100</option> </select> </td> </tr> <tr> <td width=200px>Visits per visitor</td> <td> <select name="StatPressV_SpyVisitor_Visits_Per_IP"> <option value="20" <?php if ($StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] == 20) { print "selected"; } ?> >20</option> <option value="50" <?php if ($StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] == 50) { print "selected"; } ?> >50</option> <option value="100" <?php if ($StatPressV_Option['StatPressV_SpyVisitor_Visits_Per_IP'] == 100) { print "selected"; } ?> >100</option> </select> </td> </tr> </tbody> <?php } ?> <?php if ($StatPressV_Option['StatPressV_Hide_Page_SpyBot'] != 'checked' and file_exists(STATPRESS_V_PLUGIN_PATH . 'admin/pages/luc_spybot.php')) { ?> <thead><tr> <th scope='col' colspan='2'>Bots Spy</th> </tr></thead> <tbody> <tr> <td width=200px>Bots per page</td> <td> <select name="StatPressV_SpyBot_Bots_Per_Page"> <option value="5" <?php if ($StatPressV_Option['StatPressV_SpyBot_Bots_Per_Page'] == 5) { print "selected"; } ?> >5</option> <option value="10" <?php if ($StatPressV_Option['StatPressV_SpyBot_Bots_Per_Page'] == 10) { print "selected"; } ?> >10</option> <option value="20" <?php if ($StatPressV_Option['StatPressV_SpyBot_Bots_Per_Page'] == 20) { print "selected"; } ?> >20</option> </select> </td> </tr> <tr> <td width=200px>Visits per bot</td> <td> <select name="StatPressV_SpyBot_Visits_Per_Bot"> <option value="20" <?php if ($StatPressV_Option['StatPressV_SpyBot_Visits_Per_Bot'] == 20) { print "selected"; } ?> >20</option> <option value="50" <?php if ($StatPressV_Option['StatPressV_SpyBot_Visits_Per_Bot'] == 50) { print "selected"; } ?> >50</option> <option value="100" <?php if ($StatPressV_Option['StatPressV_SpyBot_Visits_Per_Bot'] == 100) { print "selected"; } ?> >100</option> </select> </td> </tr> </tbody> <?php } ?> </table> </div> <!-- tab 4 --> <div id="tabs-4"> <?php // Use GeoIP? http://geolite.maxmind.com/download/geoip/api/php/ if ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked' and !function_exists('geoip_open')) { include STATPRESS_V_PLUGIN_PATH . 'GeoIP/geoipcity.inc'; } luc_GeoIP(); ?> </div> </div><!-- tabbed --> <br> <input type=submit value='Save options' class="button-primary"> <input type=hidden name=saveit value=yes> <input type=hidden name=page value=statpressV> <input type=hidden name=statpressV_action value=options> </form> </div> <?php luc_StatPressV_load_time(); }
function luc_update() { global $wpdb, $StatPressV_Option; $table_name = STATPRESS_V_TABLE_NAME; $action = "update"; if ($_POST['updatenow'] == 'Update Now') { $date_from = gmdate('Ymd', strtotime($_POST['datefrom'])); $date_to = gmdate('Ymd', strtotime($_POST['dateto'])); if ($date_to < $date_from) { $date = $date_from; $date_from = $date_to; $date_to = $date; } $wpdb->flush(); $text = ""; echo "<table class='widefat'>"; foreach ($_POST['update'] as $post) { if ($post == 'Browsers') { $text = luc_update_Browsers($text, $date_from, $date_to); } if ($post == 'OS') { $text = luc_update_OS($text, $date_from, $date_to); } if ($post == 'SearchEngines') { $text = luc_update_SearchEngine($text, $date_from, $date_to); } if ($post == 'Spiders' and $StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') { $text = luc_update_Spiders($text, $date_from, $date_to); } if ($post == 'GeoIP') { $text = luc_update_GeoIP($text, $date_from, $date_to); } } // echo "</tbody>"; } $up = "Update StatPress Visitors database from definition files"; echo "<div class='wrap'><h2>" . $up . "</h2>"; ?> <script> function toggle(source) { checkboxes = document.getElementsByName('update[]'); for(var i in checkboxes) checkboxes[i].checked = source.checked; } </script> <form method=post> <table class='widefat'> <thead> <tr> <th>Select definitions to update</th> </tr> </thead> <tbody> <tr><td> <input type="checkbox" name="update[]" id="Browsers" value="Browsers"> <label for="Browsers">Browsers</label> <br> <input type="checkbox" name="update[]" id="OS" value="OS"> <label for="OS">OS</label> <br> <input type="checkbox" name="update[]" id="SearchEngines" value="SearchEngines"> <label for="SearchEngines">Search Engines</label> <?php if ($StatPressV_Option['StatPressV_Dont_Collect_Spider'] == '') { echo '<br> <input type="checkbox" name="update[]" id="Spiders" value="Spiders"> <label for="Spiders">Spiders and Spambots</label>'; } ?> <?php if ($StatPressV_Option['StatPressV_Use_GeoIP'] == 'checked') { echo '<br> <input type="checkbox" name="update[]" id="GeoIP" value="GeoIP"> <label for="GeoIP">GeoIP country information</label>'; } ?> <br><br><input type="checkbox" onClick="toggle(this)" /> Select All </td></tr> <tr><td> Update records from <input type=text name=datefrom value='<?php echo $date_from; ?> ' class='datepicker'> to <input type=text name=dateto value='<?php echo $date_to; ?> ' class='datepicker'> </td></tr> <tr><td> <input type=submit name=updatenow value='Update Now' class='button-primary'> </td></tr> </tbody> </table> </form> <?php luc_StatPressV_load_time(); }
/** * Dashboard widget */ function luc_StatPresV_Dashboard_Widget() { global $wpdb; $table_name = STATPRESS_V_TABLE_NAME; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { die('StatPress is not installed'); } # Table properties $unique_color = "#114477"; $web_color = "#3377B6"; $rss_color = "#f38f36"; $spider_color = "#83b4d8"; $lastmonth = luc_StatPress_lastmonth(); $thismonth = gmdate('Ym', current_time('timestamp')); $yesterday = gmdate('Ymd', current_time('timestamp') - 86400); $today = gmdate('Ymd', current_time('timestamp')); $tlm[0] = substr($lastmonth, 0, 4); $tlm[1] = substr($lastmonth, 4, 2); print "<table class='widefat'><thead><tr>\n\t\t\t<th scope='col'></th>\n\t\t\t<th scope='col'>" . __('Total', 'statpress') . "</th>\n\t\t\t<th scope='col'>" . __('Yesterday', 'statpress') . "<br /><font size=1>" . gmdate('d M, Y', current_time('timestamp') - 86400) . "</font></th>\n\t\t\t<th scope='col'>" . __('Today', 'statpress') . "<br /><font size=1>" . gmdate('d M, Y', current_time('timestamp')) . "</font></th>\n\t\t\t</tr></thead>\n\t\t\t<tbody id='the-list'>"; ################################################################################################ # VISITORS ROW print "<tr><td>" . __('Visitors', 'statpress') . "</td>"; #TOTAL $qry_total = $wpdb->get_var("\n\t\t\t\t\tSELECT count(DISTINCT ip)\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed = ''\n\t\t\t\t\t\tAND spider = ''\n\t\t\t\t\t"); echo "<td>" . $qry_total . "</td>\n"; $qry = $wpdb->get_results("\n\t\t\t\t\tSELECT date, COUNT(DISTINCT ip) as total\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed = ''\n\t\t\t\t\t\tAND spider = ''\n\t\t\t\t\t\tAND date BETWEEN {$yesterday} AND {$today}\n\t\t\t\t\tGROUP BY date"); echo luc_print_dashstats($yesterday, $today, $qry); echo "</tr>"; ################################################################################################ # PAGE VIEWS ROW print "<tr><td>" . __('Page Views', 'statpress') . "</td>"; #TOTAL $qry_total = $wpdb->get_var("\n\t\t\t\t\tSELECT COUNT(date)\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed = ''\n\t\t\t\t\t\tAND spider = ''\n\t\t\t\t\t"); echo "<td>" . $qry_total . "</td>\n"; $qry = $wpdb->get_results("\n\t\t\t\t\tSELECT date, COUNT(date) as total\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed = ''\n\t\t\t\t\t\tAND spider = ''\n\t\t\t\t\t\tAND date BETWEEN {$yesterday} AND {$today}\n\t\t\t\t\tGROUP BY date"); echo luc_print_dashstats($yesterday, $today, $qry); echo "</tr>"; ################################################################################################ # SPIDERS ROW print "<tr><td>Spiders</td>"; #TOTAL $qry_total = $wpdb->get_var("\n\t\t\t\t\tSELECT COUNT(date)\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed = ''\n\t\t\t\t\t\tAND spider <> ''\n\t\t\t\t\t"); print "<td>" . $qry_total . "</td>\n"; $qry = $wpdb->get_results("\n\t\t\t\t\tSELECT date, COUNT(date) as total\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed = ''\n\t\t\t\t\t\tAND spider <> ''\n\t\t\t\t\t\tAND date BETWEEN {$yesterday} AND {$today}\n\t\t\t\t\tGROUP BY date"); echo luc_print_dashstats($yesterday, $today, $qry); echo "</tr>"; ################################################################################################ # FEEDS ROW print "<tr><td>Feeds</td>"; #TOTAL $qry_total = $wpdb->get_var("\n\t\t\t\t\tSELECT count(date)\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed <> ''\n\t\t\t\t\t\tAND spider = ''\n\t\t\t\t\t"); print "<td>" . $qry_total . "</td>\n"; $qry = $wpdb->get_results("\n\t\t\t\t\tSELECT date, COUNT(date) as total\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tWHERE feed <> ''\n\t\t\t\t\t\tAND spider = ''\n\t\t\t\t\t\tAND date BETWEEN {$yesterday} AND {$today}\n\t\t\t\t\tGROUP BY date"); echo luc_print_dashstats($yesterday, $today, $qry); echo "</tr>"; ################################################################################################## $qry_s = $wpdb->get_var("\n\t\t\t\t\tSELECT date\n\t\t\t\t\tFROM {$table_name}\n\t\t\t\t\tLIMIT 1;\n\t\t\t\t\t"); $cstart = strtotime($qry_s); $cstart = date("d.m.Y", $cstart); print "<tr><td><i>Counter Start</i></td>"; print "<td colspan='3'><i>{$cstart}</i></td>\n"; print "</table><br />\n\n"; // More Details link print "<div class='wrap'><a href='admin.php?page=statpress-visitors/admin/luc_admin.php'>" . __('More details', 'statpress') . " »</a></div>"; luc_StatPressV_load_time(); }