chiro-canto/public/api/v1/doc/index.php

57 lines
1.5 KiB
PHP
Executable File

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include("$root/vendor/erusev/parsedown/Parsedown.php");
$Parsedown = new Parsedown();
$lang = isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'en';
require("$root/lang/$lang/lang.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API v1 Documentation | Chiro - Canto</title>
<link rel="stylesheet" href="/styles/style.css">
</head>
<?php
include("$root/analytics/matomo.php");
include("$root/analytics/owa.php");
?>
<body>
<?php
include("$root/menu.php");
include("$root/header.php");
?>
<section>
<h2>Documentation API v1</h2>
<?php
if (isset($_GET['page']) and file_exists("md/".$_GET['page'].".md")) {
$page = $_GET['page'].".md";
$md = file_get_contents("$root/api/v1/doc/md/$page", "r");
print_r($Parsedown->text($md));
} else {
$doc_paths = glob("$root/api/v1/doc/md/*.md");
?>
<ul>
<?php
foreach ($doc_paths as $path) {
$file = explode('.', basename($path))[0];
?>
<li><a href="?page=<?=$file?>"><?=$file?></a></li>
<?php
}
?>
</ul>
<?php
}
?>
</section>
<?php
include("$root/footer.php");
?>
</body>
</html>