notes app created with files backend
This commit is contained in:
parent
7755aa53f7
commit
9d716fd449
9 changed files with 85 additions and 14 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,4 +1,4 @@
|
|||
/favicon.ico
|
||||
/local/net
|
||||
/local/urls
|
||||
/local/videos
|
||||
/favicon.ico
|
||||
/local/media/urls
|
||||
/local/media/videos
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
<?php
|
||||
$title = "Password generator";
|
||||
$_title = "Password generator";
|
||||
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||
require "$root/templates/header.php";
|
||||
|
||||
$str = strtr(base64_encode(random_bytes(15)), '+/', '-_');
|
||||
$str[random_int(0, 19)] = random_int(0, 1) ? '-' : '_';
|
||||
echo "<div>$str</div>\n";
|
||||
echo "<button onclick='navigator.clipboard.writeText(\"$str\").then(
|
||||
() => { result.innerHTML = \"Copied\"; } );'>Copy</button><br>\n";
|
||||
echo "<span id='result'></span>\n";
|
||||
|
||||
require "$root/templates/footer.php";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$title = "Apps";
|
||||
$_title = "Apps";
|
||||
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||
require "$root/templates/header.php";
|
||||
?>
|
||||
|
|
@ -9,8 +9,10 @@ require "$root/templates/header.php";
|
|||
<a href="app/pswd.php">Password generator</a><br>
|
||||
<h4>Private</h4>
|
||||
<a href="vw">Vaultwarden</a><br>
|
||||
<a href="local/apps/get.php">Media manager</a><br>
|
||||
<a href="local/apps/load.php">Media downloader</a><br>
|
||||
<a href="grafana">Grafana</a><br>
|
||||
<a href="local/notes">Notes</a><br>
|
||||
<a href="local/media/get.php">Media viewer</a><br>
|
||||
<a href="local/media/load.php">Media downloader</a><br>
|
||||
<?php
|
||||
require "$root/templates/footer.php";
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
<?php
|
||||
$title = "Media manager";
|
||||
$_title = "Media viewer";
|
||||
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||
require "$root/templates/header.php";
|
||||
|
||||
$urls_base = __DIR__ . "/../urls";
|
||||
$urls_base = __DIR__ . "/urls";
|
||||
if (isset($_GET["list"])) {
|
||||
$file = "$urls_base/" . $_GET["list"];
|
||||
$urls = json_decode(file_get_contents($file));
|
||||
$url = $urls[array_rand($urls)];
|
||||
echo "<a href='$url'>Watch</a><br>";
|
||||
header("Location: " . $urls[array_rand($urls)]);
|
||||
} else {
|
||||
foreach (scandir($urls_base) as $list) {
|
||||
if ($list === '.' || $list === '..')
|
||||
continue;
|
||||
echo "<a href='" . $_SERVER['PHP_SELF'] . "?list=$list'>List $list</a><br>";
|
||||
echo "<a href='" . $_SERVER['PHP_SELF'] . "?list=$list'>Try $list</a><br>";
|
||||
}
|
||||
}
|
||||
|
||||
8
local/notes/db.php
Normal file
8
local/notes/db.php
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
#create schema notes;
|
||||
$pdo = new PDO("pgsql:dbname=php", "", "", [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
$pdo->query("create table mail(id int)");
|
||||
?>
|
||||
15
local/notes/index.php
Normal file
15
local/notes/index.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
$_title = "Notes";
|
||||
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||
require "$root/templates/header.php";
|
||||
?>
|
||||
<a href="write.php">Write a note</a><br>
|
||||
<h4>Notes</h4>
|
||||
<?php
|
||||
foreach (scandir("notesDir") as $note) {
|
||||
if ($note === '.' || $note === '..')
|
||||
continue;
|
||||
echo "<a href='write.php?title=$note'>$note</a><br>\n";
|
||||
}
|
||||
require "$root/templates/footer.php";
|
||||
?>
|
||||
41
local/notes/write.php
Normal file
41
local/notes/write.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
$title = "";
|
||||
$note = "";
|
||||
switch ($_SERVER["REQUEST_METHOD"]) {
|
||||
case "GET":
|
||||
if (isset($_GET["title"])) {
|
||||
$title = $_GET["title"];
|
||||
$note = file_get_contents("notesDir/" . base64_encode($title));
|
||||
};
|
||||
break;
|
||||
case "POST":
|
||||
file_put_contents("notesDir/" . base64_encode($_POST["title"]), $_POST["note"]);
|
||||
header("Location: .");
|
||||
exit;
|
||||
}
|
||||
$_title = "Notes";
|
||||
$root = $_SERVER["DOCUMENT_ROOT"];
|
||||
require "$root/templates/header.php";
|
||||
?>
|
||||
<form method="post">
|
||||
<input name="title" class="content" placeholder="Title" value="<?= $title ?>">
|
||||
<button type="submit" class="content">Save</button>
|
||||
<button class="">Delete</button><br><br>
|
||||
<textarea name="note" class="note content" placeholder="Note"><?= $note ?></textarea>
|
||||
</form>
|
||||
<style>
|
||||
button {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
.content {
|
||||
color: #ffffff;
|
||||
background-color: #303030;
|
||||
}
|
||||
.note {
|
||||
width: 98%;
|
||||
height: 280px;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
require "$root/templates/footer.php";
|
||||
?>
|
||||
3
marks
Normal file
3
marks
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
todo:
|
||||
- notes manager
|
||||
- video downloader
|
||||
|
|
@ -2,7 +2,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><?= $title ?></title>
|
||||
<title><?= $_title ?></title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue