'ignored']); exit; } $base = '/var/www/weval/wevia-ia/wevialife-data/obsidian'; if (!is_dir($base)) mkdir($base, 0755, true); $path = $data['path'] ?? ''; $content = $data['content'] ?? ''; if (!$path || !$content) { echo json_encode(['error' => 'missing path or content']); exit; } // Security: only allow .md files, no path traversal $path = str_replace('..', '', $path); if (!preg_match('/\.md$/', $path)) { echo json_encode(['error' => 'only .md files']); exit; } $fullPath = $base . $path; $dir = dirname($fullPath); if (!is_dir($dir)) mkdir($dir, 0755, true); $decoded = base64_decode($content); if ($decoded === false) { echo json_encode(['error' => 'base64 decode failed']); exit; } file_put_contents($fullPath, $decoded); echo json_encode(['status' => 'ok', 'path' => $path, 'size' => strlen($decoded)]);