mirror of
https://github.com/unraid/webgui.git
synced 2025-12-31 22:50:25 -06:00
Update evalContent.php
This commit is contained in:
@@ -6,28 +6,33 @@
|
||||
// The PHP error logged will also include the path of the .page file for easier debugging
|
||||
|
||||
$evalSuccess = false;
|
||||
ob_start();
|
||||
try {
|
||||
set_error_handler(function($severity, $message, $file, $line) use ($evalFile) {
|
||||
// Only convert errors (not warnings, notices, etc.) to exceptions
|
||||
if ($severity & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)) {
|
||||
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||
} else {
|
||||
error_log("PHP Warning/notice in $evalFile");
|
||||
}
|
||||
// Let warnings and notices be handled normally
|
||||
return false;
|
||||
});
|
||||
eval($evalContent);
|
||||
restore_error_handler();
|
||||
$evalSuccess = true;
|
||||
ob_end_flush();
|
||||
} catch (Throwable $e) {
|
||||
restore_error_handler();
|
||||
error_log("Error evaluating content in $evalFile): ".$e->getMessage()."\nStack trace:\n".$e->getTraceAsString());
|
||||
ob_clean();
|
||||
echo "<script>console.error('".htmlspecialchars("Error evaluating content in $evalFile: ".$e->getMessage())."');</script>";
|
||||
ob_end_flush();
|
||||
$evalFile = $evalFile ?? "Unknown";
|
||||
if ( ! ($evalContent ?? false) ) {
|
||||
error_log("No evalContent within $evalFile");
|
||||
return;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
try {
|
||||
set_error_handler(function($severity, $message, $file, $line) use ($evalFile) {
|
||||
// Only convert errors (not warnings, notices, etc.) to exceptions
|
||||
if ($severity & (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR)) {
|
||||
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||
} else {
|
||||
error_log("PHP Warning/notice in $evalFile");
|
||||
}
|
||||
// Let warnings and notices be handled normally
|
||||
return false;
|
||||
});
|
||||
eval($evalContent);
|
||||
restore_error_handler();
|
||||
$evalSuccess = true;
|
||||
ob_end_flush();
|
||||
} catch (Throwable $e) {
|
||||
restore_error_handler();
|
||||
error_log("Error evaluating content in $evalFile): ".$e->getMessage()."\nStack trace:\n".$e->getTraceAsString());
|
||||
ob_clean();
|
||||
echo "<script>console.error('".htmlspecialchars("Error evaluating content in $evalFile: ".$e->getMessage())."');</script>";
|
||||
ob_end_flush();
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user