# Central License Manager

This folder is a standalone multi-app activation manager that lives separately from the legacy `license_manager/` code.

## What it includes

- `index.php` — landing page + JSON API endpoints
- `manage.php` — admin dashboard for apps, licenses, and activations
- `install.php` — schema check / auto-install page
- `config.php` — local config and move-to-another-server settings
- `bootstrap.php` — shared DB, schema, and helper logic

## Tables it manages

- `clm_apps`
- `clm_licenses`
- `clm_activations`

## API endpoints

Use the folder base URL as the app setting:

```text
LICENSE_API_URL=https://your-domain.example/central_license_manager
```

Then the client will call:

- `index.php?action=activate`
- `index.php?action=verify`
- `index.php?action=deactivate`
- `index.php?action=health`

Admin/owner endpoints require the secret:

- `index.php?action=issue`
- `index.php?action=list`
- `index.php?action=apps`
- `index.php?action=update`

## Moving this folder later

1. Copy the whole `central_license_manager/` directory to the new server.
2. Set `CLM_DB_HOST`, `CLM_DB_NAME`, `CLM_DB_USER`, `CLM_DB_PASS`.
3. Set `CLM_API_SECRET` and `CLM_ADMIN_PASSWORD`.
4. Open `install.php` once to auto-create the tables.
5. Point each client app to the new base URL.

## Compatibility note

The API currently returns both:

- `max_activations`
- `allowed_activations`

That keeps older client code working while you gradually upgrade each app to send a dedicated `app_slug`.

## Current repo integration

This repo's `lib/LicenseService.php` now auto-detects this folder when `LICENSE_API_URL` is not set and uses it as the activation authority.

Default client values in this app:

- `LICENSE_APP_SLUG=bilingual-accounting`
- `LICENSE_APP_NAME=Bilingual Accounting`

You can override them per app with environment variables:

- `LICENSE_API_URL`
- `LICENSE_API_SECRET`
- `LICENSE_APP_SLUG`
- `LICENSE_APP_NAME`
- `LICENSE_PRODUCT_NAME`
- `LICENSE_PRODUCT_VERSION`

So when you move `central_license_manager/` to another server later, you only need to point each app to the new base URL and set the right app slug/name.
