<commit_before><?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Yahoo! Placefinder class
 * Geocodes zip/post codes into longtitude and latitude
 *
 * This CodeIgniter library connects to Yahoo's Placefinder service 
 *
 * @package   yahoo_placefinder
 * @version   1.0
 * @author    <NAME>, Too many tabs <orattue[at]toomanytabs.com>
 * @copyright Copyright (c) 2010, <NAME>
 * @license   http://www.opensource.org/licenses/mit-license.php
 * @link      http://github.com/ollierattue/codeigniter-yahoo-placefinder
 */

class Placefinder 
{
	var $yahoo_geo_app_id;
	var $CI;

	/**
	 * Constructor
	 *
	 * @access	public
	 */
	
	public function __construct()
	{
		if (!isset($this->CI))
		{
			$this->CI =& get_instance();
		}

		$this->CI->load->config('yahoo_placefinder_config');

		$this->yahoo_geo_app_id = $this->CI->config->item('yahoo_geo_app_id'));
		
		log_message('debug', "Yahoo Placefiner Class Initialized");
	}
			
	// --------------------------------------------------------------------
	
	/**
	* Geocode - supports http://developer.yahoo.com/geo/placefinder
	* @access public
	* @param string - refers to postal in database
	* @return array or FALSE
	*/

	function geocode($postal_code = NULL)
	{
		// Open the cURL session
		$curlSession = curl_init();
		$postal_code = urlencode($postal_code);

		if (!defined($this->yahoo_geo_app_id) || !$this->yahoo_geo_app_id)
		{
			return FALSE;
		}

		$url = "http://where.yahooapis.com/geocode?postal={$postal_code}&flags=P&appid={$this->yahoo_geo_app_id}";

		// Set the URL
		curl_setopt ($curlSession, CURLOPT_URL, $url);
		
		// No headers, please
		curl_setopt ($curlSession, CURLOPT_HEADER, 0);
		
		// Return it direct, don't print it out
		curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1); 
		
		// This connection will timeout in 30 seconds<commit_msg>Fixed a syntax bug and defined check which always failed<commit_after><?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Yahoo! Placefinder class
 * Geocodes zip/post codes into longtitude and latitude
 *
 * This CodeIgniter library connects to Yahoo's Placefinder service 
 *
 * @package   yahoo_placefinder
 * @version   1.0
 * @author    <NAME>, Too many tabs <orattue[at]toomanytabs.com>
 * @copyright Copyright (c) 2010, <NAME>
 * @license   http://www.opensource.org/licenses/mit-license.php
 * @link      http://github.com/ollierattue/codeigniter-yahoo-placefinder
 */

class Placefinder 
{
	var $yahoo_geo_app_id;
	var $CI;

	/**
	 * Constructor
	 *
	 * @access	public
	 */
	
	public function __construct()
	{
		if (!isset($this->CI))
		{
			$this->CI =& get_instance();
		}

		$this->CI->load->config('yahoo_placefinder_config');

		$this->yahoo_geo_app_id = $this->CI->config->item('yahoo_geo_app_id');
		
		log_message('debug', "Yahoo Placefiner Class Initialized");
	}
			
	// --------------------------------------------------------------------
	
	/**
	* Geocode - supports http://developer.yahoo.com/geo/placefinder
	* @access public
	* @param string - refers to postal in database
	* @return array or FALSE
	*/

	function geocode($postal_code = NULL)
	{
		// Open the cURL session
		$curlSession = curl_init();
		$postal_code = urlencode($postal_code);

		if (!$this->yahoo_geo_app_id)
		{
			return FALSE;
		}

		$url = "http://where.yahooapis.com/geocode?postal={$postal_code}&flags=P&appid={$this->yahoo_geo_app_id}";

		// Set the URL
		curl_setopt ($curlSession, CURLOPT_URL, $url);
		
		// No headers, please
		curl_setopt ($curlSession, CURLOPT_HEADER, 0);
		
		// Return it direct, don't print it out
		curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1); 
		
		// This connection will timeout in 30 seconds
{'fraction_non_alphanumeric': 0.17362045760430686, 'fraction_numerical': 0.005383580080753701, 'mean_word_length': 3.2275312855517635, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '102307', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1205, 'n_words': 273}