Configuration Page. Author: Johannes Lietz Author URI: http://dadabase.de/ Version: 2.0.3 */ /* WP/GeoTraq Wordpress Plugin Copyright (C) 2006 Johannes Lietz Edited by Dave Arrowsmith, 30-08-2008 This program is postcardware, which means you can redistribute it and/or modify it, but if you like it, I would be pleased if you send mit a physical snail mail (kind of oldschool geotracking ;-)) postcard to: Johannes Lietz Kopernikusstr. 94 D-40225 Duesseldorf Germany This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Edited from 2.0.2->2.0.3 by D Arrowsmith @ 4tfingers.biz to enable... 1. Admin Panel option to Ignore an array of IP address'(single &/or range) for not skewing Results with your own Visits etc 2. In-file Edit to Alow the use of particular map ICON and ShadowICON just below here 3. Admin Panel option to Allow/Remove Display of referrers if you are having Referer Spam Problems 4. Have "Unknown Country,Unknown City" Display at Map Center Your given 'lat,long' */ //////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* ************ Edit these to reflect your preferences for Map Markers */ $marker = 'manm';// 'icon63'; //'cycling'; //"marker1"; $marker_shadow = 'manmini_shadow'; //'icon63s'; //'man_shadow'; //'cycling_shadow'; //"marker1s"; /* ************ Edit these to reflect your preferences for Display Links */ $wp_geotrack_copy = "

Powered by MaxMind GeoLite City and Wordpress Geotrack Plugin, Updated: By Me!.

\n"; //$wp_geotrack_copy = "

 

\n"; /************* End Editable Variables */ //////////////////////////////////////////////////////////////////////////////////////////////////////////////// $filename = substr(__FILE__, strrpos(__FILE__, '/') + 1); if (strpos($_SERVER['PHP_SELF'], $filename) !== false){ die('You are not allowed to access this file directly!');} DEFINE('GEOTRACK_PATH', ABSPATH.'wp-content/plugins/wp_geotrack/'); DEFINE('GEOTRACK_URL', get_bloginfo('siteurl').'/wp-content/plugins/wp_geotrack/'); DEFINE('GEOTRACK_VERSION', '2.0'); if (!file_exists(GEOTRACK_PATH.'GeoLiteCity.dat')) { DEFINE('GT_NOT_INSTALLED', 'GeoLiteCity.dat needs to be "Installed Manually" at '.GEOTRACK_PATH.'GeoLiteCity.dat!
'); } require_once GEOTRACK_PATH.'geoipcity.inc.php'; $gt_options = wp_geotrack_loadoptions(); DEFINE('DEBUG', $gt_options['gt_debug']); // echo '$gt_options[gt_debug]'.$gt_options['gt_debug']; // start a PHP session if not already done if (!headers_sent()) { @session_start(); } $wp_geotrack_list = array(); /////////////////////////////////////////////////////////////////////////////////////////////////////////// /* wp_geotrack Functions Begin Here */ /////////////////////////////////////////////////////////////////////////////////////////////////////////// function wp_geotrack_encode($str) { return strtolower(get_settings('blog_charset')) == 'utf-8' ? utf8_encode($str) : $str; } function wp_geotrack_loadoptions($get_defaults = false) { $options = get_option('wp_geotrack_options'); if ($options === false) { $options = array(); } $defaults = array(); if (!defined('GT_NOT_INSTALLED')) { $defaults['gt_google_map_key'] = ''; $gi = geoip_open(GEOTRACK_PATH.'GeoLiteCity.dat', GEOIP_STANDARD); $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); $_REQUEST['record'] = $record; $defaults['gt_google_map_lat'] = $record->latitude; $defaults['gt_google_map_long'] = $record->longitude; } else { $defaults['gt_google_map_lat'] = 0; $defaults['gt_google_map_long'] = 0; } $defaults['gt_google_map_scale'] = 4; $defaults['gt_list_length'] = 100; $defaults['gt_toplist_length'] = 10; $defaults['gt_cleanup_days'] = 30; $defaults['gt_referrers_only'] = 0; $defaults['gt_referrer_display'] = 0; // ADD gt_referrer_display // $defaults['gt_dateformat'] = '%d.%m.%Y %H:%i'; $defaults['gt_ignored_ip_address'] = '65.55.109.*|65.55.110.*|65.55.165.*|65.55.232.*|131.107.0.9|131.107.0.56'; // ADD gt_ignored_ip_address // $defaults['gt_exclude_user_agents'] = 'bot|spider|inktomi|crawl|slurp|library|java' .'|scout|jakarta|seek|find|htdig|archiver|fetch|search|scooter|libwww|wget|' .'control|mvaclient|cfnetwork|larbin|trivial|curl'; $defaults['gt_debug'] = 0; foreach ($defaults as $name => $value) { if ($get_defaults || !isset($options[$name])) { $options[$name] = $value; } } return $options; } // display debugMsg data: function debugMsg($obj) { if (DEBUG) { echo "\n\n"; } } function wp_geotrack_install() { global $wpdb, $table_prefix; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } $sql = "CREATE TABLE IF NOT EXISTS `".$table_prefix."geotrack` ( `row_id` int(11) NOT NULL auto_increment, `ip` varchar(39) NOT NULL default '', `country` varchar(50) default NULL, `country_code` varchar(2) default NULL, `flagname` varchar(50) NOT NULL default '', `city` varchar(50) default NULL, `latitude` float default '0', `longitude` float default '0', `uri` text NOT NULL, `method` varchar(10) NOT NULL default '', `status` int(3) NOT NULL default '0', `referrer` text, `user_agent` varchar(255) default NULL, `access_time` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`row_id`) ) TYPE=MyISAM;"; $wpdb->query($sql); $sql = "CREATE TABLE IF NOT EXISTS `".$table_prefix."geotrack_exclude` ( `exclude_id` int(11) NOT NULL auto_increment, `str` varchar(255) NOT NULL default '', PRIMARY KEY (`exclude_id`), UNIQUE KEY `str` (`str`) ) TYPE=MyISAM;"; $wpdb->query($sql); //////// ??????????????????????? $sql = 'ALTER TABLE `'.$table_prefix.'geotrack_exclude` DROP `exclude_id`'; $wpdb->query($sql); //////// ??????????????????????? $sql = "INSERT IGNORE INTO `".$table_prefix."geotrack_exclude` VALUES ('%.kz'),('%.tripod.com'),('%.weblog.ro/%'), ('%/track/%'),('%12.163.72.13%'),('%1place1%'),('%1xsearch%'),('%9k.com%'),('%accounting%'),('%aciphex%'), ('%acne%'),('%actos%'),('%acyclovir%'),('%adipex%'),('%adult%'),('%advicer%'),('%aldara%'),('%aldera%'), ('%alfuzosin%'),('%ambien%'),('%amoxil%'),('%anal%'),('%anzwers%'),('%ares%'),('%assparade%'),('%augmentation%'), ('%backorder%'),('%ballaire%'),('%beastiality%'),('%bestiality%'),('%bestsitereviews%'),('%betting%'), ('%bigmouthful%'),('%blackjack%'),('%bloating%'),('%blowjob%'),('%book%'),('%boom.ru%'),('%bowel%'),('%breast%'), ('%britney%'),('%buddy4u%'),('%bukake%'),('%buy%'),('%byethost31%'),('%c0ck%'),('%cabinetrefacingideas%'), ('%cams%'),('%carisoprodol%'),('%casino%'),('%celebrex%'),('%celebrity%'),('%celebs%'),('%cellulite%'), ('%chat-nett%'),('%chiki-piki%'),('%cialis%'),('%cigarette%'),('%clio%'),('%cock%'),('%craps%'),('%creampie%'), ('%credit%'),('%crescentarian%'),('%crumsa%'),('%cum%'),('%cyclobenzaprine%'),('%d4f.de%'),('%dating%'), ('%debt%'),('%detox%'),('%diamonds%'),('%diarrhea%'),('%diazepam%'),('%diet%'),('%dmost%'),('%drug-tests%'), ('%duty%'),('%ebony%'),('%ejaculation%'),('%emedia%'),('%enlargement%'),('%ephedrine%'),('%erodiva%'), ('%eroti%'),('%erotic%'),('%escort%'),('%extender%'),('%fast-search-engine%'),('%fastsize%'),('%fbhosting%'), ('%fibromyalgia%'),('%ficken%'),('%fioricet%'),('%firsttime%'),('%fisting%'),('%fradins%'),('%freakycheats%'), ('%free%'),('%freshset%'),('%friend-finder%'),('%frogent%'),('%fuck%'),('%future-2000%'),('%gambling%'), ('%gaming%'),('%gift-basket%'),('%gorgeouswomenoncam%'),('%great-doctor%'),('%hair-loss%'),('%hawtalta%'), ('%health%'),('%heartworm%'),('%hentai%'),('%hgh%'),('%highprofit%'),('%hilton%'),('%hold-em%'),('%holdem%'), ('%hustler%'),('%hydrocodone%'),('%i-web%'),('%idate%'),('%imitrex%'),('%incest%'),('%insertion%'),('%insurance%'), ('%inthevip%'),('%isendit%'),('%iwas2%'),('%jack%'),('%juris%'),('%kalbe%'),('%kazaa%'),('%kentris%'), ('%kitchen%'),('%knatty%'),('%kredit%'),('%kylos%'),('%learnhowtoplay%'),('%leenow%'),('%lesbian%'),('%levitra%'), ('%lisinopril%'),('%livenet%'),('%loan%'),('%loliduck%'),('%lortab%'),('%machtnacht%'),('%macinstruct%'), ('%maifun%'),('%massage%'),('%mature%'),('%mcdortaklar%'),('%meds%'),('%medve%'),('%meridia%'),('%metabolism%'), ('%mikesapartment%'),('%milf%'),('%money%'),('%mortgage%'),('%mtsby%'),('%naked%'),('%nexium%'),('%nflook%'), ('%norco%'),('%nude%'),('%nutzu%'),('%obesity%'),('%op-clan%'),('%openlistings.net%'),('%osteoarthritis%'), ('%ownsthis%'),('%p0rn%'),('%pain-relief%'),('%payday%'),('%penis%'),('%perso.wanadoo.es%'),('%pharmacy%'), ('%phentemin%'),('%phentermin%'),('%phuck%'),('%pill%'),('%pills%'),('%piss%'),('%playmate%'),('%poker%'), ('%polarhome%'),('%porn%'),('%poze%'),('%pps=wm%'),('%prescription%'),('%presctiption%'),('%price%'), ('%prji.com%'),('%pron%'),('%propecia%'),('%proscar%'),('%psoriasis%'),('%psxtreme%'),('%qpoi%'),('%qway%'), ('%rape%'),('%reductil%'),('%referrer.com%'),('%refinance%'),('%rheumatism%'),('%ringtone%'),('%rinngebottet%'), ('%ronnieazza%'),('%roulette%'),('%roxtet%'),('%rulo%'),('%rutranslator%'),('%sex%'),('%shemale%'),('%shop%'), ('%sibutramine%'),('%singles%'),('%sleep-apnea%'),('%slot%'),('%slut%'),('%software%'),('%soma%'), ('%static.net%'),('%stop-smoking%'),('%store%'),('%strip%'),('%studyinslovakia%'),('%swinger%'),('%taboo%'), ('%taylorbow%'),('%tecrep%'),('%teen%'),('%tenuate%'),('%terashells%'),('%testosterone%'),('%texas%'), ('%theladysroom%'),('%thyroid%'),('%tits%'),('%tramadol%'),('%treasure%'),('%ua-princeton%'),('%ultram%'), ('%uncovered%'),('%uprima%'),('%urniture%'),('%valium%'),('%vegas%'),('%viagra%'),('%vicodin%'),('%viox%'), ('%vrajitor%'),('%watches%'),('%webhostips%'),('%welim%'),('%ws-op%'),('%wsop%'),('%xanax%'),('%xenical%'), ('%xhostar%'),('%xmlindustry%'),('%xxx%'),('%yahroo%'),('%yelucie%'),('%ymore%'),('%zindagi%'), ('http://www.google.com');"; $wpdb->query($sql); $sql = 'DELETE FROM `'.$table_prefix.'geotrack_exclude` WHERE str = \'\''; $wpdb->query($sql); //////// ??????????????????????? $sql = "CREATE TABLE IF NOT EXISTS `".$table_prefix."geotrack_ipblock` ( `row_id` INT( 11 ) NOT NULL auto_increment, `ip` VARCHAR( 39 ) NOT NULL, PRIMARY KEY ( `row_id` ), UNIQUE ( `ip` ))"; $wpdb->query($sql); $sql = 'ALTER TABLE `'.$table_prefix.'geotrack_ipblock` DROP `row_id`'; $wpdb->query($sql); $sql = 'ALTER TABLE `'.$table_prefix.'geotrack_ipblock` ADD `counter` INT( 11 ) NOT NULL DEFAULT \'0\';'; $wpdb->query($sql); $sql = 'ALTER TABLE `'.$table_prefix.'geotrack_ipblock` ADD `referrer` TEXT NOT NULL;'; $wpdb->query($sql); $sql = 'ALTER TABLE `'.$table_prefix.'geotrack_ipblock` ADD `blocked` TINYINT(1) NOT NULL DEFAULT \'0\';'; $wpdb->query($sql); //////// ??????????????????????? $sql = 'CREATE TABLE IF NOT EXISTS `'.$table_prefix.'geotrack_ip_whitelist` ( `ip` VARCHAR( 39 ) NOT NULL , UNIQUE (`ip`))'; $wpdb->query($sql); } function wp_geotrack_getlist() { global $wpdb, $table_prefix, $wp_geotrack_list, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } if (count($wp_geotrack_list) > 0) {return;} /////////////////////////////////////ignore_ip_address///////////////////////////////////// $ignored_ips = explode("|", $gt_options['gt_ignored_ip_address']); /////////////////////////////////end_ignore_ip_address///////////////////////////////////// $sql = 'SELECT *, DATE_FORMAT(access_time, \''.$gt_options['gt_dateformat'].'\') AS datestr FROM '.$table_prefix.'geotrack WHERE status < 400 AND method = \'GET\''; if ($gt_options['gt_referrers_only']) { $sql .= 'AND referrer != \'\' AND referrer NOT LIKE \'%'.$_SERVER['HTTP_HOST'].'%\' '; } $sql .= 'ORDER BY access_time DESC'; //LIMIT 0,'.($gt_options['gt_list_length'] * 5); debugMsg($sql); // low-level mysql-functions for performance optimization: $db = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); $result = mysql_query($sql); while($res = mysql_fetch_array($result, MYSQL_ASSOC)) { if (count($wp_geotrack_list) == $gt_options['gt_list_length']) { break; } /////////////////////////////////////ignore_ip_address///////////////////////////////////// if( wp_geotrack_testIP($res['ip'], $ignored_ips) == 'allow' ){ /////////////////////////////////end_ignore_ip_address///////////////////////////////////// if (!isset($wp_geotrack_list[$res['ip']])) { $obj = $res; if (strpos($res['referrer'], $_SERVER['HTTP_HOST']) !== false) { $obj['referrer'] = ''; } $obj['uri'] = array(); $wp_geotrack_list[$res['ip']] = $obj; } if ($res['referrer'] != '' && strpos($res['referrer'], $_SERVER['HTTP_HOST']) === false) { $wp_geotrack_list[$res['ip']]['referrer'] = $res['referrer']; } $wp_geotrack_list[$res['ip']]['uri'][] = $res['uri']; /////////////////////////////////////ignore_ip_address///////////////////////////////////// } /////////////////////////////////end_ignore_ip_address///////////////////////////////////// } mysql_free_result($result); } // display a list of tracked requests // you can use this function inside you PHP code, e.g. your sidebar etc. function wp_geotrack_display() { global $user_ID, $wp_geotrack_list, $wp_geotrack_copy, $gt_options; wp_geotrack_getlist(); $cnt = 0; $str = "
    \n"; foreach($wp_geotrack_list as $res) { $class = ($cnt % 2 == 0) ? ' class="alt"' : ''; $uri = htmlspecialchars($res['uri'][count($res['uri']) - 1]); // we've got an array of pages here, so it is easy to display clickpaths $str .= 'Flag of '.$res['country'].' ['.$res['datestr'].'], '.$res['country'].' - '.$res['city'].': [LastPageViewed]'; /////////////////////////////////////referrer_display_by_user_ID///////////////////////////////////// if('' != $user_ID){$blocker = 'Block?-'.$res['ip'];}else{$blocker = $res['ip'];} if($gt_options['gt_referrer_display'] == 1){ //setting allows display if ($res['referrer'] != 'NULL' && $res['referrer'] != '') { $referrer_text = $res['referrer']; if (strlen($referrer_text) > 65) { $referrer_text = substr($referrer_text, 0, 65).'...'; } $str .= '
    IP:'.$blocker.'
    Referrer: '.htmlspecialchars($referrer_text).''; }else{ $str .= '
    IP:'.$blocker.' No Referrer: Direct Hit'; } }else{ If ('' != $user_ID){ if ($res['referrer'] != 'NULL' && $res['referrer'] != '') { $referrer_text = $res['referrer']; if (strlen($referrer_text) > 65) { $referrer_text = substr($referrer_text, 0, 65).'...'; } $str .= '
    IP:'.$blocker.'
    Referrer: '.htmlspecialchars($referrer_text).''; }else{ $str .= '
    IP:'.$blocker.' No Referrer: Direct Hit'; } } } /////////////////////////////////end_referrer_display_by_user_ID///////////////////////////////////// $str .= "\n"; $cnt++; } $str .= "
\n"; $str .= $wp_geotrack_copy; return $str; } function wp_geotrack_googlemap() { global $wp_geotrack_list, $wp_geotrack_copy, $gt_options,$marker,$marker_shadow; wp_geotrack_getlist(); //google-map.firstChild.nextSibling.style.fontSize = "xx-small"; $str = '
'; $str .= $wp_geotrack_copy; return $str; } function wp_geotrack_topsites() { global $wpdb, $table_prefix, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } $sql = 'SELECT COUNT(*) AS cnt, uri FROM '.$table_prefix.'geotrack WHERE status < 400 AND method = \'GET\' GROUP BY uri ORDER BY cnt DESC LIMIT 0, '.$gt_options['gt_toplist_length']; $result = $wpdb->get_results($sql, ARRAY_A); $str = "
    \n"; if ($result){ foreach($result as $res) { $str .= '
  1. '.htmlspecialchars($res['uri']).' ('.$res['cnt'].")
  2. \n"; } } $str .= "
\n"; return $str; } function wp_geotrack_topreferrers() { global $wpdb, $table_prefix, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } $sql = 'SELECT COUNT(*) AS cnt, referrer FROM '.$table_prefix.'geotrack WHERE status < 400 AND method = \'GET\' AND referrer != \'\' AND referrer NOT LIKE \''.get_bloginfo('siteurl').'%\' GROUP BY referrer ORDER BY cnt DESC LIMIT 0, '.$gt_options['gt_toplist_length']; $result = $wpdb->get_results($sql, ARRAY_A); $str = "
    \n"; if (is_array($result)) { foreach($result as $res) { $ref = $res['referrer']; if (strlen($ref) > 70) { $ref = substr($ref, 0, 70).'...'; } $str .= '
  1. '.htmlspecialchars($ref).' ('.$res['cnt'].")
  2. \n"; } } $str .= "
\n"; return $str; } function wp_geotrack_topcountries() { global $wpdb, $table_prefix, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } $sql = 'SELECT COUNT(*) AS cnt, country, flagname FROM '.$table_prefix.'geotrack WHERE status < 400 AND method = \'GET\' GROUP BY country ORDER BY cnt DESC LIMIT 0, '.$gt_options['gt_toplist_length']; $result = $wpdb->get_results($sql, ARRAY_A); $str = "
    \n"; foreach($result as $res) { $str .= '
  1. Flag of '.$res['country'].' '.$res['country'].' ('.$res['cnt'].")
  2. \n"; } $str .= "
\n"; return $str; } function wp_geotrack_topcities() { global $wpdb, $table_prefix, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } $sql = 'SELECT COUNT(*) AS cnt, city, country, flagname FROM '.$table_prefix.'geotrack WHERE status < 400 AND method = \'GET\' GROUP BY city, country ORDER BY cnt DESC LIMIT 0, '.$gt_options['gt_toplist_length']; $result = $wpdb->get_results($sql, ARRAY_A); $str = "
    \n"; foreach($result as $res) { $str .= '
  1. Flag of '.$res['country'].' '.$res['city'].' ('.$res['country'].') ('.$res['cnt'].")
  2. \n"; } $str .= "
\n"; return $str; } // Replaces the special Tag in any post content with the list. function wp_geotrack_content($content) { if (defined('GT_NOT_INSTALLED')) { echo GT_NOT_INSTALLED; return $content; } if (strpos($content, '[wp-geotrack-googlemap]') !== false){ $content = str_replace('[wp-geotrack-googlemap]', wp_geotrack_googlemap(), $content); } if (strpos($content, '[wp-geotrack-list]') !== false){ $content = str_replace('[wp-geotrack-list]', wp_geotrack_display(), $content);} if (strpos($content, '[wp-geotrack-topsites]') !== false){ $content = str_replace('[wp-geotrack-topsites]', wp_geotrack_topsites(), $content);} if (strpos($content, '[wp-geotrack-topreferrers]') !== false){ $content = str_replace('[wp-geotrack-topreferrers]', wp_geotrack_topreferrers(), $content); } if (strpos($content, '[wp-geotrack-topcountries]') !== false){ $content = str_replace('[wp-geotrack-topcountries]', wp_geotrack_topcountries(), $content);} if (strpos($content, '[wp-geotrack-topcities]') !== false){ $content = str_replace('[wp-geotrack-topcities]', wp_geotrack_topcities(), $content);} return $content; } /////////////////////////////////////ignore_ip_address///////////////////////////////////// //testing that correct IP address used in order //to access area... function wp_geotrack_testIP($ip, $ip_array){ $result = 'allow'; for($i=0, $cnt=count($ip_array); $i<$cnt; $i++){ $ipregex = preg_replace("/\./", "\.", $ip_array[$i]); $ipregex = preg_replace("/\*/", ".*", $ipregex); if(preg_match('/'.$ipregex.'/', $ip)){ return 'ignore'; } } return $result; } /////////////////////////////////end_ignore_ip_address///////////////////////////////////// function wp_geotrack_init() { global $wpdb, $table_prefix, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } if (defined('GT_NOT_INSTALLED')){ return;} if (strpos($_SERVER['REQUEST_URI'], '/wp-admin/') !== false){ return; } $referrer = (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'http') === 0) ? addslashes($_SERVER['HTTP_REFERER']) : ''; //$referrer = preg_replace('/\/$/', '', $referrer); $ip = addslashes($_SERVER['REMOTE_ADDR']); if (preg_match('/[\d]{1,3}.[\d]{1,3}.[\d]{1,3}.[\d]{1,3}/', $_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = addslashes($_SERVER['HTTP_X_FORWARDED_FOR']); } /////////////////////////////////////ignore_ip_address///////////////////////////////////// $ignored_ips = explode("|", $gt_options['gt_ignored_ip_address']); if( wp_geotrack_testIP($ip, $ignored_ips) == 'ignore'){ return; } /////////////////////////////////end_ignore_ip_address///////////////////////////////////// /////////////////////////////////////ignore_wp-spamkit///////////////////////////////////// if ($_SERVER['REQUEST_URI'] != '/treadly/wp-comments-post-hidden.php'){ $uri = addslashes($_SERVER['REQUEST_URI']); }else{ return; } /////////////////////////////////end_ignore_wp-spamkit///////////////////////////////////// //$uri = preg_replace('/\/$/', '', $uri); $ua = addslashes($_SERVER['HTTP_USER_AGENT']); // exclude bots etc. and clients with empty useragents: if ($gt_options['gt_exclude_user_agents'] != '' && (preg_match('/('.$gt_options['gt_exclude_user_agents'].')/i', $ua) || $ua == '')) { return; } // exclude referrers with cetain keywords to prevent referrer spamming: $sql = 'SELECT COUNT(*) AS cnt FROM '.$table_prefix.'geotrack_exclude WHERE \''.$referrer.'\' LIKE str'; $result = $wpdb->get_results($sql, ARRAY_A); // check if tables exist: if (mysql_errno() == 1146 && strpos(mysql_error(), $table_prefix.'geotrack') !== false) { wp_geotrack_install(); $result = $wpdb->get_results($sql, ARRAY_A); } $gt_blacklisted = false; if ($result[0]['cnt'] > 0 && strpos($referrer, $_SERVER['HTTP_HOST']) !== 0) { // referrer is black-listed $gt_blacklisted = true; } if (!file_exists(GEOTRACK_PATH.'GeoLiteCity.dat')) { return; } $gi = geoip_open(GEOTRACK_PATH.'GeoLiteCity.dat', GEOIP_STANDARD); $record = geoip_record_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); $gt_data = array(); $gt_data['country'] = ($record->country_name != '') ? wp_geotrack_encode($record->country_name) : 'Unknown Country'; $gt_data['country_code'] = ($record->country_code != '') ? strtolower($record->country_code) : 'un'; $gt_data['city'] = ($record->city != '') ? wp_geotrack_encode($record->city) : 'Unknown City'; $gt_data['latitude'] = ($record->latitude != '')? $record->latitude : '-28.3593'; $gt_data['longitude'] = ($record->longitude != '')? $record->longitude : '153.5537'; $gt_data['uri'] = $uri; $gt_data['referrer'] = $referrer; $gt_data['ua'] = $ua; $gt_data['ip'] = $ip; $flagname = strtolower($gt_data['country']); $flagname = preg_replace('/[\W]/', '_', $flagname); $flagname = preg_replace('/[_]+/', '_', $flagname); $flagname = preg_replace('/_$/', '', $flagname); $flagname = preg_replace('/^_/', '', $flagname); $gt_data['flagname'] = $flagname; $_SESSION['gt_data'] = $gt_data; $sql = 'SELECT * FROM '.$table_prefix.'geotrack_ipblock WHERE ip = \''.$ip.'\' AND blocked != -1'; $result = $wpdb->get_results($sql, ARRAY_A); $die = false; $ref = ''; debugMsg($result); if (count($result) > 0) { // ip is black-listed $gt_blacklisted = true; $sql = 'UPDATE '.$table_prefix.'geotrack_ipblock SET counter = counter + 1 WHERE ip = \''.$ip.'\''; $wpdb->query($sql); $ref = $result[0]['referrer']; if ($result[0]['blocked'] == 1) $die = true; } else if ($gt_blacklisted) { // add ip to black-list $sql = 'INSERT INTO '.$table_prefix.'geotrack_ipblock (ip, counter, referrer) VALUES (\''.$ip.'\', 1, \''.$referrer.'\')'; $wpdb->query($sql); } if ($gt_blacklisted) { // remove logs from that ip $sql = 'DELETE FROM '.$table_prefix.'geotrack WHERE ip = \''.$ip.'\''; $wpdb->query($sql); if ($result[0]['counter'] >= 10) { if ($result[0]['counter'] == 10) { $hostname = @gethostbyaddr($ip); $message = "There have been visits on your blog from IP: IP: $ip ($hostname) Country: ".$gt_data['country']." City: ".$gt_data['city']." which claim to be referred from: $ref The WP-Geotrack plugin thinks, that this might be referrer spam, which means that someone is trying to pretend that this site has set a link to your site, so that you and your visitors might want to see where these referrer came from, but in fact it is a porn-, spam- or fraud-site. If the site above is porn-, spam- or fraud-site, you should block the visitor's IP by following this link: ".get_settings('siteurl').'/wp-admin/options-general.php?page=wp_geotrack.php&block='.urlencode($ip).' If the site above is NOT spam or porn and contains a normal link to your site, you should remove this IP from your blacklist: '.get_settings('siteurl').'/wp-admin/options-general.php?page=wp_geotrack.php&remove='.urlencode($ip).' (Advanced users: if you regularly receive non-spam warnings, you can check the table '.$table_prefix.'geotrack_exclude in your database and remove the row which causes these warnings.)'; @wp_mail(get_settings('admin_email'), sprintf(__('[%s] WP-Geotrack: Suspicious IP'), get_settings('blogname')), $message); } if ($die && !headers_sent()) { header('HTTP/1.0 403 Bad referrer'); die('HTTP/1.0 403 Bad referrer

HTTP/1.0 403 Bad referrer

Sorry, your IP '.$ip.' has been blocked due to misuse of this service!
Please drop a quick note the server admin '.$_SERVER['SERVER_ADMIN'].' if you think this is a mistake! '); } } } } // The logging-function that is call by Wordpress inside the header of each page except admin pages. function wp_geotrack_log() { global $wpdb, $table_prefix, $gt_options; if (DEBUG) { $wpdb->show_errors(); } else { $wpdb->hide_errors(); } if(count($_SESSION['gt_data']) == 0) { return; } debugMsg($_SESSION); $status = 0; if (function_exists('headers_list')) { $headers = headers_list(); foreach($headers as $header) { preg_match('/^Status: ([\d]{3})/',$header,$status_arr); if (isset($status_arr[1])) { $status = $status_arr[1]; break; } } } /////////////////////////////////////ignore_ip_address///////////////////////////////////// $ignored_ips = explode('|',$gt_options['gt_ignored_ip_address']); if ( wp_geotrack_testIP($_SESSION['gt_data']['ip'], $ignored_ips) == 'ignore') { return; } /////////////////////////////////end_ignore_ip_address///////////////////////////////////// $sql = 'INSERT INTO '.$table_prefix.'geotrack SET country = \''.$_SESSION['gt_data']['country'].'\', country_code = \''.$_SESSION['gt_data']['country_code'].'\', flagname = \''.$_SESSION['gt_data']['flagname'].'\', city = \''.$_SESSION['gt_data']['city'].'\', latitude = \''.$_SESSION['gt_data']['latitude'].'\', longitude = \''.$_SESSION['gt_data']['longitude'].'\', uri = \''.$_SESSION['gt_data']['uri'].'\', method = \''.$_SERVER['REQUEST_METHOD'].'\', status = '.$status.', referrer = \''.$_SESSION['gt_data']['referrer'].'\', user_agent = \''.$_SESSION['gt_data']['ua'].'\', access_time = NOW(), ip = \''.$_SESSION['gt_data']['ip'].'\''; $wpdb->query($sql); debugMsg($sql); // Purge ALL old entries form db: if ($gt_options['gt_cleanup_days'] > 0) { $sql = 'DELETE FROM '.$table_prefix.'geotrack WHERE UNIX_TIMESTAMP(access_time) < UNIX_TIMESTAMP() - '.$gt_options['gt_cleanup_days'].' * 86400'; $wpdb->query($sql); } } function wp_geotrack_add_menu() { if (function_exists('add_options_page')) { add_options_page( 'WP-Geotrack Plugin Options', 'WP-Geotrack Plugin', 9, basename(__FILE__), 'wp_geotrack_admin_menu' ); } } function wp_geotrack_admin_menu() { global $wpdb, $table_prefix; $options = wp_geotrack_loadoptions(isset($_POST['restore_defaults'])); if (isset($_GET['block'])) { $sql = 'UPDATE '.$table_prefix.'geotrack_ipblock SET blocked = 1 WHERE ip = \''.$_GET['block'].'\''; $wpdb->query($sql); echo '

IP '.$_GET['block'].' has been blocked!

'; } else if (isset($_GET['remove'])) { $sql = 'DELETE FROM '.$table_prefix.'geotrack_ipblock WHERE ip = \''.$_GET['remove'].'\''; $wpdb->query($sql); echo '

IP '.$_GET['remove'].' has been removed from your blacklist!

'; } if (isset($_POST['info_update'])) { /////////////////////////////////////ignore_ip_address addition to array///////////////////////////////////// // need 'gt_referrer_display', $fields = array('gt_google_map_key', 'gt_google_map_lat', 'gt_google_map_long', 'gt_google_map_scale', 'gt_list_length', 'gt_toplist_length', 'gt_referrers_only', 'gt_cleanup_days', 'gt_dateformat', 'gt_exclude_user_agents', 'gt_ignored_ip_address', 'gt_referrer_display', 'gt_debug'); foreach ($fields as $field) { $options[$field] = $_POST[$field]; } /////////////////////////////////////ignore_ip_address///////////////////////////////////// $options['gt_ignored_ip_address'] = preg_replace('/\s+/', '|', $options['gt_ignored_ip_address']); /////////////////////////////////end_ignore_ip_address///////////////////////////////////// $options['gt_exclude_user_agents'] = preg_replace('/\s+/', '|', $options['gt_exclude_user_agents']); ?>

Options saved successfully!

Defaults restored successfully!

'; } else if (isset($_POST['install_db'])) { wp_geotrack_install(); echo '

Installed MySQL Database Tables

'; } if (!file_exists(GEOTRACK_PATH.'GeoLiteCity.dat')) { echo '
The Geo-IP Database is not installed yet!
Please intall it by clicking "Install/Update Geo-IP Database" below. If this fails, you can download the file here, unpack it (e.g. with WinZip, Stuffit Expander oder GunZip) and upload it to the wp_geotrack-folder inside your plugins-folder.
'; } update_option('wp_geotrack_options',$options); $_SESSION['GT_UPDATE_ALLOWED'] = true; ?>

WP/GeoTrack Plugin Options

General Plugin Options
List length
Number of log-entries to display in our list and in your map.
Top-List length
Number of Top-Sites and Top-Referres to display in your list.
Cleanup days
Clean up database automatically after displaying the list.
0 will never do any cleanup, you might want to purge old entries manually from your db
Any number x will delete entries that are older than x days.
Referrers only />
If checked, only requests that have an external referrer will displayed in your list.
Referrerals Displayed to Visitors />
If checked, The referrer address will displayed to ALL Visitors not just those logged in, in your list.
Date format
The dateformat for displaying the date in your list, see http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html, eg:
%d.%m.%Y %H:%i => 24.02.2006 14:59 (little endian)
%m/%d/%Y %h:%i %p => 02/24/2006 02:59 PM (american middle endian)
Exclude user agents
List of space-separated user agents to exclude from your tracking. EG: "bot" will exclude every user agent that contains "bot" in its name, e.g. "Googlebot" and "MSN-Bot". Case insensitive.
Ignore IP Address
List of space-separated IP-Addresses that will be completely Ignored in the tracking. EG: MSN-BOT
EG: 192.168.0.203 will exclude the single IP Address and 192.168.0.* will exclude the IP Address Range
Debug />
Display debugging information (as comments in your HTML code)
Google Map Options
Google Map Key
If you want to use Google-Maps, you have to enter your Maps API key here. If you don't have a key yet, you can get one for your site here:
http://www.google.de/apis/maps/signup.html (Google Account required)
Google Map Center (Latitude / Longitude) /
Your current guessed location: city .' ('. $_REQUEST['record']->country_name . ') ('. $_REQUEST['record']->latitude . '/' . $_REQUEST['record']->longitude . ')'; ?>
Google Map Scale
Set the initial scale of your Google map. Enter a number between 1 (complete world is visible) and 15 (street level).
4 might be a good starting point, and street level is not really useful because we only have city level information in our database.

More actions: