From ecce4ac6d62afd50431051a535452ec6f1349543 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Thu, 22 May 2025 11:38:11 -0400 Subject: [PATCH] fix time log when shared does not exists --- gulliver/system/class.bootstrap.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index bdbdc6f91..65a737522 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -786,9 +786,27 @@ class Bootstrap $endTime = microtime(true); $time = $endTime - self::$startingTime; Bootstrap::verifyPath(PATH_DATA . 'logs', true); - $fpt = fopen(PATH_DATA . 'logs/time.log', 'a'); - fwrite($fpt, sprintf("%s %7.6f %-15s %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), $_SERVER ['REQUEST_URI'])); - fclose($fpt); + + // Define the log file path + $logFilePath = PATH_DATA . 'logs/time.log'; + + // Check if the directory exists, if not, create it + if (is_dir(PATH_DATA . 'logs')) { + + // Attempt to open the log file + $fpt = fopen($logFilePath, 'a'); + if ($fpt === false) { + // Handle the error if the file cannot be opened + error_log("Failed to open log file: " . $logFilePath); + return; // Exit or handle as needed + } + + // Write to the log file + fwrite($fpt, sprintf("%s %7.6f %-15s %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), $_SERVER['REQUEST_URI'])); + + // Close the file + fclose($fpt); + } } /**