scratch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 28  →  ?path2? @ 29
File deleted
/quickload/store-text.php
/quickload/share-text.php
@@ -0,0 +1,42 @@
<?php
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 ##
###########################################################################
 
require_once('inc/pseudocrypt.php');
require_once('inc/functions.php');
require_once('config.php');
 
#### Build the user path.
$userPath = join(
DIRECTORY_SEPARATOR,
array(
$STORE_FOLDER,
$SHARED_EDITOR_FILE
)
);
 
#### Check for path traversals
$pathPart = pathinfo($userPath);
if (strcasecmp(
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;
#### Store the file.
atomized_put_contents($userPath, $_POST['data']);
break;
case 'GET':
if(!file_exists($userPath))
return;
header('Content-Type: text/html; charset=utf-8');
echo atomized_get_contents($userPath);
break;
}
 
/quickload/text.html
@@ -70,17 +70,25 @@
<script>
$(document).ready(() => {
$('#trumbowyg').trumbowyg({
autogrow: true
}).on("tbwchange", () => {
$.post("store-text.php",
{
text: $('#trumbowyg').trumbowyg('html'),
action: 'save'
},
function(data, status){
//alert("Data: " + data + "\nStatus: " + status);
autogrow: true,
disabled: true
}).on('tbwchange', () => {
$('#editor').trumbowyg('disable');
$.post('share-text.php', {
data: $('#trumbowyg').trumbowyg('html'),
}).done((data) => {
$('#trumbowyg').trumbowyg('enable');
}).fail(() => {
$('#trumbowyg').trumbowyg('enable');
});
});
$.get('share-text.php').done((data) => {
$('#trumbowyg')
.trumbowyg('html', data);
$('#trumbowyg').trumbowyg('enable');
}).fail(() => {
$('#trumbowyg').trumbowyg('enable');
});
});
</script>
</body>