[ 最終更新日: 2026-06-02 04:10 閲覧回数: 7回 ]
現在のindex.php
Ver 1.0 2026/05/10
<link rel="stylesheet" href="style.css">
<?php
require_once("./PHP Markdown Lib 2.0.0/Michelf/Markdown.inc.php");
require_once("./PHP Markdown Lib 2.0.0/Michelf/MarkdownExtra.inc.php");
use Michelf\Markdown;
use Michelf\MarkdownExtra;
$parsedown = new Michelf\Markdown();
$parsedown = new Michelf\MarkdownExtra();
// 1. パラメータからディレクトリを取得(デフォルトはトップ)
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
// 2. セキュリティ対策: ディレクトリトラバーサル防止
$dir = str_replace(array('..', '/', '\\'), '', $dir);
// 3. 読み込むファイルを決定
$mdFile = 'index.md';
if (!empty($dir)) {
$mdFile = $dir . '/index.md';
}
// 4. ファイルの存在確認と読み込み
if (file_exists($mdFile)) {
$markdownText = file_get_contents($mdFile);
$file_lastmodified = date("Y-m-d H:i", filemtime($mdFile));
}
$html = Markdown::defaultTransform($markdownText);
?>
<! DOCTYPE html>
<html lang="ja>
<head>
<meta charset="utf-8";
</head>
<body>
<p><?php print $html; ?></p>
<p><?php print "最終更新日:" .$file_lastmodified; ?></p>
</body>
</html>