<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/antibot.php');

function get_config() {
    static $config = null;
    if ($config !== null) return $config;
    $config = [];
    $yaml_path = __DIR__ . '/files/config/config.yaml';
    if (function_exists('yaml_parse_file')) {
        $config = yaml_parse_file($yaml_path);
    } else {
        $lines = file($yaml_path);
        $section = null;
        foreach ($lines as $line) {
            $line = trim($line);
            if ($line === '' || $line[0] === '#') continue;
            if (preg_match('/^([A-Z_]+):$/', $line, $m)) {
                $section = $m[1];
                continue;
            }
            if ($section && preg_match('/^([a-zA-Z0-9_]+):\s*(.+)$/', $line, $m)) {
                $key = $m[1];
                $value = trim($m[2], "\"'");
                if (is_numeric($value)) $value = $value + 0;
                if ($value === 'true') $value = true;
                if ($value === 'false') $value = false;
                $config[$section][$key] = $value;
            }
        }
    }
    return $config;
} 