Add files via upload
This commit is contained in:
parent
7dc921dafc
commit
8e58496c23
16
cron.php
Normal file
16
cron.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
// check if any pastes are expired
|
||||
$files = scandir("pastes/");
|
||||
|
||||
foreach($files as $file){
|
||||
$filename = $file;
|
||||
$file = json_encode("pastes/" . $file);
|
||||
if($file->expiration != "never"){
|
||||
if(time() > $file->expiration * 10 + $file->date){
|
||||
rename($filename, "../exp/" . $filename)
|
||||
echo "deleted" . $filename . "<br>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
74
css/style.css
Normal file
74
css/style.css
Normal file
@ -0,0 +1,74 @@
|
||||
body{
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
text-align:center;
|
||||
}
|
||||
#logo{
|
||||
display:inline;
|
||||
margin:5px;
|
||||
}
|
||||
#menu{
|
||||
background:#efe;
|
||||
border-bottom:1px solid #aaa;
|
||||
width:100%;
|
||||
}
|
||||
#menu-item{
|
||||
border-right:1px solid #aaa;
|
||||
padding:5px;
|
||||
}
|
||||
#menu-items{
|
||||
|
||||
}
|
||||
#main{
|
||||
padding:25px;
|
||||
padding-top:0px;
|
||||
margin:auto;
|
||||
width:80%;
|
||||
height:100%;
|
||||
background:#fcfcfc;
|
||||
border-left:1px solid #aaa;
|
||||
border-right:1px solid #aaa;
|
||||
text-align:center;
|
||||
overflow:auto;
|
||||
}
|
||||
#newPaste{
|
||||
display:inline-block;
|
||||
text-align:left;
|
||||
padding:5px;
|
||||
width:100%;
|
||||
}
|
||||
|
||||
#paste{
|
||||
height:50%;
|
||||
width:50%;
|
||||
}
|
||||
|
||||
#displayPaste{
|
||||
display:inline-block;
|
||||
padding:5px;
|
||||
width:100%;
|
||||
text-align:left;
|
||||
}
|
||||
a{
|
||||
color:#000;
|
||||
text-decoration:none;
|
||||
}
|
||||
#pasteitem{
|
||||
border:1px solid #ccc;
|
||||
padding:10px;
|
||||
margin:2%;
|
||||
}
|
||||
input{
|
||||
margin:5px;
|
||||
|
||||
}
|
||||
#statuslink{
|
||||
color:#11c;
|
||||
text-decoration:underline;
|
||||
}
|
||||
#status{
|
||||
padding:10px;
|
||||
background:#fdd;
|
||||
border-radius:5px;
|
||||
border:2px solid #daa;
|
||||
}
|
||||
46
display.php
Normal file
46
display.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$paste = file_get_contents("pastes/" . $_GET["paste"]);
|
||||
$displayPaste = true; // display the paste?
|
||||
$pasteJSON = json_decode($paste);
|
||||
|
||||
function displayPaste($paste){
|
||||
echo str_replace(
|
||||
["_NAME_", "_PASTE_", "_DATE_", "_STATUS_"],
|
||||
[$paste->name, $paste->paste, $paste->prettydate, ""],
|
||||
file_get_contents("templates/displayPaste.html"));
|
||||
}
|
||||
|
||||
function displayEncryptedPaste($paste, $password){
|
||||
echo str_replace(
|
||||
["_NAME_", "_PASTE_", "_DATE_", "_STATUS_"],
|
||||
[
|
||||
openssl_decrypt($paste->name, "AES-256-OFB", $password),
|
||||
openssl_decrypt($paste->paste, "AES-256-OFB", $password),
|
||||
$paste->prettydate,
|
||||
"<span id='status'>This is an encrypted paste. If it is displaying as gibberish or random symbols then that means you entered the wrong password and need to <a id='statuslink' href='display.php?paste=" . $_GET["paste"] . "'>try again</a></span>.",
|
||||
],
|
||||
file_get_contents("templates/displayPaste.html"));
|
||||
}
|
||||
|
||||
|
||||
if($_POST["password"]){
|
||||
displayEncryptedPaste($pasteJSON, $_POST["password"]);
|
||||
}
|
||||
|
||||
if($paste == false){
|
||||
echo "Paste not found.";
|
||||
$displayPaste = false;
|
||||
}
|
||||
else {
|
||||
$paste = json_decode($paste);
|
||||
if($paste->privacy != "Private"){
|
||||
displayPaste($paste);
|
||||
}
|
||||
if($paste->privacy == "Private"){
|
||||
$passPage = str_replace("_id_", $_GET["paste"], file_get_contents("templates/password.html"));
|
||||
echo $passPage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
45
index.php
Normal file
45
index.php
Normal file
@ -0,0 +1,45 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Getgle Docs: Military-Grade Hardened Texthost</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="menu">
|
||||
<table id="menu-items">
|
||||
<tr>
|
||||
<td><a href="../"><img src="logo.png" height="30px" id="logo"></a></td>
|
||||
<td><a href="index.php"><span id="menu-item">Upload</span></a></td>
|
||||
<td><a href="list.php"><span id="menu-item">Public Pastes</span></a></td>
|
||||
<td><a href="about.html"><span id="menu-item">About</span></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div id="newPaste">
|
||||
<?php
|
||||
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') {
|
||||
echo "<span id='status'>WARNING! You are accessing this site without SSL. Please <a id='statuslink' href='https://docs.getgle.org'>click here to use SSL</a></span>";
|
||||
}
|
||||
?>
|
||||
<form action="upload.php" method="POST" autocomplete="off">
|
||||
<h3>New paste</h3>
|
||||
<textarea name="paste" id="paste"></textarea>
|
||||
<h3>Paste options</h3>
|
||||
Paste Name:
|
||||
<input type="text" name="name" maxlength="120"><br>
|
||||
Paste Privacy:
|
||||
<select name="privacy" onchange="if(this.value == 'Private'){this.form['password'].style.visibility='visible'}else{this.form['password'].style.visibility='hidden'}">
|
||||
<option value="Public" selected="selected">Public</option>
|
||||
<option value="Unlisted">Unlisted</option>
|
||||
<option value="Private">Military Grade (AES-256)</option>
|
||||
</select>
|
||||
<br>
|
||||
Password:
|
||||
<input type="text" name="password" style="visibility:hidden;"><br>
|
||||
</select><br>
|
||||
<input type="submit" value="Submit New Paste">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
1
list.json
Normal file
1
list.json
Normal file
@ -0,0 +1 @@
|
||||
[{"name":"e","url":"5eff162ea1a56","date":1593775662,"prettydate":"2020\/07\/03 7:27:42"},{"name":"CRIME STATISTICS 50\/13","url":"5effb23128200","date":1593815601,"prettydate":"2020\/07\/03 6:33:21"},{"name":"fizzbuzz in small","url":"5f00ceb5c0388","date":1593888437,"prettydate":"2020\/07\/04 2:47:17"},{"name":"i hate sweden","url":"5f01d67ca0688","date":1593955964,"prettydate":"2020\/07\/05 9:32:44"},{"name":"discord","url":"5f02bf3c995ce","date":1594015548,"prettydate":"2020\/07\/06 2:05:48"},{"name":"puffin browser server list","url":"5f034432d1f79","date":1594049586,"prettydate":"2020\/07\/06 11:33:06"},{"name":"Script","url":"5f08f0b6a6dcc","date":1594421430,"prettydate":"2020\/07\/10 6:50:30"},{"name":"SCRRIIIIPT","url":"5f093499b3327","date":1594438809,"prettydate":"2020\/07\/10 11:40:09"},{"name":"fugger","url":"5f0cf9b96de32","date":1594685881,"prettydate":"2020\/07\/13 8:18:01"},{"name":"Untitled","url":"5f0efcbfbaf59","date":1594817727,"prettydate":"2020\/07\/15 8:55:27"},{"name":"hywzwhzj","url":"5f0f88ee7980b","date":1594853614,"prettydate":"2020\/07\/15 6:53:34"},{"name":"ai-dungeon-3-cures-coronachan","url":"5f11cf3c2a657","date":1595002684,"prettydate":"2020\/07\/17 12:18:04"},{"name":"ai-dungeon-3-cures-coronachan-2","url":"5f11d0d0c780a","date":1595003088,"prettydate":"2020\/07\/17 12:24:48"},{"name":"gpt-3-calculates-pi","url":"5f11e479ba629","date":1595008121,"prettydate":"2020\/07\/17 1:48:41"},{"name":"hhnrrmnyng","url":"5f129f51e83f3","date":1595055953,"prettydate":"2020\/07\/18 3:05:53"},{"name":"Untitled","url":"5f137372b232a","date":1595110258,"prettydate":"2020\/07\/18 6:10:58"},{"name":"bv","url":"5f14fc4736128","date":1595210823,"prettydate":"2020\/07\/19 10:07:03"},{"name":"language-models-cant","url":"5f185e96ea5bf","date":1595432598,"prettydate":"2020\/07\/22 11:43:18"},{"name":"Untitled","url":"5f1a2752f0264","date":1595549522,"prettydate":"2020\/07\/23 8:12:02"},{"name":"Untitled","url":"5f1c9f6b879c5","date":1595711339,"prettydate":"2020\/07\/25 5:08:59"},{"name":"disk","url":"5f1e1ead98071","date":1595809453,"prettydate":"2020\/07\/26 8:24:13"},{"name":"wegw","url":"5f1e1ed8f1bda","date":1595809496,"prettydate":"2020\/07\/26 8:24:56"},{"name":"Send this message to 15 people","url":"5f1f4e8746050","date":1595887239,"prettydate":"2020\/07\/27 6:00:39"}]
|
||||
14
list.php
Normal file
14
list.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$pastes = json_decode(file_get_contents("list.json"));
|
||||
$template = file_get_contents("templates/publicpastes.html");
|
||||
|
||||
function renderPastes($p){
|
||||
$displayPastes = "";
|
||||
foreach($p as $paste){
|
||||
$displayPaste = "<a href='display.php?paste=" . $paste->url . "'><div id='pasteitem'><span id='pastetitle'>" . $paste->name . "</span><br><span id='pastedate'><i>Uploaded on " . $paste->prettydate ."</i></span></div></a>";
|
||||
$displayPastes = $displayPaste . $displayPastes;
|
||||
}
|
||||
return $displayPastes;
|
||||
}
|
||||
echo str_replace("_PASTES_", renderPastes($pastes), $template);
|
||||
?>
|
||||
35
upload.php
Normal file
35
upload.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
$pi = $_POST; // shorthand for Post Input
|
||||
if($pi["name"] == ""){
|
||||
$pi["name"] = "Untitled";
|
||||
}
|
||||
$pi["name"] = htmlspecialchars(substr($pi["name"], 0, 120));
|
||||
$pi["date"] = time();
|
||||
$pi["prettydate"] = date("Y/m/d g:i:s");
|
||||
|
||||
$postAllowed = true;
|
||||
|
||||
if($pi["privacy"] == "Private"){
|
||||
$pi["paste"] = openssl_encrypt($pi["paste"], "AES-256-OFB", $pi["password"]);
|
||||
$pi["name"] = openssl_encrypt($pi["name"], "AES-256-OFB", $pi["password"]);
|
||||
}
|
||||
|
||||
if($postAllowed == true){
|
||||
$url = uniqid();
|
||||
file_put_contents("pastes/" . $url, json_encode($pi));
|
||||
if($pi["privacy"] == "Public"){
|
||||
$listfile = json_decode(file_get_contents("list.json"));
|
||||
$list = Array(
|
||||
"name" => $pi["name"],
|
||||
"url" => $url,
|
||||
"date" => $pi["date"],
|
||||
"prettydate" => $pi["prettydate"]
|
||||
);
|
||||
array_push($listfile, $list);
|
||||
file_put_contents("list.json", json_encode($listfile));
|
||||
}
|
||||
header("Location: display.php?paste=" . $url);
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user