/quickload/text.html |
@@ -107,15 +107,7 @@ |
}); |
|
// Retrieve the contents of the shared file. |
$.get('share-text.php', |
{ |
headers: { |
'Cache-Control': 'no-cache, no-store, must-revalidate', |
'Pragma': 'no-cache', |
'Expires': '0' |
}, |
cache: false |
}).done((data) => { |
$.get('share-text.php').done((data) => { |
$('#trumbowyg') |
.trumbowyg('html', data); |
$('#trumbowyg').trumbowyg('enable'); |
@@ -144,11 +136,6 @@ |
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 |
/quickload/inc/functions.php |
@@ -3,64 +3,29 @@ |
########################################################################### |
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
########################################################################### |
function atomized_put_contents($file, $data, $block = 1) |
function atomized_put_contents($file, $data) |
{ |
$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; |
$fp = fopen($file, "w+"); |
if (flock($fp, LOCK_EX)) { |
fwrite($fp, $data); |
fflush($fp); |
flock($fp, LOCK_UN); |
} |
$c = fread($f, $s); |
flock($f, LOCK_UN); |
fclose($f); |
return $c; |
fclose($fp); |
} |
|
########################################################################### |
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
########################################################################### |
function get_file_size($file, $block = 1) |
function atomized_get_contents($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; |
$fp = fopen($file, "r+"); |
$ct = ''; |
if (flock($fp, LOCK_SH)) { |
if (filesize($file)) { |
$ct = fread($fp, filesize($file)); |
} |
fseek($f, -1, SEEK_CUR); |
$i += $s; |
} while ($s > 1); |
|
while (fgetc($f) !== false) |
$i++; |
|
flock($f, LOCK_UN); |
fclose($f); |
return $i; |
flock($fp, LOCK_UN); |
} |
fclose($fp); |
return $ct; |
} |