Ejemplo n.º 1
0
 public function execute($params = array())
 {
     //echo $_POST['ip'];
     //echo "hola" . filter_input(INPUT_POST,'ip');
     //echo $_POST['netmask'];
     /*	// create IPv4 object
     		$ip_calc = new Net_IPv4();
     
     		// set variables
     		$ip_calc->ip = $ip;
     		$ip_calc->netmask = "255.255.255.0";*/
     /*$cidr = $ip . '/' . $mask;//'100.12.37.0/255.255.255.0';
     		$net = Net_IPv4::parseAddress($cidr);
     		echo $net->network."<br />";   // 192.168.0.0
     		echo $net->ip."<br />";        // 192.168.0.50
     		echo $net->broadcast."<br />"; // 192.168.255.255
     		echo $net->bitmask."<br />";   // 16
     		echo $net->long."<br />";      // 3232235520 (long/double version of 192.168.0.50)
     		echo $net->netmask."<br />";   // 255.255.0.0*/
     //$ipFinal = $net->ip . '/' . $net->bitmask;
     //echo $ipFinal;
     //echo $ip;
     //echo $mask;
     /*$geoip = new GeoIP();
     		$geoip_result = $geoip->consulta($ipFinal);*/
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (!empty($_POST['ip']) && !empty($_POST['netmask'])) {
             $ip = filter_input(INPUT_POST, 'ip');
             $mask = filter_input(INPUT_POST, 'netmask');
             $geoip = new GeoIP($ip, $mask);
             $geoip_result = $geoip->consulta();
         }
     }
     require 'app/Views/result.view.php';
 }
Ejemplo n.º 2
0
 function generateContent()
 {
     if (isset($_GET['ip'])) {
         Framework::$autoLoader->importFolder(dirname($this->paths['utils']) . '/classes');
         $geoip = new GeoIP();
         $result = $geoip->getCountry(value($_GET['ip']));
         if ($result) {
             return Alert::success('<h4>Maxmind GeoIP</h4>IP: <b>' . $_GET['ip'] . '</b> is located in <b>' . $result['country'] . '</b> (' . $result['code'] . ')');
         } else {
             return Alert::error('<h4>Maxmind GeoIP</h4>IP: <b>' . $_GET['ip'] . '</b> is not found in the country database.');
         }
     } else {
         return new Form(array('method' => 'get', 'fields' => array(new Input(array('name' => 'ip', 'placeholder' => 'IP address')), new Input(array('type' => 'submit', 'value' => 'Lookup', 'class' => 'btn btn-primary'))), 'class' => 'input-append'));
     }
 }
Ejemplo n.º 3
0
 public function getGeoIpId($clientIp)
 {
     $id = null;
     if ($geoip = $this->geoIp->byAddr($clientIp)) {
         $id = $this->geoIpRepository->findOrCreate($this->geoIp->byAddr($clientIp), array('latitude', 'longitude'));
     }
     return $id;
 }
Ejemplo n.º 4
0
 public function getGeoIpId($clientIp)
 {
     $id = null;
     if ($geoIpData = $this->geoIp->searchAddr($clientIp)) {
         $id = $this->geoIpRepository->findOrCreate($geoIpData, ['latitude', 'longitude']);
     }
     return $id;
 }
Ejemplo n.º 5
0
    function getTable($res, $width = '850', $obj = '')
    {
        $extra_table_attr = array('width' => $width);
        $tbl = new HTML_Table(get_class($this), 'display', 0, 0, 2, $extra_table_attr);
        $frm = new HTML_Form();
        $kk_trick = array();
        $tbl->addRow('', $kk_trick, '<tfoot>');
        $tbl->addCell(tableFooter($obj), NULL, 'data', array('colspan' => '5'));
        $tbl->addRow('main_table');
        $tbl->addCell($frm->addInput('checkbox', 'checkboxall', '', array('class' => 'check-all')), 'first', 'header');
        $tbl->addCell('Location', null, 'header');
        $tbl->addCell('Time on site', null, 'header');
        $tbl->addCell('User', null, 'header');
        $tbl->addCell('On-Page', null, 'header');
        $tbl->addCell('Referer', null, 'header');
        $tbl->addCell('', null, 'header');
        if ($res) {
            $objGeoIP = new GeoIP();
            while ($res->fetch($res)) {
                $objGeoIP->search_ip($res->ip);
                if ($objGeoIP->found()) {
                    $country = $objGeoIP->getCountryName();
                } else {
                    $country = $res->ip;
                }
                $check_this = $frm->addInput('checkbox', 'check_row[]', $res->id, array('id' => 'check_row[]'));
                $tbl->addRow($class);
                $tbl->addCell($check_this);
                $tbl->addCell('<a href="http://www.geoiptool.com/es/?IP=' . $res->ip . '" target="_blank">' . $country . '</a>');
                $tbl->addCell(round(($res->hora - $res->conected_from) / 60, 2) . ' Min.');
                $tbl->addCell($res->user != '' ? $res->user : '******');
                $tbl->addCell('<a href="http://www.' . $web->domain . $res->page . '" target="_blank">' . $res->page . '</a>');
                $tbl->addCell('<a href="' . $res->referer . '" target="_blank">' . substr($res->referer, 0, 20) . '</a>');
                $tbl->addCell('<a href="admin-generic-edit.php?id=' . $res->id . '&fld=' . strtolower(get_class()) . '">
									<img src="/template/kadmin/images/icons/pencil.png" alt="Edit" />
									</a>&nbsp;&nbsp;&nbsp;
									<a href="admin-generic-list.php?id=' . $res->id . '&fld=' . strtolower(get_class()) . '&action=delete" 
											onClick="return confirmDel();">
									<img src="/template/kadmin/images/icons/cross.png" alt="Delete" />
									</a>');
            }
        }
        return $tbl->display();
    }
Ejemplo n.º 6
0
 function test_country()
 {
     $geo = new GeoIP();
     $nl = gethostbyname('nu.nl');
     // IP in the Netherlands
     $us = gethostbyname('google.com');
     // IP in the US
     $this->assertEquals($geo->getCountry($nl), array('code' => 'NL', 'country' => 'Netherlands'));
     $this->assertEquals($geo->getCountry($us), array('code' => 'US', 'country' => 'United States'));
     $this->assertTrue($geo->inCountry('NL', $nl));
     $this->assertTrue($geo->inCountry('Netherlands', $nl));
     $this->assertFalse($geo->inCountry('US', $nl));
     $this->assertFalse($geo->inCountry('NL', $us));
     $this->assertTrue($geo->inCountry('US', $us));
     $this->assertTrue($geo->inCountry('United States', $us));
 }
Ejemplo n.º 7
0
 public function init()
 {
     switch ($this->mode) {
         case 'MEMORY_CACHE':
             self::$flags = GeoIP::MEMORY_CACHE;
             break;
         default:
             self::$flags = GeoIP::STANDARD;
             break;
     }
     self::$geoip = GeoIP::getInstance($this->filename, self::$flags);
     // Run parent
     parent::init();
 }
Ejemplo n.º 8
0
 public function init()
 {
     $this->filename = Yii::getPathOfAlias('app.geoip.dats') . DS . $this->filedat . '.dat';
     $this->mode = YII_DEBUG === true ? 'STANDARD' : 'MEMORY_CACHE';
     switch ($this->mode) {
         case 'MEMORY_CACHE':
             self::$flags = GeoIP::MEMORY_CACHE;
             break;
         default:
             self::$flags = GeoIP::STANDARD;
             break;
     }
     self::$geoip = GeoIP::getInstance($this->filename, self::$flags);
     // Run parent
     parent::init();
 }
Ejemplo n.º 9
0
 function ip_to_country_iso_code($ip = null, $default_iso_code = 'US')
 {
     if (empty($ip)) {
         $ip = smart_get_client_ip();
     }
     $location = \GeoIP::getLocation($ip);
     // check if NOT returned default
     if ($location['default'] === false && !empty($location['isoCode'])) {
         return $location['isoCode'];
     } else {
         return $default_iso_code;
     }
 }
Ejemplo n.º 10
0
if (file_exists($binaryPath) && file_exists($bannerPath)) {
    if ($array["diectDownload"]) {
        $array["content"] = encode(@file_get_contents($binaryPath));
    } else {
        $array["content"] = "";
    }
    $array["containsFile"] = true;
    $array["runpath"] = encode($win->getStartUpPath());
    $array["filename"] = encode(str_replace('.binary', '', $arrayInjection["binary"]));
    $dir = str_replace('/doc/', '', getCurrentPath()) . "/injections/" . $id . "/";
    $array["bannerpPath"] = encode($dir . $arrayInjection["banner"]);
    $array["binaryPath"] = encode($dir . $arrayInjection["binary"]);
    $bannerPath = $dir . $arrayInjection["banner"];
    $bannerPath = str_replace(' ', '%20', $bannerPath);
    require_once "GeoIP.php";
    $geo = new GeoIP();
    $array["ip"] = $geo->getIP();
    //"186.83.211.150";
    $tmp = $geo->getLocation($array["ip"]);
    unset($geo);
    $array["country"] = $tmp["country"];
    unset($tmp);
} else {
    exit;
}
unset($binaryPath);
if ($array["isWin"]) {
    createHeader();
    $array["os.name"] = $win->getOSVersion();
    $array["language"] = $win->getLanguage();
    $array["browser.name"] = $win->getBrowserName();
Ejemplo n.º 11
0
 function queryHandler($p)
 {
     echo '<h2>Result for ' . $p['ip'] . '</h2>';
     d(GeoIP::getRecord($p['ip']));
     echo 'Time zone: ' . GeoIP::getTimezone($p['ip']) . '<br/>';
 }
Ejemplo n.º 12
0
    }
    echo '</tbody></table>';
    Product::reindex();
    $product = Product::search($request->name);
    dd($product);
    return redirect()->route('elasticIndex', compact('product'));
}]);
Route::get('t', ['as' => 'elasticSearcht', 'uses' => function (Request $request) {
    if (function_exists('apache_request_headers')) {
        $headers = apache_request_headers();
    } else {
        $headers = $_SERVER;
    }
    //Get the forwarded IP if it exists
    if (array_key_exists('X-Forwarded-For', $headers) && filter_var($headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
        $the_ip = $headers['X-Forwarded-For'];
    } elseif (array_key_exists('HTTP_X_FORWARDED_FOR', $headers) && filter_var($headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
        $the_ip = $headers['HTTP_X_FORWARDED_FOR'];
    } else {
        $the_ip = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
    }
    dd(GeoIP::getLocation($the_ip));
}]);
Route::get('pasarela', function () {
    return view('pasarelaPrueba');
});
use Agrosellers\Services\ZonaPagos;
Route::get('consulta/{id}', function ($id) {
    $zp = ZonaPagos::create();
    dd($zp->checkPay($id));
});
Ejemplo n.º 13
0
 public function doCreate(CreateReportRequest $request)
 {
     $location = \GeoIP::getLocation();
     $allSoldProducts = [];
     $report = new SMReport();
     $soldProduct = $request->sold_product;
     $quantity = $request->quantity;
     $extraSoldProducts = $request->extra_sold_products;
     $extraQuantity = $request->extra_quantity;
     if (!empty($soldProduct)) {
         $allSoldProducts[$soldProduct] = $quantity;
     }
     if (!empty($extraSoldProducts)) {
         foreach ($extraSoldProducts as $key => $singleSoldProduct) {
             $allSoldProducts[$singleSoldProduct] = $extraQuantity[$key];
         }
     }
     $report->sm_id = \Auth::user()->id;
     $report->month = $request->month . '-' . $request->year;
     $report->date = $request->date;
     $report->doctor_id = $request->doctor;
     $report->total_sold_products_price = !empty($allSoldProducts) ? $this->productPrice($allSoldProducts) : '0';
     $report->feedback = $request->feedback;
     $report->follow_up = $request->follow_up;
     $report->lat = $location['lat'];
     $report->lon = $location['lon'];
     try {
         if ($report->save()) {
             if (!empty($request->promoted_products)) {
                 foreach ($request->promoted_products as $singleProduct) {
                     $promotedProduct = new AMReportPromotedProduct();
                     $promotedProduct->report_id = $report->id;
                     $promotedProduct->product_id = $singleProduct;
                     $promotedProduct->save();
                 }
             }
             if (!empty($request->samples_products)) {
                 foreach ($request->samples_products as $singleProduct) {
                     $sampleProduct = new AMReportSampleProduct();
                     $sampleProduct->report_id = $report->id;
                     $sampleProduct->product_id = $singleProduct;
                     $sampleProduct->save();
                 }
             }
             if (!empty($request->gifts)) {
                 foreach ($request->gifts as $singleGift) {
                     $gift = new AMReportGift();
                     $gift->report_id = $report->id;
                     $gift->gift_id = $singleGift;
                     $gift->save();
                 }
             }
             if (!empty($request->sold_product)) {
                 $soldProduct = new AMReportSoldProduct();
                 $soldProduct->report_id = $report->id;
                 $soldProduct->product_id = $request->sold_product;
                 $soldProduct->quantity = $request->quantity;
                 $soldProduct->save();
             }
             if (!empty($extraSoldProducts)) {
                 foreach ($extraSoldProducts as $key => $singleSoldProduct) {
                     $soldProduct = new AMReportSoldProduct();
                     $soldProduct->report_id = $report->id;
                     $soldProduct->product_id = $singleSoldProduct;
                     $soldProduct->quantity = $extraQuantity[$key];
                     $soldProduct->save();
                 }
             }
         }
         return redirect()->back()->with('message', 'Report has been created successfully !');
     } catch (ParseException $ex) {
         echo 'Failed to create new report , with error message: ' . $ex->getMessage();
     }
 }
Ejemplo n.º 14
0
 // eo filestring found
 #---------------------------------------------------------------------------
 #  if user not found: load array with  users ip info
 #---------------------------------------------------------------------------
 if (!$found && $ip != 'localhost') {
     //  user not known insert into array: ip, time page and do geolookup
     $users++;
     if (isset($SITE['geoKey']) && $SITE['geoKey'] != '') {
         ws_message('<!-- module wsFooter.php (' . __LINE__ . '): loading inc/geoIp.php -->');
         include_once 'inc/geoIp.php';
         $ipaddress = $ip;
         ws_message('<!-- module wsFooter.php (' . __LINE__ . '): user not found IPaddress =  ' . $ip . ' -->');
         #---------------------------------------------------------------------------
         #  if user not found: do geo lookup
         #---------------------------------------------------------------------------
         $ipinfo = GeoIP::getGeoArray($ipaddress);
         // geo lookup
     } else {
         $ipinfo['CODE'] = '';
         $ipinfo['FLAG'] = '';
     }
     if (getenv('HTTP_USER_AGENT')) {
         $agent = getenv('HTTP_USER_AGENT');
     } else {
         if ($_SERVER['HTTP_USER_AGENT']) {
             $agent = $_SERVER['HTTP_USER_AGENT'];
         } else {
             $agent = '';
         }
     }
     #---------------------------------------------------------------------------
Ejemplo n.º 15
0
<?php

namespace GeoIP;

error_reporting(-1);
chdir(dirname(__FILE__));
require 'vendor/autoload.php';
try {
    $dbFile = 'db/geo.sdb';
    if (!is_file($dbFile)) {
        throw new Exception('Run init.php to initialise the database');
    }
    $ipAddress = isset($argv) && isset($argv[1]) ? $argv[1] : '';
    if (!$ipAddress) {
        echo 'Usage: php ' . basename(__FILE__) . ' [ip_address]' . "\n";
        exit(1);
    }
    $dbh = new \PDO('sqlite:' . $dbFile);
    $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    echo json_encode(GeoIP::lookup($ipAddress, $dbh)) . "\n";
} catch (\Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
exit(0);
    //dd($data);
    //dd(DB::getQueryLog());
    $data['meta_title'] = 'Find the Best ' . $category_name . ' Restaurants in ' . $city_name . ' | Restaurant Listings|';
    $data['meta_description'] = $category_name . ' Online food Order, Get Menu, Reviews, Contact, Location Maps, Directions';
    $data['meta_keywords'] = $city_name . ', ' . $category_name . ' Online food Order, Get Menu, Reviews, Contact, Location Maps, Directions';
    $agent = new Agent();
    if ($agent->isMobile()) {
        return \View::make('mobile_search')->with($data);
    } else {
        return \View::make('search')->with($data);
    }
});
Route::get('category/{category_name}', function ($category_name) {
    //dd(Input::get('current_location'));
    DB::connection()->enableQueryLog();
    $data['locations'] = GeoIP::getLocation();
    if ($data['locations']['country'] == 'United States') {
        $data['search_city'] = $data['locations']['city'];
        $data['search_state'] = $data['locations']['state'];
    } else {
        $data['search_city'] = 'Phoenix';
        $data['search_state'] = 'AZ';
    }
    $data['location'] = $data['search_city'] . ', ' . $data['search_state'];
    //Get the filter options matching the location
    $data['filter_options']['city'] = DB::table('city')->take(5)->get();
    //Get restaurants matching the keywords and the location
    $data['restaurants'] = DB::table('restaurants')->join('city', 'city.id', '=', 'restaurants.city_id')->join('state', 'state.id', '=', 'restaurants.state_id')->join('restaurants_info', 'restaurants_info.restaurants_id', '=', 'restaurants.id')->where('restaurants.categories', 'LIKE', '%' . $category_name . '%')->where('city.city', '=', $data['search_city'])->where('state.short', '=', $data['search_state'])->orderBy('restaurants.rank', 'desc')->orderBy('restaurants.categories', 'asc')->paginate(10);
    $data['cuisine'] = DB::table('categories')->get();
    foreach ($data['restaurants'] as $r) {
        if ($r->hours != '') {
Ejemplo n.º 17
0
<?php

require 'classMySQL.php';
echo "Consulta \n";
$ip = $argv[1];
$geoip = new GeoIP();
$geoip_result = $geoip->consulta($ip);
Ejemplo n.º 18
0
        $resultado = $this->con->prepare('select l.city_name, l.country_name, b.latitude, b.longitude, b.postal_code  from cities_blocks_ip4 b INNER JOIN cities_locations l ON l.geoname_id = b.geoname_id where b.network = :ip');
        $resultado->execute(array(':ip' => $ip));
        return $resultado;
    }
    public function closeConnection()
    {
        $this->con = null;
    }
}
class GeoIP
{
    private $ip;
    public function __construct($dir)
    {
        $this->ip = $dir;
    }
    public function consult()
    {
        $data = new Database();
        $data->connect();
        $resultado = $data->consulta($this->ip);
        while ($datos = $resultado->fetch()) {
            print "\n" . 'City Name:' . $datos[0] . ' Country Name:' . $datos[1] . ' Latitude:' . $datos[2] . ' Longitude:' . $datos[3] . ' Postal Code:' . $datos[4] . "\n";
        }
    }
}
$geoip = new GeoIP($argv[1]);
$geoip->consult();
?>
</body>
</html>