{"id":25672914,"url":"https://github.com/yashokuu/blockaccess","last_synced_at":"2026-05-18T14:05:55.335Z","repository":{"id":270588973,"uuid":"910831402","full_name":"yashokuu/blockAccess","owner":"yashokuu","description":"This PHP project detects the client's geolocation and VPN usage using the ip-api service and applies access control logic based on the detected data.","archived":false,"fork":false,"pushed_at":"2025-01-24T12:38:52.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T16:33:23.472Z","etag":null,"topics":["404","access-control","acessdenied","ban","blocker","country-blocker","github","ip-blocker","php","restrictions"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yashokuu.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-01T15:10:14.000Z","updated_at":"2025-01-24T12:34:29.000Z","dependencies_parsed_at":"2025-02-12T16:35:13.645Z","dependency_job_id":"c3980424-5a1f-4b40-a951-58560172259a","html_url":"https://github.com/yashokuu/blockAccess","commit_stats":null,"previous_names":["siyam-yas/blockaccess","yashokuu/blockaccess"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashokuu%2FblockAccess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashokuu%2FblockAccess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashokuu%2FblockAccess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yashokuu%2FblockAccess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yashokuu","download_url":"https://codeload.github.com/yashokuu/blockAccess/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240475230,"owners_count":19807292,"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":["404","access-control","acessdenied","ban","blocker","country-blocker","github","ip-blocker","php","restrictions"],"created_at":"2025-02-24T12:19:28.901Z","updated_at":"2025-11-17T14:01:23.124Z","avatar_url":"https://github.com/yashokuu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e[!WARNING]\n\u003e This version might contain unexpected behaviors.\n\n\u003e[!IMPORTANT]\n\u003e Untested Version (3.1_beta) \n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=blockAccess\" width=\"450\"/\u003e\n---\n\nThis PHP project detects the client's geolocation and VPN usage using the `ip-api` service and applies access control logic based on the detected data.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Features\" width=\"450\"/\u003e\n---\n- Detects the client's country based on their IP address.\n- Identifies if the client is using a VPN or proxy.\n- Implements flexible access control logic using a configuration file (`access.txt`).\n- Provides user-friendly error messages in case of failures.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Requirements\" width=\"450\"/\u003e\n---\n- PHP-enabled web server.\n- Internet access to query the IP-API service.\n- A configuration file named `access.txt` for access rules.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Installation\" width=\"450\"/\u003e\n---\n1. Clone or download the repository to your PHP server.\n2. Place the PHP file (`access_control.php`) in your server's web directory.\n3. Create an `access.txt` file in the same directory with access rules. Example:\n   ```\n   allow:USA\n   allow:Canada\n   block:India\n   block:Israel\n   only:Malaysia\n   ```\n4. Add this code to the file where you want to restrict access:\n   ```php\n   \u003c?php include \"access_control.php\"; ?\u003e\n   ```\n5. Ensure the server can make outbound HTTP requests to `http://ip-api.com`.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=How+It+Works\" width=\"450\"/\u003e\n---\n1. **IP Detection**: The script uses `$_SERVER['REMOTE_ADDR']` to get the client's IP address. If the server is behind a proxy, it checks `$_SERVER['HTTP_X_FORWARDED_FOR']` for the forwarded IP.\n2. **API Query**: The IP is sent to the IP-API service to fetch geolocation and VPN data.\n3. **Error Handling**: If the API call fails or returns an error, access is granted by default with a warning message.\n4. **Access Logic**:\n   - Reads `access.txt` to determine rules.\n   - Grants access to countries marked as `allow`.\n   - Denies access to countries marked as `block`.\n   - Overrides other rules for countries marked as `only`.\n5. **Response**: Displays a message based on the access decision.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Customization\" width=\"450\"/\u003e\n---\n- **Access Rules**:\n  Modify the `access.txt` file to add, remove, or update country rules.\n- **VPN Policy**:\n  Adjust the `if ($isVpn)` block in `access_control.php` to change the behavior for VPN users.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Example+'access.txt'\" width=\"450\"/\u003e\n---\n```plaintext\n# This file contains access rules for the website:\n# - 'allow' specifies countries that are explicitly allowed to access the site.\n# - 'block' specifies countries that are explicitly denied access to the site.\n# - 'only' specifies countries that are granted special access, overriding other restrictions.\n\nallow:USA\nallow:Canada\nblock:India\nblock:Israel\nonly:Malaysia\n```\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Instructions+for+use\" width=\"450\"/\u003e\n---\n1. Add the `access_control.php` script to your PHP project.\n2. Create and configure the `access.txt` file with your desired rules.\n3. Include the `access_control.php` script in any PHP file where you want to apply access restrictions:\n   ```php\n   \u003c?php include \"access_control.php\"; ?\u003e\n   ```\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Notes\" width=\"450\"/\u003e\n---\n- Ensure compliance with privacy and legal regulations when implementing geolocation-based restrictions.\n- The script depends on the availability of the IP-API service. Consider implementing caching to reduce API usage.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=License\" width=\"450\"/\u003e\n---\nThis project is licensed under the YASL License. See the `LICENSE` file for details.\n\n---\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Acknowledgement\" width=\"450\"/\u003e\n---\n- [IP-API](http://ip-api.com) for providing the geolocation and VPN detection service.\n- [Flag API](https://flagsapi.com) for providing additional country flag data.\n---\n\n\n\n\u003ca id=\"styles\"\u003e\u003c/a\u003e  \n\u003cimg src=\"https://readme-typing-svg.herokuapp.com?font=Lexend+Giga\u0026size=25\u0026pause=1000\u0026color=CCA9DD\u0026vCenter=true\u0026width=435\u0026height=25\u0026lines=Version+:+3.1_Alpha\" width=\"450\"/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyashokuu%2Fblockaccess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyashokuu%2Fblockaccess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyashokuu%2Fblockaccess/lists"}