A small utility that captures client geolocation (via browser) and stores results locally. This repository contains a simple PHP front-end that attempts to capture the browser's coordinates and helper Python scripts to run the local server and display results.
■ Quick overview
- Purpose: collect latitude/longitude in
loc.txt
and client IP info indata_ip.txt
. - Main files:
index.php
— entry point which includesip.php
andaction.php
.action.php
— client-side JS to request geolocation and server-side PHP to save coordinates.ip.php
— (not modified) expected to collect client IP info.tool.py
— Python helper to start PHP built-in server and optional Cloudflare tunnel.result.py
— Python script to pretty-print saved results usingpystyle
.
Prerequisites:
- PHP (CLI) — for
php -S
built-in server. - Python 3.8+ and
pip
— to run the helper scripts. - Optional:
cf.exe
(Cloudflare tunnel) if you want external tunnel functionality.
Install Python dependencies:
pip install -r requirements.txt
Run the helper that starts the local PHP server (and optionally Cloudflare tunnel):
python3 tool.py
Then open a browser to:
http://127.0.0.1:8080
Collected output files:
loc.txt
— contains saved latitude, longitude, and generated links.data_ip.txt
— contains client IP information (ifip.php
writes to it).
- action.php contains both server-side PHP and client-side JavaScript. The JS may have small typos or logic issues that prevent location capture from working in some browsers. If you don't see saved coordinates, check the browser console and the
loc.txt
file. - The
tool.py
helper by default asks whether to use Cloudflare Tunnel. AnswerY
to start the tunnel (requirescf.exe
available in PATH), orN
to run local-only. - Ensure the page is served over a secure context or allow location access in the browser when prompted.
■ Known small bugs (you can fix these in action.php
):
- typos in JavaScript variable names (e.g.,
positio
instead ofposition
). - FormData variable naming mismatch (
fromData
vsformdata
) andformdata.append
case-sensitivity. - Google Maps link in PHP is missing the protocol colon (
https//
should behttps://
) and uses latitude twice — should include latitude and longitude.
- After starting
tool.py
, visiting the page and allowing location access should result in appended entries inloc.txt
(latitude, longitude, and links) anddata_ip.txt
.
This repository stores client location and IP information locally in project files. Use responsibly and only with explicit consent from the clients whose data is collected.
If you want, I can also:
- fix the small JS/PHP typos in
action.php
so the capture works immediately. - add a tiny unit test or a smoke-check script to confirm
loc.txt
gets written.
Feel free to tell me which of those you'd like next.