# DNA My Site — Portable App (PHP)

A lightweight, portable toolkit to **map your website’s DNA**: pages, includes, assets, and variables — with an interactive graph and exportable inventory.

**Highlights**
- Scan a **local directory** (on the same server) — recommended for HostGator/cPanel.
- Optional **FTP** scan (standard FTP only; SFTP requires additional setup — see notes).
- **Upload** a ZIP (or folder) to analyze offline.
- Parse **PHP includes/require**, HTML assets (img/link/script), and **variable definitions** (PHP `$var = ...`, `define(...)`).
- Interactive **graph** with curved edges, filters, search, legends.
- Export JSON/CSV inventories and a graph image (PNG) from the browser.
- **Settings** saved to `/data/settings.json`. Your data lives alongside the app.
- Designed for **PHP 8+**. No database required.

---

## Quick Start (Local Scan)
1. Upload the folder `dna-my-site/` to your hosting (e.g., `/public_html/dna-my-site/`).
2. Visit `https://YOURDOMAIN/dna-my-site/`.
3. Open **Settings → Local Scan Root** and set your website path, e.g. `/home/USER/public_html/`.
4. Click **Scan → Local Scan**. Large files are skipped by default (configurable).
5. Switch to **Graph** to explore connections. Use **Inventory** tabs to view lists.
6. Use **Export** to download JSON/CSV or a graph image.

## FTP Scan (Optional)
- Standard FTP only (host, user, password). If your server only supports SFTP, see “SFTP Note” below.
- Provide a **Starting Path** (e.g., `/` or `/public_html`).
- We only fetch file names and sample content needed to resolve dependencies (size-limited).

## Upload ZIP
- Go to **Upload → Analyze ZIP**.
- The ZIP is extracted under `/data/uploads/SESSIONID/` (blocked from web by `.htaccess`).
- We scan the extracted copy only (original ZIP deleted after extraction).

## Exports
- `data/dna.json` is the canonical export. Also export CSVs for pages, includes, assets, variables.
- Frontend can export the live graph as **PNG**.

## SFTP Note
This package ships **FTP** (not SFTP) support out of the box for simplicity. If you need SFTP:
- Install **phpseclib** on your host (via Composer or manual vendor drop-in), then update `api/scan_ftp.php`
  where marked `// TODO: SFTP` (instructions inline).

## Security
- `/data/uploads` is protected with `.htaccess` deny rules.
- Settings are stored in JSON; **credentials are not encrypted** (keep permissions tight).

## Requirements
- PHP 8.0+
- `zip` extension enabled for upload ZIP extraction (common on shared hosting).
- Outbound internet access for CDN (Cytoscape & Tailwind). If you need fully offline, download the vendor files to `public/vendor/` and switch the script tags in `index.php` (instructions inline).

## Uninstall
- Delete the `dna-my-site/` folder. That’s it.

---

## Changelog
- v0.1.0 (initial) — Local/FTP scan, ZIP upload, parser heuristics, graph UI, exports, settings.

Enjoy!
