30 lines
765 B
PHP
30 lines
765 B
PHP
<?php
|
|
|
|
if (!isset($_COOKIE['_session']) || !file_exists('/tmp/apcontrol-sessions')) {
|
|
if (substr($_SERVER['REQUEST_URI'],0,5) === '/api/') {
|
|
http_response_code(403); die('<h3>403, API Forbidden</h3>');
|
|
}
|
|
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('<h3>403, API Forbidden</h3>');
|
|
}
|
|
header('Location: login.php'); die;
|
|
}
|
|
unset($sessions);
|
|
|
|
// global variables
|
|
$supported_ap_software = [
|
|
'mastodon',
|
|
];
|
|
|
|
// functions
|
|
function apiresult($data) {
|
|
header('Content-Type: application/json');
|
|
echo json_encode($data); die;
|
|
}
|