Add download single note
This commit is contained in:
parent
53d3516b04
commit
630ac914b0
25
index.php
25
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';
|
||||
}
|
||||
|
|
3
note.php
3
note.php
|
@ -5,7 +5,8 @@
|
|||
<input type="submit" name="preview" value="preview" accesskey="p" formtarget="_blank">
|
||||
<input type="submit" name="links" value="links" accesskey="l">
|
||||
<input type="submit" name="stats" value="stats" accesskey="i">
|
||||
<input type="submit" name="delete" value="delete" accesskey="d">
|
||||
<input type="submit" name="download" value="download" accesskey="d">
|
||||
<input type="submit" name="delete" value="delete">
|
||||
<input hidden name="lastchanged" value="<? echo $lastchanged; ?>">
|
||||
<?php
|
||||
if (isset($_POST['stats']))
|
||||
|
|
Loading…
Reference in New Issue