'; } // --------------------------------------------------------------------------- // CONTENT ROUTER // --------------------------------------------------------------------------- function dsc01_content() { if (function_exists('head_add_css')) { head_add_css('/addon/dsc01/view/css/dsc01.css'); } if (function_exists('head_add_js')) { head_add_js('/addon/dsc01/view/js/dsc01.js'); } $association_slug = argv(1) ?? ''; $sub_route = strtolower(argv(2) ?? ''); // Index — list the ten DSC categories if (!$association_slug) { return dsc01_render_index(); } $raw = @file_get_contents('addon/vs01/config.json'); $cfg = $raw ? json_decode($raw, true) : []; if (json_last_error() !== JSON_ERROR_NONE || !isset($cfg['associations'][$association_slug])) { return dsc01_render_not_found(); } $access = dsc01_access_state($association_slug); // Manage route — operator only (stub) if ($sub_route === 'manage') { if ($access !== 'operator') { return dsc01_access_wall($association_slug); } return dsc01_render_manage($association_slug); } // POST — submission handler if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($access === 'public') { return dsc01_access_wall($association_slug); } if (!dsc01_verify_csrf()) { return '
Invalid form token. Please reload and try again.
'; } return dsc01_handle_post($association_slug, $access); } // Association landing — checklist return dsc01_render_landing($association_slug, $access); } // --------------------------------------------------------------------------- // NOT FOUND // --------------------------------------------------------------------------- function dsc01_render_not_found() { return '
Association not found.
'; } // --------------------------------------------------------------------------- // CSRF // --------------------------------------------------------------------------- function dsc01_csrf_token() { if (empty($_SESSION['dsc01_csrf'])) { $_SESSION['dsc01_csrf'] = bin2hex(random_bytes(16)); } return ''; } function dsc01_verify_csrf() { return isset($_POST['dsc01_csrf'], $_SESSION['dsc01_csrf']) && hash_equals($_SESSION['dsc01_csrf'], $_POST['dsc01_csrf']); }