# Deploy Kebell Download di cPanel (PHP + MySQL)

Website ini **tidak butuh Node.js**. Cukup PHP 8.0+ dan MySQL/MariaDB
yang sudah tersedia di hampir semua hosting cPanel.

## Ringkas

1. Buat database MySQL di cPanel
2. Import `database/schema.sql` lalu `database/seed.sql` via phpMyAdmin
3. Upload semua file ke `public_html`
4. Isi kredensial di `php/config.php` (atau environment)
5. Aktifkan SSL, cek situs, masuk panel admin tersembunyi

## Langkah 1 — Buat database MySQL

1. Login cPanel → **MySQL Databases**.
2. Buat database baru, misal `username_kebell` (cPanel menambahkan
   prefix username di depan nama database).
3. Buat user MySQL baru + password kuat, lalu **Add User to Database**
   dan beri hak **ALL PRIVILEGES**.
4. Catat: nama database, username, password, host (biasanya `localhost`).

## Langkah 2 — Import skema + data awal

1. cPanel → **phpMyAdmin** → pilih database yang baru dibuat.
2. Tab **Import** → **Choose File** → pilih `database/schema.sql` → **Go**.
3. Ulangi untuk `database/seed.sql`.
4. Cek: tabel `apps` harus berisi **12 baris**, `categories` **8 baris**.

Alternatif lewat terminal (SSH, bila diaktifkan):

```bash
mysql -u username_kebell -p username_kebell < database/schema.sql
mysql -u username_kebell -p username_kebell < database/seed.sql
```

## Langkah 3 — Upload file ke public_html

1. cPanel → **File Manager** → buka `public_html`.
2. Upload file ZIP proyek, lalu **Extract** di `public_html`.
   (Atau upload lewat FTP/FileZilla ke folder yang sama.)
3. Pastikan struktur akhirnya seperti ini:

```
public_html/
  index.html
  .htaccess
  css/style.css
  js/app.js
  js/admin.js
  js/security.js
  data/apps.json
  php/config.php
  php/db.php
  php/api.php
  php/admin-api.php
  database/schema.sql
  database/seed.sql
```

4. Hak akses: file `644`, folder `755`. File `php/config.php` tidak
   boleh bisa dibaca publik (sudah diblokir di `.htaccess`).

## Langkah 4 — Isi kredensial database

Edit `php/config.php` **atau** (lebih aman) buat file di luar `public_html`:

```
/home/username/kebell-config.php
```

Isinya:

```php
<?php
return [
  'db_host' => 'localhost',
  'db_name' => 'username_kebell',
  'db_user' => 'username_kebell',
  'db_pass' => 'PASSWORD_KUAT_DI_SINI',
];
```

Kalau memakai environment (cPanel → **SetEnv** di `.htaccess`):

```
SetEnv KEBELL_DB_NAME username_kebell
SetEnv KEBELL_DB_USER username_kebell
SetEnv KEBELL_DB_PASS PASSWORD_KUAT_DI_SINI
```

## Langkah 5 — Domain / subdomain + SSL

1. **Domains** (atau **Subdomains**): arahkan domain ke `public_html`.
   Contoh subdomain: `download.namadomain.com`.
2. **SSL/TLS Status** → **Run AutoSSL** (atau instal sertifikat).
3. Setelah SSL aktif, buka `.htaccess` dan hapus tanda `#` pada
   bagian **Force HTTPS** (bagian 3).
4. Buka `https://domain-kamu/` — halaman utama harus tampil dengan
   12 APK contoh.

## Langkah 6 — Masuk panel admin (tersembunyi)

Panel admin **tidak ada link-nya** di halaman publik. Cara buka:

- Tekan **Ctrl+Shift+A**, atau
- Buka URL `https://domain-kamu/#kebell-admin`, atau
- Klik logo **Kebell Download** 5 kali berturut-turut.

Login default:

- Username: `admin`
- Password: `admin123`

**Segera ganti password** di menu **Pengaturan** setelah login pertama.
Password disimpan sebagai hash SHA-256, bukan teks asli. Login gagal
5 kali berturut-turut mengunci akun selama 5 menit. Sesi berakhir
otomatis setelah 30 menit.

## Mode statis (tanpa MySQL)

Kalau database belum diisi, situs tetap jalan:

- `js/app.js` mencoba `php/api.php` dulu (timeout singkat).
- Kalau gagal, situs memakai `data/apps.json` + localStorage.
- Perubahan di panel admin tersimpan di localStorage dan langsung
  terlihat di halaman publik.

## Troubleshooting

| Gejala | Periksa |
| --- | --- |
| Halaman putih / 500 | Error log cPanel → **Errors**; cek `php/config.php` |
| APK tidak tampil | `php/api.php?action=list` di browser; cek import seed |
| Login admin gagal | Password default `admin123`, cek tabel `admins` |
| Download tidak jalan | Link di admin harus `https://...`, cek `.htaccess` |
| CSS tidak termuat | Pastikan folder `css/` ter-upload, cek cache browser |
| HTTPS redirect loop | Matikan dulu Force HTTPS, pastikan SSL sudah aktif |
