<commit_before><?php namespace Controller;

class BaseController {
	
	static $blog = [];

	public function __construct(){
		\Bootie\App::load_database();
	}

	public function ip2geo(){
		extract($_POST);

		$ip = getenv('REMOTE_ADDR');

		if( $ip != '127.0.0.1' ) {

			$blog = self::$blog;
			$geoip = self::ip2geolocation($ip);

			$hit = new \Model\Hit();
			$hit->city = $geoip->city;
			$hit->country = $geoip->country;
			$hit->region = $geoip->region;
			$hit->latitude = $geoip->latitude;
			$hit->longitude = $geoip->longitude;
			$hit->path = $path;
			$hit->user_id = $blog->data->id;
			$hit->user_agent = getenv('HTTP_USER_AGENT');
			$hit->created = TIME;
			$hit->updated = TIME;
			$hit->save();

			return TRUE;
		}

		return FALSE;
	}	

	private function ip2geolocation($ip)
	{
	    //$apiurl = 'http://freegeoip.net/json/' . $ip;
	    $apiurl = 'http://www.telize.com/geoip/' . $ip;
	    
	    $ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $apiurl);
	    curl_setopt($ch, CURLOPT_HEADER, false);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
	    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
	    $data = curl_exec($ch);
	    curl_close($ch);
	 <commit_msg>Geoip curl fix<commit_after><?php namespace Controller;

class BaseController {
	
	static $blog = [];

	public function __construct(){
		\Bootie\App::load_database();
	}

	public function ip2geo(){
		extract($_POST);

		$ip = getenv('REMOTE_ADDR');

		if( $ip != '127.0.0.1' ) {

			$blog = self::$blog;
			$geoip = self::ip2geolocation($ip);
			$hit = new \Model\Hit();

			if($geoip)
			{
				if($geoip->city)
				{
					$hit->city = $geoip->city;
				}

				if($geoip->country)
				{
					$hit->country = $geoip->country;
				}

				if($geoip->region)
				{
					$hit->region = $geoip->region;
				}

				if($geoip->latitude)
				{
					$hit->latitude = $geoip->latitude;
				}

				if($geoip->longitude)
				{
					$hit->longitude = $geoip->longitude;
				}
			}

			$hit->path = $path;
			$hit->user_id = $blog->data->id;
			$hit->user_agent = getenv('HTTP_USER_AGENT');
			$hit->created = TIME;
			$hit->updated = TIME;
			$hit->save();
			
			return TRUE;
		}
		return FALSE;
	}	

	private function ip2geolocation($ip)
	{
	    //$apiurl = 'http://freegeoip.net/json/' . $ip;
	    $apiurl = 'http://www.telize.com/geoip/' . $ip;
	    
	    $ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $apiurl);
	    curl_setopt($ch, CURLOPT_HEADER, false);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
	    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
	    $data = curl_exec($ch);
	    curl_close($ch);
	 
{'fraction_non_alphanumeric': 0.18678479143595422, 'fraction_numerical': 0.007382798080472499, 'mean_word_length': 2.961988304093567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '4926560', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1033, 'n_words': 170}