{"id":22586046,"url":"https://github.com/dimchtz/clientip","last_synced_at":"2025-03-28T17:21:30.082Z","repository":{"id":56969167,"uuid":"300996690","full_name":"DimChtz/ClientIP","owner":"DimChtz","description":"Client IP detector and various IP validators","archived":false,"fork":false,"pushed_at":"2020-10-04T20:45:37.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T17:54:52.207Z","etag":null,"topics":["client","detect","ip","localhost","visitor"],"latest_commit_sha":null,"homepage":"","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/DimChtz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-03T22:51:54.000Z","updated_at":"2021-08-14T11:04:37.000Z","dependencies_parsed_at":"2022-08-21T06:40:15.518Z","dependency_job_id":null,"html_url":"https://github.com/DimChtz/ClientIP","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimChtz%2FClientIP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimChtz%2FClientIP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimChtz%2FClientIP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimChtz%2FClientIP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DimChtz","download_url":"https://codeload.github.com/DimChtz/ClientIP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246068281,"owners_count":20718503,"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":["client","detect","ip","localhost","visitor"],"created_at":"2024-12-08T07:10:38.251Z","updated_at":"2025-03-28T17:21:30.059Z","avatar_url":"https://github.com/DimChtz.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP ClientIP - v0.1.0\n\nClient IP detector and various IP validators\n\n[![Total Downloads](https://img.shields.io/packagist/dt/dimchtz/clientip.svg)](https://packagist.org/packages/dimchtz/clientip)\n[![Latest Stable Version](https://img.shields.io/packagist/v/dimchtz/clientip.svg)](https://packagist.org/packages/dimchtz/clientip)\n[![Software License](https://img.shields.io/packagist/l/dimchtz/clientip.svg?style=flat-square)](https://github.com/DimChtz/ClientIP/blob/main/LICENSE)\n\n## Installation\n\n```sh\ncomposer require dimchtz/clientip\n```\n\n## Initialization\n\n```php\n$client = new DimChtz\\ClientIP\\ClientIP();\n```\n\nYou can also add additional IP services (for the external IP detection functionality):\n\n```php\n$client = new DimChtz\\ClientIP\\ClientIP(array(\n\t'http://v4.ident.me/',\n\t'http://checkip.amazonaws.com/',\n\t'http://ipecho.net/plain',\n));\n```\n\n## Usage \u0026 Examples\n\n#### Getting client's IP (without localhost check)\n\n```php\n$client = new DimChtz\\ClientIP\\ClientIP();\n\necho 'Visitor\\'s IP: ' . $client-\u003eget_ip(false);\n```\n\n#### Getting client's IP (with localhost check)\n\nBy default `get_ip()` will return the external IP if the user is on localhost.\n\n```php\n$client = new DimChtz\\ClientIP\\ClientIP();\n\necho 'Visitor\\'s IP: ' . $client-\u003eget_ip();\n```\n\n#### Getting client's external IP\n\n```php\n$client = new DimChtz\\ClientIP\\ClientIP();\n\necho 'Visitor\\'s external IP: ' . $client-\u003eget_external_ip();\n```\n\n#### Check if the visitor's IP is localhost\n\n```php\n$client = new DimChtz\\ClientIP\\ClientIP();\n\necho $client-\u003eis_localhost() ? 'It is localhost' : 'It is not localhost';\n```\n\n#### Check if an IP is valid (both IPv4 \u0026 IPv6)\n\n```php\necho DimChtz\\ClientIP\\ClientIP::is_valid_ip('192.168.56.23') ? 'It is valid IP' : 'It is not valid IP';\n```\n\n#### Check if an IP is valid IPv4\n\n```php\necho DimChtz\\ClientIP\\ClientIP::is_valid_ipv4('192.168.56.23') ? 'It is valid IPv4' : 'It is not valid IPv4';\n```\n\n#### Check if an IP is valid IPv6\n\n```php\necho DimChtz\\ClientIP\\ClientIP::is_valid_ipv6('::1') ? 'It is valid IPv6' : 'It is not valid IPv6';\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchtz%2Fclientip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimchtz%2Fclientip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchtz%2Fclientip/lists"}