diff --git a/index.php b/index.php
index 09505a9..f920f57 100644
--- a/index.php
+++ b/index.php
@@ -21,7 +21,15 @@
$_SESSION['index'] = array_map(fn($value): string => str_replace('.md', '', $value), $files);
}
- function download()
+ function downloadnote($path)
+ {
+ header('Content-disposition: attachment; filename=' . basename($path));
+ header('Content-type: text/markdown');
+ readfile($path);
+ exit;
+ }
+
+ function downloadall()
{
$zip = new ZipArchive();
$zip_name = 'bbn.zip';
@@ -111,20 +119,19 @@
}
$nextpage = 'home';
+ $preview = '';
if (isset($_GET['download']))
{
- download();
+ downloadall();
}
-
- $preview = '';
- if (isset($_GET['clip']) && $_GET['param'])
+ else if (isset($_GET['clip']) && $_GET['param'])
{
$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md');
savenote('todo', $content);
$_GET['param'] = '';
}
- else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']) || isset($_POST['stats']))
+ else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']) || isset($_POST['stats']) || isset($_POST['download']))
{
$title = $_POST['title'];
$content = $_POST['content'];
@@ -137,7 +144,11 @@
removefromindex($previoustitle);
}
- if (!isset($_POST['home']))
+ if (isset($_POST['download']))
+ {
+ downloadnote($dir . '/' . $title . '.md');
+ }
+ else if (!isset($_POST['home']))
{
$nextpage = 'note';
}
diff --git a/note.php b/note.php
index 2900b07..81d8203 100644
--- a/note.php
+++ b/note.php
@@ -5,7 +5,8 @@
-
+
+