diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e0dc92f --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +GUSI_FRAMEWORK_ENCRYPTION_KEY=YourEncryptionKey +GUSI_FRAMEWORK_DB_USER=YourDatabaseUser +GUSI_FRAMEWORK_DB_PASSWORD=YourDatabasePassword \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8881db8..6ec03c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Ignore .env files +.env + # Ignore .log debug files in App/Logs/Debug App/Logs/Debug/*.log diff --git a/.htaccess b/.htaccess index 0a29bf1..e786efa 100644 --- a/.htaccess +++ b/.htaccess @@ -25,6 +25,11 @@ AddOutputFilterByType DEFLATE text/xml + + Order allow,deny + Deny from all + + Options -Indexes RewriteEngine On diff --git a/App/Core/Application/App.php b/App/Core/Application/App.php index 2c7123c..0ef1a16 100644 --- a/App/Core/Application/App.php +++ b/App/Core/Application/App.php @@ -46,9 +46,32 @@ public function __construct() private function init() { $this->loadModules(); + $this->loadEnvironmentVariables(); Router::getInstance()->handleRequest(); } + /** + * Loads environment variables from the .env file. + */ + private function loadEnvironmentVariables(){ + if (file_exists('.env')) { + $envData = file_get_contents('.env'); + $envLines = explode("\n", $envData); + foreach ($envLines as $line) { + $line = trim($line); + if (empty($line) || strpos($line, '#') === 0) { + continue; + } + $parts = explode('=', $line, 2); + if (count($parts) === 2) { + $key = trim($parts[0]); + $value = trim($parts[1]); + putenv("$key=$value"); + } + } + } + } + /** * Loads modules from the App/Modules directory. */