Files
PHPSemapForm/config.php
2025-12-09 10:07:14 +01:00

75 lines
2.3 KiB
PHP

<?php
/**
* Configuration file for SemapForm PHP Application
*
* Loads configuration from .env file
*/
// Load .env file
function loadEnv($path) {
if (!file_exists($path)) {
return;
}
$lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
// Skip comments
if (strpos(trim($line), '#') === 0) {
continue;
}
// Parse KEY=VALUE
if (strpos($line, '=') !== false) {
list($key, $value) = explode('=', $line, 2);
$key = trim($key);
$value = trim($value);
// Remove quotes if present
if (preg_match('/^(["\'])(.*)\\1$/', $value, $matches)) {
$value = $matches[2];
}
// Set environment variable if not already set
if (!getenv($key)) {
putenv("$key=$value");
$_ENV[$key] = $value;
$_SERVER[$key] = $value;
}
}
}
}
// Load environment variables from .env file
loadEnv(__DIR__ . '/.env');
// Error reporting (set to 0 in production)
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Email configuration
define('MAIL_ENABLED', getenv('MAIL_ENABLED') !== false ? filter_var(getenv('MAIL_ENABLED'), FILTER_VALIDATE_BOOLEAN) : true);
define('SMTP_HOST', getenv('SMTP_HOST') ?: 'smtp.ph-freiburg.de');
define('SMTP_PORT', getenv('SMTP_PORT') ?: 587); // Use 587 for TLS, 465 for SSL
define('SMTP_ENCRYPTION', getenv('SMTP_ENCRYPTION') ?: 'tls'); // 'ssl' or 'tls' or '' for none
define('SMTP_USERNAME', getenv('SMTP_USERNAME') ?: 'None');
define('SMTP_PASSWORD', getenv('SMTP_PASSWORD') ?: 'None');
define('MAIL_FROM', getenv('MAIL_FROM') ?: 'your_mail_here@example.com');
define('MAIL_TO', getenv('MAIL_TO') ?: 'receiver_mail@example.com');
// Application settings
define('BASE_PATH', __DIR__);
define('STATIC_PATH', '/static');
// Logging configuration
define('LOG_FILE', BASE_PATH . '/mail.log');
define('LOG_ENABLED', false);
// Debug settings
define('DEBUG_SHOW_TOAST', false); // Set to true to always show success toast for styling
// Signature validation API (optional Python service)
define('SIGNATURE_API_URL', 'https://api.theprivateserver.de/library');
// Email regex pattern
define('EMAIL_REGEX', '/^[^@\s]+@[^@\s]+\.[^@\s]+$/');