/quickload/share-text.php |
@@ -4,16 +4,50 @@ |
## Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 ## |
########################################################################### |
|
header('Content-Type: text/html; charset=utf-8'); |
header('Cache-Control: no-cache, no-store, must-revalidate'); |
header('Pragma: no-cache'); |
header('Expires: 0'); |
|
require_once('inc/pseudocrypt.php'); |
require_once('inc/functions.php'); |
require_once('config.php'); |
|
if(!isset($_POST['fingerprint']) or empty($_POST['fingerprint']) or |
!isset($_POST['action']) or empty($_POST['action'])) |
return; |
|
#### Check fingerprint consistency. |
$fingerprint = strtoupper($_POST['fingerprint']); |
if(strlen($fingerprint) !== 32) |
return; |
|
$action = strtoupper($_POST['action']); |
|
#### Data must be sent in order to save a file. |
if($action === 'SAVE' and (!isset($_POST['data']) or empty($_POST['data']))) |
return; |
|
#### Hash fingerprint. |
$file = strtolower( |
PseudoCrypt::hash( |
preg_replace( |
'/\D/', |
'', |
hash( |
'sha512', |
$fingerprint |
) |
) |
).'.html' |
); |
|
#### Build the user path. |
$userPath = join( |
DIRECTORY_SEPARATOR, |
array( |
$STORE_FOLDER, |
$SHARED_EDITOR_FILE |
$file |
) |
); |
|
@@ -23,22 +57,14 @@ |
realpath($pathPart['dirname']), realpath($STORE_FOLDER)) != 0) |
return; |
|
switch($_SERVER['REQUEST_METHOD']) { |
case 'POST': |
#### Retrieve uploaded file. |
if(!isset($_POST['data']) or empty($_POST['data'])) |
return; |
|
switch($action) { |
case 'SAVE': |
#### Store the file. |
atomized_put_contents($userPath, $_POST['data']); |
break; |
case 'GET': |
case 'LOAD': |
if(!file_exists($userPath)) |
return; |
header('Content-Type: text/html; charset=utf-8'); |
header('Cache-Control: no-cache, no-store, must-revalidate'); |
header('Pragma: no-cache'); |
header('Expires: 0'); |
echo atomized_get_contents($userPath); |
break; |
} |