Exemplo 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;
 }
Exemplo 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}";
}
Exemplo n.º 3
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;
}
<?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";
Exemplo n.º 5
0
    $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"
        // ["countryCode"]=> string(2) "RU"
        // ["countryName"]=> string(18) "Russian Federation"
        // ["regionName"]=> string(10) "Sverdlovsk"
        // ["cityName"]=> string(6) "Pyshma"
        // ["zipCode"]=> string(6) "624091"
        // ["latitude"]=> string(7) "56.9523"
        // ["longitude"]=> string(7) "63.2513"
<?php

include 'ip2locationlite.class.php';
//Load the class
$ipLite = new ip2location_lite();
$ipLite->setKey('239493602d86db252cf667f5121ad2ec98c88127e4cdc4f25208ad1535119b2c');
//Get errors and locations
$longitude = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
$errors = $ipLite->getError();
//Getting the result
echo "<p>\n";
echo "<strong>First result</strong><br />\n";
if (!empty($longitude) && is_array($longitude)) {
    foreach ($longitude as $field => $val) {
        if (strcmp($field, "longitude") == 0) {
            echo $val . "<br />\n";
            $lon1 = $val;
        }
        if (strcmp($field, "latitude") == 0) {
            echo $val . "<br />\n";
            $lat1 = $val;
        }
    }
}
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";
Exemplo n.º 7
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;
 }