open($zip_name, ZipArchive::CREATE); foreach($_SESSION['index'] as $path) { if (!str_ends_with($path, '.del')) { $path = $path . '.md'; if (file_exists($path)) { $zip->addFile($path, basename($path)); } } } $zip->close(); header('Content-disposition: attachment; filename=' . $zip_name); header('Content-type: application/zip'); readfile($zip_name); unlink($zip_name); } function savenote($title, $content) { global $dir; $path = $dir . '/' . $title; $lastchanged = filemtime($path . '.md'); $previous = $_POST['lastchanged']; if ((int)$lastchanged > (int)$previous) { $tempcontent = file_get_contents($path . '.md'); if ($tempcontent != $content) { $temptitle = $title . '_conflict_' . $lastchanged; file_put_contents($dir . '/' . $temptitle . '.md', $tempcontent); array_unshift($_SESSION['index'], $dir . '/' . $temptitle); } } file_put_contents($path . '.md', $content); removefromindex($title); array_unshift($_SESSION['index'], $path); } function removefromindex($title) { global $dir; $key = array_search($dir . '/' . $title, $_SESSION['index']); if ($key !== FALSE) { array_splice($_SESSION['index'], $key, 1); } } function downloadnote($path) { header('Content-disposition: attachment; filename=' . basename($path)); header('Content-type: text/markdown'); readfile($path); } function linksdiv($content) { $divcontent = '
Access denied.