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);
 | 
							$_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 = new ZipArchive();
 | 
				
			||||||
		$zip_name = 'bbn.zip';
 | 
							$zip_name = 'bbn.zip';
 | 
				
			||||||
| 
						 | 
					@ -111,20 +119,19 @@
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	$nextpage = 'home';
 | 
						$nextpage = 'home';
 | 
				
			||||||
 | 
						$preview = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (isset($_GET['download']))
 | 
						if (isset($_GET['download']))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		download();
 | 
							downloadall();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						else if (isset($_GET['clip']) && $_GET['param'])
 | 
				
			||||||
	$preview = '';
 | 
					 | 
				
			||||||
	if (isset($_GET['clip']) && $_GET['param'])
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md');
 | 
							$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md');
 | 
				
			||||||
		savenote('todo', $content);
 | 
							savenote('todo', $content);
 | 
				
			||||||
		$_GET['param'] = '';
 | 
							$_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'];
 | 
							$title = $_POST['title'];
 | 
				
			||||||
		$content = $_POST['content'];
 | 
							$content = $_POST['content'];
 | 
				
			||||||
| 
						 | 
					@ -137,7 +144,11 @@
 | 
				
			||||||
			removefromindex($previoustitle);
 | 
								removefromindex($previoustitle);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!isset($_POST['home']))
 | 
							if (isset($_POST['download']))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								downloadnote($dir . '/' . $title . '.md');
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else if (!isset($_POST['home']))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			$nextpage = 'note';
 | 
								$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="preview" value="preview" accesskey="p" formtarget="_blank">
 | 
				
			||||||
		<input type="submit" name="links" value="links" accesskey="l">
 | 
							<input type="submit" name="links" value="links" accesskey="l">
 | 
				
			||||||
		<input type="submit" name="stats" value="stats" accesskey="i">
 | 
							<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; ?>">
 | 
							<input hidden name="lastchanged" value="<? echo $lastchanged; ?>">
 | 
				
			||||||
		<?php
 | 
							<?php
 | 
				
			||||||
		if (isset($_POST['stats']))
 | 
							if (isset($_POST['stats']))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue