Ejemplo n.º 1
0
 public function authenticate()
 {
     $record = User::model()->findByAttributes(array('username' => $this->username, 'is_active' => 1));
     if (!$record) {
         $record = User::model()->findByAttributes(array('email' => $this->username, 'is_active' => 1));
     }
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->password !== md5($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $record->id;
             $this->setState('userId', $record->id);
             $this->setState('username', $record->username);
             $this->setState('usertype', $record->user_type);
             $this->errorCode = self::ERROR_NONE;
             include_once Yii::app()->basePath . '/../ip2locationlite.class.php';
             //Load the class
             $ipLite = new ip2location_lite();
             $ipLite->setKey('6d81a70b31f21d507cdf42cc2d3d9f2f2592821074b0e5191012c1584a68c9cb');
             //Get errors and locations
             $locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
             $errors = $ipLite->getError();
             //Getting the result
             Yii::app()->session['latitude'] = $locations['latitude'];
             Yii::app()->session['longitude'] = $locations['longitude'];
             Yii::app()->session['isLoggedIn'] = true;
         }
     }
     return !$this->errorCode;
 }
Ejemplo n.º 2
0
function get_location()
{
    $my_ip = $_SERVER['REMOTE_ADDR'];
    if ($my_ip == "127.0.0.1") {
        return "Only Localhost";
        exit;
    }
    include 'ip2locationlite.class.php';
    $ipLite = new ip2location_lite();
    $ipLite->setKey('342200b4507822659cc0459457382e732e0783b7ba5e01a084be0580797c45d0');
    $locations = $ipLite->getCity($my_ip);
    $country = $locations['countryName'];
    $region = $locations['regionName'];
    $city = $locations['cityName'];
    return "{$city}, {$region}, {$country}";
}
Ejemplo n.º 3
0
 function getCountryGeoLocation()
 {
     include_once 'ip2locationlite.class.php';
     //Set geolocation cookie
     if (!isset($_COOKIE["geolocation_juzon"])) {
         $ipLite = new ip2location_lite();
         $ipLite->setKey('06fc082707b16fc07af8082fdeceed43569eece7ad373b60b82a8870b0f555c6');
         $visitorGeolocation = $ipLite->getCountry($_SERVER['REMOTE_ADDR']);
         if ($visitorGeolocation['statusCode'] == 'OK') {
             $data = base64_encode(serialize($visitorGeolocation));
             setcookie("geolocation_juzon", $data, time() + 3600 * 24 * 7);
             //set cookie for 1 week
         }
     } else {
         $visitorGeolocation = unserialize(base64_decode($_COOKIE["geolocation_juzon"]));
     }
     return $visitorGeolocation;
     //array(5) { ["statusCode"]=> string(2) "OK" ["statusMessage"]=> string(0) "" ["ipAddress"]=> string(14) "113.190.88.196" ["countryCode"]=> string(2) "VN" ["countryName"]=> string(8) "VIET NAM" }
 }
Ejemplo n.º 4
0
<?php

require_once "includes/functions.php";
require_once "includes/db_connection.php";
$ip = $_SERVER['REMOTE_ADDR'];
$query_string = $_SERVER['QUERY_STRING'];
$http_referer = $_SERVER['HTTP_REFERER'];
$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
include 'includes/layouts/ip2locationlite.class.php';
//Load the class
$ipLite = new ip2location_lite();
$ipLite->setKey('ADD_API_KEY_HERE');
//Get errors and locations
$locations = $ipLite->getCity($ip);
$errors = $ipLite->getError();
//Getting the result
if (!empty($locations) && is_array($locations)) {
    foreach ($locations as $field => $val) {
        if ($field == 'countryName') {
            $country = $val;
        }
        if ($field == 'cityName') {
            $city = $val;
        }
    }
}
if (is_bot()) {
    $isbot = 1;
} else {
    $isbot = 0;
}
Ejemplo n.º 5
0
<?php

include 'ip2locationlite.class.php';
//Load the class
$ipLite = new ip2location_lite();
$ipLite->setKey('239493602d86db252cf667f5121ad2ec98c88127e4cdc4f25208ad1535119b2c');
//Get errors and locations
$locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
$errors = $ipLite->getError();
//Getting the result
echo "<p>\n";
echo "<strong>First result</strong><br />\n";
if (!empty($locations) && is_array($locations)) {
    foreach ($locations as $field => $val) {
        echo $field . ' : ' . $val . "<br />\n";
    }
}
echo "</p>\n";
//Show errors
echo "<p>\n";
echo "<strong>Dump of all errors</strong><br />\n";
if (!empty($errors) && is_array($errors)) {
    foreach ($errors as $error) {
        echo var_dump($error) . "<br /><br />\n";
    }
} else {
    echo "No errors" . "<br />\n";
}
echo "</p>\n";
Ejemplo n.º 6
0
<?php

// Database connection string
//$ConnStr = "Driver={SQL Server};Server=92.55.94.2;Database=draft;uid=sa;pwd=G30net#";
if (ReadCookies("DefaultLanguage") == "") {
    include 'ip2locationlite.class.php';
    //Load the class
    $ipLite = new ip2location_lite();
    $ipLite->setKey('6fd5f186e30b05cfb5da94f5d9f073a66242543b9521cd5969c7fd903fa1b878');
    //Language variable
    $locations = $ipLite->getCountry("217.16.79.81");
    //$locations = $ipLite->getCountry(getIP());
    //$errors = $ipLite->getError();
    //Getting the result
    if (!empty($locations) && is_array($locations)) {
        foreach ($locations as $field => $val) {
            if ($field == "countryCode") {
                $defLang = $val;
            }
        }
    }
    if ($defLang == "US") {
        $defLang = "en";
    }
    $defLang = strtolower($defLang);
    WriteCookies("DefaultLanguage", $defLang, 14);
} else {
    $defLang = strtolower(ReadCookies("DefaultLanguage"));
}
if ($_SERVER['HTTP_HOST'] == "panorama.gps-ks.com" || $_SERVER['HTTP_HOST'] == "gps-ks.com") {
    $defLang = "al";
Ejemplo n.º 7
0
 * User: Ristee
 * Date: 13.11.2015
 * Time: 14:27
 */
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
if (isset($_GET['id'])) {
    $linkid = $_GET['id'];
} else {
    $linkid = 0;
}
require __DIR__ . '/../functions/auth.php';
require __DIR__ . '/../functions/Link.php';
require __DIR__ . '/ip2locationlite.class.php';
//LOAD THE CLASS
$ipLite = new ip2location_lite();
$ipLite->setKey('ae923f3e42d55c11ae0d9b6dcdba688847e96da84503d36b78f5deca0a47b0e6');
$auth = new Auth();
if ($auth->isAuth()) {
    $link = new Link();
    $iplinks = $link->getDownList($linkid);
    foreach ($iplinks as &$iplink) {
        $location = $ipLite->getCity(long2ip($iplink['ip']));
        $error = $ipLite->getError();
        $iplink['error'] = $error;
        $iplink['location'] = $location;
        $iplink['ip'] = long2ip($iplink['ip']);
        //array(11) {
        // ["statusCode"]=> string(2) "OK"
        // ["statusMessage"]=> string(0) ""
        // ["ipAddress"]=> string(14) "109.200.117.62"
Ejemplo n.º 8
0
<?php

include 'ip2locationlite.class.php';
$api_key = "yourapikey";
//Load the class
$ipLite = new ip2location_lite();
$ipLite->setKey($api_key);
$ip = $_SERVER["REMOTE_ADDR"];
$locations = $ipLite->getCity($ip);
if ($ip == "127.0.0.1") {
    echo "35.9846572 -84.2957059";
} else {
    if (!empty($locations) && is_array($locations)) {
        echo $locations["latitude"] . " " . $locations["longitude"];
    } else {
        echo "unknown";
    }
}
<?php

include_once 'ip2locationlite.class.php';
//Set geolocation cookie
if (!$_COOKIE["geolocation"]) {
    $ipLite = new ip2location_lite();
    $ipLite->setKey('239493602d86db252cf667f5121ad2ec98c88127e4cdc4f25208ad1535119b2c');
    $visitorGeolocation = $ipLite->getCountry($_SERVER['REMOTE_ADDR']);
    if ($visitorGeolocation['statusCode'] == 'OK') {
        $data = base64_encode(serialize($visitorGeolocation));
        setcookie("geolocation", $data, time() + 3600 * 24 * 7);
        //set cookie for 1 week
    }
} else {
    $visitorGeolocation = unserialize(base64_decode($_COOKIE["geolocation"]));
}
echo $visitorGeolocation;
var_dump($visitorGeolocation);
Ejemplo n.º 10
0
    }
    public function getCity($host)
    {
        return $this->getResult($host, 'ip-city');
    }
    private function getResult($host, $name)
    {
        $ip = @gethostbyname($host);
        // if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
        if (filter_var($ip, FILTER_VALIDATE_IP)) {
            $xml = @file_get_contents('http://' . $this->service . '/' . $this->version . '/' . $name . '/?key=' . $this->apiKey . '&ip=' . $ip . '&format=xml');
            if (get_magic_quotes_runtime()) {
                $xml = stripslashes($xml);
            }
            try {
                $response = @new SimpleXMLElement($xml);
                foreach ($response as $field => $value) {
                    $result[(string) $field] = (string) $value;
                }
                return $result;
            } catch (Exception $e) {
                $this->errors[] = $e->getMessage();
                return;
            }
        }
        $this->errors[] = '"' . $host . '" is not a valid IP address or hostname.';
        return;
    }
}
$ipLite = new ip2location_lite();
$ipLite->setKey('9f611743324fc19b5e90eaf6336dd642c87610f6dc458ddadf5d004da515bd53');
Ejemplo n.º 11
0
    }
    $browser = $_GET['b'];
    if ($browser = "Microsoft Internet Explorer") {
        $browser = "MSIE";
    }
    $os = $_GET['c'];
    $resolution = $_GET['d'];
    $language = $_GET['e'];
    $color = $_GET['f'];
    $ip = $_SERVER['REMOTE_ADDR'];
    $pageadd = $_SERVER['HTTP_REFERER'];
    $pageid = $_GET['g'];
    //file_get_contents("http://api.hostip.info/get_html.php?ip=12.215.42.19");
    include 'ip2locationlite.class.php';
    //Load the class
    $ipLite = new ip2location_lite();
    $ipLite->setKey('bfa4c5277fd57f155bc2304f445032602af56229574da720fc6cbfdf4e90bdc3');
    //Get errors and locations
    $locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
    $tags = get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=' . $ip);
    $country = "Unknown";
    $city = "Unknown";
    $state = "Unknown";
    $country = $locations['countryName'];
    $city = $locations['cityName'];
    $state = $locations['regionName'];
    $res = mysql_query("insert into tracker(c_id,c_ip,c_reffer,c_os,c_browser,c_resolution,c_language,c_color,ts,c_country,c_pageid,c_city,c_state,c_page) values('" . $cid . "','" . $ip . "','" . $site . "','" . $os . "','" . $browser . "','" . $resolution . "','" . $language . "','" . $color . "',NOW(),'" . $country . "','" . $pageid . "','" . $city . "','" . $state . "','" . $pageadd . "')");
    echo "Complete!";
} catch (Exception $e) {
    echo $e;
}
Ejemplo n.º 12
0
function PricerrTheme_get_country_code_of_ip($ip)
{
    global $wpdb;
    $s = "select * from " . $wpdb->prefix . "job_ipcache where ipnr='{$ip}'";
    $r = $wpdb->get_results($s);
    if (count($r) == 0) {
        $ipLite = new ip2location_lite();
        $ipLite->setKey(get_option('PricerrTheme_ip_key_db'));
        //Get errors and locations
        $locations = $ipLite->getCountry($ip);
        $ccode = $locations['countryCode'];
        $s = "insert into " . $wpdb->prefix . "job_ipcache (ipnr, country) values('{$ip}','{$ccode}')";
        $wpdb->query($s);
        return $ccode;
    }
    return $r[0]->country;
}
	/**
	 * Return a query-able IPInfo object
	 * 
	 * @return ip2location_lite
	 */
	protected function _connectIP() {
		$api = SiteConfig::current_site_config()->IPInfoKey;
		$ipLite = new ip2location_lite();
		$ipLite->setKey($api);
		return $ipLite;
	}
Ejemplo n.º 14
0
 public static function getCurrentLocation($full = false)
 {
     /*$ip = $_SERVER['REMOTE_ADDR'];
       $query = @unserialize(file_get_contents('http://ip-api.com/php/' . $ip));
       if ($query && $query['status'] == 'success') {
           return ($full) ? $query : $query['city'].', '.$query['country'];
       }
       return false;*/
     // Get Ip Location
     require_once JPATH_SITE . '/modules/mod_zoofilter/assets/classes/ip2locationlite.class.php';
     //Load the class
     $ipLite = new ip2location_lite();
     $ipLite->setKey('7ab1ad10b9609141a85f9267502590992ccba49bab33fbf8568688a16eebc0be');
     //Get errors and locations
     $query = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
     if ($query && $query['statusCode'] == 'OK') {
         $return = array('country' => ucwords(strtolower($query['countryName'])), 'city' => ucwords(strtolower($query['cityName'])), 'regionName' => ucwords(strtolower($query['regionName'])), 'lat' => $query['latitude'], 'lon' => $query['longitude']);
         return $full ? $return : $return['city'] . ', ' . $return['country'];
     }
     return false;
 }