Browse Source

更新后台主页

tags/6.1.7
tianya 2 years ago
parent
commit
1a680bfcb2
2 changed files with 453 additions and 443 deletions
  1. +33
    -0
      src/admin/index_body.php
  2. +420
    -443
      src/admin/templets/index_body.htm

+ 33
- 0
src/admin/index_body.php View File

@@ -35,6 +35,39 @@ else if ($dopost == 'setskin') {
} elseif ($dopost == 'get_seo') {
//直接采用DedeBIZ重写方法
exit;
} elseif($dopost == 'get_articles'){
?>
<table width="100%" class="table table-borderless">
<?php
$query = "SELECT arc.id, arc.arcrank, arc.title, arc.typeid, arc.pubdate, arc.channel, ch.editcon, tp.typename FROM `#@__archives` arc LEFT JOIN `#@__channeltype` ch ON ch.id = arc.channel LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.arcrank<>-2 ORDER BY arc.id DESC LIMIT 0,12";
$arcArr = array();
$dsql->Execute('m', $query);
while($row = $dsql->GetArray('m'))
{
$arcArr[] = $row;
}
?>
<?php
if(count($arcArr) > 1)
{
foreach($arcArr as $row)
{
if(trim($row['editcon'])==''){
$row['editcon'] = 'archives_edit.php';
}
$rowarcrank = $row['arcrank']==-1? "&nbsp;<small>[未审核]</small>":"";
$pubdate = GetDateMk($row['pubdate']);
echo "<tr><td><a href='{$row['editcon']}?aid={$row['id']}&channelid={$row['channel']}'>{$row['title']}</a>{$rowarcrank}</td><td width='90'>{$pubdate}</td></tr>";
}
} else {
?>
<tr><td colspan="2">暂无文档</td></tr>
<?php
}
?>
</table>
<?php
exit;
} elseif ($dopost == "system_info") {
if (!extension_loaded("openssl")) {
echo json_encode(array(


+ 420
- 443
src/admin/templets/index_body.htm View File

@@ -1,444 +1,421 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo $cfg_soft_lang; ?>">
<title>系统概况</title>
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<base target="_self">
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/indexbody.css">
<script src="../static/js/jquery.js"></script>
<script src="../static/js/bootstrap.bundle.js"></script>
<script src="../static/js/webajax.js"></script>
<script src="../static/js/chart.min.js"></script>
<script src="js/indexbody.js"></script>
<script src="js/main.js"></script>
<style>
table.stattable td{padding:.6rem;font-size:12px;border-bottom:1px solid #f0f0f0;text-align:right;vertical-align:middle}
table.stattable td.today{font-size:12px;color:#000}
.row{display:flex;flex-wrap:wrap}
.row>[class*='col-']{display:flex;flex-direction:column}
.table{margin-bottom:0}
.stattable{width:100%}
.col-md-6:nth-child(2n){margin-left:-15px}
.web-info{padding:10px;background:#f6f6f6;border-radius:.2rem;text-align:center}
.web-info p{margin-bottom:10px}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div id="__testEvn" class="col-md-12"></div>
<div class="col-md-12 mt-3">
<div class="card">
<div class="card-header"><a title="点击查看流量统计图" href="#statChart"><i class="fa fa-line-chart"></i></a>&nbsp;流量统计表</div>
<div class="card-body">
<table class="stattable">
<tbody>
<tr class="title">
<td width="10%"></td>
<td width="20%">浏览次数(PV)</td>
<td width="20%">独立访客(UV)</td>
<td width="20%">IP</td>
<td width="18%" >访问次数</td>
</tr>
<tr class="bg-white">
<td class="today">今日</td>
<td class="today" id="today_pv"></td>
<td class="today" id="today_uv"></td>
<td class="today" id="today_ip"></td>
<td class="today" id="today_vv"></td>
</tr>
<tr class="bg-white">
<td>昨日</td>
<td id="yestoday_pv"></td>
<td id="yestoday_uv"></td>
<td id="yestoday_ip"></td>
<td id="yestoday_vv"></td>
</tr>
<tr class="bg-white grey9 hide" style="display:table-row">
<td>历史累计</td>
<td id="total_pv"></td>
<td id="total_uv"></td>
<td id="total_ip"></td>
<td id="total_vv"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-6 mt-3 updatenews">
<div class="card">
<div class="card-header"><i class="fa fa-gear"></i>&nbsp;系统信息</div>
<div class="card-body">
<div id="updateinfos">
<?php echo "<iframe name='stafrm' src='{$offUrl}&uptime={$oktime}' frameborder='0' id='stafrm' style='width:98%;height:60px;padding:.6rem'></iframe>"; ?>
</div>
<table width="98%" class="table table-borderless">
<tr>
<td>
<div class="web-info">
<p>操作系统</p>
<span><?php echo PHP_OS; ?></span>
</div>
</td>
<td>
<div class="web-info">
<p>Web服务器</p>
<span><?php echo $_SERVER['SERVER_SOFTWARE']; ?></span>
</div>
</td>
<td>
<div class="web-info">
<p>服务器IP</p>
<span><?php echo gethostbyname($_SERVER['SERVER_NAME']); ?></span>
</div>
</td>
<td>
<div class="web-info">
<p>PHP版本</p>
<span><?php echo @phpversion(); ?></span>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-6 mt-3">
<div class="card">
<div class="card-header"><i class="fa fa-database"></i>&nbsp;版本授权</div>
<div class="card-body" id="_systeminfo">正在载入</div>
</div>
</div>
<div class="col-md-6 mt-3">
<div class="card">
<div class="card-header"><a name="statChart"><i class="fa fa-bar-chart"></i>&nbsp;流量统计图</a></div>
<div class="card-body">
<canvas id="statChart"></canvas>
</div>
</div>
</div>
<div class="col-md-6 mt-3">
<div class="card">
<div class="card-header"><i class="fa fa-file-word-o"></i>&nbsp;最新文档</div>
<div class="card-body">
<table width="100%" class="table table-borderless">
<?php
$query = "SELECT arc.id, arc.arcrank, arc.title, arc.typeid, arc.pubdate, arc.channel, ch.editcon, tp.typename FROM `#@__archives` arc LEFT JOIN `#@__channeltype` ch ON ch.id = arc.channel LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id WHERE arc.arcrank<>-2 ORDER BY arc.id DESC LIMIT 0,12";
$arcArr = array();
$dsql->Execute('m', $query);
while($row = $dsql->GetArray('m'))
{
$arcArr[] = $row;
}
?>
<?php
if(count($arcArr) > 1)
{
foreach($arcArr as $row)
{
if(trim($row['editcon'])==''){
$row['editcon'] = 'archives_edit.php';
}
$rowarcrank = $row['arcrank']==-1? "&nbsp;<span class='btn btn-danger btn-sm'>未审核</span>":"";
$pubdate = GetDateMk($row['pubdate']);
echo "<tr><td><a href='{$row['editcon']}?aid={$row['id']}&channelid={$row['channel']}'>{$row['title']}</a>{$rowarcrank}</td><td width='90'>{$pubdate}</td></tr>";
}
} else {
?>
<tr><td colspan="2">暂无文档</td></tr>
<?php
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="footer mt-2">
<div id="loaddiv" style="display:none">
<p align="center"><img src="images/loadinglit.gif">请稍后,正在下载更新文件列表</p>
</div>
<div id="editTab">
<span id="editTabBody">请稍候,正在载入</span>
</div>
<div id="addTab">
<form name="addform" action="index_body.php">
<input type="hidden" name="dopost" value="addnew">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" colspan="3" background="images/tbg.gif">
<div style="float:left;margin-left:10px">增加快捷操作项</div>
<div style="float:right;padding:2px 10px 0 0">
<a href="javascript:CloseTab('addTab')"><img src="images/close.gif"></a>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="height:10px;border-top:1px solid #8DA659"></td>
</tr>
<tr>
<td width="22%" height="26" align="right">链接标题:</td>
<td width="78%"><input name="title" type="text" class="pubinputs" style="margin-bottom:10px;width:260px"></td>
</tr>
<tr>
<td width="22%" height="26" align="right">链接网址:</td>
<td width="78%"><input name="link" type="text" class="pubinputs" style="width:260px"></td>
</tr>
<tr>
<td height="36"></td>
<td><input type="submit" name="Submit" value="保存项目" class="np coolbg"></td>
</tr>
</table>
</form>
</div>
</div>
<script>
$(function(){
$.get("index_testenv.php", function (data){
if (data !== ''){
$("#__testEvn").html(data);
}
});
});
</script>
<script>
var dedebizInfo;
function ViewDedeBIZ(){
console.log(dedebizInfo);
ShowMsg(`
<table width="100%" class="table table-borderless">
<tbody>
<tr>
<td style="width:50%">版本号:</td>
<td>V${dedebizInfo.result.server_version}</td>
</tr>
<tr>
<td style="width:50%">运行时间:</td>
<td>${dedebizInfo.result.server_run_time}</td>
</tr>
<tr>
<td style="width:50%">服务器系统:</td>
<td>${dedebizInfo.result.server_goos}(${dedebizInfo.result.server_goarch})</td>
</tr>
<tr>
<td style="width:50%">内存占用:</td>
<td>${dedebizInfo.result.server_memory_usage}%</td>
</tr>
</tbody>
</table>
`);
}
function LoadServer(){
$.get("index_body.php?dopost=system_info", function(data){
let rsp = JSON.parse(data);
if (rsp.code === 200){
let infoStr = `<table width="100%" class="table table-borderless"><tbody>`;
if (typeof rsp.result.domain !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">授权域名:</td>
<td>${rsp.result.domain} <a href="<?php echo $cfg_biz_dedebizUrl;?>/auth/?domain=${rsp.result.domain}" class="btn btn-success btn-sm">查看</a></td>
</tr>
`;
}
if (typeof rsp.result.title !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">站点名称:</td>
<td>${rsp.result.title}</td>
</tr>
`;
}
if (typeof rsp.result.stype !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">站点类型:</td>
<td>${rsp.result.stype}</td>
</tr>
`;
}
if (typeof rsp.result.auth_version !== "undefined" && typeof rsp.result.auth_at !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">授权版本:</td>
<td>V${rsp.result.auth_version}.x.x(时间:${rsp.result.auth_at})</td>
</tr>
`;
}
if (rsp.result.core === null || rsp.result.core.code != 200){
//下面是DedeBIZ Core组件信息
infoStr += `
<tr>
<td style="width:50%">版本组件:</td>
<td><a href="<?php echo $cfg_biz_dedebizUrl;?>/start?code=-1008" target="_blank" class="btn btn-danger btn-sm">如何启动组件</a></td>
</tr>
`;
} else {
dedebizInfo = JSON.parse(rsp.result.core.data);
infoStr += `
<tr>
<td style="width:50%">版本组件:</td>
<td><a href="javascript:ViewDedeBIZ()" class="btn btn-success btn-sm">查看组件信息</a></td>
</tr>
`;
}
infoStr += "</tbody></table>";
$("#_systeminfo").html(infoStr);
} else {
$("#_systeminfo").html(`
<table width="100%" class="table table-borderless">
<tbody>
<tr>
<td style="width:50%">尚未启动商业版服务,原因:${rsp.msg}</td>
<td style="text-align:right">当前版本:社区版<a href="<?php echo $cfg_biz_dedebizUrl;?>/start?code=${rsp.code}" target="_blank" class="btn btn-success btn-sm" style="margin-left:10px">升级商业版</a></td>
</tr>
<tr>
<td colspan="2">如果您已购买商业使用授权,您可以在我们的授权中心查询到相信关商业授权信息,如果授权类型同查询不符,则说明您可能购买了非法商业授权,请及时同我们取得联系</td>
</tr>
</tbody>
</table>
`);
}
});
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
function LoadStat() {
$.get("index_body.php?dopost=get_statistics", function(data){
let rsp = JSON.parse(data);
if (rsp.code == 200) {
var tpv = parseInt(rsp.result.pv);
var tuv = parseInt(rsp.result.uv);
var tip = parseInt(rsp.result.ip);
var tvv = parseInt(rsp.result.vv);
$("#today_pv").html(tpv);
$("#today_uv").html(tuv);
$("#today_ip").html(tip);
$("#today_vv").html(tvv);
$.get("index_body.php?dopost=get_statistics&sdate=-1", function(data){
let rsp = JSON.parse(data);
if (rsp.code == 200) {
$("#total_pv").html(parseInt(rsp.result.pv)+tpv);
$("#total_uv").html(parseInt(rsp.result.uv)+tuv);
$("#total_ip").html(parseInt(rsp.result.ip)+tip);
$("#total_vv").html(parseInt(rsp.result.vv)+tvv);
}
});
}
});
var d = new Date();
d.setDate(d.getDate() - 1);
var s = d.Format("yyyy-MM-dd");
s = s.replaceAll("-","");
$.get("index_body.php?dopost=get_statistics&sdate="+s, function(data){
let rsp = JSON.parse(data);
if (rsp.code == 200) {
$("#yestoday_pv").html(rsp.result.pv);
$("#yestoday_uv").html(rsp.result.uv);
$("#yestoday_ip").html(rsp.result.ip);
$("#yestoday_vv").html(rsp.result.vv);
}
});
}
async function LoadStatChart() {
const ctx = document.getElementById('statChart').getContext('2d');
let labels = [];
let pvs = [];
let ips = [];
let uvs = [];
let vvs = [];
for (let i = 15; i > 0; i--) {
var d = new Date();
d.setDate(d.getDate() - i);
var s = d.Format("yyyy-MM-dd");
labels.push(d.Format("MM-dd"));
s = s.replaceAll("-","");
let resp = await fetch("index_body.php?dopost=get_statistics&sdate="+s);
let data = await resp.json();
if (data.code == 200) {
pvs.push(typeof data.result.pv=="undefined"? 0 : data.result.pv);
ips.push(typeof data.result.ip=="undefined"? 0 : data.result.ip);
uvs.push(typeof data.result.uv=="undefined"? 0 : data.result.uv);
vvs.push(typeof data.result.vv=="undefined"? 0 : data.result.vv);
}
}
console.log(pvs);
console.log(ips);
console.log(uvs);
console.log(vvs);
const myChart = new Chart(ctx, {
type: 'line',
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: '<?php echo $cfg_webname; ?>流量统计图'
}
}
},
data: {
labels: labels,
datasets: [{
label: 'IP',
data: ips,
borderColor: 'rgba(255, 99, 132, 1)',
backgroundColor :'rgba(255, 99, 132, 0.2)',
borderWidth: 1
},
{
label: 'PV',
data: pvs,
borderColor: 'rgba(54, 162, 235, 1)',
backgroundColor :'rgba(54, 162, 235, 0.2)',
borderWidth: 1
},{
label: 'UV',
data: uvs,
borderColor: 'rgba(255, 206, 86, 1)',
backgroundColor: 'rgba(255, 206, 86, 0.2)',
borderWidth: 1
},{
label: '访问次数',
data: vvs,
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderWidth: 1
}
]
},
});
}
$(document).ready(function(){
LoadServer();
LoadStat();
LoadStatChart();
setInterval(function(){
LoadServer();
}, 60000)
});
</script>
</body>
<!DOCTYPE html>
<html>
<head>
<meta charset="<?php echo $cfg_soft_lang; ?>">
<title>系统概况</title>
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<base target="_self">
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
<link rel="stylesheet" href="../static/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/indexbody.css">
<script src="../static/js/jquery.js"></script>
<script src="../static/js/bootstrap.bundle.js"></script>
<script src="../static/js/webajax.js"></script>
<script src="../static/js/chart.min.js"></script>
<script src="js/indexbody.js"></script>
<script src="js/main.js"></script>
<style>
table.stattable td{padding:.6rem;font-size:12px;border-bottom:1px solid #f0f0f0;text-align:right;vertical-align:middle}
table.stattable td.today{font-size:12px;color:#000}
.row{display:flex;flex-wrap:wrap}
.row>[class*='col-']{display:flex;flex-direction:column}
.table{margin-bottom:0}
.stattable{width:100%}
.mt-30{margin-top:30px}
.web-info{padding:10px;background:#f6f6f6;border-radius:.2rem;text-align:center}
.web-info p{margin-bottom:10px}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div id="__testEvn" class="col-md-12"></div>
<div class="col-md-12 mt-30">
<div class="card">
<div class="card-header"><a title="点击查看流量统计图" href="#statChart"><i class="fa fa-line-chart"></i></a>&nbsp;流量统计表</div>
<div class="card-body">
<table class="stattable">
<tbody>
<tr class="title">
<td width="10%"></td>
<td width="20%">浏览次数(PV)</td>
<td width="20%">独立访客(UV)</td>
<td width="20%">IP</td>
<td width="18%" >访问次数</td>
</tr>
<tr class="bg-white">
<td class="today">今日</td>
<td class="today" id="today_pv"></td>
<td class="today" id="today_uv"></td>
<td class="today" id="today_ip"></td>
<td class="today" id="today_vv"></td>
</tr>
<tr class="bg-white">
<td>昨日</td>
<td id="yestoday_pv"></td>
<td id="yestoday_uv"></td>
<td id="yestoday_ip"></td>
<td id="yestoday_vv"></td>
</tr>
<tr class="bg-white grey9 hide" style="display:table-row">
<td>历史累计</td>
<td id="total_pv"></td>
<td id="total_uv"></td>
<td id="total_ip"></td>
<td id="total_vv"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-6 mt-30 updatenews">
<div class="card">
<div class="card-header"><i class="fa fa-gear"></i>&nbsp;系统信息</div>
<div class="card-body">
<div id="updateinfos">
<?php echo "<iframe name='stafrm' src='{$offUrl}&uptime={$oktime}' frameborder='0' id='stafrm' style='width:98%;height:60px;padding:.6rem'></iframe>"; ?>
</div>
<table width="98%" class="table table-borderless">
<tr>
<td>
<div class="web-info">
<p>操作系统</p>
<span><?php echo PHP_OS; ?></span>
</div>
</td>
<td>
<div class="web-info">
<p>Web服务器</p>
<span><?php echo $_SERVER['SERVER_SOFTWARE']; ?></span>
</div>
</td>
<td>
<div class="web-info">
<p>服务器IP</p>
<span><?php echo gethostbyname($_SERVER['SERVER_NAME']); ?></span>
</div>
</td>
<td>
<div class="web-info">
<p>PHP版本</p>
<span><?php echo @phpversion(); ?></span>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-6 mt-30">
<div class="card">
<div class="card-header"><i class="fa fa-database"></i>&nbsp;版本授权</div>
<div class="card-body" id="_systeminfo">正在载入</div>
</div>
</div>
<div class="col-md-6 mt-30">
<div class="card">
<div class="card-header"><a name="statChart"><i class="fa fa-bar-chart"></i>&nbsp;流量统计图</a></div>
<div class="card-body">
<canvas id="statChart"></canvas>
</div>
</div>
</div>
<div class="col-md-6 mt-30">
<div class="card">
<div class="card-header"><i class="fa fa-file-word-o"></i>&nbsp;最新文档</div>
<div class="card-body" id="newarticles">
正在载入
</div>
</div>
</div>
</div>
</div>
<div class="footer mt-2">
<div id="loaddiv" style="display:none">
<p align="center"><img src="images/loadinglit.gif">请稍后,正在下载更新文件列表</p>
</div>
<div id="editTab">
<span id="editTabBody">请稍候,正在载入</span>
</div>
<div id="addTab">
<form name="addform" action="index_body.php">
<input type="hidden" name="dopost" value="addnew">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" colspan="3" background="images/tbg.gif">
<div style="float:left;margin-left:10px">增加快捷操作项</div>
<div style="float:right;padding:2px 10px 0 0">
<a href="javascript:CloseTab('addTab')"><img src="images/close.gif"></a>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="height:10px;border-top:1px solid #8DA659"></td>
</tr>
<tr>
<td width="22%" height="26" align="right">链接标题:</td>
<td width="78%"><input name="title" type="text" class="pubinputs" style="margin-bottom:10px;width:260px"></td>
</tr>
<tr>
<td width="22%" height="26" align="right">链接网址:</td>
<td width="78%"><input name="link" type="text" class="pubinputs" style="width:260px"></td>
</tr>
<tr>
<td height="36"></td>
<td><input type="submit" name="Submit" value="保存项目" class="np coolbg"></td>
</tr>
</table>
</form>
</div>
</div>
<script>
$(function(){
$.get("index_testenv.php", function (data){
if (data !== ''){
$("#__testEvn").html(data);
}
});
$.get("index_body.php?dopost=get_articles", function (data){
if (data !== ''){
$("#newarticles").html(data);
}
});
});
</script>
<script>
var dedebizInfo;
function ViewDedeBIZ(){
console.log(dedebizInfo);
ShowMsg(`
<table width="100%" class="table table-borderless">
<tbody>
<tr>
<td style="width:50%">版本号:</td>
<td>V${dedebizInfo.result.server_version}</td>
</tr>
<tr>
<td style="width:50%">运行时间:</td>
<td>${dedebizInfo.result.server_run_time}</td>
</tr>
<tr>
<td style="width:50%">服务器系统:</td>
<td>${dedebizInfo.result.server_goos}(${dedebizInfo.result.server_goarch})</td>
</tr>
<tr>
<td style="width:50%">内存占用:</td>
<td>${dedebizInfo.result.server_memory_usage}%</td>
</tr>
</tbody>
</table>
`);
}
function LoadServer(){
$.get("index_body.php?dopost=system_info", function(data){
let rsp = JSON.parse(data);
if (rsp.code === 200){
let infoStr = `<table width="100%" class="table table-borderless"><tbody>`;
if (typeof rsp.result.domain !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">授权域名:</td>
<td>${rsp.result.domain} <a href="<?php echo $cfg_biz_dedebizUrl;?>/auth/?domain=${rsp.result.domain}" class="btn btn-success btn-sm">查看</a></td>
</tr>
`;
}
if (typeof rsp.result.title !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">站点名称:</td>
<td>${rsp.result.title}</td>
</tr>
`;
}
if (typeof rsp.result.stype !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">站点类型:</td>
<td>${rsp.result.stype}</td>
</tr>
`;
}
if (typeof rsp.result.auth_version !== "undefined" && typeof rsp.result.auth_at !== "undefined"){
infoStr += `
<tr>
<td style="width:50%">授权版本:</td>
<td>V${rsp.result.auth_version}.x.x(时间:${rsp.result.auth_at})</td>
</tr>
`;
}
if (rsp.result.core === null || rsp.result.core.code != 200){
//下面是DedeBIZ Core组件信息
infoStr += `
<tr>
<td style="width:50%">版本组件:</td>
<td><a href="<?php echo $cfg_biz_dedebizUrl;?>/start?code=-1008" target="_blank" class="btn btn-danger btn-sm">如何启动组件</a></td>
</tr>
`;
} else {
dedebizInfo = JSON.parse(rsp.result.core.data);
infoStr += `
<tr>
<td style="width:50%">版本组件:</td>
<td><a href="javascript:ViewDedeBIZ()" class="btn btn-success btn-sm">查看组件信息</a></td>
</tr>
`;
}
infoStr += "</tbody></table>";
$("#_systeminfo").html(infoStr);
} else {
$("#_systeminfo").html(`
<table width="100%" class="table table-borderless">
<tbody>
<tr>
<td style="width:60%">尚未启动商业版服务,原因:${rsp.msg}</td>
<td style="text-align:right">当前版本:社区版<a href="<?php echo $cfg_biz_dedebizUrl;?>/start?code=${rsp.code}" target="_blank" class="btn btn-success btn-sm" style="margin-left:10px">升级商业版</a></td>
</tr>
<tr>
<td colspan="2">如果您已购买商业版授权,您可以在我们的授权中心查询到相信关授权信息,如果查询结果与实际授权不符,则说明您可能购买了非法商业授权,请及时与我们取得联系,谢谢。</td>
</tr>
</tbody>
</table>
`);
}
});
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
function LoadStat() {
$.get("index_body.php?dopost=get_statistics", function(data){
let rsp = JSON.parse(data);
if (rsp.code == 200) {
var tpv = parseInt(rsp.result.pv);
var tuv = parseInt(rsp.result.uv);
var tip = parseInt(rsp.result.ip);
var tvv = parseInt(rsp.result.vv);
$("#today_pv").html(tpv);
$("#today_uv").html(tuv);
$("#today_ip").html(tip);
$("#today_vv").html(tvv);
$.get("index_body.php?dopost=get_statistics&sdate=-1", function(data){
let rsp = JSON.parse(data);
if (rsp.code == 200) {
$("#total_pv").html(parseInt(rsp.result.pv)+tpv);
$("#total_uv").html(parseInt(rsp.result.uv)+tuv);
$("#total_ip").html(parseInt(rsp.result.ip)+tip);
$("#total_vv").html(parseInt(rsp.result.vv)+tvv);
}
});
}
});
var d = new Date();
d.setDate(d.getDate() - 1);
var s = d.Format("yyyy-MM-dd");
s = s.replaceAll("-","");
$.get("index_body.php?dopost=get_statistics&sdate="+s, function(data){
let rsp = JSON.parse(data);
if (rsp.code == 200) {
$("#yestoday_pv").html(rsp.result.pv);
$("#yestoday_uv").html(rsp.result.uv);
$("#yestoday_ip").html(rsp.result.ip);
$("#yestoday_vv").html(rsp.result.vv);
}
});
}
async function LoadStatChart() {
const ctx = document.getElementById('statChart').getContext('2d');
let labels = [];
let pvs = [];
let ips = [];
let uvs = [];
let vvs = [];
for (let i = 15; i > 0; i--) {
var d = new Date();
d.setDate(d.getDate() - i);
var s = d.Format("yyyy-MM-dd");
labels.push(d.Format("MM-dd"));
s = s.replaceAll("-","");
let resp = await fetch("index_body.php?dopost=get_statistics&sdate="+s);
let data = await resp.json();
if (data.code == 200) {
pvs.push(typeof data.result.pv=="undefined"? 0 : data.result.pv);
ips.push(typeof data.result.ip=="undefined"? 0 : data.result.ip);
uvs.push(typeof data.result.uv=="undefined"? 0 : data.result.uv);
vvs.push(typeof data.result.vv=="undefined"? 0 : data.result.vv);
}
}
console.log(pvs);
console.log(ips);
console.log(uvs);
console.log(vvs);
const myChart = new Chart(ctx, {
type: 'line',
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: '<?php echo $cfg_webname; ?>流量统计图'
}
}
},
data: {
labels: labels,
datasets: [{
label: 'IP',
data: ips,
borderColor: 'rgba(255, 99, 132, 1)',
backgroundColor :'rgba(255, 99, 132, 0.2)',
borderWidth: 1
},
{
label: 'PV',
data: pvs,
borderColor: 'rgba(54, 162, 235, 1)',
backgroundColor :'rgba(54, 162, 235, 0.2)',
borderWidth: 1
},{
label: 'UV',
data: uvs,
borderColor: 'rgba(255, 206, 86, 1)',
backgroundColor: 'rgba(255, 206, 86, 0.2)',
borderWidth: 1
},{
label: '访问次数',
data: vvs,
borderColor: 'rgba(75, 192, 192, 1)',
backgroundColor: 'rgba(75, 192, 192, 0.2)',
borderWidth: 1
}
]
},
});
}
$(document).ready(function(){
LoadServer();
LoadStat();
LoadStatChart();
setInterval(function(){
LoadServer();
}, 60000)
});
</script>
</body>
</html>

Loading…
Cancel
Save