c30eb9b7ad
Build and Package Oraset / build (macos-latest) (push) Waiting to run
Build and Package Oraset / build (ubuntu-latest) (push) Waiting to run
Build and Package Oraset / build (windows-latest) (push) Waiting to run
Build and Package Oraset / release (push) Blocked by required conditions
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
// 简化版文档列表 API
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
// 禁用缓存
|
|
header('Cache-Control: no-cache, no-store, must-revalidate');
|
|
header('Pragma: no-cache');
|
|
header('Expires: 0');
|
|
|
|
$md_dir = dirname(__FILE__) . '/md';
|
|
$version_file = dirname(dirname(__FILE__)) . '/download/version.txt';
|
|
|
|
// 获取版本号
|
|
$current_version = '4.0.1-BetaN(+AU)';
|
|
if (file_exists($version_file)) {
|
|
$current_version = trim(file_get_contents($version_file));
|
|
}
|
|
|
|
// 获取所有 md 文件
|
|
$articles = array();
|
|
|
|
if (is_dir($md_dir)) {
|
|
$files = glob($md_dir . '/*.md');
|
|
if ($files !== false) {
|
|
foreach ($files as $file) {
|
|
$name = basename($file, '.md');
|
|
$content = @file_get_contents($file);
|
|
|
|
$title = $name;
|
|
if ($content && preg_match('/^# (.+)$/m', $content, $matches)) {
|
|
$title = $matches[1];
|
|
}
|
|
|
|
$articles[] = array(
|
|
'name' => $name,
|
|
'title' => $title,
|
|
'desc' => ''
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 输出 JSON
|
|
echo json_encode(array(
|
|
'version' => $current_version,
|
|
'articles' => $articles
|
|
));
|
|
?>
|