Additional error checking for scratchpads
This commit is contained in:
@@ -70,8 +70,17 @@ try {
|
||||
|
||||
if ($cmd === 'load') {
|
||||
$text = '';
|
||||
if (@is_file($resolved) && @is_readable($resolved)) {
|
||||
$text = (string)io_readFile($resolved, false);
|
||||
$exists = @is_file($resolved);
|
||||
if ($exists) {
|
||||
if (!@is_readable($resolved)) {
|
||||
luxtools_scratchpad_json(500, ['ok' => false, 'error' => 'unreadable']);
|
||||
}
|
||||
|
||||
$read = io_readFile($resolved, false);
|
||||
if ($read === false) {
|
||||
luxtools_scratchpad_json(500, ['ok' => false, 'error' => 'unreadable']);
|
||||
}
|
||||
$text = (string)$read;
|
||||
}
|
||||
luxtools_scratchpad_json(200, ['ok' => true, 'text' => $text]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user