<?php
if (!defined('ROOT'))
{
    define('ROOT', dirname(dirname(__FILE__)));

    define('SOURCE_APRS',   1);
    define('SOURCE_CWOP',   2);
    define('SOURCE_CBAPRS', 3);
    define('SOURCE_OGN',    5);

    define('OBJECT_PACKET',   4);
    define('STATUS_PACKET',   10);

    // Load the bootstrap config
    if (apcu_enabled() && apcu_exists('bootstrap.config'))
    {
      $bootstrap_config = apcu_fetch('bootstrap.config');
    }
    else
    {
      $bootstrap_config = parse_ini_file(ROOT . '/../config/backend.ini', true);
      if (apcu_enabled())
      {
        apcu_store('bootstrap.config', $bootstrap_config);
      }
    }

    require_once ROOT . '/includes/autoload.php';
    require_once ROOT . '/includes/common.php';
    require_once ROOT . '/includes/version.php';

    date_default_timezone_set("UTC");

    ini_set("error_reporting", "true");
    error_reporting(E_ALL|E_STRICT);

    ini_set("display_errors", "false");
    ini_set("display_errors", "on");

    // Load the configuration into the global scope
    $config = ConfigRepository::getInstance()->getAll();

    // Dev overrides
    if (isset($_SERVER["SERVER_ADDR"]) && $_SERVER['SERVER_ADDR'] == '192.168.9.100')
    {
      $config["website"]["websocket_url"] = 'ws://192.168.9.209:9000/ws';
      $config["website"]["ajax_domain"] = '192.168.9.100';
    }

    // Start a local (or Dummy) Session
    if (!defined('NO_SESSION')) $tdSession = Session::getInstance();

    // Load languages
    $language = LanguageRepository::getInstance()->getAll();
}
