fix contents

This commit is contained in:
icret 2021-11-16 12:57:14 +08:00
parent 7b519752d0
commit 9b14b06e63
12 changed files with 36 additions and 199 deletions

View File

@ -1,137 +0,0 @@
<?php
/*
* 统计中心
*/
require_once '../application/header.php';
require_once APP_ROOT . '/config/api_key.php';
require_once APP_ROOT . '/api/application/apiFunction.php';
require_once APP_ROOT . '/application/chart.php';
// 检测登录
if (!is_online()) {
checkLogin();
}
// 统计图表
// 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;
}
}
?>
<div class="row">
<style>
.autoshadow {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1);
margin: 0px 0px 10px 10px;
width: 130px;
height: 80px;
text-align: center;
}
</style>
<div class="row">
<div class="clo-md-12">
<div class="alert alert-warning">统计时间:<?php echo $char_data['total_time']; ?></div>
</div>
<div class="col-md-12">
<div class="col-md-2 alert alert-success autoshadow">今日上传
<hr />
<?php printf("%u 张", preg_replace('/\D/s', '', $char_data['number'][0])); ?>
</div>
<div class="col-md-2 alert alert-success autoshadow">昨日上传
<hr />
<?php printf("%u 张", preg_replace('/\D/s', '', $char_data['number'][1])); ?>
</div>
<div class="col-md-2 alert alert-primary autoshadow">
累计上传
<hr />
<?php printf("%u 张", read_total_json('filenum')); ?>
</div>
<div class="col-md-2 alert alert-primary autoshadow">
缓存文件
<hr />
<?php printf("%u 张", getFileNumber(APP_ROOT . $config['path'] . 'cache/')); ?>
</div>
<div class="col-md-2 alert alert-primary autoshadow">
可疑图片
<hr />
<?php printf("%u 张", getFileNumber(APP_ROOT . $config['path'] . 'suspic/')); ?>
</div>
<div class="col-md-2 alert alert-primary autoshadow">
文件夹
<hr />
<?php printf("%d 个", read_total_json('dirnum')); ?>
</div>
<div class="col-md-2 alert alert-primary autoshadow">
占用存储
<hr />
<?php echo getDistUsed(disk_total_space('.') - disk_free_space('.')); ?>
</div>
<div class="col-md-2 alert alert-primary autoshadow">
剩余空间
<hr />
<?php echo getDistUsed(disk_free_space('.')); ?>
</div>
</div>
<div class="col-md-12">
<h4 style="text-align: center;">最近30上传趋势与空间占用上传/ 占用/MB</h4>
<canvas id="linChart-30"></canvas>
</div>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/Chart.js/3.5.0/chart.min.js"></script>
<script>
// 最近30上传趋势与空间占用-折线图
var ctx = document.getElementById("linChart-30").getContext('2d');
var myChart = new Chart(ctx, {
"type": "line",
"data": {
"labels": [<?php echo rtrim($chart_date, ','); ?>],
"datasets": [{
"label": "上传数量",
"data": [<?php echo rtrim($chart_number, ','); ?>],
"borderColor": "#4BC0C0",
"lineTension": 0.5,
"fill": true,
"backgroundColor": "rgba(120,116,126,0.2)", //背景色
},
{
"label": "占用硬盘", // 名称
"data": [<?php echo rtrim($chart_disk, ','); ?>], // 数据集
"borderColor": "rgb(255, 99, 132)", // 线条颜色
"lineTension": 0.5, // 曲度
"borderDash": [5, 5],
"fill": true,
"backgroundColor": "rgba(255, 99, 132, 0.2)", // 背景色
},
]
},
options: {}
});
</script>
<?php require_once APP_ROOT . '/application/footer.php';

View File

@ -1,41 +0,0 @@
{
"url": "https://api.github.com/repos/icret/EasyImages2.0/releases/53294083",
"assets_url": "https://api.github.com/repos/icret/EasyImages2.0/releases/53294083/assets",
"upload_url": "https://uploads.github.com/repos/icret/EasyImages2.0/releases/53294083/assets{?name,label}",
"html_url": "https://github.com/icret/EasyImages2.0/releases/tag/2.4.1",
"id": 53294083,
"author": {
"login": "icret",
"id": 16373024,
"node_id": "MDQ6VXNlcjE2MzczMDI0",
"avatar_url": "https://avatars.githubusercontent.com/u/16373024?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/icret",
"html_url": "https://github.com/icret",
"followers_url": "https://api.github.com/users/icret/followers",
"following_url": "https://api.github.com/users/icret/following{/other_user}",
"gists_url": "https://api.github.com/users/icret/gists{/gist_id}",
"starred_url": "https://api.github.com/users/icret/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/icret/subscriptions",
"organizations_url": "https://api.github.com/users/icret/orgs",
"repos_url": "https://api.github.com/users/icret/repos",
"events_url": "https://api.github.com/users/icret/events{/privacy}",
"received_events_url": "https://api.github.com/users/icret/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOCzgjBc4DLTQD",
"tag_name": "2.4.1",
"target_commitish": "master",
"name": "EasyImage2.0 简单图床 ver:2.4.1",
"draft": false,
"prerelease": false,
"created_at": "2021-11-13T10:56:59Z",
"published_at": "2021-11-13T14:18:47Z",
"assets": [
],
"tarball_url": "https://api.github.com/repos/icret/EasyImages2.0/tarball/2.4.1",
"zipball_url": "https://api.github.com/repos/icret/EasyImages2.0/zipball/2.4.1",
"body": "- 2021-11-12 v2.4.1\r\n- 增加缓存周期配置\r\n- 增加上传统计\r\n- 增加viewjs\r\n- 更新依赖件\r\n- 修复统计错误"
}

View File

@ -37,7 +37,7 @@ function getID($token)
} else {
return ('没有这个用户ID');
}
};
}
// 通过ID查找用户Token
function getIDToken($id)
@ -49,5 +49,5 @@ function getIDToken($id)
return $value;
}
}
};
}

View File

@ -55,8 +55,13 @@ function write_chart_total()
$count_contents['chart_disk'][] = [$count_day[$i] => getDirectorySize($total_contents . $count_day[$i])];
}
$count_contents = json_encode($count_contents, true); // serialize存储文件
if(!is_dir(APP_ROOT.'/admin/logs/counts/')){
mkdir(APP_ROOT.'/admin/logs/counts/',0755,true);
}
$count_contents = json_encode($count_contents, true);
file_put_contents($chart_total_file, $count_contents); // 存储文件
}
function read_chart_total()

View File

@ -25,7 +25,7 @@
// | This script is free to use, don't abuse. |
// +------------------------------------------------------------------------+
//namespace Verot\Upload;
// namespace Verot\Upload;
if (!defined('IMG_WEBP')) define('IMG_WEBP', 32);
@ -2956,7 +2956,7 @@ class Upload {
function imageunset($im) {
if (is_resource($im)) {
imagedestroy($im);
} else if (is_object($im) && $im instanceOf \GdImage) {
} else if (is_object($im) && $im instanceOf GdImage) {
unset($im);
}
}

View File

@ -30,6 +30,11 @@ class getVerson
public function downJson()
{
if(!is_dir(__DIR__.'/../admin/logs/verson/'))
{
mkdir(__DIR__.'/../admin/logs/verson/',0755,true);
}
$verson = $this->geturl($this->url);
$verson = json_decode($verson, true);
$file = fopen(__DIR__ . '/../admin/logs/verson/verson.json', 'w+');

View File

@ -638,7 +638,7 @@ function checkImg($imageUrl)
$response = get_json($imageUrl);
if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult)
//$old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$old_path = APP_ROOT . str_replace($config['imgurl'], '', $imageUrl);; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$old_path = APP_ROOT . str_replace($config['imgurl'], '', $imageUrl); // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$name = date('Y_m_d') . '_' . basename($imageUrl); // 文件名 2021_10_30_p8vypd.png
$new_path = APP_ROOT . $config['path'] . 'suspic/' . $name; // 新路径含文件名
$cache_dir = APP_ROOT . $config['path'] . 'suspic/'; // suspic路径
@ -668,15 +668,15 @@ function creat_cache_images($imgName)
require_once __DIR__ . '/class.thumb.php';
global $config;
$old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径
$cache_path = APP_ROOT . $config['path'] . 'cache/'; // cache目录的绝对路径
if (!isAnimatedGif($old_img_path)) { // 仅针对非gif创建图片缩略图
if (is_dir($cache_path)) {
$old_img_path = APP_ROOT . config_path() . $imgName; // 获取要创建缩略图文件的绝对路径
$cache_path = APP_ROOT . $config['path'] . 'cache/'; // cache目录的绝对路径
if(!is_dir($cache_path)){ // 创建cache目录
mkdir($cache_path, 0777, true);
}
if (!isAnimatedGif($old_img_path)) { // 仅针对非gif创建图片缩略图
$new_imgName = APP_ROOT . $config['path'] . 'cache/' . date('Y_m_d') . '_' . $imgName; // 缩略图缓存的绝对路径
Thumb::out($old_img_path, $new_imgName, 300, 300); // 保存缩略图
} else {
mkdir($cache_path, 0777, true); // 创建cache目录
}
Thumb::out($old_img_path, $new_imgName, 300, 300); // 保存缩略图
}
}

View File

@ -57,7 +57,6 @@ function real_ip()
*/
function write_log($file, $cacheFile = null)
{
global $config;
$name = trim(basename($file), " \t\n\r\0\x0B"); // 图片名称
$log = array($name => array(
'date' => date('Y-m-d H:i:s'), // 上传日期
@ -69,8 +68,13 @@ function write_log($file, $cacheFile = null)
$logFileName = APP_ROOT . '/admin/logs/upload/' . date('Y-m') . '.php';
// 创建日志文件夹
if(!is_dir(APP_ROOT.'/admin/logs/upload/')){
mkdir(APP_ROOT.'/admin/logs/upload',0755,true);
}
// 写入禁止浏览器直接访问
if (is_file($logFileName) == false) {
if (!is_file($logFileName)){
$php_code = '<?php exit;?>';
file_put_contents($logFileName, $php_code);
}

View File

@ -61,10 +61,10 @@ function creat_json() // 创建json文件
'yestUpload' => $yestUpload // 昨日上传数量
];
$totalJsonInfo = json_encode($totalJsonInfo, true);
if (is_dir($total_file_path . 'cache/')) {
if (is_dir(APP_ROOT.'/admin/logs/counts/')) {
file_put_contents($totalJsonName, $totalJsonInfo);
} else {
mkdir($total_file_path . 'cache/', 0777, true); // 创建cache目录
mkdir(APP_ROOT.'/admin/logs/counts/', 0777, true); // 创建cache目录
file_put_contents($totalJsonName, $totalJsonInfo);
}
}

View File

@ -74,7 +74,7 @@ $config=Array
'checkEnv'=>1,
'checkImg'=>0,
'checkImg_value'=>50,
'upload_logs'=>0,
'upload_logs'=>1,
'cache_freq'=>2,
'version'=>'2.4.2',
'form'=>'',

View File

@ -122,7 +122,7 @@ if ($handle->uploaded) {
// 上传日志控制
if ($config['upload_logs'] == true) {
require_once APP_ROOT . '/application/write-log.php';
require_once APP_ROOT . '/application/logs-write.php';
@write_log($imageUrl);
}

View File

@ -2,4 +2,5 @@
User-agent: *
Disallow:
Disallow: /config/
Disallow: /admin/
Disallow: /admin/
Disallow: /install/