修复粘贴上传

pull/18/head 2.4.3
icret 2021-11-17 22:01:01 +08:00
parent 586bd059ed
commit f1d7fcb7d4
14 changed files with 279 additions and 3844 deletions

View File

@ -68,6 +68,7 @@ RewriteRule config/(.*).(php)$ [F]
* 2021-11-17 v2.4.3 * 2021-11-17 v2.4.3
- 增加登录验证码 - 增加登录验证码
- 修复粘贴上传不显示删除连接
* 2021-11-14 v2.4.2 * 2021-11-14 v2.4.2
- 增加上传日志 - 增加上传日志

View File

@ -108,9 +108,9 @@ if (is_array($char_data)) {
<canvas id="myChart" width="1080" height="200"></canvas> <canvas id="myChart" width="1080" height="200"></canvas>
</div> </div>
</div> </div>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/chart/zui.chart.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/icret/EasyImages2.0@2.4.0/public/static/zui/lib/chart/zui.chart.min.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/chart/excanvas.js"></script> <script src="https://cdn.jsdelivr.net/gh/icret/EasyImages2.0@2.4.0/public/static/zui/lib/chart/excanvas.js"></script>
<![endif]--> <![endif]-->
<script> <script>
// 文件统计-柱状图 // 文件统计-柱状图

View File

@ -21,9 +21,7 @@ require_once APP_ROOT . '/application/total_files.php';
<link href="<?php static_cdn(); ?>/public/static/nprogress.min.css?v0.2.0" rel="stylesheet"> <link href="<?php static_cdn(); ?>/public/static/nprogress.min.css?v0.2.0" rel="stylesheet">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.4.1.min.js?v3.4.1"></script> <script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.4.1.min.js?v3.4.1"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js?v1.9.2"></script> <script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js?v1.9.2"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.js?v1.9.2"></script>
<script src="<?php static_cdn(); ?>/public/static/qrcode.min.js?v2.0"></script> <script src="<?php static_cdn(); ?>/public/static/qrcode.min.js?v2.0"></script>
<script src="<?php static_cdn(); ?>/public/static/hm.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js?vv1.5.5"></script> <script src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js?vv1.5.5"></script>
<script src="<?php static_cdn(); ?>/public/static/nprogress.min.js"></script> <script src="<?php static_cdn(); ?>/public/static/nprogress.min.js"></script>
<style> <style>

View File

@ -53,9 +53,9 @@ function real_ip()
/** /**
* 写日志 * 写日志
* 日志格式:图片名称->上传时间(北京时间->IP地址->浏览器信息->文件相对路径->cache文件相对路径 * 日志格式:图片名称->上传时间(Asia/Shanghai->IP地址->浏览器信息->文件相对路径->图片的MD5
*/ */
function write_log($file, $cacheFile = null) function write_log($file, $imgMD5)
{ {
$name = trim(basename($file), " \t\n\r\0\x0B"); // 图片名称 $name = trim(basename($file), " \t\n\r\0\x0B"); // 图片名称
$log = array($name => array( $log = array($name => array(
@ -63,7 +63,7 @@ function write_log($file, $cacheFile = null)
'ip' => real_ip(), // 上传ip 'ip' => real_ip(), // 上传ip
'user_agent' => $_SERVER['HTTP_USER_AGENT'], //浏览器信息 'user_agent' => $_SERVER['HTTP_USER_AGENT'], //浏览器信息
'path' => $file, // 文件相对路径 'path' => $file, // 文件相对路径
'cache' => $cacheFile, // 文件缓存相对位置 'md5' => $imgMD5, // 文件缓存相对位置
)); ));
$logFileName = APP_ROOT . '/admin/logs/upload/' . date('Y-m') . '.php'; $logFileName = APP_ROOT . '/admin/logs/upload/' . date('Y-m') . '.php';
@ -74,8 +74,8 @@ function write_log($file, $cacheFile = null)
} }
// 写入禁止浏览器直接访问 // 写入禁止浏览器直接访问
if (!is_file($logFileName)){ if (filesize($logFileName)==0){
$php_code = '<?php exit;?>'; $php_code = '<?php /** {图片名称{date:上传日期(Asia/Shanghai),ip:上传者IP,user_agent:上传者浏览器信息,path:图片相对路径,md5:图片的MD5}} */ exit;?>';
file_put_contents($logFileName, $php_code); file_put_contents($logFileName, $php_code);
} }

View File

@ -117,15 +117,14 @@ if ($handle->uploaded) {
flush(); flush();
} }
} }
unset($handle);
// 上传日志控制 // 上传日志控制
if ($config['upload_logs'] == true) { if ($config['upload_logs'] == true) {
require_once APP_ROOT . '/application/logs-write.php'; require_once APP_ROOT . '/application/logs-write.php';
@write_log($imageUrl); @write_log(config_path() . $handle->file_dst_name,md5_file(APP_ROOT.config_path() . $handle->file_dst_name));
} }
unset($handle);
// 图片违规检查 // 图片违规检查
if ($config['checkImg']) { if ($config['checkImg']) {
require_once APP_ROOT . '/config/api_key.php'; require_once APP_ROOT . '/config/api_key.php';

View File

@ -77,8 +77,9 @@ mustLogin();
</div> </div>
</div> </div>
</table> </table>
<script src="<?php static_cdn();?>/public/static/paste.js"></script>
<script src="<?php static_cdn();?>/public/static/copy_btn.js"></script> <script src="<?php static_cdn();?>/public/static/EasyImage.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.js?v1.9.2"></script>
<script> <script>
$('#upShowID').uploader({ $('#upShowID').uploader({
// 自动上传 // 自动上传

212
public/static/EasyImage.js Executable file
View File

@ -0,0 +1,212 @@
/**
* 来自于copy_btn.js paste.js合并
* 简单图床-复制
*/
var copyBtn = document.getElementsByClassName('copyBtn1')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("links");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn2')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("bbscode");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn3')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("markdown");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn4')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("html");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn5')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("del");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
// btn状态
$('#btnLinks').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btnBbscode').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btnMarkDown').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btnHtml').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btndel').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
/****************************************************************
* 复制截图 简单图床修改版
*/
(function () {
document.addEventListener('paste', function (e) {
var items = ((e.clipboardData || window.clipboardData).items) || [];
var file = null;
if (items && items.length) {
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
file = items[i].getAsFile();
break;
}
}
}
if (!file) {
alert('粘贴内容非图片!');
return;
}
var formData = new FormData();
formData.append('file', file);
var xhr = new XMLHttpRequest();
xhr.onload = function () {
try {
var result = JSON.parse(this.responseText);
if (result.result === 'success') {
var links = document.getElementById("links");
links.innerHTML += result.url + "\n";
var bbscode = document.getElementById("bbscode");
bbscode.innerHTML += "[img]" + result.url + "[/img]\n";
var markdown = document.getElementById("markdown");
markdown.innerHTML += "![](" + result.url + ")\n";
var html = document.getElementById("html");
html.innerHTML += "&lt;img src=\"" + result.url + "\" /&#62;\n";
var del = document.getElementById("del");
del.innerHTML += result.del + "\n";
} else {
alert('上传失败1');
}
} catch (e) {
alert('上传失败2');
}
};
xhr.onerror = function () {
alert('上传失败3');
};
xhr.open('POST', './file.php', true);
xhr.send(formData);
});
})();
/****************************************************************
* 百度统计
*/
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?5320b69f4f1caa9328dfada73c8e6a75";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();

View File

@ -1,141 +0,0 @@
var copyBtn = document.getElementsByClassName('copyBtn1')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("links");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn2')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("bbscode");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn3')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("markdown");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn4')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("html");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn5')[0];
copyBtn.onclick = function () {
var copyVal = document.getElementById("del");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//success info
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
// btn状态
$('#btnLinks').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btnBbscode').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btnMarkDown').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btnHtml').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});
$('#btndel').on('click', function () {
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
setTimeout(function () {
$btn.button('reset');
}, 2000);
});

View File

@ -1,7 +0,0 @@
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?5320b69f4f1caa9328dfada73c8e6a75";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();

File diff suppressed because one or more lines are too long

View File

@ -1,54 +0,0 @@
/**
* 复制截图 简单图床修改版
*/
(function () {
document.addEventListener('paste', function (e) {
var items = ((e.clipboardData || window.clipboardData).items) || [];
var file = null;
if (items && items.length) {
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
file = items[i].getAsFile();
break;
}
}
}
if (!file) {
alert('粘贴内容非图片!');
return;
}
var formData = new FormData();
formData.append('file', file);
var xhr = new XMLHttpRequest();
xhr.onload = function () {
try {
var result = JSON.parse(this.responseText);
if (result.result === 'success') {
var links = document.getElementById("links");
links.innerHTML += result.url + "\n";
var bbscode = document.getElementById("bbscode");
bbscode.innerHTML += "[img]" + result.url + "[/img]\n";
var markdown = document.getElementById("markdown");
markdown.innerHTML += "![](" + result.url + ")\n";
var html = document.getElementById("html");
html.innerHTML += "&lt;img src=\"" + result.url + "\" /&#62;\n";
} else {
alert('上传失败1');
}
} catch (e) {
alert('上传失败2');
}
};
xhr.onerror = function () {
alert('上传失败3');
};
xhr.open('POST', './file.php', true);
xhr.send(formData);
});
})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long