53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* 班级操行分管理系统 - 前端配置
|
|
*
|
|
* 开发者: Canglan
|
|
* 联系方式: admin@sea-studio.top
|
|
* 版权归属: Sea Network Technology Studio
|
|
* 许可证: MIT License
|
|
*
|
|
* 版权所有 © Sea Network Technology Studio
|
|
*/
|
|
|
|
// 加载环境变量
|
|
$envFile = __DIR__ . '/.env';
|
|
if (file_exists($envFile)) {
|
|
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
foreach ($lines as $line) {
|
|
if (strpos(trim($line), '#') === 0) {
|
|
continue;
|
|
}
|
|
if (strpos($line, '=') !== false) {
|
|
list($key, $value) = explode('=', $line, 2);
|
|
putenv(trim($key) . '=' . trim($value));
|
|
}
|
|
}
|
|
}
|
|
|
|
// 定义常量
|
|
define('API_BASE_URL', getenv('API_BASE_URL') ?: 'http://localhost:8000');
|
|
define('API_TIMEOUT', (int)(getenv('API_TIMEOUT') ?: 30));
|
|
define('JWT_STORAGE_KEY', getenv('JWT_STORAGE_KEY') ?: 'class_system_token');
|
|
define('USER_STORAGE_KEY', getenv('USER_STORAGE_KEY') ?: 'class_system_user');
|
|
define('SITE_NAME', getenv('SITE_NAME') ?: '班级操行分管理系统');
|
|
define('SESSION_TIMEOUT', (int)(getenv('SESSION_TIMEOUT') ?: 30));
|
|
|
|
// 会话配置
|
|
ini_set('session.cookie_httponly', 1);
|
|
ini_set('session.use_only_cookies', 1);
|
|
ini_set('session.cookie_secure', 1);
|
|
session_start();
|
|
|
|
// 时区设置
|
|
date_default_timezone_set('Asia/Shanghai');
|
|
|
|
// 错误报告(生产环境关闭)
|
|
if (getenv('APP_ENV') === 'production') {
|
|
error_reporting(0);
|
|
ini_set('display_errors', 0);
|
|
} else {
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors', 1);
|
|
}
|
|
?>
|