App/index.php

28 lines
1.0 KiB
PHP
Executable File

<?php #/index.php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once "bin/init.php";
if ("JSON"==$man->RequestedContentType()) { // User wants JSON. So tell him what he wants. What he really really wants.
http_response_code($man->ResponseCode());
header('Content-type: application/json');
echo trim(json_encode($man->Output()));
} elseif ("PRINT"==$man->RequestedContentType()) { // User wants a PRINTOUT. Oh my.
header('Content-type: text/html');
if (200 <= $man->ResponseCode() && 300 > $man->ResponseCode()) {
$man->printer->CreateHtml($man->input["print"]);
http_response_code($man->printer->ResponseCode());
echo trim($man->printer->GetHtml());
} else {
http_response_code($man->ResponseCode());
}
} else { // Say hello to new connection. And then crush him with our very bad HTML-JS-Client. It will automatically try to authenticate if jwt is found in cookies
http_response_code(200);
header('Content-type: text/html');
include "res/main.html";
}
include "bin/exit.php"; // Closing connections