scratch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 33  →  ?path2? @ 34
/quickload/inc/functions.php
@@ -3,29 +3,64 @@
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function atomized_put_contents($file, $data)
function atomized_put_contents($file, $data, $block = 1)
{
$fp = fopen($file, "w+");
if (flock($fp, LOCK_EX)) {
fwrite($fp, $data);
fflush($fp);
flock($fp, LOCK_UN);
$f = fopen($file, 'a');
if (!$f || !flock($f, LOCK_EX | LOCK_NB, $block) || $block)
return;
ftruncate($f, 0);
fwrite($f, $data, strlen($data));
flock($f, LOCK_UN);
fclose($f);
}
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function atomized_get_contents($file, $block = 1)
{
$f = fopen($file, 'r+');
if (!$f || !flock($f, LOCK_SH | LOCK_NB, $block) || $block)
return;
$s = get_file_size($file);
if ($s == 0) {
flock($f, LOCK_UN);
fclose($f);
return;
}
fclose($fp);
$c = fread($f, $s);
flock($f, LOCK_UN);
fclose($f);
return $c;
}
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function atomized_get_contents($file)
function get_file_size($file, $block = 1)
{
$fp = fopen($file, "r+");
$ct = '';
if (flock($fp, LOCK_SH)) {
if (filesize($file)) {
$ct = fread($fp, filesize($file));
$f = fopen($file, 'r+');
if (!$f || !flock($f, LOCK_SH | LOCK_NB, $block) || $block)
return;
$s = 1073741824;
$i = 0;
fseek($f, 0, SEEK_SET);
do {
fseek($f, $s, SEEK_CUR);
 
if (fgetc($f) === false) {
fseek($f, -$s, SEEK_CUR);
$s = (int)($s / 2);
continue;
}
flock($fp, LOCK_UN);
}
fclose($fp);
return $ct;
fseek($f, -1, SEEK_CUR);
$i += $s;
} while ($s > 1);
 
while (fgetc($f) !== false)
$i++;
flock($f, LOCK_UN);
fclose($f);
return $i;
}
/quickload/share-text.php
@@ -36,6 +36,9 @@
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;
}
/quickload/text.html
@@ -107,7 +107,15 @@
});
// Retrieve the contents of the shared file.
$.get('share-text.php').done((data) => {
$.get('share-text.php',
{
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'
},
cache: false
}).done((data) => {
$('#trumbowyg')
.trumbowyg('html', data);
$('#trumbowyg').trumbowyg('enable');
@@ -136,6 +144,11 @@
url: 'upload-files.php',
type: 'POST',
data: formData,
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': '0'
},
cache: false,
processData: false,
contentType: false