{"id":21945865,"url":"https://github.com/ip2location/ip2location-codeigniter4","last_synced_at":"2025-04-22T21:24:21.319Z","repository":{"id":41567014,"uuid":"402258628","full_name":"ip2location/ip2location-codeigniter4","owner":"ip2location","description":"IP2Location library for CodeIgniter 4. Use IP2Location geolocation database to lookup the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type that any IP address or hostname originates from.","archived":false,"fork":false,"pushed_at":"2024-01-03T08:19:24.000Z","size":646,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-18T21:16:48.805Z","etag":null,"topics":["codeigniter-ip2location","geolocation","geolocation-information","ip-address-database","ip-database","ip-geolocation","ip-lookup","ip2location-bin-database"],"latest_commit_sha":null,"homepage":"https://www.ip2location.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ip2location.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-09-02T01:59:29.000Z","updated_at":"2024-07-26T14:19:16.000Z","dependencies_parsed_at":"2024-01-03T02:02:16.699Z","dependency_job_id":null,"html_url":"https://github.com/ip2location/ip2location-codeigniter4","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"73b3da0b9f8aecab64c9dab169ab25261b793a97"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-codeigniter4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-codeigniter4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-codeigniter4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-codeigniter4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2location-codeigniter4/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250326066,"owners_count":21412201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codeigniter-ip2location","geolocation","geolocation-information","ip-address-database","ip-database","ip-geolocation","ip-lookup","ip2location-bin-database"],"created_at":"2024-11-29T04:19:49.410Z","updated_at":"2025-04-22T21:24:21.301Z","avatar_url":"https://github.com/ip2location.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"IP2Location CodeIgniter 4 Library\n===============================\nThis module enables users to retrieve below geolocation information from an IP address. It supports both the IPv4 and IPv6 address.\n\n* Country\n* Region\n* City\n* Latitude \u0026 Longitude\n* ZIP Code\n* Time Zone\n* Area Code\n* Net Speed\n* ISP\n* Domain\n* Mobile Information\n* Weather Station Information\n* Elevation\n* Usage Type\n* Address Type\n* Category\n\nThis library will only work with CodeIgniter 4. For CodeIgniter 3, you can get it from [here](https://github.com/ip2location/codeigniter-ip2location).\n\n\n## Installation\nUpload `Controllers`, `Libraries` and `Models` to CodeIgniter `app` folder.\n\n## Usage\nThis module is able to query the IP address information from either BIN database or web service. This section will explain how to use this extension to query from BIN database and web service.\n\nSample codes are given in this project, under **Controllers** folder. After added the following line into the *app\\Config\\Routes.php* file, you may run the sample code by using \u003cyour_domain\u003e/index.php/ip2location_test. \n```php\n$routes-\u003eget('ip2location_test', 'IP2Location_test::index');\n```\n\n### BIN Database\nUse following codes in your application for get geolocation information.\n```php\n    // (optional) Define IP2Location database path. By default, the IP2LOCATION_DATABASE is pointed to *app/Libraries/IP2Location/IP2LOCATION-DB.BIN* if you choose not to change the original settings.\n    define('IP2LOCATION_DATABASE', '/path/to/ip2location/database');\n\n    $ipl = new IP2Location_lib();\n    $countryCode = $ipl-\u003egetCountryCode('8.8.8.8');\n```\n\nBelow are the methods supported for BIN data file lookup.\n```php\n    $countryCode = $ipl-\u003egetCountryCode($ip);\n    $countryName = $ipl-\u003egetCountryName($ip);\n    $regionName = $ipl-\u003egetRegionName($ip);\n    $cityName = $ipl-\u003egetCityName($ip);\n    $latitude = $ipl-\u003egetLatitude($ip);\n    $longitude = $ipl-\u003egetLongitude($ip);\n    $isp = $ipl-\u003egetISP($ip);\n    $domainName = $ipl-\u003egetDomainName($ip);\n    $zipCode = $ipl-\u003egetZIPCode($ip);\n    $timeZone = $ipl-\u003egetTimeZone($ip);\n    $netSpeed = $ipl-\u003egetNetSpeed($ip);\n    $iddCode = $ipl-\u003egetIDDCode($ip);\n    $areaCode = $ipl-\u003egetAreaCode($ip);\n    $weatherStationCode = $ipl-\u003egetWeatherStationCode($ip);\n    $weatherStationName = $ipl-\u003egetWeatherStationName($ip);\n    $mcc = $ipl-\u003egetMCC($ip);\n    $mnc = $ipl-\u003egetMNC($ip);\n    $mobileCarrierName = $ipl-\u003egetMobileCarrierName($ip);\n    $elevation = $ipl-\u003egetElevation($ip);\n    $usageType = $ipl-\u003egetUsageType($ip);\n    $addressType = $ipl-\u003egetAddressType($ip);\n    $category = $ipl-\u003egetCategory($ip);\n```\n\n### Web Service\nUse following codes in your application for get geolocation information.\n```php\n    // (required) Define IP2Location API key.\n    define('IP2LOCATION_API_KEY', 'your_api_key');\n\n    // (required) Define IP2Location Web service package of different granularity of return information.\n    define('IP2LOCATION_PACKAGE', 'WS1');\n\n    // (optional) Define to use https or http.\n    define('IP2LOCATION_USESSL', false);\n\n    // (optional) Define extra information in addition to the above-selected package. Refer to https://www.ip2location.com/web-service/ip2location for the list of available addons.\n    define('IP2LOCATION_ADDONS', []);\n\n    // (optional) Define Translation information. Refer to https://www.ip2location.com/web-service/ip2location for available languages.\n    define('IP2LOCATION_LANGUAGE', 'zh-cn');\n\n    $ipl = new IP2Location_lib();\n    print_r ($ipl-\u003egetWebService('8.8.8.8'));\n```\n\nTo use IP2Location.io API for getting the geolocation information, you can use the following code to do so:\n```php\n\t// (required) Define IP2Location.io API key.\n    define('IP2LOCATION_IO_API_KEY', 'your_api_key');\n\n    // (optional) Define Translation information. Refer to https://www.ip2location.io/ip2location-documentation for available languages.\n    define('IP2LOCATION_IO_LANGUAGE', 'zh-cn');\n\n    $ipl = new IP2Location_lib();\n    print_r ($ipl-\u003egetWebService('8.8.8.8'));\n```\n\n### MySQL Query\nUse following codes in your application for get geolocation information.\n```php\n    define('IP2LOCATION_DATABASE_TABLE', 'ip2location_table_name');\n\n    $db = model('IP2Location_model', false);\n    print_r ($db-\u003elookup('8.8.8.8'));\n```\n\n### IPTools\nUse following codes in your application for get IPTools class information.\n```php\n    $ipl = new IP2Location_lib();\n    var_dump($ipl-\u003eisIpv4('8.8.8.8'));echo '\u003cbr\u003e';\n    var_dump($ipl-\u003eisIpv6('2001:4860:4860::8888'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003eipv4ToDecimal('8.8.8.8'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003edecimalToIpv4(134744072));echo '\u003cbr\u003e';\n    print_r($ipl-\u003eipv6ToDecimal('2001:4860:4860::8888'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003edecimalToIpv6('42541956123769884636017138956568135816'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003eipv4ToCidr('8.0.0.0', '8.255.255.255'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003ecidrToIpv4('8.0.0.0/8'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003eipv6ToCidr('2002:0000:0000:1234:abcd:ffff:c0a8:0000', '2002:0000:0000:1234:ffff:ffff:ffff:ffff'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003ecidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003ecompressIpv6('2002:0000:0000:1234:FFFF:FFFF:FFFF:FFFF'));echo '\u003cbr\u003e';\n    print_r($ipl-\u003eexpandIpv6('2002::1234:FFFF:FFFF:FFFF:FFFF'));echo '\u003cbr\u003e';\n```\n\n## Dependencies\nThis module requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at\n\n* IP2Location LITE BIN Data (Free): https://lite.ip2location.com\n* IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com\n\nAn outdated BIN database was provided in this release for your testing. You are recommended to visit the above links to download the latest BIN database.\n\nFor the BIN database update, you can just rename the downloaded BIN database to *IP2LOCATION-DB.BIN* and replace the copy in *app/Libraries/IP2Location/* (if you didn't change the default IP2LOCATION_DATABASE constant as described in the Usage section).\n\nYou can also sign up for [IP2Location Web Service](https://www.ip2location.com/web-service/ip2location) or [IP2Location.io IP GEOLOCATION API](https://www.ip2location.io/sign-up) to get one free API key.\n\n## IPv4 BIN vs IPv6 BIN\n* Use the IPv4 BIN file if you just need to query IPv4 addresses.\n* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.\n\n## SUPPORT\nEmail: support@ip2location.com\n\nWebsite: https://www.ip2location.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-codeigniter4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2location-codeigniter4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-codeigniter4/lists"}