'success', 'message' => 'File ' . ($_POST['action'] === 'create' ? 'created' : 'updated') . ' successfully.' ]; } elseif ($_POST['action'] === 'delete') { $filename = basename($_POST['filename']); $filepath = $directory . '/' . $filename; if (strpos(realpath(dirname($filepath)), $directory) !== 0) { die("Invalid file path"); } if (is_file($filepath) && pathinfo($filepath, PATHINFO_EXTENSION) === 'md') { unlink($filepath); $_SESSION['alert'] = [ 'type' => 'warning', 'message' => 'File deleted successfully.' ]; } } } header('Location: ' . $_SERVER['PHP_SELF']); exit; } $editFile = isset($_GET['edit']) ? basename($_GET['edit']) : null; if ($editFile !== null && strpos($editFile, '..') !== false) { $editFile = null; } if (empty($_SESSION['csrf_token'])) { $_SESSION['csrf_token'] = bin2hex(random_bytes(32)); } // Display alert from session if it exists if (isset($_SESSION['alert'])) { $alertType = $_SESSION['alert']['type']; $alertMessage = $_SESSION['alert']['message']; $alert = ""; unset($_SESSION['alert']); } function renderFileListItem($file) { $basename = basename($file); return "
  • " . htmlspecialchars($basename) . " Last updated: " . date("F d, Y H:i", filemtime($file)) . "
  • "; } ?> Vincent's MarkDown

    Markdown Files