refactor: 全面代码重构与项目结构整理
安全性: - 所有SQL查询改用参数化查询(db_query),防止SQL注入 - TUSHARE_API_TOKEN集中到config.php常量,移除硬编码和多份拷贝 - getBasic.inc.php中$_REQUEST输出到JS时添加htmlspecialchars转义 代码组织: - 21个页面文件移至charts/子目录,根目录仅保留入口文件 - ajax.inc.php拆分:esfTradeDaily/esfListDaily迁至getEstate.inc.php - getBasic.inc.php拆分:HTML组件函数迁至新建的widgets.inc.php - 前端依赖去重:移除lib/echarts.min.js、libai/3.4.16.js、research/js/3.4.16.js 规范化: - AJAX响应格式统一为jsonResponse()标准封装 - 前端全局变量统一为window.chartConfig对象模式 - 修复PHP 8.4 Deprecated警告(getEstateData、getStockHistoryDataByTS参数顺序) - html/head.php中jQuery/CSS路径改为绝对路径,修复charts/子目录加载问题 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
include_once "../inc/getBasic.inc.php";
|
||||
include_once "../inc/getData.inc.php";
|
||||
include_once "../inc/postJson.inc.php";
|
||||
include_once "../inc/getFinanceData.class.php";
|
||||
|
||||
$_REQUEST['ts_code']=$_REQUEST['ts_code']?$_REQUEST['ts_code']:'000002';
|
||||
$_REQUEST['yst']=$_REQUEST['yst']?$_REQUEST['yst']:'2015';
|
||||
$_REQUEST['yed']=$_REQUEST['yed']?$_REQUEST['yed']:date('Y');
|
||||
$ts_name = tscodeToName(ts_code_conv($_REQUEST['ts_code']));
|
||||
$title="六段式表格:".$ts_name.'('.$_REQUEST['ts_code'].')';
|
||||
$years=yearList($_REQUEST['yst'],$_REQUEST['yed']);
|
||||
$thWidth = round(1/(count($years)+1)*100,1);
|
||||
$thWidth .='%';
|
||||
$urlAppend="ts_code={$_REQUEST['ts_code']}&yst={$_REQUEST['yst']}&yed={$_REQUEST['yed']}";
|
||||
|
||||
include_once "../html/head.php";
|
||||
?>
|
||||
|
||||
|
||||
<form name="main" id="main" method="get"> <div style="width:100%;text-align:center">
|
||||
|
||||
股票代码: <input type='text' name='ts_code' id='ts_code' width="30px" value='<?=$_REQUEST['ts_code']?>' >
|
||||
开始时间: <input type='input' name='yst' id='yst' width='20px' list='yearlist' autocomplete="off" >
|
||||
<datalist id="yearlist">
|
||||
<option value="2022"></option>
|
||||
<option value="2021"></option>
|
||||
<option value="2020"></option>
|
||||
<option value="2019"></option>
|
||||
<option value="2018"></option>
|
||||
<option value="2017"></option>
|
||||
<option value="2016"></option>
|
||||
<option value="2015"></option>
|
||||
</datalist>
|
||||
|
||||
结束时间: <input type='input' name='yed' id='yed' width='20px'list='yearlist' autocomplete="off" >
|
||||
|
||||
<script>
|
||||
$("#yst").val('<?=$_REQUEST['yst']?>');
|
||||
$("#yed").val('<?=$_REQUEST['yed']?>');
|
||||
</script>
|
||||
<input type='submit' value="给我查!">
|
||||
|
||||
<div > </div>
|
||||
|
||||
</div> </form>
|
||||
|
||||
<div id="container" style="margin:0 auto;height:auto;width: 90%">
|
||||
<table id="fina" class="display" style="width: 100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<?php
|
||||
for($i=0;$i<count($years);$i++) echo "<th style='width:{$thWidth};text-align: left;'> ".yearToname($years[$i])."</th>\n";
|
||||
?>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<?php
|
||||
for($i=0;$i<count($years);$i++) echo "<th style='width:{$thWidth};text-align: left;'> ".yearToname($years[$i])."</th>\n";
|
||||
?>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include_once "../html/footer.php"; ?>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#fina').DataTable( {
|
||||
paging:false,
|
||||
scrollY:950,
|
||||
ordering:false,
|
||||
"ajax": 'https://echart.doorcome.cn/inc/ajax.inc.php?t=financeData&<?=$urlAppend?>'
|
||||
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user