# Panduan Upload & Fix Logout Issue

## Masalah
Setelah logout, sistem mengarah ke halaman directory listing (Index of /rwl/) bukan ke halaman login.

## Penyebab
1. File `.htaccess` tidak ter-upload atau tidak dikonfigurasi dengan benar
2. Logout redirect menggunakan relative URL yang tidak konsisten di hosting

## Solusi yang Sudah Diterapkan

### 1. File `logout.php` (Root folder)
✅ Diubah redirect dari `index.php` ke absolute URL `login_secure.php`
```php
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$login_url = $protocol . '://' . $host . '/login_secure.php?message=' . urlencode('You have been logged out successfully');
header("Location: " . $login_url);
```

### 2. File `.htaccess` (Root folder: /dsp-report/)
✅ Ditambahkan konfigurasi:
- DirectoryIndex untuk prioritas file index
- Options -Indexes untuk disable directory listing

### 3. File `.htaccess` (Folder /rwl/)
✅ Dibuat baru dengan konfigurasi:
- DirectoryIndex media.php
- Disable directory listing
- Rewrite rules untuk redirect ke media.php

### 4. File `.htaccess` (Folder /pgn/)
✅ Dibuat baru dengan konfigurasi yang sama seperti RWL

## Cara Upload ke Hosting

### File yang HARUS di-upload ulang:

1. **`/logout.php`** (Root folder)
   - Path hosting: `/public_html/logout.php`

2. **`/.htaccess`** (Root folder)
   - Path hosting: `/public_html/.htaccess`
   - ⚠️ PENTING: Pastikan file .htaccess ter-upload (file hidden)

3. **`/rwl/.htaccess`** (RWL folder)
   - Path hosting: `/public_html/rwl/.htaccess`
   - ⚠️ File BARU, pastikan ter-upload

4. **`/pgn/.htaccess`** (PGN folder)
   - Path hosting: `/public_html/pgn/.htaccess`
   - ⚠️ File BARU, pastikan ter-upload

### Upload via FileZilla/cPanel File Manager:

#### Via FileZilla:
1. Connect ke hosting
2. **PENTING**: Di FileZilla → Server → Force showing hidden files (centang)
3. Upload file-file di atas ke path yang sesuai
4. Pastikan permission:
   - `.htaccess` files → 644
   - `logout.php` → 644

#### Via cPanel File Manager:
1. Login ke cPanel
2. Buka File Manager
3. **PENTING**: Klik "Settings" (kanan atas) → Centang "Show Hidden Files (dotfiles)"
4. Navigate ke folder yang sesuai
5. Upload/Edit file-file di atas
6. Pastikan permission 644

## Verifikasi Upload

### 1. Cek .htaccess ter-upload:
Akses via browser:
```
https://dsp-report.web.id/.htaccess
```
Seharusnya muncul error 403 Forbidden (bukan 404 Not Found)

### 2. Cek Directory Listing Disabled:
Akses via browser:
```
https://dsp-report.web.id/rwl/
```
Seharusnya redirect ke media.php (bukan tampil directory listing)

### 3. Test Logout:
1. Login ke sistem
2. Klik tombol Logout
3. Seharusnya redirect ke: `https://dsp-report.web.id/login_secure.php`

## Troubleshooting

### Jika masih muncul directory listing:
1. Pastikan `.htaccess` benar-benar ter-upload (check via SSH/cPanel)
2. Pastikan Apache mod_rewrite enabled (hubungi hosting support)
3. Check error log di cPanel untuk detail error

### Jika logout masih error:
1. Clear browser cache
2. Check PHP error log di cPanel
3. Pastikan file `login_secure.php` ada di root folder

## Command Upload (via FTP):
```bash
# Upload logout.php
put C:\xampp\htdocs\dsp-report\logout.php /public_html/logout.php

# Upload .htaccess files (pastikan show hidden files enabled)
put C:\xampp\htdocs\dsp-report\.htaccess /public_html/.htaccess
put C:\xampp\htdocs\dsp-report\rwl\.htaccess /public_html/rwl/.htaccess
put C:\xampp\htdocs\dsp-report\pgn\.htaccess /public_html/pgn/.htaccess
```

## Notes
- File `.htaccess` adalah hidden file (awalan titik)
- Pastikan FTP client/File Manager di-setting untuk show hidden files
- Backup file lama sebelum overwrite
- Test logout setelah upload untuk memastikan fix berhasil
