parent
6169e582a7
commit
7b519752d0
|
@ -66,6 +66,9 @@ RewriteRule config/(.*).(php)$ – [F]
|
|||
|
||||
<details><summary><mark><font color=darkred>点击查看2.0版更新日志</font></mark></summary>
|
||||
|
||||
* 2021-11-14 v2.4.2
|
||||
- 增加上传日志
|
||||
|
||||
* 2021-11-12 v2.4.1
|
||||
- 增加缓存周期配置
|
||||
- 增加上传统计
|
||||
|
|
|
@ -303,13 +303,6 @@ if (isset($_POST['form'])) {
|
|||
<label id="listNumber"><?php echo $config['listNumber']; ?></label><label>张</label>
|
||||
<input type="range" class="form-control" name="listNumber" value="<?php echo $config['listNumber']; ?>" min="10" max="100" step="10" onchange="document.getElementById('listNumber').innerHTML=value" title="可在网址后填写参数实时更改预览数量 如:https://img.545141.com/application/list.php?num=3">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="switch">
|
||||
<input type="hidden" name="checkEnv" value="0">
|
||||
<input type="checkbox" name="checkEnv" value="1" <?php if ($config['checkEnv']) {echo 'checked="checked"';} ?>>
|
||||
<label style="font-weight: bold">开启PHP插件检测-安全设置检测-版本检测</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="switch">
|
||||
<input type="hidden" name="checkImg" value="0">
|
||||
|
@ -332,7 +325,24 @@ if (isset($_POST['form'])) {
|
|||
<input type="range" class="form-control" name="cache_freq" value="<?php echo $config['cache_freq']; ?>" min="1" step="1"max="24" onchange="document.getElementById('cache_freq').innerHTML=value">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p style="font-weight: bold">当前软件版本:<span class="label label-badge label-outline"><?php echo $config['version']; ?></span></p>
|
||||
<div class="switch">
|
||||
<input type="hidden" name="checkEnv" value="0">
|
||||
<input type="checkbox" name="checkEnv" value="1" <?php if ($config['checkEnv']) {echo 'checked="checked"';} ?>>
|
||||
<label style="font-weight: bold">开启PHP插件检测-安全设置检测-版本检测</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="switch">
|
||||
<input type="hidden" name="upload_logs" value="0">
|
||||
<input type="checkbox" name="upload_logs" value="1" <?php if ($config['upload_logs']) {echo 'checked="checked"';} ?> title="日志每月保存一个文件;经过测试每月二十万条数据并不影响速度!">
|
||||
<label style="font-weight: bold">开启上传日志</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p style="font-weight: bold">
|
||||
当前版本:<span class="label label-badge label-outline"><?php echo $config['version']; ?></span>
|
||||
Github:<a href="https://github.com/icret/EasyImages2.0/releases" target="_blank"><span class="label label-badge label-success label-outline"><?php echo getVersion(); ?></span></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="hidden" class="form-control" name="form" value="" placeholder="隐藏的保存">
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"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- 修复统计错误"
|
||||
}
|
|
@ -31,7 +31,7 @@ function getLatelyTime($type = '')
|
|||
|
||||
$total_contents = APP_ROOT . $config['path']; // 获取用户自定义的上传目录
|
||||
$chart_total_file_md5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名
|
||||
$chart_total_file = $total_contents . "cache/chart-$chart_total_file_md5.php"; // 文件绝对目录
|
||||
$chart_total_file = APP_ROOT . "/admin/logs/counts/chart-$chart_total_file_md5.php"; // 文件绝对目录
|
||||
|
||||
function write_chart_total()
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ 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存储文件
|
||||
file_put_contents($chart_total_file, $count_contents); // 存储文件
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ class getVerson
|
|||
|
||||
public function readJson()
|
||||
{
|
||||
if (file_exists(__DIR__ . '/../i/cache/verson.json')) {
|
||||
$file = fopen(__DIR__ . '/../i/cache/verson.json', 'r');
|
||||
$test = fread($file, filesize(__DIR__ . '/../i/cache/verson.json'));
|
||||
if (file_exists(__DIR__ . '/../admin/logs/verson/verson.json')) {
|
||||
$file = fopen(__DIR__ . '/../admin/logs/verson/verson.json', 'r');
|
||||
$test = fread($file, filesize(__DIR__ . '/../admin/logs/verson/verson.json'));
|
||||
$verson = json_decode($test, true);
|
||||
return $verson['tag_name'];
|
||||
fclose($file);
|
||||
|
@ -32,7 +32,7 @@ class getVerson
|
|||
|
||||
$verson = $this->geturl($this->url);
|
||||
$verson = json_decode($verson, true);
|
||||
$file = fopen(__DIR__ . '/../i/cache/verson.json', 'w+');
|
||||
$file = fopen(__DIR__ . '/../admin/logs/verson/verson.json', 'w+');
|
||||
fwrite($file, $verson);
|
||||
fclose($file);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ function total_files($file)
|
|||
|
||||
$total_file_path = APP_ROOT . $config['path']; // 获取用户自定义的上传目录
|
||||
$totalJsonMD5 = strval(md5_file(APP_ROOT . '/config/config.php')); // 以config.php文件的md5命名
|
||||
$totalJsonName = $total_file_path . "cache/total-files-$totalJsonMD5.php"; // 文件绝对目录
|
||||
|
||||
$totalJsonName = APP_ROOT . "/admin/logs/counts/total-files-$totalJsonMD5.php"; // 文件绝对目录
|
||||
|
||||
function creat_json() // 创建json文件
|
||||
{
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/function.php';
|
||||
|
||||
/**
|
||||
* 获得用户的真实IP地址
|
||||
* <br />来源:ecshop
|
||||
* <br />$_SERVER和getenv的区别,getenv不支持IIS的isapi方式运行的php
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function real_ip()
|
||||
{
|
||||
static $realip = NULL;
|
||||
if ($realip !== NULL) {
|
||||
return $realip;
|
||||
}
|
||||
if (isset($_SERVER)) {
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||||
/* 取X-Forwarded-For中第一个非unknown的有效IP字符串 */
|
||||
foreach ($arr as $ip) {
|
||||
$ip = trim($ip);
|
||||
|
||||
if ($ip != 'unknown') {
|
||||
$realip = $ip;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$realip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} else {
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
$realip = $_SERVER['REMOTE_ADDR'];
|
||||
} else {
|
||||
$realip = '0.0.0.0';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (getenv('HTTP_X_FORWARDED_FOR')) {
|
||||
$realip = getenv('HTTP_X_FORWARDED_FOR');
|
||||
} elseif (getenv('HTTP_CLIENT_IP')) {
|
||||
$realip = getenv('HTTP_CLIENT_IP');
|
||||
} else {
|
||||
$realip = getenv('REMOTE_ADDR');
|
||||
}
|
||||
}
|
||||
// 使用正则验证IP地址的有效性,防止伪造IP地址进行SQL注入攻击
|
||||
preg_match("/[\d\.]{7,15}/", $realip, $onlineip);
|
||||
$realip = !empty($onlineip[0]) ? $onlineip[0] : '0.0.0.0';
|
||||
return $realip;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写日志
|
||||
* 日志格式:图片名称->上传时间(北京时间)->IP地址->浏览器信息->文件相对路径->cache文件相对路径
|
||||
*/
|
||||
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'), // 上传日期
|
||||
'ip' => real_ip(), // 上传ip
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'], //浏览器信息
|
||||
'path' => $file, // 文件相对路径
|
||||
'cache' => $cacheFile, // 文件缓存相对位置
|
||||
));
|
||||
|
||||
$logFileName = APP_ROOT . '/admin/logs/upload/' . date('Y-m') . '.php';
|
||||
|
||||
// 写入禁止浏览器直接访问
|
||||
if (is_file($logFileName) == false) {
|
||||
$php_code = '<?php exit;?>';
|
||||
file_put_contents($logFileName, $php_code);
|
||||
}
|
||||
|
||||
$log = json_encode($log, true);
|
||||
file_put_contents($logFileName, PHP_EOL . $log, FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
/*
|
||||
for ($i = 0; $i < 100000; $i++) {
|
||||
write_log('/i/2021/11/13/12der8s.jpg', '/i/cache/2021_11_13_12der8s.jpg');
|
||||
}
|
||||
*/
|
|
@ -45,7 +45,7 @@ $config=Array
|
|||
<a href="https://app.cloudcone.com/?ref=3521" target="_blank"><img src="/public/images/ad.jpg" /></a>
|
||||
</div>
|
||||
',
|
||||
'showSwitch'=>0,
|
||||
'showSwitch'=>1,
|
||||
'listNumber'=>20,
|
||||
'customize'=>' <!-- 统计代码-->
|
||||
<script>
|
||||
|
@ -74,9 +74,10 @@ $config=Array
|
|||
'checkEnv'=>1,
|
||||
'checkImg'=>0,
|
||||
'checkImg_value'=>50,
|
||||
'version'=>'2.4.1',
|
||||
'form'=>'',
|
||||
'upload_logs'=>0,
|
||||
'cache_freq'=>2,
|
||||
'version'=>'2.4.2',
|
||||
'form'=>'',
|
||||
'TinyImag_key'=>'',
|
||||
'moderatecontent_key'=>'',
|
||||
'footer'=>'<a href="/admin/terms.php" target="_blank">请勿上传违反中国政策的图片</a>
|
||||
|
|
10
file.php
10
file.php
|
@ -107,8 +107,8 @@ if ($handle->uploaded) {
|
|||
}
|
||||
|
||||
// 压缩图片 后压缩模式,不影响前台输出速度
|
||||
if (!isAnimatedGif($handle->file_dst_pathname))
|
||||
if ($config['compress']) {
|
||||
if ($config['compress']) {
|
||||
if (!isAnimatedGif($handle->file_dst_pathname)) {
|
||||
require 'application/compress/Imagick/class.Imgcompress.php';
|
||||
$img = new Imgcompress($handle->file_dst_pathname, 1);
|
||||
$img->compressImg($handle->file_dst_pathname);
|
||||
|
@ -116,9 +116,15 @@ if ($handle->uploaded) {
|
|||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
unset($handle);
|
||||
|
||||
// 上传日志控制
|
||||
if ($config['upload_logs'] == true) {
|
||||
require_once APP_ROOT . '/application/write-log.php';
|
||||
@write_log($imageUrl);
|
||||
}
|
||||
|
||||
// 图片违规检查
|
||||
if ($config['checkImg']) {
|
||||
|
|
Loading…
Reference in New Issue