ujp
This commit is contained in:
+26
-2
@@ -1,8 +1,32 @@
|
||||
<?php
|
||||
file_put_contents(sys_get_temp_dir() . '/delete_template_entry.log', date('c') . " request=" . ($_SERVER['REQUEST_URI'] ?? 'cli') . "\n", FILE_APPEND);
|
||||
require_once __DIR__ . '/../config/config_enhanced.php';
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
file_put_contents(sys_get_temp_dir() . '/delete_template_entry.log', date('c') . " included=config_enhanced\n", FILE_APPEND);
|
||||
// Avoid including legacy config.php to prevent duplicate function declarations
|
||||
if (!function_exists('getConfigFromDB') && file_exists(__DIR__ . '/../config/config.php')) {
|
||||
require_once __DIR__ . '/../config/config.php';
|
||||
file_put_contents(sys_get_temp_dir() . '/delete_template_entry.log', date('c') . " included=config_php_fallback\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if (php_sapi_name() !== 'cli') header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
// Global exception/shutdown handlers to capture fatal errors during HTTP execution
|
||||
set_exception_handler(function($e){
|
||||
if (function_exists('writeLog')) writeLog('ERROR', 'Unhandled exception in delete_template.php', ['message'=>$e->getMessage(), 'trace'=>$e->getTraceAsString()]);
|
||||
if (php_sapi_name() !== 'cli') http_response_code(500);
|
||||
echo json_encode(['success'=>false,'error'=>$e->getMessage()]);
|
||||
exit;
|
||||
});
|
||||
register_shutdown_function(function(){
|
||||
$err = error_get_last();
|
||||
if ($err) {
|
||||
if (function_exists('writeLog')) writeLog('ERROR', 'Shutdown error in delete_template.php', ['error' => $err]);
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
http_response_code(500);
|
||||
echo json_encode(['success'=>false,'error'=>$err['message']]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Bypass authentication when debug=true is provided in query string
|
||||
$debugMode = isset($_GET['debug']) && $_GET['debug'] === 'true';
|
||||
|
||||
Reference in New Issue
Block a user