Changeset 357 for wp-slimstat-ex
- Timestamp:
- 06/28/08 07:15:16 (6 months ago)
- Location:
- wp-slimstat-ex
- Files:
-
- 4 modified
-
branches/pins/GeoSlimStat/pin.php (modified) (5 diffs)
-
trunk/lib/functions.php (modified) (1 diff)
-
trunk/wp-slimstat-ex-config.php (modified) (1 diff)
-
trunk/wp-slimstat-ex-options.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-slimstat-ex/branches/pins/GeoSlimStat/pin.php
r355 r357 369 369 for ($i = 0; $i < $count_ips; $i++) { 370 370 $uris[$i] = 'http://www.seomoz.org/ip2location/look.php?ip='.long2ip($ips[$i]); 371 // $uris[$i] = 'http://www.webconfs.com/ip-to-city.php?submit=submit&ipaddress='.long2ip($ips[$i]); 371 372 } 372 373 $data = $this->multi_remote_fopen($uris, false); … … 406 407 } 407 408 409 function ip_lookup_multi_sub($ips) {// just for city information 410 $count_ips = count($ips); 411 $uris = array(); 412 $info = array(); 413 for ($i = 0; $i < $count_ips; $i++) { 414 $uris[$i] = 'http://www.melissadata.com/lookups/iplocation.asp?ipaddress='.long2ip($ips[$i]); 415 } 416 $data = $this->multi_remote_fopen($uris, false); 417 for ($i = 0; $i < $count_ips; $i++) { 418 $result = trim(strip_tags($data[$i], '<b>')); 419 if (preg_match('#City\s*<b>(.*?)</b>\s*State or Region\s*<b>(.*?)</b>#is', $result, $loc)) { 420 $city = trim($loc[1]) == '-' ? '' : trim($loc[1]); 421 $city .= trim($loc[2]) == '-' ? '' : ', '.trim($loc[2]); 422 $info[$ips[$i]] = ucwords(strtolower($city)); 423 } 424 } 425 return $info; 426 } 427 428 function insert_geo_data($info) { 429 global $wpdb; 430 $ip = $info['ip']; 431 $lat = $info['lat']; 432 $long = $info['long']; 433 $city = $wpdb->escape($info['city']); 434 $country_abrv = $wpdb->escape($info['country_abrv']); 435 $query = "INSERT INTO {$this->tbGeo} (ip, country_abrv, city, latitude, longitude) 436 VALUES ($ip, '$country_abrv', '$city', '$lat', '$long')"; 437 $result = $wpdb->query($query); 438 } 439 408 440 function multi_queryHostIP($iparrs) { 409 441 global $wpdb; … … 427 459 $count_ips = count($iparrs[$i]); 428 460 $infos = $this->ip_lookup_multi($iparrs[$i]); 429 461 $info_sub = $ips_sub = array(); 430 462 for ($j=0; $j<$count_ips; $j++) { 431 $info = $infos[$iparrs[$i][$j]]; 463 $ip = $iparrs[$i][$j]; 464 $info = $infos[$ip]; 432 465 $lat = round(trim($info['lat']), 4); 433 466 $long = round(trim($info['long']), 4); 434 $city = $ip_info['city'] ? trim($info['city']) : '';435 $country_abrv = SSTrack::_determineCountry($iparrs[$i][$j]);436 467 if(!$lat && !$long) { 437 $_neg[] = $ip arrs[$i][$j];468 $_neg[] = $ip; 438 469 update_option('geo_slimstat_negip', $_neg); 439 470 continue; … … 441 472 if (is_null($lat)) $lat = 0; 442 473 if (is_null($long)) $long = 0; 443 $country_abrv = $wpdb->escape($country_abrv); 444 $city = $wpdb->escape($city); 445 $query = "INSERT INTO {$this->tbGeo} (ip, country_abrv, city, latitude, longitude) 446 VALUES (".$iparrs[$i][$j].", '$country_abrv', '$city', '$lat', '$long')"; 447 $result = $wpdb->query($query); 474 $country_abrv = SSTrack::_determineCountry($ip); 475 $city = $info['city'] ? trim($info['city']) : ''; 476 if ($city == '') { 477 $ips_sub[] = $ip; 478 $info_sub[$ip]['lat'] = $lat; 479 $info_sub[$ip]['long'] = $long; 480 $info_sub[$ip]['country_abrv'] = $country_abrv; 481 } else { 482 $this->insert_geo_data( array( 'ip'=>$ip, 'city'=>$city, 'lat'=>$lat, 'long'=>$long, 'country_abrv'=>$country_abrv ) ); 483 } 484 } 485 486 if (!empty($ips_sub)) { 487 $cities = $this->ip_lookup_multi_sub($ips_sub); 488 foreach ($ips_sub as $ip) { 489 $city = isset($cities[$ip]) ? $cities[$ip] : ''; 490 $this->insert_geo_data( array( 'ip'=>$ip, 'city'=>$city, 'lat'=>$info_sub[$ip]['lat'], 'long'=>$info_sub[$ip]['long'], 'country_abrv'=>$info_sub[$ip]['country_abrv'] ) ); 491 } 448 492 } 449 493 } … … 580 624 if ( function_exists('curl_multi_init') ) { 581 625 $count = count($ips[$i]); 582 if ( $count !=0 && ($count % 20) == 0 ) $i++;626 if ( $count !=0 && ($count % 50) == 0 ) $i++; 583 627 $ips[$i][] = $r['remote_ip']; 584 628 } else { -
wp-slimstat-ex/trunk/lib/functions.php
r300 r357 584 584 function _whoisLink($ip) { 585 585 global $SlimCfg; 586 $output = ($SlimCfg->option['whois'])?'<a href="http://ip-lookup.net/?'.$ip.'" title="Who is?" onclick="window.open(this.href, \'whois\', \'width=550,height=600,scrollbars=yes\'); return false;">':''; 586 $output = ''; 587 if ($SlimCfg->option['whois']) { 588 $link = $SlimCfg->option['whois_db'] == 'iplookup' ? 'http://ip-lookup.net/?'.$ip : 'http://private.dnsstuff.com/tools/ipall.ch?ip='.$ip.'#map'; 589 $w_h = $SlimCfg->option['whois_db'] == 'iplookup' ? 'width=550,height=600,scrollbars=yes' : 'width=550,height=800,scrollbars=yes'; 590 $output .= '<a href="'.$link.'" title="Who is?" onclick="window.open(this.href, \'whois\', \''.$w_h.'\'); return false;">'; 591 } 587 592 $output .= ($SlimCfg->option['iptohost'])?$SlimCfg->trimString(gethostbyaddr($ip)):$ip; 588 593 $output .= ($SlimCfg->option['whois'])?'</a>':''; -
wp-slimstat-ex/trunk/wp-slimstat-ex-config.php
r319 r357 58 58 59 59 function default_options() { 60 return array('tracking'=>1, 'usepins'=>1, 'cachelimit'=>0, 'guesstitle'=>1, 'dbmaxage'=>0, 'limitrows'=>20, 'iptohost'=>0, 'whois'=>1, ' meta'=>0, 'visit_type'=>'uniques', 'count_type'=>'hits', 'stats_type'=>'all', 'time_offset'=>0, 'use_ajax'=>1, 'nice_titles'=>1, 'ignore_bots'=>0, 'track_mode'=>'full');60 return array('tracking'=>1, 'usepins'=>1, 'cachelimit'=>0, 'guesstitle'=>1, 'dbmaxage'=>0, 'limitrows'=>20, 'iptohost'=>0, 'whois'=>1, 'whois_db'=>'dnsstuff', 'meta'=>0, 'visit_type'=>'uniques', 'count_type'=>'hits', 'stats_type'=>'all', 'time_offset'=>0, 'use_ajax'=>1, 'nice_titles'=>1, 'ignore_bots'=>0, 'track_mode'=>'full'); 61 61 } 62 62 -
wp-slimstat-ex/trunk/wp-slimstat-ex-options.php
r321 r357 299 299 <option value="1"<?php selected(1, (int)$SlimCfg->option['whois']); ?>>true</option> 300 300 <option value="0"<?php selected(0, (int)$SlimCfg->option['whois']); ?>>false</option> 301 </select> &mdash 302 <select name="ssex_op[whois_db]"> 303 <option value="dnsstuff"<?php selected('dnsstuff', $SlimCfg->option['whois_db']); ?>>dnsstuff.com</option> 304 <option value="iplookup"<?php selected('iplookup', $SlimCfg->option['whois_db']); ?>>ip-lookup.net</option> 301 305 </select><br /> 302 306 <?php _e('— Use "Whois" link on "Visitors" modules', 'wp-slimstat-ex') ?></td>
