添加后台代理代码

This commit is contained in:
2026-03-15 01:27:05 +08:00
parent 11f9ac4dc1
commit ea08c9366a
5254 changed files with 721042 additions and 0 deletions

View File

@@ -0,0 +1,194 @@
<?php
/**
* OpenSSL算法支持检查工具
* 用于诊断3DES和AES加密问题
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>OpenSSL算法检查</title>";
echo "<style>
body{font-family: Arial, sans-serif; margin: 20px; background: #f8f9fa;}
.container{max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);}
.section{margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px;}
.success{color: #28a745; font-weight: bold;}
.error{color: #dc3545; font-weight: bold;}
.warning{color: #ffc107; font-weight: bold;}
.code{background: #f8f9fa; padding: 10px; border-left: 4px solid #007cba; margin: 10px 0; font-family: monospace;}
table{width: 100%; border-collapse: collapse; margin: 10px 0;}
th,td{border: 1px solid #ddd; padding: 8px; text-align: left;}
th{background-color: #f2f2f2;}
</style>";
echo "</head><body>";
echo "<div class='container'>";
echo "<h1>🔍 OpenSSL加密算法支持检查</h1>";
echo "<p><strong>检查时间:</strong> " . date('Y-m-d H:i:s') . "</p>";
echo "<p><strong>PHP版本:</strong> " . PHP_VERSION . "</p>";
// 检查OpenSSL扩展
echo "<div class='section'>";
echo "<h2>📋 OpenSSL扩展状态</h2>";
if (extension_loaded('openssl')) {
echo "<div class='success'>✅ OpenSSL扩展已加载</div>";
$version = OPENSSL_VERSION_TEXT;
echo "<div>版本信息: $version</div>";
} else {
echo "<div class='error'>❌ OpenSSL扩展未加载</div>";
}
echo "</div>";
// 获取所有支持的加密算法
echo "<div class='section'>";
echo "<h2>🔐 支持的加密算法</h2>";
$algorithms = openssl_get_cipher_methods(true); // true表示包括别名
sort($algorithms);
echo "<h3>🔍 查找3DES相关算法</h3>";
$des_algorithms = array_filter($algorithms, function($alg) {
return stripos($alg, 'des') !== false;
});
if (!empty($des_algorithms)) {
echo "<div class='success'>✅ 找到 " . count($des_algorithms) . " 个DES相关算法:</div>";
echo "<ul>";
foreach ($des_algorithms as $alg) {
echo "<li><code>$alg</code></li>";
}
echo "</ul>";
} else {
echo "<div class='error'>❌ 未找到DES相关算法</div>";
}
echo "<h3>🔍 查找AES相关算法</h3>";
$aes_algorithms = array_filter($algorithms, function($alg) {
return stripos($alg, 'aes') !== false;
});
if (!empty($aes_algorithms)) {
echo "<div class='success'>✅ 找到 " . count($aes_algorithms) . " 个AES相关算法:</div>";
echo "<ul>";
foreach (array_slice($aes_algorithms, 0, 20) as $alg) { // 只显示前20个
echo "<li><code>$alg</code></li>";
}
if (count($aes_algorithms) > 20) {
echo "<li>... 还有 " . (count($aes_algorithms) - 20) . " 个AES算法</li>";
}
echo "</ul>";
} else {
echo "<div class='error'>❌ 未找到AES相关算法</div>";
}
echo "</div>";
// 测试具体的加密算法
echo "<div class='section'>";
echo "<h2>🧪 算法测试</h2>";
// 测试3DES
echo "<h3>测试3DES算法</h3>";
$test_data = "Hello World";
$test_key = str_pad("testkey", 24, "0");
$des_candidates = ['des-ede3', 'des-ede3-ecb', '3des', 'des3', 'tripledes'];
foreach ($des_candidates as $algorithm) {
if (in_array($algorithm, $algorithms)) {
echo "<div class='code'>";
echo "<strong>算法: $algorithm</strong><br>";
try {
$encrypted = openssl_encrypt($test_data, $algorithm, $test_key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
if ($encrypted !== false) {
echo "<span class='success'>✅ 加密成功</span> - 长度: " . strlen($encrypted) . " 字节<br>";
$decrypted = openssl_decrypt($encrypted, $algorithm, $test_key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
if (trim($decrypted, "\0") === $test_data) {
echo "<span class='success'>✅ 解密成功</span><br>";
} else {
echo "<span class='error'>❌ 解密失败</span><br>";
}
} else {
echo "<span class='error'>❌ 加密失败</span><br>";
}
} catch (Exception $e) {
echo "<span class='error'>❌ 异常: " . $e->getMessage() . "</span><br>";
}
echo "</div>";
} else {
echo "<div class='warning'>⚠️ 算法 $algorithm 不支持</div>";
}
}
// 测试AES-128
echo "<h3>测试AES-128算法</h3>";
$aes_key = str_pad("testkey", 16, "0");
$aes_candidates = ['aes-128-ecb', 'aes128', 'aes-128', 'AES-128-ECB'];
foreach ($aes_candidates as $algorithm) {
if (in_array($algorithm, $algorithms) || in_array(strtolower($algorithm), $algorithms)) {
$algo_name = in_array($algorithm, $algorithms) ? $algorithm : strtolower($algorithm);
echo "<div class='code'>";
echo "<strong>算法: $algo_name</strong><br>";
try {
$encrypted = openssl_encrypt($test_data, $algo_name, $aes_key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
if ($encrypted !== false) {
echo "<span class='success'>✅ 加密成功</span> - 长度: " . strlen($encrypted) . " 字节<br>";
$decrypted = openssl_decrypt($encrypted, $algo_name, $aes_key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
if (trim($decrypted, "\0") === $test_data) {
echo "<span class='success'>✅ 解密成功</span><br>";
} else {
echo "<span class='error'>❌ 解密失败</span><br>";
}
} else {
echo "<span class='error'>❌ 加密失败</span><br>";
}
} catch (Exception $e) {
echo "<span class='error'>❌ 异常: " . $e->getMessage() . "</span><br>";
}
echo "</div>";
} else {
echo "<div class='warning'>⚠️ 算法 $algorithm 不支持</div>";
}
}
echo "</div>";
// 推荐的修复方案
echo "<div class='section'>";
echo "<h2>🔧 推荐的修复方案</h2>";
if (in_array('des-ede3', $algorithms)) {
echo "<div class='success'>";
echo "<h3>✅ 3DES修复方案</h3>";
echo "<p>使用 <code>des-ede3</code> 算法替代原来的测试中的算法。</p>";
echo "<div class='code'>";
echo "// 修复后的3DES加密代码<br>";
echo "\$encrypted = openssl_encrypt(\$data, 'des-ede3', \$key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);";
echo "</div>";
echo "</div>";
} else {
echo "<div class='error'>";
echo "<h3>❌ 3DES问题</h3>";
echo "<p>系统不支持3DES算法需要检查OpenSSL配置。</p>";
echo "</div>";
}
if (in_array('aes-128-ecb', $algorithms)) {
echo "<div class='success'>";
echo "<h3>✅ AES-128修复方案</h3>";
echo "<p>使用 <code>aes-128-ecb</code> 算法。</p>";
echo "<div class='code'>";
echo "// 修复后的AES-128加密代码<br>";
echo "\$encrypted = openssl_encrypt(\$data, 'aes-128-ecb', \$key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);";
echo "</div>";
echo "</div>";
} else {
echo "<div class='error'>";
echo "<h3>❌ AES-128问题</h3>";
echo "<p>系统不支持AES-128-ECB算法需要检查OpenSSL配置。</p>";
echo "</div>";
}
echo "</div>";
echo "</div>";
echo "</body></html>";
?>

View File

@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>微信登录调试页面</title>
</head>
<body>
<h1>微信登录调试信息</h1>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "<h2>GET参数:</h2>";
echo "<pre>" . print_r($_GET, true) . "</pre>";
echo "<h2>POST参数:</h2>";
echo "<pre>" . print_r($_POST, true) . "</pre>";
session_start();
echo "<h2>Session数据:</h2>";
echo "<pre>" . print_r($_SESSION, true) . "</pre>";
echo "<h2>服务器信息:</h2>";
echo "<pre>";
echo "REQUEST_URI: " . $_SERVER['REQUEST_URI'] . "\n";
echo "SCRIPT_NAME: " . $_SERVER['SCRIPT_NAME'] . "\n";
echo "Query String: " . $_SERVER['QUERY_STRING'] . "\n";
echo "</pre>";
// 测试数据库连接
echo "<h2>数据库连接测试:</h2>";
try {
$pdo = new PDO(
"mysql:host=rm-bp1btyuwq77591x0jpo.mysql.rds.aliyuncs.com:3306;dbname=youlehudong;charset=utf8",
"games",
"Games0791!!",
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
echo "数据库连接成功\n";
} catch (Exception $e) {
echo "数据库连接失败: " . $e->getMessage() . "\n";
}
?>
<h2>操作</h2>
<p><a href="javascript:history.back()">返回上一页</a></p>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<?php
// 测试微信登录callback
error_reporting(E_ALL);
ini_set('display_errors', 1);
echo "=== WeChat Login Callback Test ===\n";
// 模拟GET参数
$_GET['code'] = 'test_code_123';
$_GET['state'] = 'test_state_456';
// 设置服务器变量
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/api/login/weixin/callback';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
// 切换工作目录到source/public
$original_dir = getcwd();
chdir(__DIR__ . '/../../source/public');
// 包含框架
try {
require_once 'index.php';
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// 恢复工作目录
chdir($original_dir);
echo "\n=== Test Complete ===\n";
?>