| 27 | | $mini_track_options['last_online_in_profile'] = true; // automatic in profiles |
|---|
| 28 | | $mini_track_options['online_status_in_post'] = true; // automatic in posts |
|---|
| 29 | | |
|---|
| 30 | | $mini_track_options['track_time']['members'] = 30; // minutes before timeout (logout is immediate timeout) |
|---|
| 31 | | $mini_track_options['track_time']['guests'] = 30; // minutes |
|---|
| 32 | | $mini_track_options['track_time']['bots'] = 15; // minutes |
|---|
| | 27 | $mini_track_options['last_online_in_profile'] = true; // show automatically in profiles |
|---|
| | 28 | $mini_track_options['online_status_in_post'] = true; // show automatically in posts |
|---|
| | 29 | |
|---|
| | 30 | $mini_track_options['track_time']['members'] = 30; // minutes before timeout (logout is immediate timeout, so large is okay) |
|---|
| | 31 | $mini_track_options['track_time']['guests'] = 30; // minutes (busy sites may want 5-10 minutes) |
|---|
| | 32 | $mini_track_options['track_time']['bots'] = 15; // minutes (busy sites may want 5 minutes) |
|---|
| 38 | | $mini_track_options['fast_index'] = false; // false = accurately tracks NAT/proxy/spoof users // true = faster by IP only |
|---|
| 39 | | |
|---|
| | 38 | $mini_track_options['fast_index'] = false; // false = accurately tracks NAT/proxy/spoofing users // true = faster but by IP only |
|---|
| | 39 | |
|---|
| | 40 | $mini_track_options['ban_speed'] = 50; // temporarily ban any user for the track_time if they exceed this many pages per minute |
|---|
| | 41 | // (not recommended to set this lower than 50 ppm because some bots like google move that fast) |
|---|
| | 42 | // set to 0 (zero) to disable. |
|---|
| | 43 | $mini_track_options['ban_pages'] = 95; // temporarily ban any user for the track_time if they exceed this many pages in a single session |
|---|
| | 44 | // (not recommended to set this lower than 100 because some bots like google take that many at once) |
|---|
| | 45 | // set to 0 (zero) to disable. |
|---|
| | 46 | |
|---|
| | 47 | // you will be able to also temporarily ban (or unban) via the realtime display panel |
|---|
| | 48 | // note about banning: it still loads the bbPress core, just doesn't serve any content |
|---|
| 50 | | $mini_track_options['bots']="Googlebot\-Image|Googlebot|mediapartners|MSNBOT|MSN stealth|froogle|" |
|---|
| 51 | | ."Yahoo\! Slurp|Slurp|YahooSeeker|Yahoo Test|Yahoo stealth|Ask Jeeves|AskJeeves|teoma_agent|Teoma|teomaagent|slurp\@inktomi|inktomi|" |
|---|
| 52 | | ."Gigabot|Netcraft|ia_archiver|lycos|fast\-webcrawler|turnitinbot|technorati|Findexa|NextLinks|findlinks|" |
|---|
| 53 | | ."ZyBorg|InfoSeek|looksmart|Scooter|MARTINI|SurveyBot|Overture|VerticalCrawler|FastSearch|modspider|" |
|---|
| 54 | | ."Gais|gaisbo|zyborg|surveybot|Bloglines|BlogSearch|blogpulse|thumbshots|Snapbot|" |
|---|
| 55 | | ."Feedfetcher|BlogSearch|PubSub|pubsub|Syndic8|userland|become\.com|Yeti|naver|Sogou|Netcache|Netapp|BlogTick|Baiduspider|" |
|---|
| 56 | | ."Toluu|SimplePie|" |
|---|
| 57 | | ."Virtual Reach|Wordpress\/2\.|Yandex|linkcheck|idbot|id\-search|Nutch|larbin|heritrix|WebAlta|Indy Library|" |
|---|
| 58 | | ."Java\/|Wget\/|libcurl|libwww|Python-urllib|urllib|lwp-trivial|GT::WWW|Snoopy|HTTP::Lite|PHPCrawl|URI::Fetch|Zend_Http_Client|http client|PECL::HTTP|" // scrapers |
|---|
| | 60 | /* STOP EDITING HERE */ |
|---|
| | 61 | |
|---|
| | 62 | $mini_track_options['geoip'] = false; // "ip2c"; // cc lookup -> false | mysql | ip2c |
|---|
| | 63 | $mini_track_options['flags'] = false; // "/images/flags/"; // images instead of cc - path to flags |
|---|
| | 64 | |
|---|
| | 65 | $mini_track_options['debug'] = false; // true = shows more info when you hover over IP in display panel - makes saved data very large, don't use regularly |
|---|
| | 66 | |
|---|
| | 67 | $bb->load_options = true; // better db performance, but probably won't work here, put it into your bb-config.php |
|---|
| | 68 | |
|---|
| | 69 | // I don't recommend fiddling with this - if you know of other common bots, let me know for addition |
|---|
| | 70 | |
|---|
| | 71 | $mini_track_options['bots']="msnbot\-Products|msnbot\-media|MS Search|MSNBOT|MSN Stealth|" // Microsoft |
|---|
| | 72 | ."Googlebot\-Image|Googlebot\/Test|AdsBot-Google|Mediapartners|gsa-crawler|Feedfetcher|Froogle|Googlebot|Google Stealth|" // Google |
|---|
| | 73 | ."Ask Jeeves|AskJeeves|teoma_agent|teomaagent|Teoma|Ask Stealth|" // Ask (uses Teoma) |
|---|
| | 74 | ."YahooSeeker|YahooFeedSeeker|YahooVideoSearch|Yahoo-MMCrawler|Yahoo\-MMAudVid|Yahoo\-Blogs|Yahoo\! Mindset|YahooYSMcm|Yahoo Test|Scooter|Yahoo\! Slurp|Slurp\/cat|DE Slurp|Slurp China|Y\!J-BSC|Fast Crawler|slurp\@inktomi|slurp|inktomi|Yahoo stealth|" // Yahoo |
|---|
| | 75 | ."Gigabot|Netcraft|ia_archiver|fast\-webcrawler|turnitinbot|technorati|Findexa|NextLinks|findlinks|Scooter|Lycos|almaden\.ibm|almaden|" |
|---|
| | 76 | ."ZyBorg|InfoSeek|looksmart|MARTINI|SurveyBot|Overture|VerticalCrawler|FastSearch|modspider|NAMEPROTECT|WebFilter|Robozilla|" |
|---|
| | 77 | ."Gais|gaisbo|zyborg|surveybot|Bloglines|BlogSearch|blogpulse|internetseer|sitecheck|MarkWatch|flunky|SlySearch|" |
|---|
| | 78 | ."AideRSS|BlogSearch|PubSub|pubsub|Syndic8|userland|become\.com|Cowbot|Yeti|naver|Sogou|Netcache|Netapp|BlogTick|Baiduspider|" |
|---|
| | 79 | ."Toluu|SimplePie|T\-H\-U\-N\-D\-E\-R\-S\-T\-O\-N\-E|dtSearchSpider|eidetica|fantom|Girafa|grub\.org|IncyWincy|Sqworm|larbin|ScoutAbout|" |
|---|
| | 80 | ."UbiCrawler|Webclipping|Webrank|Websquash|Whizbang|cosmos|Zealbot|semanticdiscovery|Snapbot|thumbshots|" |
|---|
| | 81 | ."Virtual Reach|Wordpress\/2\.|Yandex|linkcheck|idbot|id\-search|Nutch|heritrix|WebAlta|Indy Library|Intelliseek|LNSpiderguy|LinkWalker|" |
|---|
| | 82 | ."Java\/|Wget\/|libcurl|libwww|Python-urllib|urllib|lwp-trivial|GT::WWW|Snoopy|Microsoft URL Control|HTTP::Lite|PHPCrawl|URI::Fetch|PECL::HTTP|Zend_Http_Client|http client|HTTPClient|" // scrapers |
|---|
| | 104 | |
|---|
| | 105 | // admin hooks |
|---|
| | 106 | if (defined('BB_IS_ADMIN') && BB_IS_ADMIN && isset($_GET['action']) && $_GET['action']=="activate" && $_GET['plugin'] && strpos($_GET['action'],basename(__FILE__)) ) { |
|---|
| | 107 | bb_register_activation_hook( __FILE__, 'mini_track_activation'); |
|---|
| | 108 | @require_once("mini-track-admin.php"); |
|---|
| | 109 | } |
|---|
| | 110 | if (isset($_GET['mini_track_display']) || isset($_GET['mini_track_reset']) || isset($_GET['mini_track_ip']) || isset($_GET['mini_track_ban']) || isset($_GET['mini_track_unban'])) { |
|---|
| | 111 | if (isset($_GET['mini_track_ip'])) {add_action('bb_init','mini_track_ip',100);} |
|---|
| | 112 | else {add_action('bb_init','mini_track_display',100);} |
|---|
| | 113 | @require_once("mini-track-admin.php"); |
|---|
| | 114 | } |
|---|
| | 115 | |
|---|
| 90 | | $users=0; $members=0; $bots=0; $onpage=0; $names=""; $index=""; $debug=""; |
|---|
| 91 | | $mini_track=bb_get_option('mini_track'); |
|---|
| 92 | | list($index,$debug)=mini_track_index($bb_current_user->ID); |
|---|
| | 118 | |
|---|
| | 119 | $mini_track=bb_get_option('mini_track'); // start with latest data from db |
|---|
| | 120 | $time=time(); // snapshot time for all calculations |
|---|
| | 121 | |
|---|
| | 122 | if (!empty($mini_track)) { |
|---|
| | 123 | // clean up expired entries (especially if plugin has been inactive) |
|---|
| | 124 | $cutoff['guests']=$time-$mini_track_options['track_time']['guests']*60; // seconds to consider guests "online" |
|---|
| | 125 | $cutoff['members']=$time-$mini_track_options['track_time']['members']*60; // seconds to consider members "online" |
|---|
| | 126 | $cutoff['bots']=$time-$mini_track_options['track_time']['bots']*60; // seconds to consider bots "online" |
|---|
| | 127 | |
|---|
| | 128 | foreach ($mini_track as $key=>$value) { |
|---|
| | 129 | if ($value->id) {$type="members";} elseif (isset($value->bot)) {$type="bots";} else {$type="guests";} |
|---|
| | 130 | if ($value->time<$cutoff[$type]) { // bye-bye |
|---|
| | 131 | if ($value->id) {mini_track_logout($value->id);} // store last seen date when members leave |
|---|
| | 132 | unset($mini_track[$key]); |
|---|
| | 133 | } |
|---|
| | 134 | } |
|---|
| | 135 | } |
|---|
| | 136 | |
|---|
| | 137 | list($index,$debug)=mini_track_index($bb_current_user->ID); // calculate "index" for current user |
|---|
| 95 | | if (!is_array($mini_track) || !array_key_exists($index,$mini_track)) { |
|---|
| 96 | | $mini_track[$index]->seen=time(); if ($bb_current_user->ID) {@bb_update_usermeta($bb_current_user->ID,'mini_track',date('r'));} |
|---|
| | 140 | if (empty($mini_track) || !array_key_exists($index,$mini_track)) { |
|---|
| | 141 | |
|---|
| | 142 | $mini_track[$index]->seen=$time; // we can't store the time before this as it might create a new index and we need to know that |
|---|
| | 143 | if ($bb_current_user->ID) {@bb_update_usermeta($bb_current_user->ID,'mini_track',date('r'));} |
|---|
| | 144 | if (isset($_SERVER['HTTP_REFERER'])) { |
|---|
| 101 | | |
|---|
| 102 | | // determine bots from agent - moved to first time seen to save cpu cycles and re-check unnecessary |
|---|
| | 150 | $mini_track[$index]->ip=mini_track_remote_addr(); // grap ip or proxy/cache/nat ip if valid |
|---|
| | 151 | if ($mini_track_options['geoip']=="mysql" || $mini_track_options['geoip']===true) { // geoip methods |
|---|
| | 152 | $mini_track[$index]->cc=$bbdb->get_var("SELECT cc FROM maxmind WHERE start <= inet_aton('".$mini_track[$index]->ip."') ORDER BY `start` DESC LIMIT 1"); |
|---|
| | 153 | } elseif ($mini_track_options['geoip']=="ip2c") { // slow but easy ip2c |
|---|
| | 154 | require_once(rtrim(dirname(__FILE__),' /\\')."/ip2c/ip2c.php"); |
|---|
| | 155 | $ip2c = new ip2country(rtrim(dirname(__FILE__),' /\\')."/ip2c/ip-to-country.bin"); |
|---|
| | 156 | $res = $ip2c->get_country($mini_track[$index]->ip); |
|---|
| | 157 | if ($res == false) {$mini_track[$index]->cc="??";} else {$mini_track[$index]->cc=$res['id2'];} |
|---|
| | 158 | } |
|---|
| | 159 | |
|---|
| | 160 | // determine bots from agent - moved to first seen to save cpu cycles and re-check unnecessary |
|---|
| 107 | | |
|---|
| | 166 | else { |
|---|
| | 167 | $mini_track[$index]->pages++; // count how many pages they've viewed |
|---|
| | 168 | |
|---|
| | 169 | // check for ban-able activity |
|---|
| | 170 | $active=$time - $mini_track[$index]->seen; // seconds active |
|---|
| | 171 | if ($mini_track[$index]->pages>30 && $active>30 && !($bb_current_user->ID && bb_current_user_can('administrate'))) { |
|---|
| | 172 | if ($mini_track_options['ban_speed'] && ($mini_track[$index]->pages/$active)>$mini_track_options['ban_speed']/60) {$mini_track[$index]->ban=1;} |
|---|
| | 173 | if ($mini_track_options['ban_pages'] && $mini_track[$index]->pages>$mini_track_options['ban_pages']) {$mini_track[$index]->ban=1;} |
|---|
| | 174 | } |
|---|
| | 175 | |
|---|
| | 176 | } // end repeat user |
|---|
| | 177 | |
|---|
| | 178 | $mini_track[$index]->time=$time; |
|---|
| | 179 | $mini_track[$index]->url=mini_track_safe_url($_SERVER['REQUEST_URI']); // current page |
|---|
| 123 | | if ($value->id) {$type="members";} elseif (isset($value->bot)) {$type="bots";} else {$type="guests";} |
|---|
| 124 | | if ($value->time<$cutoff[$type]) { |
|---|
| 125 | | // store last seen date when they leave |
|---|
| 126 | | if ($value->id) {mini_track_logout($value->id);} |
|---|
| 127 | | unset($mini_track[$key]); |
|---|
| 128 | | } else {$users++; |
|---|
| 129 | | if ($value->id) {$members++; $names.="<a href='$profile$value->id'>$value->name</a>, ";} |
|---|
| 130 | | if (isset($value->bot)) {$bots++;} |
|---|
| | 186 | ++$users; |
|---|
| | 187 | if ($value->id) {++$members; $names.="<a href='$profile$value->id'>$value->name</a>, ";} |
|---|
| | 188 | if (isset($value->bot)) {++$bots;} |
|---|
| 132 | | } |
|---|
| 133 | | } |
|---|
| 134 | | // @bb_update_option('mini_track',$mini_track); // argh stupid bbPress read before write wastes queries |
|---|
| 135 | | // $bbdb->get_var("UPDATE bb_topicmeta SET `meta_value` = '' WHERE topic_id = '0' AND meta_key = 'mini_track' LIMIT 1"); |
|---|
| 136 | | // $bbdb->update( $bbdb->topicmeta, array( 'meta_value' => bb_maybe_serialize( $mini_track )), array( 'topic_id' => 0, 'meta_key' => 'mini_track' ) ); |
|---|
| 137 | | |
|---|
| 138 | | if (bb_get_option('bb_db_version')>1600) {$table="$bbdb->meta"; $where="WHERE object_type='bb_option'";} // 1.0 compatibility |
|---|
| 139 | | else {$table="$bbdb->topicmeta"; $where="WHERE topic_id = 0";} // 0.9 compatibility |
|---|
| 140 | | $value=addslashes(bb_maybe_serialize( $mini_track)); |
|---|
| 141 | | @$bbdb->query("UPDATE $table SET meta_value='$value' $where AND meta_key='mini_track' LIMIT 1"); |
|---|
| 142 | | |
|---|
| 143 | | // this serialized string will get nasty for more than a few dozen people online |
|---|
| 144 | | $mini_track_current['users']=$users; |
|---|
| 145 | | $mini_track_current['members']=$members; |
|---|
| 146 | | $mini_track_current['bots']=$bots; |
|---|
| 147 | | $mini_track_current['names']=rtrim($names,", "); |
|---|
| 148 | | $mini_track_current['onpage']=$onpage; |
|---|
| 149 | | } // mini_track_init |
|---|
| 150 | | |
|---|
| 151 | | |
|---|
| 152 | | function mini_track($display=0) { |
|---|
| | 190 | if (isset($value->ban)) {$ban[$value->ip]=1;} // build list of banned IPs for double-check later |
|---|
| | 191 | if ($mini_track_options['geoip'] && isset($value->cc)) {@$cc[$value->cc]++;} |
|---|
| | 192 | } // foreach |
|---|
| | 193 | |
|---|
| | 194 | mini_track_save(); // store the data |
|---|
| | 195 | |
|---|
| | 196 | // enforce bans |
|---|
| | 197 | if ((isset($mini_track[$index]->ban) || isset($ban[$index->ip])) && !($bb_current_user->ID && bb_current_user_can('administrate'))) { // don't let admin ban themselves |
|---|
| | 198 | @header("HTTP/1.1 503 Service Temporarily Unavailable"); |
|---|
| | 199 | @header("Status: 503 Service Temporarily Unavailable"); |
|---|
| | 200 | @header("Connection: Close"); |
|---|
| | 201 | @exit(); // user has a temporary ban either because of page count or speed (or same IP as ban) no content for them until the timeout clears |
|---|
| | 202 | } |
|---|
| | 203 | |
|---|
| | 204 | // remember results for possible use later in page |
|---|
| | 205 | $mini_track_current['users']=$users; // user count |
|---|
| | 206 | $mini_track_current['members']=$members; // member count |
|---|
| | 207 | $mini_track_current['bots']=$bots; // bot count |
|---|
| | 208 | $mini_track_current['names']=rtrim($names,", ");// member names |
|---|
| | 209 | $mini_track_current['onpage']=$onpage; // number on same page |
|---|
| | 210 | if ($mini_track_options['geoip'] && is_array($cc)) { // country code counts |
|---|
| | 211 | $mini_track_current['cc']=" from "; arsort($cc); |
|---|
| | 212 | foreach ($cc as $key=>$value) { |
|---|
| | 213 | if ($mini_track_options['flags']) {$mini_track_current['cc'].="<img alt=' $key ' title='$key [$value]' src='".$mini_track_options['flags'].strtolower($key).".png'>";} else {$mini_track_current['cc'].="<span title='[$value]'>$key</span>, ";}} |
|---|
| | 214 | $mini_track_current['cc']=rtrim($mini_track_current['cc'],", ").(($mini_track_options['flags']) ? ' ' : '.'); |
|---|
| | 215 | } |
|---|
| | 216 | |
|---|
| | 217 | } // end mini_track_init |
|---|
| | 218 | |
|---|
| | 219 | function mini_track($display=0) { // displays formatted output |
|---|
| 161 | | if (bb_current_user_can('administrate')) {$start="<a href='?mini_track_display'>"; $end="</a>";} else {$start=""; $end="";} |
|---|
| 162 | | echo "<div class='mini_track'>There are <span class='mini_track_num'>".$mini_track_current['users']."</span> total $start"."users online".$end."."; |
|---|
| 163 | | if ($mini_track_current['onpage']>1 && !$mini_track_options['show_only_on_front_page']) {echo " <span class='mini_track_num'>".$mini_track_current['onpage']."</span> of them are on this page.";} |
|---|
| 164 | | if ($mini_track_current['members']>0) {echo " <span class='mini_track_num'>".$mini_track_current['members']."</span> of them are members";} |
|---|
| 165 | | if ($mini_track_current['members']>0 && ($display==2 || $display=="members")) {echo ": ".$mini_track_current['names'];} |
|---|
| 166 | | elseif ($mini_track_current['members']>0 && $display==1) {echo ".";} |
|---|
| 167 | | echo "</div>"; |
|---|
| 168 | | } |
|---|
| | 228 | if (bb_current_user_can('administrate')) {$start="<a target='_self' href='?mini_track_display'>"; $end="</a>";} else {$start=""; $end="";} |
|---|
| | 229 | $output="<div class='mini_track'>"; |
|---|
| | 230 | $output.="There are <span class='mini_track_num'>".$mini_track_current['users']."</span> $start"."users online".$end; |
|---|
| | 231 | if ($mini_track_options['geoip'] && isset($mini_track_current['cc'])) {$output.=$mini_track_current['cc'];} else {$output.=".";} |
|---|
| | 232 | if ($mini_track_current['onpage']>1 && !$mini_track_options['show_only_on_front_page']) {$output.=" <span class='mini_track_num'>".$mini_track_current['onpage']."</span> of them are on this page.";} |
|---|
| | 233 | if ($mini_track_current['members']>0) {$output.=" <span class='mini_track_num'>".$mini_track_current['members']."</span> of them are members";} |
|---|
| | 234 | if ($mini_track_current['members']>0 && ($display==2 || $display=="members")) {$output.=": ".$mini_track_current['names'];} |
|---|
| | 235 | elseif ($mini_track_current['members']>0 && $display==1) {$output.=".";} |
|---|
| | 236 | echo $output."</div>"; |
|---|
| | 237 | } |
|---|
| | 238 | } |
|---|
| | 239 | |
|---|
| | 240 | function mini_track_safe_url($url) {return substr(strip_tags(stripslashes(trim(urldecode($url),"?& "))),0,128);} |
|---|
| | 241 | |
|---|
| | 242 | function mini_track_style() {global $mini_track_options; echo "<style type='text/css'>".$mini_track_options['style']."</style>"; } //stylesheet injection |
|---|
| | 243 | |
|---|
| | 244 | function mini_track_save() { |
|---|
| | 245 | global $mini_track, $bbdb; |
|---|
| | 246 | // @bb_update_option('mini_track',$mini_track); // argh stupid bbPress read before write wastes queries |
|---|
| | 247 | // $bbdb->get_var("UPDATE bb_topicmeta SET `meta_value` = '' WHERE topic_id = '0' AND meta_key = 'mini_track' LIMIT 1"); |
|---|
| | 248 | // $bbdb->update( $bbdb->topicmeta, array( 'meta_value' => bb_maybe_serialize( $mini_track )), array( 'topic_id' => 0, 'meta_key' => 'mini_track' ) ); |
|---|
| | 249 | |
|---|
| | 250 | if (bb_get_option('bb_db_version')>1600) {$table="$bbdb->meta"; $where="WHERE object_type='bb_option'";} // 1.0 compatibility |
|---|
| | 251 | else {$table="$bbdb->topicmeta"; $where="WHERE topic_id = 0";} // 0.9 compatibility |
|---|
| | 252 | $value=addslashes(bb_maybe_serialize($mini_track)); // this serialized string will get nasty for more than a few dozen people online |
|---|
| | 253 | @$bbdb->query("UPDATE $table SET meta_value='$value' $where AND meta_key='mini_track' LIMIT 1"); // save serialized results to db |
|---|
| 233 | | function mini_track_style() {global $mini_track_options; echo "<style type='text/css'>".$mini_track_options['style']."</style>"; } |
|---|
| 234 | | |
|---|
| 235 | | function mini_track_safe_url($url) {return substr(strip_tags(stripslashes(trim(urldecode($url),"?& "))),0,128);} |
|---|
| 236 | | |
|---|
| 237 | | function mini_track_activation() { |
|---|
| 238 | | global $mini_track, $mini_track_statistics, $mini_track_done; unset($mini_track_done); |
|---|
| 239 | | $mini_track=array(); @bb_update_option('mini_track',$mini_track); |
|---|
| 240 | | $mini_track_statistics=bb_get_option('mini_track_statistics'); |
|---|
| 241 | | if (empty($mini_track_statistics)) {$mini_track_statistics=array(); @bb_update_option('mini_track_statistics',$mini_track_statistics);} |
|---|
| | 318 | function mini_track_login($id=0) { |
|---|
| | 319 | global $mini_track; |
|---|
| | 320 | $mini_track=bb_get_option('mini_track'); |
|---|
| | 321 | list($index,$debug)=mini_track_index(0); unset($mini_track[$index]); // remove the entity with same info but 0 user id |
|---|
| | 322 | @bb_update_option('mini_track',$mini_track); |
|---|
| 253 | | } |
|---|
| 254 | | function mini_track_login($id=0) { |
|---|
| 255 | | global $mini_track; |
|---|
| 256 | | $mini_track=bb_get_option('mini_track'); |
|---|
| 257 | | list($index,$debug)=mini_track_index(0); unset($mini_track[$index]); // remove the entity with same info but 0 user id |
|---|
| 258 | | @bb_update_option('mini_track',$mini_track); |
|---|
| 259 | | } |
|---|
| 260 | | |
|---|
| 261 | | function mini_track_ip(){ |
|---|
| 262 | | if (!bb_current_user_can('administrate') || !$_GET['mini_track_ip']) {return;} |
|---|
| 263 | | $ip=$_GET['mini_track_ip']; $rdns=gethostbyaddr($ip); if ($rdns==$ip) {$rdns="(no rDNS)";} |
|---|
| 264 | | echo "<html><pre><h2>IP ".$ip."</h2><h3>".$rdns."</h3>"; |
|---|
| 265 | | $data=mini_track_ip_lookup($ip); |
|---|
| 266 | | foreach ($data as $key=>$value) { |
|---|
| 267 | | if (eregi("abuse|tech|nettype|comment|remark|ReferralServer|signature|auth|encryption",$key)===false) {echo "$key: $value <br />";} |
|---|
| 268 | | } |
|---|
| 269 | | exit(); |
|---|
| 270 | | } |
|---|
| 271 | | |
|---|
| 272 | | function mini_track_ip_lookup($ip,$server=0){ |
|---|
| 273 | | $host=array('ws.arin.net','wq.apnic.net','www.db.ripe.net','lacnic.net','www.afrinic.net'); |
|---|
| 274 | | $keyword=array('arin.net','apnic.net','ripe.net','lacnic.net','afrinic.net'); |
|---|
| 275 | | $path=array('/whois/?queryinput=','/apnic-bin/whois.pl?searchtext=','/whois/?form_type=simple&searchtext=','/cgi-bin/lacnic/whois?query=','/cgi-bin/whois?form_type=simple&searchtext='); |
|---|
| 276 | | do {unset($data); |
|---|
| 277 | | if ($fp = fsockopen ($host[$server], 80, &$errno, &$errstr, 10)) { |
|---|
| 278 | | $request = "GET $path[$server]$ip HTTP/1.0\r\nHost: $host[$server]\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)\r\n\r\n"; |
|---|
| 279 | | $page=''; fputs ($fp, $request); while (!feof($fp)) {$page.=fgets ($fp,1024);} fclose ($fp); // echo $page; |
|---|
| 280 | | preg_match("/\<pre\>(.*)\<\/pre\>/sim",$page,$temp); $lines=explode("\n",strip_tags($temp[0])); |
|---|
| 281 | | foreach ($lines as $line) {$line=trim($line);if ((!ereg('^\#|\%.*$',$line)) && ($line>'')) {$temp=explode(":",$line,2); $data[trim($temp[0])] = trim($temp[1]);}} |
|---|
| 282 | | } else {$data['error'] = "$errstr ($errno)\n";} |
|---|
| 283 | | $server=0; for ($i = 1; $i <= count($host); $i++){if (strpos($data['ReferralServer'],$keyword[$i])){$server=$i;break;}} |
|---|
| 284 | | } while ($server>0); |
|---|
| 285 | | return $data; |
|---|
| 323 | | function mini_track_display() { |
|---|
| 324 | | if (!bb_current_user_can('administrate')) {return;} |
|---|
| 325 | | global $mini_track, $mini_track_current, $mini_track_options; |
|---|
| 326 | | $bb_uri=bb_get_option('uri'); $profile=$bb_uri."profile.php?id="; |
|---|
| 327 | | if (isset($_GET['mini_track_reset'])) {mini_track_activation(); mini_track_init();} |
|---|
| 328 | | echo '<html><head><title>'.count($mini_track).' Users Online « '.bb_get_option('name').'</title> |
|---|
| 329 | | <meta http-equiv="refresh" content="'.$mini_track_options['display_refresh_time'].';url='.$bb_uri.'?mini_track_display" /> |
|---|
| 330 | | <style>table {border:1px solid #111; font-size:14px; font-family: arial, san-serif; line-height:150%;} table td {text-align:center; white-space:nowrap;} table .link {text-align:left;} table th.link {padding-left:5em;} |
|---|
| 331 | | table th {background: #aaa;} .alt {background: #eee;} .tiny {font-size:12px;} .bot {color:red; font-size:90%;} .guest {color:green;} |
|---|
| 332 | | .link div {padding-left: 5px; width:500px; white-space:nowrap; overflow; hidden;} </style> |
|---|
| 333 | | <script>window.onload=titlelink; function titlelink() {blank="_blank"; for (i=0;x=document.links[i];++i){x.target=blank; if (!x.title.length) {x.title=x.href;}}};</script> |
|---|
| 334 | | </head><body>'; |
|---|
| 335 | | echo "<div style='float:right;'>[<a href='$bb_url?mini_track_reset'><small>reset</small></a>]</div>"; |
|---|
| 336 | | mini_track(2); |
|---|
| 337 | | echo "<br clear=both /><table width='99%' cellpadding=1 cellspacing=1> |
|---|
| 338 | | <tr class=alt><th>#</th><th>user</th><th>ip</th><th>referer</th><th>pages</th><th>time online</th><th>last activity</th><th class=link>last URL</th></tr>"; |
|---|
| 339 | | $mini_track=array_reverse($mini_track,true); |
|---|
| 340 | | $counter=0; |
|---|
| 341 | | foreach ($mini_track as $key=>$value) { |
|---|
| 342 | | $url=urldecode($value->url); |
|---|
| 343 | | echo "<tr".(($counter % 2) ? " class=alt" : "")."><td align=right class=tiny> ".(++$counter)." </td><td>"; // line number |
|---|
| 344 | | if ($value->id) echo "<a href='$profile$value->id'>$value->name</a>"; // member profile link |
|---|
| 345 | | elseif (isset($value->bot)) {echo "<span class=bot>".preg_replace("/[^A-Za-z_ ]+?/is","",$mini_track_options['bots'][$value->bot-1])."</span>";} else {echo "<span class=guest>guest</span>";} |
|---|
| 346 | | echo "</td><td class=tiny><a ".(($mini_track_options['debug']) ?" title='$value->debug' " : "")." href='?mini_track_ip=$value->ip'>$value->ip</a></td>"; |
|---|
| 347 | | if (isset($value->referer)) {$parse_url=parse_url($value->referer); // referer |
|---|
| 348 | | $host=substr(ereg_replace("^(www[0-9]?|search|talk|community|support|foro|mitmachen|board[s]?|forum[s]?)(\.?)","",$parse_url['host']),0,30); |
|---|
| 349 | | echo "<td><a href='$value->referer'>".$host."</a></td>";} else {echo "<td> </td>"; |
|---|
| 350 | | } |
|---|
| 351 | | echo "<td>".intval($value->pages)."</td>"; // page count |
|---|
| 352 | | echo "<td class=tiny>".ceil((($value->time)-$value->seen+1)/60)." minutes</td>"; // total activity time |
|---|
| 353 | | echo "<td class=tiny>".ceil(((time())-$value->time+1)/60)." minutes ago</td>"; // last activity time |
|---|
| 354 | | echo "<td class=link><div style='overflow:hidden;'><a href='$url'>$url</a></div></td></tr>"; // last url |
|---|
| 355 | | } |
|---|
| 356 | | echo "</table></body></html>"; |
|---|
| 357 | | exit(); |
|---|
| 358 | | } |
|---|