get_var("SHOW TABLES LIKE '$table_name'") != $table_name) or ($AnalyticStats_Option['AnalyticStats_DB_Version'] <> AnalyticStats_DB_VERSION)) {$wpdb->query("ALTER TABLE $table_name DROP COLUMN threat_score"); $wpdb->query("ALTER TABLE $table_name DROP COLUMN threat_type"); $AnalyticStats_Option['AnalyticStats_DB_Version'] = AnalyticStats_DB_VERSION; update_option('AnalyticStats_Option', $AnalyticStats_Option); luc_AnalyticStats_CreateTable(); }; $mincap = $AnalyticStats_Option['AnalyticStats_MinPermit']; if ($mincap == '') $mincap = 'switch_themes'; if (isset($_GET['AnalyticStats-action'])) { if ($_GET['AnalyticStats-action'] == 'updategeoipdat') luc_GeoIP_update_db('country'); if ($_GET['AnalyticStats-action'] == 'updategeoipcitydat') luc_GeoIP_update_db('city'); } // add submenu add_menu_page('Stats', 'Stats', $mincap, __FILE__, 'luc_main',AnalyticStats_PLUGIN_URL.'/images/stat.png'); add_submenu_page(__FILE__, __('Visitor Spy', 'AnalyticStats'), __('Visitor Spy', 'AnalyticStats'), $mincap,'AnalyticStats/action=spyvisitors', 'luc_spy_visitors'); if ($AnalyticStats_Option['AnalyticStats_Dont_Collect_Spider'] == '') add_submenu_page(__FILE__, __('Bot Spy', 'AnalyticStats'), __('Bot Spy', 'AnalyticStats'), $mincap,'AnalyticStats/action=spybot', 'luc_spy_bot'); add_submenu_page(__FILE__, __('Yesterday ', 'AnalyticStats'), __('Yesterday ', 'AnalyticStats'), $mincap,'AnalyticStats/action=yesterday', 'luc_yesterday'); add_submenu_page(__FILE__, __('Referrer', 'AnalyticStats'), __('Referrer', 'AnalyticStats'), $mincap, 'AnalyticStats/action=referrer', 'luc_AnalyticStats_referrer'); add_submenu_page(__FILE__, __('URL Monitoring', 'AnalyticStats'), __('URL Monitoring', 'AnalyticStats'), $mincap, 'AnalyticStats/action=urlmonitoring', 'luc_AnalyticStats_url_monitoring'); add_submenu_page(__FILE__, __('Statistics', 'AnalyticStats'), __('Statistics', 'AnalyticStats'), $mincap,'AnalyticStats/action=details','luc_statistics'); add_submenu_page(__FILE__, __('Options', 'AnalyticStats'), __('Options', 'AnalyticStats'), $mincap,'AnalyticStats/action=options', 'luc_Options'); } function luc_AnalyticStats_load_time() { echo "
Stats page generated in " . timer_stop(0,2) . " seconds with ".get_num_queries()." SQL queries.
"; } function AnalyticStats_admin_init() { global $wpdb,$AnalyticStats_Option; // Add JQuery support wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); // jQuery Tabs wp_enqueue_script('jquery-ui-tabs'); // jQuery Pagination //wp_enqueue_script('jquery-pagination', AnalyticStats_PLUGIN_URL . '/js/jquery.pagination.js', array ('jquery', 'jquery-ui-core')); // Add AJAX support wp_enqueue_script('luc-ajax-geoip', AnalyticStats_PLUGIN_URL . '/js/luc.ajax.geoip.js', array ('jquery')); //wp_enqueue_script('luc-ajax-pagination', AnalyticStats_PLUGIN_URL . '/js/luc.ajax.pagination.js', array ('jquery')); wp_enqueue_script('luc-ajax-tables', AnalyticStats_PLUGIN_URL . '/js/luc.ajax.tables.js', array ('jquery')); // jQuery CSS wp_enqueue_style('wp_customtextCSS', AnalyticStats_PLUGIN_URL . '/css/style.css'); wp_enqueue_style('jquery.ui.theme', AnalyticStats_PLUGIN_URL . '/css/jquery-ui-1.8.16.custom.css'); wp_enqueue_style('jquery.pagination.theme', AnalyticStats_PLUGIN_URL . '/css/pagination.css'); wp_enqueue_style('jquery.overrides', AnalyticStats_PLUGIN_URL . '/css/jquery.override.css'); // Add AJAX support //wp_enqueue_script('my-ajax-request', AnalyticStats_PLUGIN_URL . '/js/ajax.js', array ('jquery')); // Handlers for AJAX tables in admin add_action('wp_ajax_table_latest_hits', 'luc_main_table_latest_hits'); add_action('wp_ajax_table_latest_search', 'luc_main_table_latest_search'); add_action('wp_ajax_table_latest_referrers', 'luc_main_table_latest_referrers'); add_action('wp_ajax_table_latest_feeds', 'luc_main_table_latest_feeds'); add_action('wp_ajax_table_latest_spiders', 'luc_main_table_latest_spiders'); add_action('wp_ajax_table_latest_spambots', 'luc_main_table_latest_spambots'); add_action('wp_ajax_table_latest_undefagents', 'luc_main_table_latest_undefagents'); //AJAX handler for GeoIP database downloads add_action('wp_ajax_geoipdbupdate', 'luc_GeoIP_update_db'); add_action('wp_ajax_page_views_table', 'luc_callback_page_views_table'); } function luc_Options() { global $wpdb; global $AnalyticStats_Option; if ($_POST['saveit'] == 'yes') { // General Tab $AnalyticStats_Option['AnalyticStats_Use_GeoIP'] = (isset($_POST['AnalyticStats_Use_GeoIP']) ? $_POST['AnalyticStats_Use_GeoIP'] : ''); $AnalyticStats_Option['AnalyticStats_MinPermit'] = (isset($_POST['AnalyticStats_MinPermit']) ? $_POST['AnalyticStats_MinPermit'] : $AnalyticStats_Option['AnalyticStats_MinPermit']); // Data Collection and Retention $AnalyticStats_Option['AnalyticStats_Dont_Collect_Logged_User'] = (isset($_POST['AnalyticStats_Dont_Collect_Logged_User']) ? $_POST['AnalyticStats_Dont_Collect_Logged_User'] : ''); $AnalyticStats_Option['AnalyticStats_Dont_Collect_Logged_User_MinPermit'] = (isset($_POST['AnalyticStats_Dont_Collect_Logged_User_MinPermit']) ? $_POST['AnalyticStats_Dont_Collect_Logged_User_MinPermit'] : ''); $AnalyticStats_Option['AnalyticStats_Dont_Collect_Spider'] = (isset($_POST['AnalyticStats_Dont_Collect_Spider']) ? $_POST['AnalyticStats_Dont_Collect_Spider'] : ''); // Pages Options $AnalyticStats_Option['AnalyticStats_SpyVisitor_IP_Per_Page'] = (isset($_POST['AnalyticStats_SpyVisitor_IP_Per_Page']) ? $_POST['AnalyticStats_SpyVisitor_IP_Per_Page'] : $AnalyticStats_Option['AnalyticStats_SpyVisitor_IP_Per_Page']); $AnalyticStats_Option['AnalyticStats_SpyVisitor_Visits_Per_IP'] = (isset($_POST['AnalyticStats_SpyVisitor_Visits_Per_IP']) ? $_POST['AnalyticStats_SpyVisitor_Visits_Per_IP'] : $AnalyticStats_Option['AnalyticStats_SpyVisitor_Visits_Per_IP']); $AnalyticStats_Option['AnalyticStats_Rows_Per_Latest'] = (isset($_POST['AnalyticStats_Rows_Per_Latest']) ? $_POST['AnalyticStats_Rows_Per_Latest'] : $AnalyticStats_Option['AnalyticStats_Rows_Per_Latest']); $AnalyticStats_Option['AnalyticStats_Show_Browser_name']= (isset($_POST['AnalyticStats_Show_Browser_name']) ? $_POST['AnalyticStats_Show_Browser_name'] : ''); $AnalyticStats_Option['AnalyticStats_Show_OS_name']= (isset($_POST['AnalyticStats_Show_OS_name']) ? $_POST['AnalyticStats_Show_OS_name'] : ''); $AnalyticStats_Option['AnalyticStats_Show_domain_name']= (isset($_POST['AnalyticStats_Show_domain_name']) ? $_POST['AnalyticStats_Show_domain_name'] : ''); $AnalyticStats_Option['AnalyticStats_locate_IP']= (isset($_POST['AnalyticStats_locate_IP']) ? $_POST['AnalyticStats_locate_IP'] : $AnalyticStats_Option['AnalyticStats_locate_IP']); update_option('AnalyticStats_Option', $AnalyticStats_Option); echo "

" . __('Recorded !', 'AnalyticStats') . "

"; } ?>

Options

Data Collection
> more info
>
Access Control
Minimum capability to view statistics more info
Main page :
>
>
'Latest' Reports : Default number of rows
Visitor Spy
Visitors per page
Visits per visitor  

0) { $p = strpos($surl, 'url='); if ($p === false) return $surl; $surl = substr($surl, 0, $p); } return $surl; } function luc_main_table_latest_hits() { global $wpdb; global $AnalyticStats_Option; $table_name = AnalyticStats_TABLE_NAME; $querylimit = (isset ($_POST['hitsrows']) ? $_POST['hitsrows'] : $AnalyticStats_Option['AnalyticStats_Rows_Per_Latest']); ?>
User"; ?> get_results("SELECT date, time, ip,urlrequested, os, browser,feed,user, language, country, post_title FROM $table_name WHERE (os<>'' OR browser <>'') AND spider NOT LIKE '%Spam Bot%' ORDER BY id DESC LIMIT $querylimit;"); $text_OS = ($AnalyticStats_Option['AnalyticStats_Show_OS_name']=='checked') ? true : false; $text_browser =($AnalyticStats_Option['AnalyticStats_Show_Browser_name']=='checked' )? true : false; foreach ($rks as $rk) { echo ""; echo " "; echo ((isset($rk->post_title)) ?"" :""); echo ""; if (($AnalyticStats_Option['AnalyticStats_Dont_Collect_Logged_User'] != 'checked') or (($AnalyticStats_Option['AnalyticStats_Dont_Collect_Logged_User'] == 'checked')and (current_user_can($AnalyticStats_Option['AnalyticStats_Dont_Collect_Logged_User_MinPermit'])))) {echo (($rk->user != '') ? "" : "");} echo " "; } ?>
Date Time IP Language Country Page OS Browser Feed
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . "" . luc_language($rk) . " " . luc_HTML_IMG($rk->country, 'country', false) . "" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "" . luc_HTML_IMG($rk->os, 'os', $text_OS) . " " . luc_HTML_IMG($rk->browser, 'browser', $text_browser) . "" .$rk->user. " " . luc_HTML_IMG($rk->feed, 'feed', false) . "
get_results("SELECT date, time, ip, urlrequested, referrer, search, searchengine, os, language, country, post_title FROM $table_name WHERE search<>'' ORDER BY id DESC LIMIT $querylimit;"); foreach ($qry as $rk) { echo ""; echo " "; echo ((isset($rk->post_title)) ?"" :""); echo ""; } ?>
Date Time IP Language Country Terms Page Engine
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . "" . luc_language($rk) . " " . luc_HTML_IMG($rk->country, 'country', false) . " " . urldecode($rk->search) . "" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "" . luc_HTML_IMG($rk->searchengine, 'searchengine', false) . "
Domain" ?> get_results("SELECT date, time, ip, referrer, urlrequested, os, language, country, post_title FROM $table_name WHERE (referrer NOT LIKE '" . get_option('home') . "%') AND spider='' AND referrer <>'' AND searchengine='' ORDER BY id DESC LIMIT $querylimit;"); foreach ($qry as $rk) { echo ""; echo " "; echo ((isset($rk->post_title)) ?"" :""); echo "\n"; } ?>
Date Time IP Language Country URL Page
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . "" . luc_language($rk) . " " . luc_HTML_IMG($rk->country, 'country', false) . " " . urldecode($rk->referrer) . "" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "
Domain" ?> User"; ?> get_results("SELECT date, time, ip, urlrequested, feed, language, country, post_title FROM $table_name WHERE feed<>'' AND spider='' ORDER BY id DESC LIMIT $querylimit;"); foreach ($qry as $rk) { echo ""; echo " "; echo ((isset($rk->post_title)) ?"" :""); echo ""; if ($AnalyticStats_Option['AnalyticStats_Dont_Collect_Logged_User'] != 'checked') echo ($rk->user != '') ? "": ""; echo ""; } ?>
Date Time IP Language Country Page Feed
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . "" . luc_language($rk) . " " . luc_HTML_IMG($rk->country, 'country', false) . "" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "" . luc_HTML_IMG($rk->feed, 'feed', true) . "" . $rk->user . " 
get_results("SELECT date, time, ip, urlrequested, spider, agent, post_title FROM $table_name WHERE spider<>'' AND spider NOT LIKE '%spam bot' ORDER BY id DESC LIMIT $querylimit;"); foreach ($qry as $rk) { echo ""; echo ((isset($rk->post_title)) ?"" :""); echo ""; } ?>
Date Time IP Page Agent
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . " " . luc_HTML_IMG($rk->spider, 'spider', false) . "" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). " " . $rk->agent . "
get_results("SELECT date, time, ip, agent, COUNT(ip) AS ipcount FROM $table_name WHERE spider LIKE '%spam bot' GROUP BY ip,agent ORDER BY id DESC LIMIT $querylimit;"); foreach ($qry as $rk) { echo ""; } ?>
Date Time IP Agent Count
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . " " . $rk->agent . " " . $rk->ipcount . "
" . $str . ""; } return $href; } function luc_main_table_latest_undefagents() { global $wpdb; global $AnalyticStats_Option; $table_name = AnalyticStats_TABLE_NAME; $querylimit = (isset ($_POST['undefagentsrows']) ? $_POST['undefagentsrows'] : $AnalyticStats_Option['AnalyticStats_Rows_Per_Latest']); ?> get_results("SELECT date, time, ip, urlrequested, agent, post_title FROM $table_name WHERE (os='' OR browser='') AND searchengine='' AND spider='' GROUP BY ip,agent ORDER BY id DESC LIMIT $querylimit;"); foreach ($qry as $rk) { echo ""; echo ((isset($rk->post_title)) ?"" :""); } ?>
Date Time IP Agent Page
" . luc_hdate($rk->date) . " " . $rk->time . " " . luc_create_href($rk->ip, 'ip') . " " . $rk->agent . " " .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "

" . __('Overview', 'AnalyticStats') . "

"; // VISITORS ROW luc_ROW ("DISTINCT ip","feed=''","spider=''",$visitors_color,"Visitors"); // VISITORS FEEDS ROW luc_ROW ("DISTINCT ip","feed<>''","spider=''",$rss_visitors_color,"Visitors RSS Feeds"); // PAGEVIEWS ROW luc_ROW ("*","feed=''","spider=''",$pageviews_color,"Pageviews"); // PAGEVIEWS FEEDS ROW luc_ROW ("*","feed<>''","spider=''",$rss_pageviews_color,"Pageviews RSS Feeds"); // SPIDERS ROW if ($AnalyticStats_Option['AnalyticStats_Dont_Collect_Spider'] != 'checked') luc_ROW ("*","feed=''","spider<>''",$spider_color,"Spiders"); ?>
Yesterday
" . gmdate('d M, Y', current_time('timestamp')-86400) ."
Today
" . gmdate('d M, Y', current_time('timestamp')) ."
Rows:
Rows:
Rows:
Rows:
Rows:

Latest Spambots

Rows:
"; echo "
"; echo " ". __('AnalyticStats table size', 'AnalyticStats').": " . luc_tablesize($wpdb->prefix. 'AnalyticStats') . "
"; echo " ". __('AnalyticStats current time', 'AnalyticStats').": ".current_time('mysql')."
"; echo " ". __('RSS2 url', 'AnalyticStats').": ".get_bloginfo('rss2_url').'('.luc_AnalyticStats_extractfeedreq(get_bloginfo('rss2_url')).")
"; echo " ". __('ATOM url', 'AnalyticStats').": ".get_bloginfo('atom_url').'('.luc_AnalyticStats_extractfeedreq(get_bloginfo('atom_url')).")
"; echo " ". __('RSS url', 'AnalyticStats').": ".get_bloginfo('rss_url').'('.luc_AnalyticStats_extractfeedreq(get_bloginfo('rss_url')).")
"; echo " ". __('COMMENT RSS2 url', 'AnalyticStats').": ".get_bloginfo('comments_rss2_url').' ('.luc_AnalyticStats_extractfeedreq(get_bloginfo('comments_rss2_url')).")
"; echo " ". __('COMMENT ATOM url', 'AnalyticStats').": ".get_bloginfo('comments_atom_url').' ('.luc_AnalyticStats_extractfeedreq(get_bloginfo('comments_atom_url')).")
"; luc_AnalyticStats_load_time(); ?>
date] = $qry->num; } echo "
$text ".(($total[$yesterday] != 0) ? $total[$yesterday] :' ') ."\n ".(($total[$today] != 0) ? $total[$today] :' ') ."\n"; } function requete_main($count,$feed,$spider) { global $wpdb; $table_name = AnalyticStats_TABLE_NAME; $qry = $wpdb->get_results("SELECT count($count) AS num, date FROM $table_name WHERE $feed AND $spider GROUP BY date ASC"); return $qry; } function luc_HTML_IMG($key, $type, $showname) { if ($key != '') { $search = strtolower($key); $title = $key; // Look for fields in definition file $lines =($type === "country") ? file(AnalyticStats_PLUGIN_PATH . "/def/domain.dat"):file(AnalyticStats_PLUGIN_PATH . "/def/" . $type . ".dat"); foreach ($lines as $line_num => $line) { $entry = explode("|", strtolower($line)); if (in_array($search, $entry, true)) { // We have a match $title = explode('|',$line); $title = $title[0]; $img = (($type === "country") ? AnalyticStats_PLUGIN_URL . "images/domain/" . $entry[1] . ".png" : AnalyticStats_PLUGIN_URL . "images/" . $type . "/" . str_replace(" ", "_", str_replace(".", "-", $entry[0])) . ".png"); break; } } return ($showname === true )? "$title  $title" : "" . $title . ""; } else return " "; } function luc_language($rk) { if($rk->language != '') { $lines = file(AnalyticStats_PLUGIN_PATH .'/def/languages.dat'); foreach($lines as $line_num => $ligne) { list($langue,$id)=explode("|",$ligne); if($id==$rk->language) break; // break, the language is found } return $langue; } else return " "; } function luc_statistics() { global $wpdb; $querylimit = "LIMIT 10"; # Top days luc_ValueTable2("date","Top days",5); // Search terms luc_ValueTable2("search", __('Top search terms', 'AnalyticStats'), 20, "", "", "AND search<>''"); // Top referrer luc_ValueTable2("referrer", __('Top referrer', 'AnalyticStats'), 10, "", "", "AND referrer<>'' AND referrer NOT LIKE '%" . get_bloginfo('url') . "%'"); // O.S. luc_ValueTable2("os", __('O.S.', 'AnalyticStats'), 0, "", "", "AND feed='' AND spider='' AND os<>''"); // Browser luc_ValueTable2("browser", __('Browser', 'AnalyticStats'), 0, "", "", "AND feed='' AND spider='' AND browser<>''"); // Feeds luc_ValueTable2("feed", __('Feeds', 'AnalyticStats'), 5, "", "", "AND feed<>''"); // SE luc_ValueTable2("searchengine", __('Search engines', 'AnalyticStats'), 10, "", "", "AND searchengine<>''"); // Countries luc_ValueTable2("country", __('Countries ', 'AnalyticStats'), 10, "", "", "AND country<>'' AND spider=''"); // Spider luc_ValueTable2("spider", __('Spiders', 'AnalyticStats'), 10, "", "", "AND spider<>''"); } function luc_page_periode() { global $wpdb; // pp is the display page periode if(isset($_GET['pp'])) { // Get Current page periode from URL $periode = $_GET['pp']; if($periode <= 0) // Periode is less than 0 then set it to 1 $periode = 1; } else // URL does not show the page set it to 1 $periode = 1; return $periode; } function luc_page_posts() { global $wpdb; // pa is the display pages Articles if(isset($_GET['pa'])) { $pageA = $_GET['pa'];// Get Current page Articles from URL if($pageA <= 0) // Article is less than 0 then set it to 1 $pageA = 1; } else // URL does not show the Article set it to 1 $pageA = 1; return $pageA; } function luc_AnalyticStats_url_monitoring() { global $wpdb, $AnalyticStats_Option; $table_name =AnalyticStats_TABLE_NAME; $querylimit = 100; $pa = luc_page_posts(); $action = "urlmonitoring"; // Number of distinct spiders after $day_ago $Num = $wpdb->get_var("SELECT COUNT(*) FROM $table_name WHERE realpost=0 AND (spider ='' OR spider LIKE 'Unknown Spam Bot') "); $NumPage = ceil($Num / $querylimit); echo "

" . __('URL Monitoring', 'statpress') . "


This page is designed to help you secure your website:
Learn more
"; luc_print_pa_link ($NumPage,$pa,$action); $LimitValue = ($pa * $querylimit) - $querylimit; ?> get_results("SELECT date,time,ip,urlrequested,agent,os,browser,spider,country,realpost FROM $table_name WHERE realpost=0 AND (spider ='' OR spider LIKE 'Unknown Spam Bot') ORDER BY id DESC LIMIT $LimitValue, $querylimit;"); foreach ($qry as $rk) { echo ""; } ?>
Date Time IP Country URL requested Agent Spider OS Browser
" .luc_hdate($rk->date). " " .$rk->time. " " .luc_create_href($rk->ip, 'ip'). " " .luc_HTML_IMG($rk->country, 'country', false). " " .urldecode($rk->urlrequested)." " . $rk->agent . " " .luc_HTML_IMG($rk->spider, 'spider', false). " " .luc_HTML_IMG($rk->os, 'os', $text_OS). " " .luc_HTML_IMG($rk->browser, 'browser', $text_browser). "
"; luc_print_pa_link ($NumPage,$pa,$action); luc_AnalyticStats_load_time(); } function luc_spy_bot() { global $wpdb; $table_name = AnalyticStats_TABLE_NAME; $action = 'spybot'; // number of IP or bot by page $LIMIT = 5; $LIMIT_PROOF = 40; $pa = luc_page_posts(); $LimitValue = ($pa * $LIMIT) - $LIMIT; // Number of distinct spiders $Num = $wpdb->get_var("SELECT count(distinct spider) FROM $table_name WHERE spider<>''"); $NA = ceil($Num/$LIMIT); // Number of distinct spider between $currentdate and $limidate $NumberSpiders = $wpdb->get_var("SELECT count(distinct spider) FROM $table_name WHERE spider<> '' AND date BETWEEN $limitdate AND $currentdate"); $NumSpiders = ceil($NumberSpiders/ $LIMIT); echo "

" . __('Bot Spy', 'AnalyticStats') . "

"; // selection of spider, group by spider, order by most recently visit (last id in the table) $sql = "SELECT * FROM $table_name as T1 JOIN (SELECT spider,max(id) as MaxId FROM $table_name WHERE spider<>'' GROUP BY spider ORDER BY MaxId DESC LIMIT $LimitValue, $LIMIT ) as T2 ON T1.spider = T2.spider ORDER BY MaxId DESC, timestamp DESC "; $qry = $wpdb->get_results($sql); ?>
$rk->spider) {echo "
"; echo ((isset($rk->post_title)) ?"" :""); $robot=$rk->spider; $num_row=1; } elseif ($num_row < $LIMIT_PROOF) {echo ""; echo ((isset($rk->post_title)) ?"" :""); $num_row+=1; } echo "\n"; } echo "
"; $img=str_replace(" ","_",strtolower($rk->spider)); $img=str_replace('.','',$img).".png"; $lines = file(AnalyticStats_PLUGIN_PATH .'/def/spider.dat'); foreach($lines as $line_num => $spider) //seeks the tooltip corresponding to the photo { list($title,$id)=explode("|",$spider); if($title==$rk->spider) break; // break, the tooltip ($title) is found } echo "".$title." http more info

" . $rk->ip . "
" . $rk->agent . "
" . luc_hdate($rk->date) . " " . $rk->time . "
" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "
" . luc_hdate($rk->date) . " " . $rk->time . "
" .$rk->post_title."" . luc_post_title_Decode(urldecode($rk->urlrequested)). "
"; luc_print_pp_link ($NA,$pa,$action); echo "
"; luc_AnalyticStats_load_time(); } function luc_spy_visitors() { global $wpdb; global $AnalyticStats_Option; $table_name = AnalyticStats_TABLE_NAME; $action = 'spyvisitors'; // number of IP or bot by page $LIMIT = $AnalyticStats_Option['AnalyticStats_SpyVisitor_IP_Per_Page']; $LIMIT_PROOF = $AnalyticStats_Option['AnalyticStats_SpyVisitor_Visits_Per_IP']; if ($LIMIT == 0) $LIMIT = 20; if ($LIMIT_PROOF == 0) $LIMIT_PROOF = 20; $pp = luc_page_periode(); // Number of distinct ip (unique visitors) $NumIP = $wpdb->get_var("SELECT count(distinct ip) FROM $table_name WHERE spider=''"); $NP = ceil($NumIP/$LIMIT); $LimitValue = ($pp * $LIMIT) - $LIMIT; $sql = "SELECT * FROM $table_name as T1 JOIN (SELECT ip,max(id) as MaxId FROM $table_name WHERE spider='' GROUP BY ip ORDER BY MaxId DESC LIMIT $LimitValue, $LIMIT ) as T2 ON T1.ip = T2.ip ORDER BY MaxId DESC, id DESC "; $qry = $wpdb->get_results($sql); if ($AnalyticStats_Option['AnalyticStats_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 "

" . __('Visitor Spy', 'AnalyticStats') . "

"; ?> '; foreach ($qry as $rk) { // Visitor Spy if ($ip <> $rk->ip) //this is the first time these ip appear, print informations { if ($geoip_isok === true) $gir = GeoIP_record_by_addr($gic, $rk->ip); echo ""; if ($rk->country <> '') echo "HTTP country " . luc_HTML_IMG($rk->country, 'country', false); else echo "Hostip country "; ($geoip_isok === true?$lookupsvc = "GeoIP details":$lookupsvc = "Hostip details"); echo " " . $rk->ip . " ip . "');>" . $lookupsvc . "
"; if ($geoip_isok === true) echo "
Country: " . utf8_encode($gir->country_name) . " (" . $gir->country_code . ")
City: " . utf8_encode($gir->city) . "
Latitude/Longitude: " . $gir->latitude . " " . $gir->longitude . "
"; else echo " "; echo "
" . $rk->os . ", " . $rk->browser . "
" . gethostbyaddr($rk->ip) . "
" . $rk->agent . "
" . luc_hdate($rk->date) . " " . $rk->time . "
"; echo ((isset($rk->post_title)) ? "
".$rk->post_title : "
".luc_post_title_Decode(urldecode($rk->urlrequested))); if ($rk->searchengine != '') echo "
arrived from " . $rk->searchengine . " searching " . urldecode($rk->search) . ""; else if ($rk->referrer != '' && strpos($rk->referrer, $home) === false) echo "
arrived from " . $rk->referrer . ""; echo "
\n"; $ip = $rk->ip; $num_row = 1; } elseif ($num_row < $LIMIT_PROOF) { echo "
" . luc_hdate($rk->date) . " " . $rk->time . "
"; echo ((isset($rk->post_title)) ? "
".$rk->post_title: "
".luc_post_title_Decode(urldecode($rk->urlrequested))); if ($rk->searchengine != '') echo "
arrived from " . $rk->searchengine . " searching search) . " "; else if ($rk->referrer != '' && strpos($rk->referrer, $home) === false) echo "
arrived from " . $rk->referrer . " "; $num_row += 1; echo "
"; } } echo "
\n"; luc_print_pp_link($NP,$pp,$action); echo "
"; luc_AnalyticStats_load_time(); } function luc_yesterday() { $start = microtime(true); global $wpdb; global $AnalyticStats_Option; $table_name = AnalyticStats_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(); $sql_posts_pages = "SELECT post_date_gmt,post_title,post_name,post_type FROM $wpdb->posts WHERE post_status = 'publish' AND (post_type = 'page' OR post_type = 'post') AND DATE_FORMAT(post_date_gmt, '%Y%m%d') <= $yesterday;"; // 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 = ''", $yesterday); 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<>''", $yesterday); 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 = ''", $yesterday); 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<>''", $yesterday); foreach ($qry_pageviews_feeds as $p) { $posts[$p->post_name]['pageviews_feeds'] = $p->total; $total_pageviews_feeds += $p->total; } $spider = $AnalyticStats_Option['AnalyticStats_Dont_Collect_Spider']; if ($spider == '') { $qry_spiders = requete_day("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 FROM $table_name WHERE feed='' AND spider='' AND date = $yesterday ;"); $total_visitors_feeds = $wpdb->get_var("SELECT count(DISTINCT ip) as total FROM $table_name WHERE feed<>'' AND spider='' AND date = $yesterday ;"); echo ""; _e("Displaying report for " . gmdate('d M, Y', strtotime($yesterday)) . " (" . $total_posts_pages . " posts/pages)");echo" "; luc_print_pa_link ($NA,$pa,$action); // Sort the results by total usort($posts, "luc_posts_pages_custom_sort"); echo ""; if ($spider == '') echo ""; echo ""; echo ""; if ($spider == '') echo ""; $i = 0; foreach ($posts as $p) { if (($i >= $LimitValueArticles) and ($i < $LimitValueArticles+$NumberDisplayPost)) { echo ""; if ($spider == '') echo ""; echo ""; } $i++; }; echo "
" . __('URL', 'statpressV') . "
" . __('Visitors', 'statpressV') . "
" . __('Visitors Feeds', 'statpressV') . "
" . __('Views', 'statpressV') . "
" . __('Views Feeds', 'statpressV') . "
" . __('Spider', 'statpressV') . "
All URL " . __($total_visitors, 'statpressV') . " " . __($total_visitors_feeds, 'statpressV') . " " . __($total_pageviews, 'statpressV') . " " . __($total_pageviews_feeds, 'statpressV') . "" . __($total_spiders, 'statpressV') . "
" . ($p[post_type]=='page' ? "[page]: ".$p['post_title'] : $p['post_title'])." " . $p['visitors']. " " . $p['visitors_feeds'] . " " . $p['pageviews']. " " . $p['pageviews_feeds'] . "" . $p['spiders'] . "
"; luc_print_pa_link ($NA,$pa,$action); luc_AnalyticStats_load_time(); } function requete_day($count, $where_one, $where_two, $yesterday) { global $wpdb; $table_name = AnalyticStats_TABLE_NAME; $qry = $wpdb->get_results("SELECT post_name, total FROM ( (SELECT 'page_accueil' AS post_name, count($count) AS total FROM $table_name WHERE date = $yesterday AND $where_one AND $where_two GROUP BY post_name) UNION ALL (SELECT post_name, count($count) AS total FROM $wpdb->posts AS p JOIN $table_name AS t ON t.urlrequested LIKE CONCAT('%',p.post_name,'%') WHERE t.date = $yesterday AND p.post_status = 'publish' AND (p.post_type = 'page' OR p.post_type = 'post') AND $where_two GROUP BY p.post_name) ) req GROUP BY post_name"); return $qry; } // Define the custom sort function function luc_posts_pages_custom_sort($a, $b) { return $a['visitors'] < $b['visitors']; } function luc_AnalyticStats_referrer() { global $wpdb; $table_name = AnalyticStats_TABLE_NAME; $action = "referrer"; $visitors_color = "#114477"; $rss_visitors_color = "#FFF168"; $pageviews_color = "#3377B6"; $rss_pageviews_color = "#f38f36"; $spider_color = "#83b4d8"; $pa = luc_page_posts(); $query = $wpdb->get_results("SELECT distinct referrer FROM $table_name WHERE referrer<>'' AND referrer NOT LIKE '%" . get_bloginfo('url') . "%' AND searchengine='' "); $NumberArticles = $wpdb->num_rows; $LIMITArticles = 100; $NA = ceil($NumberArticles / $LIMITArticles); $LimitValueArticles = ($pa-1) * $LIMITArticles; echo "

" . __('Referrer ', 'AnalyticStats')."

"; luc_print_pp_link($NA,$pa,$action); echo ""; $strqry = "SELECT count(referrer) as total,ip, referrer FROM $table_name WHERE referrer<>'' AND referrer NOT LIKE '%".get_bloginfo('url')."%' AND searchengine='' GROUP BY referrer ORDER by total DESC LIMIT $LimitValueArticles, $LIMITArticles"; $query = $wpdb->get_results($strqry); foreach ($query as $url) {echo ""; echo ""; echo "\n"; } echo '
IP URL Total
" . $url->ip . "

$url->referrer

" . $url->total . "
'; luc_print_pp_link ($NA,$pa,$action); luc_AnalyticStats_load_time(); } function luc_print_pp_link($NA,$pp,$action) { // For all pages ($NA) Display first 5 pages, 4 pages before current page($pp), 4 pages after current page , each 25 pages and the 5 last pages for($action) $GUIL1 = FALSE; $GUIL2 = FALSE;// suspension points not writed if ($NA >1) {for ($i = 1; $i <= $NA; $i++) if ($i <= $NA) { // $page is not the last page if($i == $pp) echo " [{$i}] "; // $page is current page else { // Not the current page Hyperlink them if (($i <= 3) or (($i >= $pp-3) and ($i <= $pp+3)) or ($i >= $NA-2) or is_int($i/25)) { if ($action == "overview") echo ' '; else echo ' '; } else { if ($GUIL1 == FALSE) {echo "... "; $GUIL1 = TRUE; } if (($i == $NA-3) and ($GUIL2 == FALSE)) { echo " ... "; $GUIL2 = TRUE; } // suspension points writed } } } } } function luc_print_pa_link ($NA,$pa,$action) { // For all pages ($NA) Display first 5 pages, 5 pages before current page($pa), 5 pages after current page , 5 last pages $GUIL1 = FALSE;// suspension points not writed $GUIL2 = FALSE; if ($NA >1) {echo '
'; echo "Pages and Posts : "; for ($j = 1; $j <= $NA; $j++) if ($j <= $NA) { // $i is not the last Articles page if($j == $pa) // $i is current page echo " [{$j}] "; else { // Not the current page Hyperlink them if (($j <= 5) or (($j >= $pa-4) and ($j <= $pa+4)) or ($j >= $NA-5)or is_int($i/50)) echo ' '; else { if ($GUIL1 == FALSE) {echo "... "; $GUIL1 = TRUE;} if (($j == $pa+6) and ($GUIL2 == FALSE)) { echo " ... "; $GUIL2 = TRUE;} // suspension points writed } } } } } function luc_gunzip($srcName, $dstName) { $sfp = gzopen($srcName, "rb"); if ($sfp !== false) { $fp = fopen($dstName, "w"); if ($fp === false) return false; while ($string = gzread($sfp, 4096)) { fwrite($fp, $string, strlen($string)); } gzclose($sfp); fclose($fp); return true; } return false; } function luc_GeoIP() { global $AnalyticStats_Option; $ipAddress = htmlentities($_SERVER['REMOTE_ADDR']); $geoip = luc_GeoIP_get_data($ipAddress); if (file_exists(luc_GeoIP_dbname('country'))) { $stat = stat(luc_GeoIP_dbname('country')); $dbsize = number_format_i18n($stat['size']); $dbmtime = date_i18n('r', $stat['mtime']); } else { $AnalyticStats_Option['AnalyticStats_Use_GeoIP'] = ''; update_option('AnalyticStats_Option', $AnalyticStats_Option); } if (file_exists(luc_GeoIP_dbname('city'))) { $statcity = stat(luc_GeoIP_dbname('city')); $dbcitysize = number_format_i18n($statcity['size']); $dbcitymtime = date_i18n('r', $statcity['mtime']); } else { $AnalyticStats_Option['AnalyticStats_Use_GeoIP'] = ''; update_option('AnalyticStats_Option', $AnalyticStats_Option); } // Draw page ?>
GeoIP Lookup
Warning: GeoIP consumes lot of CPU time, its use is discouraged, do not use it or have permission from your host before activating.
/>
Database OK"; else { echo "Database NOT found. Please download and install databases first. Disabling Option! "; $AnalyticStats_Option['AnalyticStats_Use_GeoIP'] = ''; update_option('AnalyticStats_Option', $AnalyticStats_Option); } } ?>


WARNING! Downloading database updates from MaxMind more than once per day will get your IP address banned!
Indicate the preferred method to locate the country of visitors :
/>
/>
Database NOT found" . $geoipdb . ""; $AnalyticStats_Option['AnalyticStats_Use_GeoIP'] = ''; update_option('AnalyticStats_Option', $AnalyticStats_Option); } else { echo ""; } ?> "; $AnalyticStats_Option['AnalyticStats_Use_GeoIP'] = ''; update_option('AnalyticStats_Option', $AnalyticStats_Option); } else { echo "City database file exists"; } ?>
Status
AnalyticStats GeoIP status: Enabled"; else echo "Disabled" . $geoipdb . ""; ?>
Country database
File status: Country database file exists
File location: " . luc_GeoIP_dbname('country') . "
File date (mtime): $dbmtime
File size: $dbsize bytes
City database
File status: City database NOT found" . $geoipcitydb . "
File location: " . luc_GeoIP_dbname('city') . "
File date (mtime): $dbcitymtime
File size: $dbcitysize bytes
Your GeoIP Information ($ipAddress)
Country: " . $geoip['cn'] . " (" . $geoip['cc'] . ") $cn Continent Code: " . $geoip['continent_code'] . "
Region: " . $geoip['region'] . " Area Code (USA Only): " . $geoip['area_code'] . "
City: " . $geoip['city'] . " Postal Code (USA Only): " . $geoip['postal_code'] . "
Latitude/Longitude: " . $geoip['latitude'] . " " . $geoip['longitude'] . " Metro Code (USA Only): " . $geoip['metro_code'] . "
"; } ?>
Action Information Result "; echo "Resolving hostname: " . $host . ""; if (gethostbyname($host) === $host) echo "[FAILED]"; else { echo "[OK]"; if (function_exists('curl_init')) { echo "Requesting: " . $db_url . ""; $ua = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0'; $ch = curl_init($db_url); curl_setopt($ch, CURLOPT_USERAGENT, $ua); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FILE, $db_gz_f); $execute = curl_exec($ch); // Check if any error occured if (curl_errno($ch)) { curl_close($ch); echo "[FAILED]"; } else { fclose($db_gz_f); $info = curl_getinfo($ch); curl_close($ch); clearstatcache(); echo "[OK]"; echo "Server response: " . $info['http_code'] . "[OK]"; echo "Content type: " . $info['content_type'] . "[OK]"; echo "Remote file time: " . $info['filetime'] . "[OK]"; echo "Bytes transfered: " . number_format_i18n($info['size_download']) . " bytes[OK]"; echo "Avg download speed: " . number_format_i18n($info['speed_download']) . " bytes/second[OK]"; echo "Time taken: " . $info['total_time'] . "[OK]"; // Check that the file is a plausable size if (filesize($db_gz) > 500000) { // Remove old backup if (file_exists($db . ".bak")) unlink($db . ".bak"); // Move exisiting database to backup if (file_exists($db)) rename($db, $db . ".bak"); echo "Backing up old database:[OK]"; // Unpack new database if (luc_gunzip($db_gz, $db . ".new") !== true) { echo "Unpacking archive:[FAILED]"; // Restore backup file if (file_exists($db)) rename($db . ".bak", $db); echo "Restoring backup database:[OK]"; } else { echo "Unpacking archive:[OK]"; // Rename new database if (file_exists($db . ".new")) rename($db . ".new", $db); // Remove gzip file if (file_exists($db_gz)) unlink($db_gz); } } } } else { echo "PHP not built with cURL support: Manual install required[FAILED]"; } echo ""; } if (isset ($_POST['edition'])) die(); } function luc_GeoIP_get_data($ipAddress) { global $AnalyticStats_Option; $AnalyticStats_Use_GeoIP = $AnalyticStats_Option['AnalyticStats_Use_GeoIP']; if (file_exists(luc_GeoIP_dbname('country'))) { if ($AnalyticStats_Use_GeoIP == 'checked') { $gi = geoip_open(luc_GeoIP_dbname('country'), GEOIP_STANDARD); $array['cc'] = geoip_country_code_by_addr($gi, $ipAddress); $array['cn'] = utf8_encode(geoip_country_name_by_addr($gi, $ipAddress)); } } if (file_exists(luc_GeoIP_dbname('city'))) { if ($AnalyticStats_Use_GeoIP == 'checked') { $gic = geoip_open(luc_GeoIP_dbname('city'), GEOIP_STANDARD); $gir = GeoIP_record_by_addr($gic, $ipAddress); $array['region'] = utf8_encode($gir->region); $array['city'] = utf8_encode($gir->city); $array['postal_code'] = $gir->postal_code; $array['latitude'] = $gir->latitude; $array['longitude'] = $gir->longitude; $array['area_code'] = $gir->area_code; $array['metro_code'] = $gir->metro_code; $array['continent_code'] = $gir->continent_code; } } if (count($array) > 0) return $array; else return false; } function luc_ValueTable2($fld,$fldtitle,$limit = 0,$param = "", $queryfld = "", $exclude= "") { global $wpdb; $table_name = AnalyticStats_TABLE_NAME; if ($queryfld == '') { $queryfld = $fld; } print "
"; $rks = $wpdb->get_var("SELECT count($param $queryfld) as rks FROM $table_name WHERE 1=1 $exclude;"); if($rks > 0) { $sql="SELECT count($param $queryfld) as pageview, $fld FROM $table_name WHERE 1=1 $exclude GROUP BY $fld ORDER BY pageview DESC"; if($limit > 0) { $sql=$sql." LIMIT $limit"; } $qry = $wpdb->get_results($sql); $tdwidth=450; // Collects data $data=array(); foreach ($qry as $rk) { $pc=round(($rk->pageview*100/$rks),1); if($fld == 'date') { $rk->$fld = luc_hdate($rk->$fld); } if($fld == 'urlrequested') { $rk->$fld = luc_post_title_Decode($rk->$fld); } $data[substr($rk->$fld,0,50)]=$rk->pageview; } } // Draw table body print ""; if($rks > 0) { // Chart! $chart=luc_GoogleChart("","500x200",$data); print ""; foreach ($data as $key => $value) { print ""; print ""; } } print "

$fldtitle

".__('Visits','AnalyticStats')."
$chart
".$key; print "".$value."

\n"; } function luc_GoogleChart($title,$size,$data_array) { if(empty($data_array)) { return ''; } // get hash foreach($data_array as $key => $value ) { $values[] = $value; $labels[] = $key; } $maxValue=max($values); $simpleEncoding='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; $chartData="s:"; for($i=0;$i-1) { $chartData.=substr($simpleEncoding,61*($currentValue/$maxValue),1); } else { $chartData.='_'; } } $data=$chartData."&chxt=y&chxl=0:|0|".$maxValue; return ""; } function luc_GoogleGeo($title,$size,$data_array) { if(empty($data_array)) { return ''; } // get hash foreach($data_array as $key => $value ) { $values[] = $value; $labels[] = $key; } return ""; } function luc_dropdown_caps($default = false) { global $wp_roles; $role = get_role('administrator'); foreach ($role->capabilities as $cap => $grant) { echo ""; } } function luc_AnalyticStats_Abbrevia($s, $c) { $res = ""; if (strlen($s) > $c) $res = "..."; return my_substr($s, 0, $c) . $res; } function luc_tablesize($table) { global $wpdb; $res = $wpdb->get_results("SHOW TABLE STATUS LIKE '$table'"); foreach ($res as $fstatus) { $data_lenght = $fstatus->Data_length; $data_rows = $fstatus->Rows; } return number_format(($data_lenght / 1024 / 1024), 2, ",", " ") . " MB ($data_rows records)"; } function luc_rgbhex($red, $green, $blue) { $red = 0x10000 * max(0, min(255, $red + 0)); $green = 0x100 * max(0, min(255, $green + 0)); $blue = max(0, min(255, $blue + 0)); // convert the combined value to hex and zero-fill to 6 digits return "#" . str_pad(strtoupper(dechex($red + $green + $blue)), 6, "0", STR_PAD_LEFT); } function luc_AnalyticStats_extractfeedreq($url) { if(!strpos($url, '?') === FALSE) { list($null, $q) = explode("?", $url); list($res, $null) = explode("&", $q); } else { $prsurl = parse_url($url); $res = $prsurl['path'] . $$prsurl['query']; } return $res; } class GoogChart { // Constants const BASE = 'http://chart.apis.google.com/chart?'; // Variables protected $types = array( 'pie' => 'p', 'line' => 'lc', 'sparkline' => 'ls', 'bar-horizontal' => 'bhg', 'bar-vertical' => 'bvg', ); protected $type; protected $title; protected $data = array(); protected $size = array(); protected $color = array(); protected $fill = array(); protected $labelsXY = false; protected $legend; protected $useLegend = true; protected $background = 'a,s,ffffff'; protected $query = array(); // debug public $debug = array(); // Return string public function __toString() { return $this->display(); } /** Create chart */ protected function display() { // Create query $this->query = array( 'cht' => $this->types[strtolower($this->type)], // Type 'chtt' => $this->title, // Title 'chd' => 't:'.$this->data['values'], // Data 'chl' => $this->data['names'], // Data labels 'chdl' => ( ($this->useLegend) && (is_array($this->legend)) ) ? implode('|',$this->legend) : null, // Data legend 'chs' => $this->size[0].'x'.$this->size[1], // Size 'chco' => preg_replace( '/[#]+/', '', implode(',',$this->color)), // Color ( Remove # from string ) 'chm' => preg_replace( '/[#]+/', '', implode('|',$this->fill)), // Fill ( Remove # from string ) 'chxt' => ( $this->labelsXY == true) ? 'x,y' : null, // X & Y axis labels 'chf' => preg_replace( '/[#]+/', '', $this->background), // Background color ( Remove # from string ) ); // Return chart return $this->img( GoogChart::BASE.http_build_query($this->query), $this->title ); } /** Set attributes */ public function setChartAttrs( $attrs ) { // debug $this->debug[] = $attrs; foreach( $attrs as $key => $value ) { $this->{"set$key"}($value); } } /** Set type */ protected function setType( $type ) { $this->type = $type; } /** Set title */ protected function setTitle( $title ) { $this->title = $title; } /** Set data */ protected function setData( $data ) { // Clear any previous data unset( $this->data ); // Check if multiple data if( is_array(reset($data)) ) { /** Multiple sets of data */ foreach( $data as $key => $value ) { // Add data values $this->data['values'][] = implode( ',', $value ); // Add data names $this->data['names'] = implode( '|', array_keys( $value ) ); } /** Implode data correctly */ $this->data['values'] = implode('|', $this->data['values']); /** Create legend */ $this->legend = array_keys( $data ); } else { /** Single set of data */ // Add data values $this->data['values'] = implode( ',', $data ); // Add data names $this->data['names'] = implode( '|', array_keys( $data ) ); } } /** Set legend */ protected function setLegend( $legend ) { $this->useLegend = $legend; } /** Set size */ protected function setSize( $width, $height = null ) { // check if width contains multiple params if(is_array( $width ) ) { $this->size = $width; } else { // set each individually $this->size[] = $width; $this->size[] = $height; } } /** Set color */ protected function setColor( $color ) { $this->color = $color; } /** Set labels */ protected function setLabelsXY( $labels ) { $this->labelsXY = $labels; } /** Set fill */ protected function setFill( $fill ) { // Fill must have atleast 4 parameters if( count( $fill ) < 4 ) { // Add remaining params $count = count( $fill ); for( $i = 0; $i < $count; ++$i ) $fill[$i] = 'b,'.$fill[$i].','.$i.','.($i+1).',0'; } $this->fill = $fill; } /** Set background */ protected function setBackground( $background ) { $this->background = 'bg,s,'.$background; } /** Create img html tag */ protected function img( $url, $alt = null ) { return sprintf('%s', $url, $alt, $this->size[0], $this->size[1]); } } function luc_Client_Lookup_IP($ip) { function luc_BanIP_Check($ip) { $lines = file(AnalyticStats_PLUGIN_PATH . '/def/banips.dat'); foreach ($lines as $line_num => $record) { if (strcmp(trim($record), $ip) == 0) return true; } return null; } function luc_BanIP_Add($ip) { $fp = fopen(AnalyticStats_PLUGIN_PATH . '/def/banips.dat', 'a'); if ($fp) fwrite($fp, "\n" . $ip); fclose($fp); } function luc_BanIP($ip) { if (luc_BanIP_Check($ip)) echo "IP address " . $ip . " already in ban list
"; else { luc_BanIP_Add($ip); echo "IP address " . $ip . " is now banned!
"; } } function luc_print_uas($array) { foreach ($array as $a) $ret = $ret . $a->agent . "
"; return $ret; } function luc_display_by_IP($ip) { global $wpdb; $table_name = AnalyticStats_TABLE_NAME; $qry_s = "SELECT * FROM $table_name WHERE ip = '$ip' ORDER BY date DESC "; $qry = $wpdb->get_results($qry_s); $num = $wpdb->num_rows; $qry_sa = "SELECT DISTINCT agent FROM $table_name WHERE ip = '$ip' ORDER BY agent ASC ; "; $qrya = $wpdb->get_results($qry_sa); if ($_POST['banip'] == 'Ban IP address') luc_BanIP($ip); $text = "Report for " . $ip . " "; ?>

Records in database:
Latest hit: date) . " " . $qry[0]->time) ?>
First hit: date) . " " . $qry[$num - 1]->time) ?>
User agent(s):
GeoIP Information
Country: $cn '> Continent Code:
Region: Area Code: (USA Only)
City: Postal Code: (USA Only)
Latitude/Longitude ' target='_blank' title='Lookup latitude/longitude location on Google Maps...'> Metro Code: (USA Only)
URLs Requested
Date Time OS Agent Referrer URL Requested
date)) ?> time) ?> os, 'os', false)) ?> agent) ?> referrer) ?> urlrequested)) ?>