EasyImages2.0/admin/chart.php

324 lines
10 KiB
PHP
Raw Normal View History

2021-11-12 14:17:05 +00:00
<?php
/*
* 统计中心
*/
2023-03-08 18:42:50 +00:00
require_once '../app/header.php';
require_once APP_ROOT . '/app/chart.php';
2021-11-12 14:17:05 +00:00
// 检测登录和是否开启统计
2023-04-12 07:30:49 +00:00
if (!$config['chart_on'] || !is_who_login('admin')) exit(header('Location: ' . $config['domain'] . '?hart#closed'));
2022-01-27 09:25:46 +00:00
2021-11-17 03:48:11 +00:00
// 删除统计文件
if (isset($_POST['del_total'])) {
@deldir($_POST['del_total']);
echo '
<script>
2022-01-19 10:56:59 +00:00
new $.zui.Messager("重新统计成功!", {
type: "success", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
2021-11-17 03:48:11 +00:00
}).show();
</script>
';
2023-01-30 17:27:41 +00:00
// 延时2s刷新
Header("refresh:2;url=chart.php");
2021-11-17 03:48:11 +00:00
}
2021-11-12 14:17:05 +00:00
// 统计图表
// array_reverse($arr,true) 倒叙数组并保持键值关系
$char_data = read_chart_total();
if (is_array($char_data)) {
$chart_date = '';
foreach (array_reverse($char_data['date'], true) as $value) {
$chart_date .= $value;
}
$chart_date = str_replace(date('Y/'), '', $chart_date); // 删除年份
$chart_number = '';
foreach (array_reverse($char_data['number'], true) as $value) {
$chart_number .= $value;
}
$chart_disk = '';
foreach (array_reverse($char_data['disk'], true) as $value) {
$chart_disk .= $value;
}
}
?>
2021-11-13 10:56:59 +00:00
<style>
.autoshadow {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1);
2021-11-13 14:09:30 +00:00
border: 1px;
2021-11-13 10:56:59 +00:00
margin: 0px 0px 10px 10px;
2022-01-17 06:26:29 +00:00
width: 90px;
2021-11-13 10:56:59 +00:00
height: 80px;
text-align: center;
}
2021-11-13 14:09:30 +00:00
.autoshadow:hover {
width: 105px;
height: 80px;
border: 2px;
box-shadow: 3px 2px 3px 2px rgba(19, 17, 36, 0.5);
}
2021-11-13 10:56:59 +00:00
</style>
2022-05-26 07:25:32 +00:00
<div class="row">
2021-11-13 10:56:59 +00:00
<div class="clo-md-12">
2021-11-17 03:48:11 +00:00
<div class="alert alert-warning">
2022-01-18 05:17:26 +00:00
<form action="chart.php" method="post">
<span>统计时间:<?php echo $char_data['total_time']; ?></span>
2021-11-17 03:48:11 +00:00
<input type="hidden" name="del_total" value="<?php echo APP_ROOT . '/admin/logs/counts/'; ?>">
2022-01-05 10:41:45 +00:00
<button class="btn btn-mini btn-primary"><i class="icon icon-spin icon-refresh"></i>重新统计</button>
2021-11-17 03:48:11 +00:00
</form>
</div>
2021-11-12 14:17:05 +00:00
</div>
2022-01-17 06:26:29 +00:00
<div class="col-md-12 col-xs-12">
2022-01-17 19:13:56 +00:00
<div class="col-xs-3 alert alert-success autoshadow">今日上传
<hr />
2022-02-22 13:42:19 +00:00
<?php echo read_total_json('todayUpload'); ?>
2022-01-17 19:13:56 +00:00
</div>
<div class="col-xs-3 alert alert-success autoshadow">昨日上传
<hr />
2022-02-22 13:42:19 +00:00
<?php echo read_total_json('yestUpload'); ?>
2022-01-17 19:13:56 +00:00
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
累计上传
<hr />
<?php printf("%u 张", read_total_json('filenum')); ?>
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
缓存文件
<hr />
<?php printf("%u 张", getFileNumber(APP_ROOT . $config['path'] . 'cache/')); ?>
2022-01-17 19:13:56 +00:00
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
可疑图片
<hr />
<?php printf("%u 张", getFileNumber(APP_ROOT . $config['path'] . 'suspic/')); ?>
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
文件夹
<hr />
<?php printf("%d 个", read_total_json('dirnum')); ?>
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
2022-02-22 10:56:49 +00:00
总空间
<hr />
<?php echo getDistUsed(disk_total_space('.')); ?>
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
已用空间
2022-01-17 19:13:56 +00:00
<hr />
<?php echo getDistUsed(disk_total_space('.') - disk_free_space('.')); ?>
</div>
<div class="col-xs-3 alert alert-primary autoshadow">
剩余空间
<hr />
<?php echo getDistUsed(disk_free_space('.')); ?>
</div>
2022-02-22 10:56:49 +00:00
<div class="col-xs-3 alert alert-primary autoshadow">
2022-02-22 13:42:19 +00:00
图片占用
2022-02-22 10:56:49 +00:00
<hr />
<?php echo read_total_json('usage_space'); ?>
</div>
2022-02-22 13:42:19 +00:00
<div class="col-xs-3 alert alert-primary autoshadow">
当前版本
<hr />
2023-03-09 13:45:54 +00:00
<?php echo APP_VERSION; ?>
2022-02-22 13:42:19 +00:00
</div>
2022-01-17 19:13:56 +00:00
</div>
<div class="col-md-12 col-xs-12">
<hr />
<div class="col-md-6 col-xs-12">
<span>硬盘使用量</span>
<div id="Piedisk" style="width:350px;height: 350px;"></div>
2021-11-13 10:56:59 +00:00
</div>
2022-01-17 06:26:29 +00:00
<div class="col-md-6 col-xs-12">
2022-01-17 19:13:56 +00:00
<div id="myPieChart" style="width:350px;height: 350px;"></div>
2021-11-13 10:56:59 +00:00
</div>
</div>
2022-01-17 06:26:29 +00:00
<div class="col-md-12 col-xs-12">
2021-11-13 10:56:59 +00:00
<hr />
2022-01-17 19:13:56 +00:00
<span>最近30日上传趋势与空间占用</span>
2021-11-13 14:09:30 +00:00
<div id="myLineChart" style="width: 100%;height: 300px;"></div>
2021-11-13 10:56:59 +00:00
</div>
</div>
2022-01-17 19:13:56 +00:00
<script src="<?php static_cdn(); ?>/public/static/echarts/echarts.min.js"></script>
<script>
// 基于准备好的dom初始化echarts实例
var myChart = echarts.init(document.getElementById('Piedisk'));
2021-11-12 14:17:05 +00:00
2022-01-17 19:13:56 +00:00
// 指定图表的配置项和数据
var Piedisk = {
tooltip: {
formatter: "{a} <br/>{b} : {c}%"
},
series: [{
name: '硬盘使用量',
type: 'gauge',
detail: {
valueAnimation: true,
formatter: '{value}%'
},
data: [{
2022-01-27 09:25:46 +00:00
value: <?php echo round((disk_total_space('.') - disk_free_space('.')) / disk_total_space('.') * 100, 2); ?>,
2022-01-17 19:13:56 +00:00
name: '已使用'
}]
}]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(Piedisk);
2021-11-13 05:42:41 +00:00
2021-11-13 14:09:30 +00:00
// 文件统计-折线图
var myChart = echarts.init(document.getElementById('myLineChart'));
window.onresize = function() {
myChart.resize();
2021-11-13 05:42:41 +00:00
};
2021-11-12 14:17:05 +00:00
2021-11-13 14:09:30 +00:00
var LineChart = {
color: ['#EA644A', '#38B03F'],
title: {
// text: '最近30日上传趋势与空间占用'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#6a7985'
}
}
},
legend: {
data: ['上传', '占用']
},
toolbox: {
feature: {
saveAsImage: {}
}
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: [<?php echo rtrim($chart_date, ','); ?>],
},
yAxis: {
type: 'value',
boundaryGap: [0, '100%']
},
dataZoom: [{ // 放大镜
type: 'inside',
start: 50,
end: 100
},
{
start: 0,
end: 10
}
],
series: [{
name: '占用',
type: 'line',
stack: 'x',
smooth: true,
areaStyle: {},
emphasis: {
focus: 'series'
},
data: [<?php echo rtrim($chart_disk, ','); ?>],
}, {
name: '上传',
type: 'line',
stack: 'x',
smooth: true,
areaStyle: {},
emphasis: {
focus: 'series'
},
data: [<?php echo rtrim($chart_number, ','); ?>],
},
2021-11-12 14:17:05 +00:00
2021-11-13 14:09:30 +00:00
]
2021-11-12 14:17:05 +00:00
};
2021-11-13 14:09:30 +00:00
myChart.setOption(LineChart);
2021-11-12 14:17:05 +00:00
// 硬盘统计-饼状图
2021-11-13 14:09:30 +00:00
var myChart = echarts.init(document.getElementById('myPieChart'));
2021-11-12 14:17:05 +00:00
2021-11-13 14:09:30 +00:00
myPieChart = {
color: ['#38B03F', '#353535'],
title: {
2022-01-18 05:17:26 +00:00
// text: '硬盘使用统计:GB',
2021-11-13 14:09:30 +00:00
left: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} GB ({d}%)'
},
legend: {
orient: 'vertical',
left: 'left',
data: ['剩余空间', '已用空间']
},
series: [{
2022-01-18 05:17:26 +00:00
name: '硬盘使用:',
2021-11-13 14:09:30 +00:00
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [{
value: <?php echo round(disk_free_space('.') / 1024 / 1024 / 1024, 2); ?>,
name: '剩余空间',
},
{
value: <?php echo round((disk_total_space('.') - disk_free_space('.')) / 1024 / 1024 / 1024, 2); ?>,
name: '已用空间'
},
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}]
2021-11-12 14:17:05 +00:00
};
2022-01-27 09:25:46 +00:00
2021-11-13 14:09:30 +00:00
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(myPieChart);
2021-11-12 14:17:05 +00:00
2021-11-13 14:09:30 +00:00
let currentIndex = -1;
2021-11-12 14:17:05 +00:00
2021-11-13 14:09:30 +00:00
setInterval(function() {
var dataLen = myPieChart.series[0].data.length;
// 取消之前高亮的图形
myChart.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: currentIndex
});
currentIndex = (currentIndex + 1) % dataLen;
// 高亮当前图形
myChart.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: currentIndex
});
// 显示 tooltip
myChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: currentIndex
});
}, 1000);
2022-01-27 09:25:46 +00:00
// 更改网页标题
document.title = "图床统计信息 - <?php echo $config['title']; ?>"
2021-11-12 14:17:05 +00:00
</script>
2023-03-08 18:42:50 +00:00
<?php require_once APP_ROOT . '/app/footer.php';