Skip to content

Configuration

Jeremy Peterson edited this page Feb 26, 2026 · 3 revisions

Configuration

PERTI configuration is managed through load/config.php. This file is not committed to version control for security.


Configuration File Setup

Copy the example file to create your configuration:

cp load/config.example.php load/config.php

Required Configuration

MySQL Database

// MySQL (PERTI Application Database)
define('DB_HOST', 'localhost');
define('DB_NAME', 'perti');
define('DB_USER', 'perti_user');
define('DB_PASS', 'your_secure_password');

Azure SQL (ADL Database)

// Azure SQL Server connection
define('ADL_SERVER', 'your-server.database.windows.net');
define('ADL_DATABASE', 'VATSIM_ADL');
define('ADL_USERNAME', 'your_username');
define('ADL_PASSWORD', 'your_password');

Azure SQL (TMI Database)

// VATSIM_TMI (Traffic Management Initiatives)
define('TMI_SERVER', 'your-server.database.windows.net');
define('TMI_DATABASE', 'VATSIM_TMI');
define('TMI_USERNAME', 'your_username');
define('TMI_PASSWORD', 'your_password');

PostgreSQL/PostGIS (GIS Database)

// PostGIS spatial queries (boundaries, route geometry)
define('GIS_HOST', 'your-server.postgres.database.azure.com');
define('GIS_DATABASE', 'vatcscc_gis');
define('GIS_USERNAME', 'your_username');
define('GIS_PASSWORD', 'your_password');
define('GIS_PORT', 5432);

VATSIM OAuth

Register an application at VATSIM Connect to obtain credentials:

// VATSIM Connect OAuth
define('VATSIM_OAUTH_URL', 'https://auth.vatsim.net');
define('VATSIM_CLIENT_ID', 'your_client_id');
define('VATSIM_CLIENT_SECRET', 'your_client_secret');
define('VATSIM_REDIRECT_URI', 'https://your-domain.com/login/callback.php');

Optional Configuration

Site Settings

// Site configuration
define('SITE_NAME', 'vATCSCC PERTI');
define('SITE_URL', 'https://perti.vatcscc.org');
define('TIMEZONE', 'UTC');

Discord Integration

// Discord webhook for TMI notifications
define('DISCORD_WEBHOOK_URL', 'https://discord.com/api/webhooks/...');
define('DISCORD_TMI_CHANNEL', 'webhook_url_for_tmi_channel');

Feature Flags

// Feature toggles
define('FEATURE_WEATHER_RADAR', true);
define('FEATURE_SUA_DISPLAY', true);
define('FEATURE_DEMAND_ANALYSIS', true);

// TMI features
define('DISCORD_MULTI_ORG_ENABLED', true);  // Multi-organization Discord posting
define('TMI_STAGING_REQUIRED', false);       // Require staging before publishing

// GIS mode switch (default: 1)
define('USE_GIS_DAEMONS', 1);  // Set to 0 to use Azure SQL spatial instead of PostGIS

Conditional Daemons

// ADL Archive daemon only starts if storage connection is configured
define('ADL_ARCHIVE_STORAGE_CONN', 'your_blob_storage_connection_string');

Performance Optimization

For PHP endpoints that only need MySQL (plans, sheets, reviews), add before include connect.php:

define('PERTI_MYSQL_ONLY', true);  // Skips 5 Azure SQL connections (~500-1000ms saved)

Important: Never apply PERTI_MYSQL_ONLY to files that use $conn_adl, $conn_tmi, $conn_swim, $conn_ref, or $conn_gis. Always grep for these before adding the flag.

Debug Settings

// Development/debugging (set false in production)
define('DEBUG_MODE', false);
define('SHOW_ERRORS', false);
define('LOG_QUERIES', false);

Environment-Specific Configuration

Development

define('DEBUG_MODE', true);
define('SHOW_ERRORS', true);
define('DB_HOST', 'localhost');

Production (Azure)

define('DEBUG_MODE', false);
define('SHOW_ERRORS', false);
define('DB_HOST', getenv('MYSQL_HOST') ?: 'production-server');

Using Environment Variables

For Azure App Service, use application settings:

// Read from environment variables with fallbacks
define('ADL_SERVER', getenv('ADL_SERVER') ?: 'default-server');
define('ADL_DATABASE', getenv('ADL_DATABASE') ?: 'VATSIM_ADL');
define('ADL_USERNAME', getenv('ADL_USERNAME') ?: 'default_user');
define('ADL_PASSWORD', getenv('ADL_PASSWORD') ?: '');

Daemon Configuration

VATSIM ADL Daemon

The daemon reads from load/config.php automatically. Additional settings:

Setting Default Description
Interval 15s Time between VATSIM API calls
Timeout 30s HTTP request timeout
Lock file scripts/vatsim_adl.lock Prevents duplicate instances
Log file scripts/vatsim_adl.log Daemon output log

Parse Queue Daemon

Command-line options:

php parse_queue_daemon.php --loop              # Continuous mode
php parse_queue_daemon.php --batch=100         # Custom batch size
php parse_queue_daemon.php --interval=10       # Custom interval (seconds)

ATIS Daemon

python atis_daemon.py --once                   # Single run
python atis_daemon.py --airports KJFK,KLAX     # Filter airports
python atis_daemon.py                          # Continuous (default)

Navigation Data Configuration

NASR Data Path

// Path to navigation data CSVs
define('NAVDATA_PATH', __DIR__ . '/../assets/data/');

Playbook Routes

// FAA playbook route data
define('PLAYBOOK_CSV', __DIR__ . '/../assets/data/playbook_routes.csv');

Weather Configuration

IEM Radar Tiles

// Iowa Environmental Mesonet tile server
define('IEM_TILE_URL', 'https://mesonet.agron.iastate.edu/cache/tile.py');
define('IEM_RADAR_PRODUCT', 'nexrad-n0q');  // Base reflectivity

Weather Alert Sources

// Aviation weather sources
define('AWC_SIGMET_URL', 'https://aviationweather.gov/api/data/sigmet');
define('AWC_AIRMET_URL', 'https://aviationweather.gov/api/data/airmet');

Session Configuration

// Session settings
define('SESSION_LIFETIME', 86400);  // 24 hours
define('SESSION_PATH', __DIR__ . '/../sessions/');

Security Configuration

HTTPS Enforcement

// Force HTTPS in production
define('FORCE_HTTPS', true);

CORS Settings

// Allowed origins for API requests
define('CORS_ORIGINS', [
    'https://perti.vatcscc.org',
    'https://your-custom-domain.com'
]);

Configuration Validation

Create a test script to validate your configuration:

<?php
// test_config.php
require_once 'load/config.php';

$checks = [
    'DB_HOST' => defined('DB_HOST'),
    'ADL_SERVER' => defined('ADL_SERVER'),
    'VATSIM_CLIENT_ID' => defined('VATSIM_CLIENT_ID'),
];

foreach ($checks as $const => $defined) {
    echo "$const: " . ($defined ? "OK" : "MISSING") . "\n";
}

See Also

Clone this wiki locally