# Guide Vault — Server Library V6

This version keeps the existing Guide Vault design and editor but moves the actual library out of browser storage.

## What changed

- Guides and ongoing-work records are saved in `storage/library.json`.
- Uploaded images are saved as real files in `storage/images/`.
- No guides or images are saved in `localStorage`.
- Reader access now requires its own code.
- Administrator access has a separate code.
- The library can be opened from another computer by visiting the hosted website.
- Existing V3/V4/V5 JSON backups can be imported.
- Base64 images from old backups are automatically extracted into real image files during import.
- The six demonstration guides are no longer added automatically.
- New installations begin with an empty library.

Browser storage is used only for harmless interface preferences such as light/dark mode and grid/list view.

## Default access codes

Change these in `config.php` before publishing:

- Reader: `GV-2468-READER`
- Administrator: `GV-2468-ADMIN`

The codes are checked by PHP on the server and are not included in the browser JavaScript.

## Run it on Windows

1. Install PHP 8.1 or later if PHP is not already available.
2. Extract the ZIP.
3. Double-click `start-guide-vault.bat`.
4. Open `http://localhost:8080`.

Do not open `index.php` by double-clicking it. PHP must be running.

## Put it online

This needs PHP hosting because a static HTML-only website cannot safely write a shared JSON file.

Recommended deployment:

1. Upload the package to your web server.
2. Configure the website document root as the `public` folder.
3. Keep `config.php` and the `storage` folder outside the public web root.
4. Ensure PHP can write to `storage/library.json` and `storage/images/`.
5. Change both access codes in `config.php`.
6. Use HTTPS.

On typical Linux hosting, writable permissions such as `775` for `storage` and `storage/images` are normally suitable. Avoid `777` unless your host specifically requires it.

When the host cannot change the document root, the site can be opened at `/public/`. The included `storage/.htaccess` blocks direct Apache access to stored JSON and images.

## Migrate your current guides

1. In the current Guide Vault, sign in as administrator.
2. Select **Export backup**.
3. Open this V6 version and sign in with the administrator code.
4. Select **Import backup**.
5. Choose the exported JSON file.
6. Confirm replacement.

The importer accepts:

- A plain array of guides
- `{ "guides": [...] }`
- `{ "guides": [...], "ongoingWork": [...] }`
- `{ "guides": [...], "work": [...] }`

Existing IDs, dates, categories, tags, draft/published states, featured settings, ongoing-work items and issue statuses are preserved.

## Backups

The administrator export creates a portable JSON backup. Server-stored images are temporarily embedded in the downloaded backup, so the JSON can be imported into another V6 installation without losing images.

## Files

- `public/index.php` — website
- `public/api.php` — login, JSON storage, imports, exports and image delivery
- `public/assets/app.css` — interface styles
- `public/assets/app.js` — browser interface
- `config.php` — reader/admin access codes
- `storage/library.json` — guides and ongoing work
- `storage/images/` — uploaded images
