Version 3.3.4

This commit is contained in:
Neo committed 2025-12-19 00:35:52 -08:00
1 parent 78706903a2
commit fb6b5baabc
2206 files changed
+409828 -382984

No files matched your search

+314 -316
View File
@@ -1,317 +1,315 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Generic Mapping Class
* Owner: Matt Mecham
* Last Updated: $Date: 2011-03-10 16:00:38 -0500 (Thu, 10 Mar 2011) $
*
* @example
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8021 $
*/
/**
* Factory class
*
* @author matt
*
*/
class classes_mapping
{
/**
* App object
* @var object
*/
static protected $_app;
/**
* Construct
*/
static public function bootstrap( $engine )
{
if ( ! $engine )
{
trigger_error( "No engine specified for class_mapping", E_USER_WARNING );
}
/* Pointless comment! */
$_file = IPS_ROOT_PATH . 'sources/classes/mapping/engines/' . $engine . '.php';
if ( is_file( $_file ) )
{
$classToLoad = IPSLib::loadLibrary( $_file, 'classes_mapping_' . $engine );
if ( class_exists( $classToLoad ) )
{
self::$_app = new $classToLoad();
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
return self::$_app;
}
}
/**
* Composite class
*/
abstract class classes_mapping_composite
{
/**
*
* Location services available flag
* @return boolean
*/
public function enabled()
{
return ( $this->fetchApiKey() ) ? true : false;
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return false;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function reverseGeoCodeLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* First check the DB, this is bound to be cheaper than sockets and Yahoo APIs
* and it's likely that in an album of images one has already has set the geo location */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'core_geolocation_cache',
'where' => 'geocache_key=\'' . $this->getDbKey( $lat, $lon ) . '\'',
'limit' => array( 0, 1 ) ) );
if ( ! empty( $test['geocache_country'] ) )
{
return $test;
}
/* Still here? Oh well, lets do it. */
$data = $this->liveReverseLookUp( $lat, $lon );
if ( ! is_array( $data ) )
{
return null;
}
$formatted = $this->formatReverseLookUp( $data );
/* Save to db */
if ( $formatted !== false && ! empty( $formatted['country'] ) )
{
$save = array( 'geocache_key' => $this->getDbKey( $lat, $lon ),
'geocache_lat' => $lat,
'geocache_lon' => $lon,
'geocache_raw' => serialize( $data ),
'geocache_country' => $formatted['country'],
'geocache_district' => $formatted['district'],
'geocache_district2' => $formatted['district2'],
'geocache_locality' => $formatted['locality'],
'geocache_type' => $formatted['type'],
'geocache_engine' => $formatted['engine'],
'geocache_added' => time(),
'geocache_short' => $formatted['short'] );
$this->DB->replace( 'core_geolocation_cache', $save, array( 'geocache_key' ) );
return $save;
}
else
{
return false;
}
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
return array( false, false );
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
return $array;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return false;
}
/**
* Make a key for the DB
* @param string $lat
* @param string $lon
* @return string
*/
protected function getDbKey( $lat, $lon )
{
return md5( trim($lat) . ',' . trim($lon) );
}
/**
* Attempt to get images from the cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _getImagesFromCache( $lat, $lon, $size )
{
$file_0 = md5( $lat . ',' . $lon . ',' . $size ) . '_0.png';
$file_1 = md5( $lat . ',' . $lon . ',' . $size ) . '_1.png';
if ( is_file( $this->_getCachePath() . '/' . $file_0 ) && is_file( $this->_getCachePath() . '/' . $file_1 ) )
{
return array( $this->_getCacheUrl() . '/' . $file_0, $this->_getCacheUrl() . '/' . $file_1 );
}
else
{
return false;
}
}
/**
* Write images to cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _setImageCache( $lat, $lon, $size, $key, $data )
{
if ( ! is_dir( $this->settings['upload_dir'] . '/maps' ) )
{
@mkdir( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
@chmod( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
}
$filename = md5( $lat . ',' . $lon . ',' . $size ) . '_' . $key;
/* Extension less */
if ( @file_put_contents( $this->_getCachePath() . '/' . $filename, $data ) )
{
$data = @getimagesize( $this->_getCachePath() . '/' . $filename );
if ( ! is_array( $data ) OR ! count( $data ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
else
{
if ( $data['mime'] == 'image/png' )
{
/* Add ext */
if ( ! @rename( $this->_getCachePath() . '/' . $filename, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else
{
if ( $data['mime'] == 'image/jpg' )
{
$gd = @imagecreatefromjpeg( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else if ( $data['mime'] == 'image/gif' )
{
$gd = @imagecreatefromgif( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
}
}
}
else
{
return false;
}
return true;
}
/**
* Returns cache path
* @return string
*/
protected function _getCachePath()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_dir'] . '/maps' : $this->settings['upload_dir'];
}
/**
* Returns cache path
* @return string
*/
protected function _getCacheUrl()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_url'] . '/maps' : $this->settings['upload_url'];
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Generic Mapping Class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
/**
* Factory class
*
* @author matt
*
*/
class classes_mapping
{
/**
* App object
* @var object
*/
static protected $_app;
/**
* Construct
*/
static public function bootstrap( $engine )
{
if ( ! $engine )
{
trigger_error( "No engine specified for class_mapping", E_USER_WARNING );
}
/* Pointless comment! */
$_file = IPS_ROOT_PATH . 'sources/classes/mapping/engines/' . $engine . '.php';
if ( is_file( $_file ) )
{
$classToLoad = IPSLib::loadLibrary( $_file, 'classes_mapping_' . $engine );
if ( class_exists( $classToLoad ) )
{
self::$_app = new $classToLoad();
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
}
else
{
throw new Exception( "No mapping engine class available for $engine" );
}
return self::$_app;
}
}
/**
* Composite class
*/
abstract class classes_mapping_composite
{
/**
*
* Location services available flag
* @return boolean
*/
public function enabled()
{
return ( $this->fetchApiKey() ) ? true : false;
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return false;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function reverseGeoCodeLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* First check the DB, this is bound to be cheaper than sockets and Yahoo APIs
* and it's likely that in an album of images one has already has set the geo location */
$test = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'core_geolocation_cache',
'where' => 'geocache_key=\'' . $this->getDbKey( $lat, $lon ) . '\'',
'limit' => array( 0, 1 ) ) );
if ( ! empty( $test['geocache_country'] ) )
{
return $test;
}
/* Still here? Oh well, lets do it. */
$data = $this->liveReverseLookUp( $lat, $lon );
if ( ! is_array( $data ) )
{
return null;
}
$formatted = $this->formatReverseLookUp( $data );
/* Save to db */
if ( $formatted !== false && ! empty( $formatted['country'] ) )
{
$save = array( 'geocache_key' => $this->getDbKey( $lat, $lon ),
'geocache_lat' => $lat,
'geocache_lon' => $lon,
'geocache_raw' => serialize( $data ),
'geocache_country' => $formatted['country'],
'geocache_district' => $formatted['district'],
'geocache_district2' => $formatted['district2'],
'geocache_locality' => $formatted['locality'],
'geocache_type' => $formatted['type'],
'geocache_engine' => $formatted['engine'],
'geocache_added' => time(),
'geocache_short' => $formatted['short'] );
$this->DB->replace( 'core_geolocation_cache', $save, array( 'geocache_key' ) );
return $save;
}
else
{
return false;
}
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
return array( false, false );
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
return $array;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return false;
}
/**
* Make a key for the DB
* @param string $lat
* @param string $lon
* @return string
*/
protected function getDbKey( $lat, $lon )
{
return md5( trim($lat) . ',' . trim($lon) );
}
/**
* Attempt to get images from the cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _getImagesFromCache( $lat, $lon, $size )
{
$file_0 = md5( $lat . ',' . $lon . ',' . $size ) . '_0.png';
$file_1 = md5( $lat . ',' . $lon . ',' . $size ) . '_1.png';
if ( is_file( $this->_getCachePath() . '/' . $file_0 ) && is_file( $this->_getCachePath() . '/' . $file_1 ) )
{
return array( $this->_getCacheUrl() . '/' . $file_0, $this->_getCacheUrl() . '/' . $file_1 );
}
else
{
return false;
}
}
/**
* Write images to cache
* @param string $lat
* @param string $lon
* @param string $size
*/
protected function _setImageCache( $lat, $lon, $size, $key, $data )
{
if ( ! is_dir( $this->settings['upload_dir'] . '/maps' ) )
{
@mkdir( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
@chmod( $this->settings['upload_dir'] . '/maps', IPS_FOLDER_PERMISSION );
}
$filename = md5( $lat . ',' . $lon . ',' . $size ) . '_' . $key;
/* Extension less */
if ( @file_put_contents( $this->_getCachePath() . '/' . $filename, $data ) )
{
$data = @getimagesize( $this->_getCachePath() . '/' . $filename );
if ( ! is_array( $data ) OR ! count( $data ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
else
{
if ( $data['mime'] == 'image/png' )
{
/* Add ext */
if ( ! @rename( $this->_getCachePath() . '/' . $filename, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else
{
if ( $data['mime'] == 'image/jpg' )
{
$gd = @imagecreatefromjpeg( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
else if ( $data['mime'] == 'image/gif' )
{
$gd = @imagecreatefromgif( $this->_getCachePath() . '/' . $filename );
if ( ! @imagepng( $gd, $this->_getCachePath() . '/' . $filename . '.png' ) )
{
unlink( $this->_getCachePath() . '/' . $filename );
return false;
}
}
}
}
}
else
{
return false;
}
return true;
}
/**
* Returns cache path
* @return string
*/
protected function _getCachePath()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_dir'] . '/maps' : $this->settings['upload_dir'];
}
/**
* Returns cache path
* @return string
*/
protected function _getCacheUrl()
{
return ( is_dir( $this->settings['upload_dir'] . '/maps' ) ) ? $this->settings['upload_url'] . '/maps' : $this->settings['upload_url'];
}
}
@@ -1,252 +1,250 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
*
* @example
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8644 $
*/
class classes_mapping_bing extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return defined( 'BING_API_KEY' ) ? BING_API_KEY : false;
}
//$result = $file->getFileContents( "http://where.yahooapis.com/geocode?appid=" . $this->getYahooAppId() . "&location=" . $lat . "," . $lon . "&flags=J&gflags=R&locale=" . YAHOO_LOCALE );
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://dev.virtualearth.net/REST/v1/Locations/" . $lat . "," . $lon . "?&key=" . BING_API_KEY );
if ( strstr( $json, ':{"' ) )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['statusCode'] ) AND $array['statusCode'] == 200 )
{
return $array['resourceSets'][0]['resources'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'bing' );
if ( is_array( $array ) )
{
$return['country'] = $array['address']['countryRegion'];
$return['district'] = $array['address']['adminDistrict'];
$return['district2'] = $array['address']['adminDistrict2'];
$return['locality'] = $array['address']['locality'];
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://www.bing.com/maps/?v=2&encType=1&where1=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$_size = str_replace( 'x', ',', $size );
$latlon = $lat . ',' . $lon;
$base = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/%s/%s/?mapSize=%s&pp=%s;9;A&key=" . $this->fetchApiKey();
$image0 = sprintf( $base, $latlon, 7, $_size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $_size, $latlon );
/* Try from cache */
$images = $this->_getImagesFromCache( $lat, $lon, $size );
if ( $images === false )
{
/* Fetch live */
if ( $_data_0 = @file_get_contents( $image0 ) )
{
$_data_1 = @file_get_contents( $image1 );
/* Attempt to write cache */
if ( $this->_setImageCache( $lat, $lon, $size, 0, $_data_0 ) !== false )
{
$this->_setImageCache( $lat, $lon, $size, 1, $_data_1 );
}
}
}
else
{
return array( $images[0], $images[1] );
}
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
class classes_mapping_bing extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return defined( 'BING_API_KEY' ) ? BING_API_KEY : false;
}
//$result = $file->getFileContents( "http://where.yahooapis.com/geocode?appid=" . $this->getYahooAppId() . "&location=" . $lat . "," . $lon . "&flags=J&gflags=R&locale=" . YAHOO_LOCALE );
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://dev.virtualearth.net/REST/v1/Locations/" . $lat . "," . $lon . "?&key=" . BING_API_KEY );
if ( strstr( $json, ':{"' ) )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['statusCode'] ) AND $array['statusCode'] == 200 )
{
return $array['resourceSets'][0]['resources'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'bing' );
if ( is_array( $array ) )
{
$return['country'] = $array['address']['countryRegion'];
$return['district'] = $array['address']['adminDistrict'];
$return['district2'] = $array['address']['adminDistrict2'];
$return['locality'] = $array['address']['locality'];
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://www.bing.com/maps/?v=2&encType=1&where1=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$_size = str_replace( 'x', ',', $size );
$latlon = $lat . ',' . $lon;
$base = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/%s/%s/?mapSize=%s&pp=%s;9;A&key=" . $this->fetchApiKey();
$image0 = sprintf( $base, $latlon, 7, $_size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $_size, $latlon );
/* Try from cache */
$images = $this->_getImagesFromCache( $lat, $lon, $size );
if ( $images === false )
{
/* Fetch live */
if ( $_data_0 = @file_get_contents( $image0 ) )
{
$_data_1 = @file_get_contents( $image1 );
/* Attempt to write cache */
if ( $this->_setImageCache( $lat, $lon, $size, 0, $_data_0 ) !== false )
{
$this->_setImageCache( $lat, $lon, $size, 1, $_data_1 );
}
}
}
else
{
return array( $images[0], $images[1] );
}
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
}
@@ -1,244 +1,242 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.2.3
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
*
* @example
*
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license This is NULLED!
* @package IP.Board
* @link http://hatynka.in
* @since 9th March 2005 11:03
* @version $Revision: 8644 $
*/
class classes_mapping_google extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return true;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . ',' . $lon . '&sensor=false' );
if ( $json )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['status'] ) AND strtolower( $array['status'] ) == 'ok' )
{
return $array['results'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'google' );
if ( is_array( $array ) )
{
foreach( $array['address_components'] as $idx => $data )
{
$key = $data['types'][0];
switch( $key )
{
case 'country':
$return['country'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_1':
$return['district'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_2':
$return['district2'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'sublocality':
$return['locality'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
}
}
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://maps.google.com/?zoom=11&q=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$latlon = $lat . ',' . $lon;
$base = "http://maps.google.com/maps/api/staticmap?center=%s&zoom=%s&size=%s&maptype=roadmap&markers=color:red|label:A|%s&sensor=false";
$image0 = sprintf( $base, $latlon, 7, $size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $size, $latlon );
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.3.4
* Bing mapping class
* Owner: Matt Mecham
* Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 9th March 2005 11:03
* @version $Revision: 10914 $
*/
class classes_mapping_google extends classes_mapping_composite
{
/**
* Registry object
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
protected $memberData;
/**
* Cache object
*
* @access protected
* @var object
*/
protected $cache;
protected $caches;
/**
* Method constructor
*
* @return @e void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return application key
* @return string
*/
public function fetchApiKey()
{
return true;
}
/**
* Reverse geocode look up
* I know. Seriously. This is really technical.
*
* @access public
* @param int Lat
* @param int Lon
* @return array Decoded JSON in an array
*/
public function liveReverseLookUp( $lat, $lon )
{
if ( $this->enabled() !== true )
{
return false;
}
/* Lets do it. */
$classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
$file = new $classToLoad();
/* fetch */
$json = $file->getFileContents( "http://maps.googleapis.com/maps/api/geocode/json?latlng=" . $lat . ',' . $lon . '&sensor=false' );
if ( $json )
{
$array = @json_decode( $json, TRUE );
if ( is_array( $array ) AND ! empty( $array['status'] ) AND strtolower( $array['status'] ) == 'ok' )
{
return $array['results'][0];
}
}
return false;
}
/**
*
* Parses the result of the look up to return info we need
* @param array $array
* @return array $return
*/
public function formatReverseLookUp( array $array )
{
$return = array( 'country' => '',
'district' => '',
'distrcit2' => '',
'locality' => '',
'short' => '',
'type' => 'address',
'engine' => 'google' );
if ( is_array( $array ) )
{
foreach( $array['address_components'] as $idx => $data )
{
$key = $data['types'][0];
switch( $key )
{
case 'country':
$return['country'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_1':
$return['district'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'administrative_area_level_2':
$return['district2'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
case 'sublocality':
$return['locality'] = ( $data['long_name'] ) ? $data['long_name'] : $data['short_name'];
break;
}
}
$return['short'] = $this->_getShort( $return );
}
return $return;
}
/**
* Returns a URL for the main map (click event)
* @param string $lat
* @param string $lon
* @return string URL
*/
public function getMapUrl( $lat, $lon )
{
return 'http://maps.google.com/?zoom=11&q=' . urlencode( $lat . ',' . $lon );
}
/*
* Fetch image URLS
* Returns an array with 2 image URLs for use next to the image
* Yes.
*
* @access public
* @param string lat
* @param string lon
* @param string Image size (200x200 is default)
*/
public function getImageUrls( $lat, $lon, $size='200x200' )
{
/* Init */
$latlon = $lat . ',' . $lon;
$base = "http://maps.google.com/maps/api/staticmap?center=%s&zoom=%s&size=%s&maptype=roadmap&markers=color:red|label:A|%s&sensor=false";
$image0 = sprintf( $base, $latlon, 7, $size, $latlon );
$image1 = sprintf( $base, $latlon, 11, $size, $latlon );
return array( $image0, $image1 );
}
/**
* Returns formatted address
*
* @param array $return
* @return string
*/
protected function _getShort( $return )
{
if ( $return['locality'] != $return['district2'] )
{
$short = $return['locality'] . ', ' . $return['district2'] . ', ' . $return['country'];
}
else
{
$short = $return['locality'] . ', ' . $return['country'];
}
return $short;
}
}
@@ -1,10 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>
@@ -1,10 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionpower.com">IP.Board</a>
</body>
</html>