上传文件至 /
This commit is contained in:
27
config.php
Normal file
27
config.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// 数据库配置:一律从环境变量读取,禁止把真实凭据写进代码。
|
||||
// 本地开发可复制 config.example.php 为 config.local.php 覆盖(该文件已被 .gitignore 排除)。
|
||||
date_default_timezone_set('Asia/Shanghai');
|
||||
|
||||
$local = __DIR__ . '/config.local.php';
|
||||
if (is_file($local)) {
|
||||
require $local;
|
||||
}
|
||||
|
||||
$servername = getenv('DB_HOST') ?: '127.0.0.1';
|
||||
$username = getenv('DB_USER') ?: 'photo_user';
|
||||
$password = getenv('DB_PASS') ?: '';
|
||||
$dbname = getenv('DB_NAME') ?: 'person_photo';
|
||||
|
||||
$user_points = 50; // 新用户初始可上传额度
|
||||
|
||||
// 创建连接
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
if ($conn->connect_error) {
|
||||
// 不要把连接细节抛给浏览器,只记服务端日志
|
||||
error_log('DB connect failed: ' . $conn->connect_error);
|
||||
http_response_code(500);
|
||||
die('数据库暂不可用,请联系管理员。');
|
||||
}
|
||||
|
||||
$conn->set_charset('utf8mb4');
|
||||
Reference in New Issue
Block a user