PHP文件插入header("Content-type: text/html; charset=utf-8"); 报错

博客内容概述
本文介绍了一个关于信息技术领域的具体案例,并详细探讨了相关的技术细节。
server { listen 80; listen 443 ssl; server_name szrengjing.com; # 索引页顺序 index index.php index.html index.htm default.php default.htm default.html; # 网站根目录 root /www/wwwroot/szrengjing.com/; # ========== 包含扩展配置(谨慎检查内容)========== include /www/server/panel/vhost/nginx/extension/szrengjing.com/*.conf; # ========== ✅ 显式支持 /chat 静态目录(关键!路径已修复)========== location /chat { alias /www/wwwroot/szrengjing.com/chat/dist; # ✅ 修复:添加 /dist index index.html; # 尝试匹配文件、目录,最后返回 404 try_files $uri $uri/ =404; # 禁止执行任何后端脚本(安全加固) location ~ \.(php|jsp|asp|py|sh|pl|cgi)$ { deny all; } # 启用缓存(可选) expires 1h; add_header Cache-Control "public, immutable"; # 启用日志以便观察(上线后可改为 off) access_log /www/wwwlogs/szrengjing.com.chat.access.log; log_not_found on; # 开启 404 记录便于排查 } # ========== ✅ BOSH 反向代理配置 ========== location /http-bind { proxy_pass https://127.0.0.1:5281/http-bind; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Content-Type "text/xml; charset=utf-8"; proxy_buffering off; proxy_cache off; proxy_read_timeout 300s; proxy_send_timeout 300s; proxy_ssl_verify off; # 忽略自签证书 proxy_ssl_session_reuse on; # WebSocket 升级头(兼容性) proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # ========== CORS 跨域支持 ========== add_header Access-Control-Allow-Origin "*" always; add_header Access-Control-Allow-Methods "POST, GET, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Accept, Authorization" always; # 处理预检请求 if ($request_method = 'OPTIONS') { return 204; } } # ========== Let's Encrypt 验证路径 ========== include /www/server/panel/vhost/nginx/well-known/szrengjing.com.conf; # ========== HTTP 强制跳转 HTTPS ========== set $isRedir 1; if ($server_port = 80) { set $isRedir 2; } if ($uri ~ /\.well-known/) { set $isRedir 1; } if ($isRedir = 2) { rewrite ^(.*)$ https://$host$1 permanent; } # ========== SSL 证书配置 ========== ssl_certificate /www/server/panel/vhost/cert/szrengjing.com/fullchain.pem; ssl_certificate_key /www/server/panel/vhost/cert/szrengjing.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:!MD5; ssl_prefer_server_ciphers on; ssl_session_tickets on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page 497 https://$host$request_uri; # ========== 错误页 ========== error_page 404 /404.html; # ========== PHP 支持(PHP 5.3)========== include enable-php-53.conf; # ========== 伪静态规则(可能包含重写,注意风险)========== include /www/server/panel/vhost/rewrite/szrengjing.com.conf; # ========== 禁止访问敏感文件 ========== location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README\.md)$ { return 404; } # ========== 允许 .well-known 访问(证书验证)========== location ~ /\.well-known { allow all; # 禁止执行脚本 location ~ .*\.php$ { deny all; } location ~ .*\.js$ { deny all; } location ~ .*\.css$ { deny all; } } # ========== 静态资源缓存策略 ========== location ~* \.(gif|jpg|jpeg|png|bmp|swf|ico)$ { expires 30d; access_log off; log_not_found off; } location ~* \.(js|css)$ { expires 12h; access_log off; log_not_found off; } # ========== 日志 ========== access_log /www/wwwlogs/szrengjing.com.log; error_log /www/wwwlogs/szrengjing.com.error.log; } server { listen 4443 ssl http2; server_name szrengjing.com; ssl_certificate /www/server/panel/vhost/cert/szrengjing.com/fullchain.pem; ssl_certificate_key /www/server/panel/vhost/cert/szrengjing.com/privkey.pem; location / { return 200 "OK\n"; add_header Content-Type text/plain; } access_log /www/wwwlogs/test-4443.log; error_log /www/wwwlogs/test-4443.error.log; }
最新发布
11-13
# 删除旧文件 rm /www/wwwroot/szrengjing.com/admin/credit_log.php # 创建新文件 cat > /www/wwwroot/szrengjing.com/admin/credit_log.php << 'EOF' <?php define('IN_ECS', true); require_once('../includes/init.php'); admin_priv('users_manage'); // 获取参数 $user_id = !empty($_GET['user_id']) ? intval($_GET['user_id']) : 0; $start_date = !empty($_GET['start_date']) ? $_GET['start_date'] : date('Y-m-01'); $end_date = !empty($_GET['end_date']) ? $_GET['end_date'] : date('Y-m-d'); // 查询日志 $sql = "SELECT l.*, u.user_name AS username FROM ecs_user_credit_log l LEFT JOIN ecs_users u ON l.user_id = u.user_id WHERE 1=1"; if ($user_id) { $sql .= " AND l.user_id = '$user_id'"; } if ($start_date) { $sql .= " AND l.created_at >= '" . $start_date . " 00:00:00'"; } if ($end_date) { $sql .= " AND l.created_at <= '" . $end_date . " 23:59:59'"; } $sql .= " ORDER BY l.created_at DESC LIMIT 100"; $res = $db->query($sql); $logs = array(); while ($row = $db->fetchRow($res)) { $logs[] = $row; } ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <title>📊 用户信用变更日志</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" /> </head> <body class="p-4"> <h2 class="mb-4">🔐 用户信用变更日志</h2> <!-- 搜索表单 --> <form method="get" class="mb-4 bg-light p-3 rounded"> <div class="row g-3"> <div class="col-md-3"> <label><strong>用户ID:</strong></label> <input type="number" name="user_id" class="form-control" value="<?= htmlspecialchars($user_id) ?>" placeholder="请输入用户ID" /> </div> <div class="col-md-3"> <label><strong>起始日期:</strong></label> <input type="date" name="start_date" class="form-control" value="<?= $start_date ?>" /> </div> <div class="col-md-3"> <label><strong>结束日期:</strong></label> <input type="date" name="end_date" class="form-control" value="<?= $end_date ?>" /> </div> <div class="col-md-3 d-flex align-items-end"> <button type="submit" class="btn btn-primary w-100">🔍 查询</button> </div> </div> </form> <!-- 数据表格 --> <table class="table table-striped table-hover"> <thead class="table-light"> <tr> <th>ID</th> <th>用户ID</th> <th>用户名</th> <th>旧分值</th> <th>新分值</th> <th>变化值</th> <th>原因</th> <th>操作时间</th> </tr> </thead> <tbody> <?php if (empty($logs)): ?> <tr> <td colspan="8" class="text-muted text-center">🔍 没有找到符合条件的记录。</td> </tr> <?php else: ?> <?php foreach ($logs as $log): ?> <tr> <td><?= $log['id'] ?></td> <td><?= $log['user_id'] ?></td> <td><?= htmlspecialchars($log['username'] ?? '未知') ?></td> <td><?= $log['old_score'] ?></td> <td><?= $log['new_score'] ?></td> <td class="<?= $log['change_value'] > 0 ? 'text-success' : ($log['change_value'] < 0 ? 'text-danger' : '') ?>"> <?= $log['change_value'] ?> </td> <td title="<?= htmlspecialchars($log['reason']) ?>"> <?= strlen($log['reason']) > 50 ? substr(htmlspecialchars($log['reason']), 0, 50).'...' : htmlspecialchars($log['reason']) ?> </td> <td><?= $log['created_at'] ?></td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </body> </html> EOF 打不开
11-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值