# ========================================================
# Apache Configuration for CBT Sekolah
# ========================================================

DirectoryIndex index.php

# Pengaturan Batas Unggah File PHP (Mendukung upload Word/Excel soal berukuran besar di cPanel/Apache)
<IfModule mod_php.c>
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
    php_value memory_limit 256M
</IfModule>
<IfModule mod_php7.c>
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
    php_value memory_limit 256M
</IfModule>
<IfModule mod_php8.c>
    php_value upload_max_filesize 64M
    php_value post_max_size 64M
    php_value max_execution_time 300
    php_value max_input_time 300
    php_value memory_limit 256M
</IfModule>

# 1. Lindungi File Sensitif dari Akses Langsung Browser
<FilesMatch "\.(sqlite|sql|log|env|git|md)$">
    Require all denied
</FilesMatch>

# 2. Keamanan Direktori Uploads (Mencegah Eksekusi Skrip Berbahaya)
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^uploads/.*\.(php[0-9]?|phtml|cgi|pl|exe)$ - [F,L,NC]
</IfModule>

# 3. Kompresi Gzip (Membuat Akses 500 Siswa Jauh Lebih Cepat dan Hemat Bandwidth)
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE font/woff2
</IfModule>

# 4. Browser Caching untuk File Statis (CSS, JS, Fonts)
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
    ExpiresByType font/woff2 "access plus 1 month"
</IfModule>
