1. <?php
  2. /**
  3. * Reloads HTTP response configuration for scheduled runs.
  4. *
  5. * This function reloads the HTTP response configuration (e.g., headers, cookies)
  6. * without relying on external libraries. It's designed for scheduled tasks
  7. * to update configurations dynamically.
  8. *
  9. * @return bool True on success, false on failure.
  10. */
  11. function reloadResponseConfig(): bool
  12. {
  13. // Define the configuration file path.
  14. $configFilePath = 'response_config.php';
  15. // Check if the configuration file exists.
  16. if (!file_exists($configFilePath)) {
  17. error_log("Error: Configuration file not found: " . $configFilePath);
  18. return false;
  19. }
  20. // Include the configuration file.
  21. require_once $configFilePath;
  22. // Check if the configuration file was successfully included.
  23. if (file_exists(__FILE__)) { // Check if it's the same file.
  24. return true;
  25. } else {
  26. error_log("Error: Failed to reload response configuration.");
  27. return false;
  28. }
  29. }
  30. // Example usage (for testing):
  31. // You can call this function from a cron job or scheduled task.
  32. //reloadResponseConfig();
  33. ?>

Add your comment