Skip to content

mohammed-alhaj-7ds/php-python-geolocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📍 Geolocation Capture — PHP + Python helper

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 in data_ip.txt.
  • Main files:
    • index.php — entry point which includes ip.php and action.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 using pystyle.

🚀 Quick start

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 (if ip.php writes to it).

🛠️ Notes & common issues

  • 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. Answer Y to start the tunnel (requires cf.exe available in PATH), or N 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 of position).
  • FormData variable naming mismatch (fromData vs formdata) and formdata.append case-sensitivity.
  • Google Maps link in PHP is missing the protocol colon (https// should be https://) and uses latitude twice — should include latitude and longitude.

✅ Success criteria

  • After starting tool.py, visiting the page and allowing location access should result in appended entries in loc.txt (latitude, longitude, and links) and data_ip.txt.

📌 Safety & privacy

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published