Advertisement
Guest User

Untitled

a guest
Dec 10th, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function setBGMPMapShortcodeArguments( $options ) {
  4.     global $bgmp;
  5.     $ipAdd = getIP();
  6.     if ($ipAdd !== 'UNKNOWN'){  
  7.         $apikey = 'yourKey';
  8.         $secret = 'yourSecret';
  9.         $quova = new Example_Quova_GeoIp($apikey, $secret);
  10.         $location = json_decode($quova->getLocation($ipAdd));
  11.         $coordinates = $bgmp->geocode($location->ipinfo->Location->CityData->postal_code);
  12.     } else { $coordinates = $bgmp->geocode( '33131' ); }
  13.    
  14.     $options[ 'mapWidth' ]                = 800;
  15.     $options[ 'mapHeight' ]               = 600;
  16.     $options[ 'latitude' ]                = $coordinates[ 'latitude' ];
  17.     $options[ 'longitude' ]               = $coordinates[ 'longitude' ];
  18.     $options[ 'zoom' ]                    = 18;
  19.     $options[ 'type' ]                    = 'ROADMAP';
  20.     $options[ 'typeControl' ]         = 'HORIZONTAL_BAR';
  21.     $options[ 'navigationControl' ]       = 'SMALL';
  22.     $options[ 'infoWindowMaxWidth' ]  = 350;
  23.    // $options[ 'categories' ]          = array( 'record-stores', 'parks' );
  24.    
  25.     return $options;
  26. }
  27. add_filter( 'bgmp_map-shortcode-arguments', 'setBGMPMapShortcodeArguments' );
  28.  
  29. function getIP() {
  30.     $ip;
  31.     if (getenv("HTTP_CLIENT_IP"))
  32.         $ip = getenv("HTTP_CLIENT_IP");
  33.     else if(getenv("HTTP_X_FORWARDED_FOR"))
  34.         $ip = getenv("HTTP_X_FORWARDED_FOR");
  35.     else if(getenv("REMOTE_ADDR"))
  36.         $ip = getenv("REMOTE_ADDR");
  37.     else
  38.         $ip = "UNKNOWN";
  39.     return $ip;
  40. }
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement