Last active
September 17, 2020 21:52
-
-
Save angeloped/938eb6bb7f2ab0277a199aadd48214b5 to your computer and use it in GitHub Desktop.
A simple note composer web app written in PHP for lazy writers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
A simple note composer web app written in PHP for lazy writers. | |
*/ | |
header('Access-Control-Allow-Origin: *'); | |
header('Access-Control-Allow-Methods: GET, POST'); | |
header("Access-Control-Allow-Headers: X-Requested-With"); | |
if(!isset($_GET["save"])){ | |
if(!file_exists("abcd")){ | |
$fiel = fopen("abcd","w"); | |
fwrite($fiel, "\n"); | |
fclose($fiel); | |
} | |
$fiel = fopen("abcd","r"); | |
$data = fread($fiel, filesize("abcd")); | |
fclose($fiel); | |
}else{ | |
$fiel = fopen("abcd","w"); | |
fwrite($fiel, $_GET["save"]); | |
fclose($fiel); | |
echo("done saving."); | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="description" content="Duh."> | |
<meta name="keywords" content="Duh."> | |
<meta name="author" content="Duh,"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<script> | |
function saveme(data) { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
console.log(this.responseText); | |
} | |
}; | |
xhttp.open("GET", "http://<?php echo $_SERVER["REMOTE_ADDR"];?>/theory.php?save="+data, true); | |
xhttp.send(); | |
} | |
function myFunction(){ | |
var x = document.getElementById("myInput").value; | |
saveme(x); | |
} | |
</script> | |
</head> | |
<body> | |
<textarea rows="40" cols="55" id="myInput" oninput="myFunction()"></textarea> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment