403, API Forbidden'); } header('Location: login.php'); die; } $session = trim($_COOKIE['_session']); $sessions = explode("\n", trim(file_get_contents('/tmp/apcontrol-sessions'))); if (!in_array($session, $sessions)) { if (substr($_SERVER['REQUEST_URI'],0,5) === '/api/') { http_response_code(403); die('

403, API Forbidden

'); } header('Location: login.php'); die; } unset($sessions); if (!file_exists($GLOBALS['appconf']['data_dir'])) mkdir($GLOBALS['appconf']['data_dir']); // global variables $GLOBALS['supported_ap_software'] = [ 'mastodon', ]; // functions function apiresult($data, $code=200) { if (isset($GLOBALS['IS_PHP']) && $GLOBALS['IS_PHP']) { $GLOBALS['api_data'] = $data; return false; } if ($code !== 200) http_response_code($code); header('Content-Type: application/json'); echo json_encode($data); die; } // classes require 'classes/PgDatabase.php';