# Worth IPTV API — cPanel deployment

This package contains PHP API and dashboard source only. It excludes local config.php, SQLite database, sessions, backups, Xtream credentials, and tests. Do not upload local api/storage or api/config/config.php.

## Requirements

- PHP 8.0+ with PDO SQLite (pdo_sqlite), SQLite3, cURL, OpenSSL, and sessions. Confirm these are enabled by your hosting provider.
- An HTTPS subdomain such as api.example.com. Set its cPanel document root to the worth-api/public folder relative to your account home. The archive must be extracted so src, config, storage, bin, and database are siblings of public, not inside it. Never use the worth-api package root as the document root.
- If your host blocks a document root outside public_html, ask hosting support for a secure document root pointing to worth-api/public. Do not place private directories inside the served document root.

## Upload and extract

1. In cPanel File Manager, open your account Home Directory (one level above public_html). Upload worth-iptv-cpanel-deployment.zip and extract it there. This creates worth-api/.
2. In cPanel Domains, create or select the API subdomain and set Document Root to worth-api/public. The domain document root is the directory served publicly.
3. In cPanel MultiPHP Manager or PHP Selector, choose PHP 8.0 or newer and confirm pdo_sqlite, sqlite3, curl, openssl, and sessions are enabled.
4. In File Manager, copy worth-api/config/config.example.php to worth-api/config/config.php. Keep config.php outside the document root. Set session.cookie_secure to true; leave xtream.allow_private_addresses false. The example database path already points to worth-api/storage/layout.sqlite.
5. Generate a new 32-byte production key in cPanel Terminal/SSH with the command below. Put the output in config.php at xtream.encryption_key, or configure it as the WORTH_CREDENTIAL_KEY environment variable. Never reuse the local development key.

~~~sh
php -r 'echo base64_encode(random_bytes(32)), PHP_EOL;'
~~~

6. Make worth-api/storage and worth-api/storage/sessions writable by the PHP account (usually permission 750 or 770 as supported by the host). Keep config.php readable by PHP but not public (usually 640 or 600). Do not use 777.

## Initialize database and administrator

Open cPanel Terminal/SSH and run these commands, replacing CPANEL_USER and ADMIN_USERNAME:

~~~sh
cd ~/worth-api
php bin/migrate.php /home/CPANEL_USER/worth-api/storage/layout.sqlite
php bin/create-admin.php /home/CPANEL_USER/worth-api/storage/layout.sqlite ADMIN_USERNAME
~~~

The last command reads the administrator password from standard input; enter a unique password when prompted. Only a password hash is stored. If cPanel CLI PHP differs from web PHP, use the host PHP 8.x executable path.

Then open https://api.example.com/admin/, sign in, register the public Xtream endpoint, sync categories, and save the layout. A new database starts empty. The hosted server must reach the Xtream host; default SSRF rules reject private or reserved IP addresses.

## URLs

- Dashboard: https://api.example.com/admin/
- Public Category Layout API v1 base: https://api.example.com/
- Resolved endpoint: https://api.example.com/index.php?panel=...

The P7 mobile/TV packages still point to the LAN test address http://192.168.100.23:8080/. To test this hosted API, set the public HTTPS base URL in each platform build configuration and rebuild the apps. Do not change API v1.

## Safety

- Only worth-api/public is the web document root. Keep src, config, storage, bin, and database outside it.
- This package includes no live configuration, database, admin password, Xtream credentials, or encryption key.
- Use HTTPS and secure admin cookies. Preserve CSRF, SSRF, redirect restrictions, and credential encryption.
- Do not disable private-address SSRF protection to reach a local/private Xtream server.
