-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtext-edit.php
More file actions
executable file
·26 lines (22 loc) · 1017 Bytes
/
text-edit.php
File metadata and controls
executable file
·26 lines (22 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php session_start();
$_SESSION["loggedin"] or die("error: you aren't authorized!\n"); ?>
<!doctype html>
<title>editor</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<?php
$filename = $_REQUEST['filename'];
if (isset($_REQUEST['file_content']))
file_put_contents($filename, $_REQUEST['file_content']);
?>
<form method="post" onsubmit="sync_to_send()">
<input type="submit" value="save"> <input value="<?= htmlentities($filename) ?>" id="filename">
<button onclick="setTimeout(()=>location='?filename='+filename.value)">open</button> <br>
<div contenteditable id="file_content" style="white-space: pre; overflow: scroll; border: 1px solid black; min-height: 100px;"><?= htmlentities(file_get_contents($filename)) ?></div>
<textarea hidden name="file_content" id="textarea_to_send"></textarea>
<script>
function sync_to_send() {
textarea_to_send.textContent = file_content.innerText
}
</script>
</form>