Files
echart/inc/config.php
T
simonandClaude Opus 4.7 eedead0d41 feat: 全面代码更新 - ECharts 5.4.2 重构、新增量化分析模块、前端库升级
- 升级 ECharts 到 5.4.2,重构 lib/ 目录结构
- 新增 DataTables 2.x 和 FixedColumns 插件
- 新增 quant/ 宏观研究报告模块
- 重构图表页面:stock_trend、hkholdbycode 等采用 JS fetch API.doorcome.cn 模式
- 新增 CLAUDE.md 补充页面文档和新数据流说明
- 更新 inc/config.php TuShare API 配置
- 更新新闻联播分析模块 news/ 和相关研究报告 research/
- 新增 api_document/ 参考文档
- 清理 .gitignore,排除 uploads/xls/.mcp.json/ source maps 等非代码文件
- 所有 PHP 文件通过 php -l 语法检查

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 18:01:55 +08:00

63 lines
1.7 KiB
PHP

<?php
define('TUSHARE_API_TOKEN', '1bc28452ba375da19320cda845ae6307578964cb3ae473d0dc702aea');
function get_db_config() {
return [
'host' => 'localhost',
'username' => 'myquant',
'password' => '_H(lU1_fF*9baRTp',
'database' => 'myquant',
'charset' => 'utf8mb4'
];
}
function get_mysqli_connection() {
$db_config = get_db_config();
$mysqli = new mysqli(
$db_config['host'],
$db_config['username'],
$db_config['password'],
$db_config['database']
);
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
$mysqli->set_charset($db_config['charset']);
return $mysqli;
}
/**
* 参数化查询,防止SQL注入。返回mysqli_result或false。
* @param mysqli $mysqli
* @param string $sql 带 ? 占位符的SQL
* @param array $params 参数值数组
* @return \mysqli_result|false
*/
function db_query($mysqli, $sql, $params = []) {
$stmt = $mysqli->prepare($sql);
if (!$stmt) return false;
if ($params) {
$types = str_repeat('s', count($params));
$stmt->bind_param($types, ...$params);
}
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
return $result;
}
/**
* 统一JSON响应格式
* @param mixed $data 响应数据
* @param string $status ok|error
* @param string $message 错误信息
*/
function jsonResponse($data = null, $status = 'ok', $message = '') {
$response = ['status' => $status];
if ($data !== null) $response['data'] = $data;
if ($message) $response['message'] = $message;
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
exit();
}