add download feature
This commit is contained in:
parent
03821833b3
commit
ab2cdcc400
65
index.php
65
index.php
|
@ -1,15 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>bbn</title>
|
||||
<link rel="manifest" href="manifest.json" />
|
||||
<meta name="theme-color" content="white" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
require 'settings.php';
|
||||
|
||||
|
@ -32,6 +21,36 @@
|
|||
$_SESSION['index'] = array_map(fn($value): string => str_replace('.md', '', $value), $files);
|
||||
}
|
||||
|
||||
function download()
|
||||
{
|
||||
$zip = new ZipArchive();
|
||||
$zip_name = 'bbn.zip';
|
||||
$zip->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));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo"file does not exist";
|
||||
}
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
|
||||
header('Content-disposition: attachment; filename=' . $zip_name);
|
||||
header('Content-type: application/zip');
|
||||
readfile($zip_name);
|
||||
|
||||
unlink($zip_name);
|
||||
exit;
|
||||
}
|
||||
|
||||
function removefromindex($title)
|
||||
{
|
||||
global $dir;
|
||||
|
@ -93,6 +112,27 @@
|
|||
|
||||
$nextpage = 'home';
|
||||
|
||||
if (isset($_GET['download']))
|
||||
{
|
||||
download();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>bbn</title>
|
||||
<link rel="manifest" href="manifest.json" />
|
||||
<meta name="theme-color" content="white" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_GET['clip']) && $_GET['param'])
|
||||
{
|
||||
$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md');
|
||||
|
@ -143,7 +183,6 @@
|
|||
$nextpage = 'note';
|
||||
$title = $_GET['param'];
|
||||
}
|
||||
|
||||
if ($nextpage == 'note')
|
||||
{
|
||||
$now = date("Y-m-d H.i.s", time());
|
||||
|
|
Loading…
Reference in New Issue