# .htaccess PURO - TUDO INTERNO - kubonet.com.br/admin
# OBJETIVO: Simular php.ini local usando apenas .htaccess
# SEM arquivos externos - configuração 100% interna


# MÉTODOS AVANÇADOS PARA FORÇAR php.ini LOCAL (apenas .htaccess)
php_admin_value user_ini.filename "php.ini"
php_admin_value user_ini.cache_ttl 0
php_value user_ini.filename "php.ini"
php_value user_ini.cache_ttl 0

# TENTAR DEFINIR CAMINHOS DE CONFIGURAÇÃO
php_admin_value cfg_file_path "/home12/kubonet/public_html/admin"
php_value cfg_file_path "/home12/kubonet/public_html/admin"
php_admin_value configuration_file "/home12/kubonet/public_html/admin/php.ini"
php_value configuration_file "/home12/kubonet/public_html/admin/php.ini"

# CONFIGURAÇÕES COMPLETAS (todas no .htaccess)
php_value memory_limit 512M
php_value max_execution_time 300
php_value max_input_time 300
php_value max_input_vars 3000
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_flag file_uploads On
php_flag display_errors On
php_flag log_errors On
php_value error_reporting "E_ALL & ~E_NOTICE & ~E_DEPRECATED"
php_value error_log "/home12/kubonet/public_html/admin/php_errors.log"
php_value session.save_path "/home12/kubonet/public_html/admin/sessions"
php_value session.gc_maxlifetime 7200
php_value session.cookie_lifetime 0
php_value date.timezone "America/Sao_Paulo"
php_flag expose_php Off
php_flag allow_url_fopen On
php_flag allow_url_include Off
php_value output_buffering 4096
php_flag implicit_flush Off
php_value default_charset "UTF-8"

# SEGURANÇA: Proteger arquivos sensíveis
<Files ".user.ini">
    Order allow,deny
    Deny from all
</Files>

<Files "*.ini">
    Order allow,deny  
    Deny from all
</Files>

<Files "*.log">
    Order allow,deny
    Deny from all
</Files>

<Files "prepend.php">
    Order allow,deny
    Deny from all
</Files>

<Files "config.php">
    Order allow,deny
    Deny from all
</Files>

# HEADERS DE SEGURANÇA
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options nosniff
    Header always set X-Frame-Options SAMEORIGIN
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# CONFIGURAÇÕES DE CACHE PARA ARQUIVOS ESTÁTICOS
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
</IfModule>

# COMPRESSÃO GZIP (se mod_deflate disponível)
<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
</IfModule>

# REWRITE RULES (se necessário para aplicação)
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # Redirecionar para HTTPS (opcional)
    # RewriteCond %{HTTPS} off
    # RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    # Bloquear acesso direto a arquivos sensíveis
    RewriteRule ^\.user\.ini$ - [F,L]
    RewriteRule ^php\.ini$ - [F,L]
    RewriteRule ^prepend\.php$ - [F,L]
</IfModule>

# FIM DA CONFIGURAÇÃO ✅
# MÉTODO: 100% .htaccess - SEM ARQUIVOS EXTERNOS
# Todas as configurações PHP definidas diretamente aqui
# 
# LIMITAÇÃO: phpinfo() ainda pode mostrar caminhos do sistema
# MAS todas as configurações (512M, 300s, etc.) estão ativas via .htaccess
# Para alterar phpinfo() é necessário arquivo externo ou cPanel MultiPHP INI