master
icret 2024-01-19 22:21:12 +08:00
parent a1e80599dd
commit fe237dd712
58 changed files with 1944 additions and 2355 deletions

View File

@ -10,7 +10,7 @@ require_once APP_ROOT . '/config/config.guest.php';
// 是否关闭图床设置 // 是否关闭图床设置
if ($config['show_admin_inc'] === 0) { if ($config['show_admin_inc'] === 0) {
echo '<h2 class="alert alert-danger">已关闭图床设置~~ <br><small>再次开启请修改config.php文件: <code>\'show_admin_inc\' => 0</code></small></h2>'; echo '<h2 class="alert alert-danger">已关闭图床设置~~ <br><small>再次开启请修改config.php文件: <code>\'show_admin_inc\' => 1,</code></small></h2>';
exit(require_once APP_ROOT . '/app/footer.php'); exit(require_once APP_ROOT . '/app/footer.php');
} }
@ -247,80 +247,6 @@ if (isset($_REQUEST['delDir'])) {
header("refresh:1;url=/admin/admin.inc.php"); header("refresh:1;url=/admin/admin.inc.php");
} }
// 监黄恢复图片
if (isset($_GET['suspic_reimg'])) {
$name = $_GET['suspic_reimg'];
if (re_checkImg($name)) {
echo "
<script>
new $.zui.Messager('恢复成功', {
type: 'success', // 定义颜色主题
icon: 'ok'
}).show();
</script>
";
} else {
echo "
<script>
new $.zui.Messager('文件不存在!', {
type: 'danger', // 定义颜色主题
icon: 'warning-sign'
}).show();
</script>
";
}
header("refresh:1;url=/admin/admin.inc.php");
}
// 回收站恢复图片
if (isset($_GET['recycle_reimg'])) {
$name = $_GET['recycle_reimg'];
if (re_checkImg($name, 'recycle/')) {
echo "
<script>
new $.zui.Messager('恢复成功', {
type: 'success', // 定义颜色主题
icon: 'ok'
}).show();
</script>
";
} else {
echo "
<script>
new $.zui.Messager('文件不存在!', {
type: 'danger', // 定义颜色主题
icon: 'warning-sign'
}).show();
</script>
";
}
header("refresh:1;url=/admin/admin.inc.php");
}
// 删除版本信息文件
if (isset($_POST['del_version_file'])) {
try {
unlink(APP_ROOT . $_POST['del_version_file']);
echo "
<script>
new $.zui.Messager('更新版本号成功', {
type: 'success', // 定义颜色主题
icon: 'ok'
}).show();
</script>
";
} catch (Exception $e) {
echo "
<script>
new $.zui.Messager('更新版本号失败', {
type: 'danger', // 定义颜色主题
icon: 'ok'
}).show();
</script>
";
}
}
auto_delete(); //定时删除 auto_delete(); //定时删除
?> ?>
<div class="row"> <div class="row">
@ -331,6 +257,7 @@ auto_delete(); //定时删除
<li><a data-tab href="#Content9">界面设置</a></li> <li><a data-tab href="#Content9">界面设置</a></li>
<li><a data-tab href="#Content2">上传设置</a></li> <li><a data-tab href="#Content2">上传设置</a></li>
<li><a data-tab href="#Content12">水印设置</a></li> <li><a data-tab href="#Content12">水印设置</a></li>
<li><a data-tab href="#Content15">远程附件</a></li>
<li><a data-tab href="#Content5">API 设置</a></li> <li><a data-tab href="#Content5">API 设置</a></li>
<li><a data-tab href="#Content13">上传压缩</a></li> <li><a data-tab href="#Content13">上传压缩</a></li>
<li><a data-tab href="#Content4">压缩图片</a></li> <li><a data-tab href="#Content4">压缩图片</a></li>
@ -400,7 +327,7 @@ auto_delete(); //定时删除
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<div class="form-group col-md-1"> <div class="form-group col-md-1">
<label data-toggle="tooltip" title="前后需加'/' 例: /i/">存储目录</label> <label data-toggle="tooltip" title="前后需加'/'">存储目录</label>
<input type="text" class="form-control" name="path" required="required" value="<?php echo $config['path']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" title="可根据Apache/Nginx配置安全,参考: https://blog.png.cm/981.html 或 README.md"> <input type="text" class="form-control" name="path" required="required" value="<?php echo $config['path']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" title="可根据Apache/Nginx配置安全,参考: https://blog.png.cm/981.html 或 README.md">
</div> </div>
<div class="form-group col-md-2"> <div class="form-group col-md-2">
@ -411,12 +338,12 @@ auto_delete(); //定时删除
<label data-toggle="tooltip" title="不懂就不要改本图床仅针对图片上传,如果想上传其他类型文件请更改此出,不同mime请以英文,分割">允许的MIME类型</label> <label data-toggle="tooltip" title="不懂就不要改本图床仅针对图片上传,如果想上传其他类型文件请更改此出,不同mime请以英文,分割">允许的MIME类型</label>
<input type="text" class="form-control" name="mime" required="required" value="php echo $config['mime'];" onkeyup="this.value=this.value.replace(/\s/g,'')"> <input type="text" class="form-control" name="mime" required="required" value="php echo $config['mime'];" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div> --> </div> -->
<div class="form-group col-md-4"> <div class="form-group col-md-3">
<label data-toggle="tooltip" title="请以英文 , 分割 最后一个不加 , <br/>想上传图片以外的格式?请关闭图床安全->图床模式">允许的扩展名</label> <label data-toggle="tooltip" title="请以英文 , 分割 最后一个不加 , <br/>非图片格式需在图床安全中关闭图床模式">允许的扩展名 | 非图片格式?</label>
<input type="text" class="form-control" name="extensions" required="required" value="<?php echo $config['extensions']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')"> <input type="text" class="form-control" name="extensions" required="required" value="<?php echo $config['extensions']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-2">
<label>上传文件的命名方式</label> <label>上传文件的命名方式</label>
<select class="chosen-select form-control" name="imgName"> <select class="chosen-select form-control" name="imgName">
<option value="default" <?php if ($config['imgName'] == 'default') echo 'selected'; ?>>默认 - 36进制时间+随机数 >> vx77yu</option> <option value="default" <?php if ($config['imgName'] == 'default') echo 'selected'; ?>>默认 - 36进制时间+随机数 >> vx77yu</option>
<option value="date" <?php if ($config['imgName'] == 'date') echo 'selected'; ?>>时间 >> 192704</option> <option value="date" <?php if ($config['imgName'] == 'date') echo 'selected'; ?>>时间 >> 192704</option>
@ -442,37 +369,44 @@ auto_delete(); //定时删除
<option value="bmp" <?php if ($config['imgConvert'] == 'bmp') echo 'selected'; ?>>BMP</option> <option value="bmp" <?php if ($config['imgConvert'] == 'bmp') echo 'selected'; ?>>BMP</option>
</select> </select>
</div> </div>
<div class="form-group col-md-2">
<label for="chunks" data-toggle="tooltip" title="开启分片后粘贴上传失效<br/>可能使部分文件上传失败<br/>建议最小1Mb(1048576字节)">分片上传 | 设置<code>0</code>关闭</label>
<div class="input-group">
<input type="number" min="0" class="form-control" id="chunks" name="chunks" required="required" value="<?php echo !empty($config['chunks']) ? $config['chunks'] : 0; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')">
<span class="input-group-addon">byte</span>
</div> </div>
<div class="form-group col-md-12"> </div>
<div class="form-group"> </div>
<div class="col-md-12">
<div class="form-group col-md-6">
<label>单次最多上传 | 当前: </label><label id="maxUploadFiles"><?php echo $config['maxUploadFiles']; ?></label><label>张</label> <label>单次最多上传 | 当前: </label><label id="maxUploadFiles"><?php echo $config['maxUploadFiles']; ?></label><label>张</label>
<input type="range" class="form-control" name="maxUploadFiles" value="<?php echo $config['maxUploadFiles']; ?>" min="1" max="200" step="1" onchange="document.getElementById('maxUploadFiles').innerHTML=value"> <input type="range" class="form-control" name="maxUploadFiles" value="<?php echo $config['maxUploadFiles']; ?>" min="1" max="200" step="1" onchange="document.getElementById('maxUploadFiles').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group col-md-6">
<label>最大上传宽度 | 当前: </label><label id="maxWidth"><?php echo $config['maxWidth']; ?></label><label>px</label> <label>最大上传宽度 | 当前: </label><label id="maxWidth"><?php echo $config['maxWidth']; ?></label><label>px</label>
<input type="range" class="form-control" name="maxWidth" value="<?php echo $config['maxWidth']; ?>" min="1024" max="51200" step="1024" onchange="document.getElementById('maxWidth').innerHTML=value"> <input type="range" class="form-control" name="maxWidth" value="<?php echo $config['maxWidth']; ?>" min="1024" max="51200" step="1024" onchange="document.getElementById('maxWidth').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group col-md-6">
<label>最大上传高度 | 当前: </label><label id="maxHeight"><?php echo $config['maxHeight']; ?></label><label>px</label> <label>最大上传高度 | 当前: </label><label id="maxHeight"><?php echo $config['maxHeight']; ?></label><label>px</label>
<input type="range" class="form-control" name="maxHeight" value="<?php echo $config['maxHeight']; ?>" min="1024" max="51200" step="1024" onchange="document.getElementById('maxHeight').innerHTML=value"> <input type="range" class="form-control" name="maxHeight" value="<?php echo $config['maxHeight']; ?>" min="1024" max="51200" step="1024" onchange="document.getElementById('maxHeight').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group col-md-6">
<label>单文件最大上传(1-100MB) | 当前: </label><label id="maxSize"><?php echo $config['maxSize'] / 1024 / 1024; ?></label><label>MB</label> <label>单文件最大上传(1-100MB) | 当前: </label><label id="maxSize"><?php echo $config['maxSize'] / 1024 / 1024; ?></label><label>MB</label>
<input type="range" class="form-control" name="maxSize" value="<?php echo $config['maxSize']; ?>" min="1048576" max="104857600" step="1048576" onchange="document.getElementById('maxSize').innerHTML=value/1024/1024"> <input type="range" class="form-control" name="maxSize" value="<?php echo $config['maxSize']; ?>" min="1048576" max="104857600" step="1048576" onchange="document.getElementById('maxSize').innerHTML=value/1024/1024">
</div> </div>
<div class="form-group"> <div class="form-group col-md-6">
<label>最小上传宽度 | 当前: </label><label id="minWidth"><?php echo $config['minWidth']; ?></label><label>px</label> <label>最小上传宽度 | 当前: </label><label id="minWidth"><?php echo $config['minWidth']; ?></label><label>px</label>
<input type="range" class="form-control" name="minWidth" value="<?php echo $config['minWidth']; ?>" min="5" max="1024" step="10" onchange="document.getElementById('minWidth').innerHTML=value"> <input type="range" class="form-control" name="minWidth" value="<?php echo $config['minWidth']; ?>" min="5" max="1024" step="10" onchange="document.getElementById('minWidth').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group col-md-6">
<label>最小上传高度 | 当前: </label><label id="minHeight"><?php echo $config['minHeight']; ?></label><label>px</label> <label>最小上传高度 | 当前: </label><label id="minHeight"><?php echo $config['minHeight']; ?></label><label>px</label>
<input type="range" class="form-control" name="minHeight" value="<?php echo $config['minHeight']; ?>" min="5" max="1024" step="10" onchange="document.getElementById('minHeight').innerHTML=value"> <input type="range" class="form-control" name="minHeight" value="<?php echo $config['minHeight']; ?>" min="5" max="1024" step="10" onchange="document.getElementById('minHeight').innerHTML=value">
</div> </div>
<div class="form-group"> <div class="form-group col-md-6">
<input type="hidden" class="form-control" name="update" value="<?php echo date("Y-m-d H:i:s"); ?>" placeholder="隐藏的保存"> <input type="hidden" class="form-control" name="update" value="<?php echo date("Y-m-d H:i:s"); ?>" placeholder="隐藏的保存">
</div> </div>
<button type="submit" class="btn btn-primary">保存</button>
</div> </div>
<button type="submit" class="btn btn-primary">保存</button>
</form> </form>
</div> </div>
<div class="tab-pane fade" id="Content3"> <div class="tab-pane fade" id="Content3">
@ -584,12 +518,8 @@ auto_delete(); //定时删除
<button type="submit" class="btn btn-primary">查看</button> <button type="submit" class="btn btn-primary">查看</button>
</form> </form>
</div> </div>
<div class="col-md-2">
<h5 class="header-dividing">登录日志 <small>仅显示当月</small></h5>
<button type="button" class="btn btn-primary" data-toggle="modal" data-title="登录日志 - 仅显示当月" data-icon="book" data-moveable="true" data-width="60%" data-type="ajax" data-url="../app/viewlog.php?login_log&sign=<?php echo md5($config['password'] . date('ymdh')); ?>">查看</button>
</div>
<div class="col-md-3"> <div class="col-md-3">
<h5 class="header-dividing" data-toggle="tooltip" title="仅限存储分类路径为 Y/m/d/ 格式<br/>且每天需要访问一次后台才执行<br/>先重命名要删除文件夹作为备份<br/>超过定时日期的2倍后再彻底删除重命名的文件夹<br/>超过定时日期前和开启分离的文件夹不删除">定时删除 <small>数值为<code>0</code>关闭</small></h5> <h5 class="header-dividing" data-toggle="tooltip" title="仅限存储分类路径为 Y/m/d/ 格式<br/>且每天需要访问一次后台才执行<br/>先重命名要删除文件夹作为备份<br/>超过定时日期的2倍时间后再删除重命名的文件夹<br/>超过定时日期前和开启分离的文件夹不删除">定时删除 <small>设置<code>0</code>关闭</small></h5>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon">天数</span> <span class="input-group-addon">天数</span>
@ -600,18 +530,24 @@ auto_delete(); //定时删除
</form> </form>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<h5 class="header-dividing">清理缓存 <small>已缓存: <?php echo getFileNumber(APP_ROOT . $config['path'] . 'cache/') . '个 | 占 ' . getDistUsed(getDirectorySize(APP_ROOT . $config['path'] . 'cache/')); ?></small></h5> <h5 class="header-dividing">缩略图缓存 <small><?php echo getFileNumber(APP_ROOT . $config['path'] . 'cache/') . '个 | 占 ' . getDistUsed(getDirectorySize(APP_ROOT . $config['path'] . 'cache/')); ?></small></h5>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <button type="button" class="btn btn-primary" onclick="ajax_post('cache/','delDir')"><i class="icon icon-trash"> 清理缓存</i></button>
<button type="submit" class="btn btn-success" name="delDir" value="cache/" onClick="return confirm('确认要清理缓存?\n* 删除文件夹后将无法恢复! ');"><i class="icon icon-trash"> 清理缓存</i></button> </div>
</form> <div class="col-md-1">
<h5 class="header-dividing" data-toggle="tooltip" title="如果开启OPcache 点击重置缓存">OPcache</h5>
<button type="button" class="btn btn-primary" onclick="ajax_post('OPcache','OPcache')">重置</button>
</div>
<div class="col-md-1">
<h5 class="header-dividing" data-toggle="tooltip" title="仅显示当月">登录日志</h5>
<button type="button" class="btn btn-primary" data-toggle="modal" data-title="登录日志 - 仅显示当月" data-icon="book" data-moveable="true" data-width="60%" data-type="ajax" data-url="../app/viewlog.php?login_log&sign=<?php echo md5($config['password'] . date('ymdh')); ?>">查看</button>
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<h5 class="header-dividing">缩略图</h5> <h5 class="header-dividing"></h5>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<div class="form-group col-md-6 col-xs-12"> <div class="form-group col-md-6 col-xs-12">
<label data-toggle="tooltip" title="请选择合适的缩略图生成方式">生成方式</label> <label data-toggle="tooltip" title="请选择合适的缩略图生成方式">缩略图生成方式</label>
<div class="input-group" data-toggle="tooltip" title="原图 | 直接输出上传链接,会导致流量增加<br/>TimThumb (推荐) | 优点: 带缓存周期 | 缺点: cdn无法缓存<br/>上传生成 | 优点: 缩略图直链,缓存不失效 | 低配vps负载较大,影响前端上传速度"> <div class="input-group" data-toggle="tooltip" title="原图 | 直接输出上传链接,会导致流量增加<br/>TimThumb (推荐) | 优点: 带缓存周期 | 缺点: cdn无法缓存<br/>上传生成 | 优点: 缩略图直链,缓存不失效 | 低配vps负载较大,影响前端上传速度">
<span class="input-group-addon">生成模式</span> <span class="input-group-addon">生成模式</span>
<select class="form-control" name="thumbnail"> <select class="form-control" name="thumbnail">
@ -622,7 +558,7 @@ auto_delete(); //定时删除
</div> </div>
</div> </div>
<div class="form-group col-md-6 col-xs-12"> <div class="form-group col-md-6 col-xs-12">
<label data-toggle="tooltip" title="已生成的缩略图不会失效 需清理缓存">生成大小</label> <label data-toggle="tooltip" title="已生成的缩略图不会失效 需清理缓存">缩略图生成大小</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"></span> <span class="input-group-addon"></span>
<input type="number" name="thumbnail_w" class="form-control" min="5" placeholder="258" value="<?php echo $config['thumbnail_w']; ?>" required="required"> <input type="number" name="thumbnail_w" class="form-control" min="5" placeholder="258" value="<?php echo $config['thumbnail_w']; ?>" required="required">
@ -633,6 +569,8 @@ auto_delete(); //定时删除
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group"> <div class="form-group">
<label for="report" data-toggle="tooltip" title="举报地址支持Zoho表单、金数据、表单大师等<br/>(推荐ZOHO)留空则不显示">举报地址 <a href="https://store.zoho.com.cn/referral.do?servicename=ZohoForms&category=ZohoForms&ref=52f8a4e98a7a7d4c2475713784605af0dc842f6cc9732dd77f37b87f2959149e212e550f50a869f70360f15b80a4abc6" target="_blank"><i class="icon icon-external-link"></i></a></label> <label for="report" data-toggle="tooltip" title="举报地址支持Zoho表单、金数据、表单大师等<br/>(推荐ZOHO)留空则不显示">举报地址 <a href="https://store.zoho.com.cn/referral.do?servicename=ZohoForms&category=ZohoForms&ref=52f8a4e98a7a7d4c2475713784605af0dc842f6cc9732dd77f37b87f2959149e212e550f50a869f70360f15b80a4abc6" target="_blank"><i class="icon icon-external-link"></i></a></label>
<input type="text" class="form-control" id="report" name="report" value="<?php echo $config['report']; ?>" placeholder="可以是网址或邮箱地址" onkeyup="this.value=this.value.replace(/\s/g,'')"> <input type="text" class="form-control" id="report" name="report" value="<?php echo $config['report']; ?>" placeholder="可以是网址或邮箱地址" onkeyup="this.value=this.value.replace(/\s/g,'')">
@ -645,16 +583,20 @@ auto_delete(); //定时删除
</div> </div>
<input type="url" class="form-control" name="static_cdn_url" value="<?php echo $config['static_cdn_url']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" data-toggle="tooltip" title="jsdelivr可在后边添加版本号 例:@2.5.6"> <input type="url" class="form-control" name="static_cdn_url" value="<?php echo $config['static_cdn_url']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" data-toggle="tooltip" title="jsdelivr可在后边添加版本号 例:@2.5.6">
</div> </div>
</div>
<div class="col-md-6">
<div class="form-group"> <div class="form-group">
<div class="switch switch-inline"> <div class="switch switch-inline">
<input type="hidden" name="check_ip" value="0"> <input type="hidden" name="check_ip" value="0">
<input type="checkbox" name="check_ip" value="1" <?php if ($config['check_ip']) echo 'checked="checked"'; ?>> <input type="checkbox" name="check_ip" value="1" <?php if ($config['check_ip']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">/白IP名单上传</label> <label style="font-weight: bold">/白IP名单上传</label>
</div> </div>
<textarea class="form-control" rows="3" name="check_ip_list" data-toggle="tooltip" title="每个IP以英文,结尾 支持IP段 例:123.23.23.44,193.134.*.*" placeholder=" 每个IP以英文,结尾 支持IP段 例:192.168.1.13,123.23.23.44,193.134.*.*"><?php echo $config['check_ip_list']; ?></textarea> <textarea class="form-control" rows="4" name="check_ip_list" data-toggle="tooltip" title="每个IP以英文,结尾 支持IP段 例:123.23.23.44,193.134.*.*" placeholder=" 每个IP以英文,结尾 支持IP段 例:192.168.1.13,123.23.23.44,193.134.*.*" onkeyup="this.value=this.value.replace(/\s/g,'')"><?php echo $config['check_ip_list']; ?></textarea>
<label class="radio-inline"><input type="radio" name="check_ip_model" value="0" <?php if ($config['check_ip_model'] == 0) echo 'checked'; ?>> 黑名单模式</label> <label class="radio-inline"><input type="radio" name="check_ip_model" value="0" <?php if ($config['check_ip_model'] == 0) echo 'checked'; ?>> 黑名单模式</label>
<label class="radio-inline"><input type="radio" name="check_ip_model" value="1" <?php if ($config['check_ip_model'] == 1) echo 'checked'; ?>> 白名单模式</label> <label class="radio-inline"><input type="radio" name="check_ip_model" value="1" <?php if ($config['check_ip_model'] == 1) echo 'checked'; ?>> 白名单模式</label>
</div> </div>
</div>
</div>
<div class="col-md-12"> <div class="col-md-12">
<h5 class="header-dividing">高级设置 <?php if ($config['domain'] == $config['imgurl']) echo '<small> 网站域名与图片域名相同,锁定隐藏' . $config['path'] . '目录开关</small>'; ?></h5> <h5 class="header-dividing">高级设置 <?php if ($config['domain'] == $config['imgurl']) echo '<small> 网站域名与图片域名相同,锁定隐藏' . $config['path'] . '目录开关</small>'; ?></h5>
<div class="col-md-2"> <div class="col-md-2">
@ -735,10 +677,10 @@ auto_delete(); //定时删除
</div> </div>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="关闭后将不能进入后台设置<br/>再次开启需修改config.php: <code>'show_admin_inc'=>0</code>"> <div class="switch switch-inline" data-toggle="tooltip" title="关闭后将不能进入后台设置<br/>再次开启需修改config.php: <code>'show_admin_inc'=>1,</code>">
<input type="hidden" name="show_admin_inc" value="0"> <input type="hidden" name="show_admin_inc" value="0">
<input type="checkbox" name="show_admin_inc" value="1" <?php if ($config['show_admin_inc']) echo 'checked="checked"'; ?>> <input type="checkbox" name="show_admin_inc" value="1" <?php if ($config['show_admin_inc']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">显示设置</label> <label style="font-weight: bold">后台设置</label>
</div> </div>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
@ -847,7 +789,16 @@ auto_delete(); //定时删除
</div> </div>
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<div class="col-md-6"> <div class="col-md-4">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon" data-toggle="tooltip" title="点击查看所支持的时区列表">自定义时区 <a href="https://www.php.net/manual/zh/timezones.php" target="_blank"><i class="icon icon-external-link"></i></a>
</span>
<input class="form-control" type="text" name="timezone" value="<?php echo isset($config['timezone']) ? $config['timezone'] : 'Asia/Shanghai'; ?>" data-toggle="tooltip" title="默认时区(中国·上海) Asia/Shanghai" required="required" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group"> <div class="form-group">
<div class="input-group" data-toggle="tooltip" title="请输入限制数量 | 0 为不限制<br /> 开启监黄,水印等受网络波动和机器性能,执行完毕前限制不生效!"> <div class="input-group" data-toggle="tooltip" title="请输入限制数量 | 0 为不限制<br /> 开启监黄,水印等受网络波动和机器性能,执行完毕前限制不生效!">
<span class="input-group-addon">游客上传限制</span> <span class="input-group-addon">游客上传限制</span>
@ -856,7 +807,7 @@ auto_delete(); //定时删除
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
<div class="form-group"> <div class="form-group">
<div class="input-group" data-toggle="tooltip" title="使用nsfwjs方式需要自行搭建或使用开源接口 据说准确率能达到93%"> <div class="input-group" data-toggle="tooltip" title="使用nsfwjs方式需要自行搭建或使用开源接口 据说准确率能达到93%">
<span class="input-group-addon">图片鉴黄</span> <span class="input-group-addon">图片鉴黄</span>
@ -914,28 +865,25 @@ auto_delete(); //定时删除
<td> <td>
<a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">查看</a> <a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">查看</a>
<a class="btn btn-mini" href="/app/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a> <a class="btn btn-mini" href="/app/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a>
<a class="btn btn-mini btn-success" href="?suspic_reimg=<?php echo $filen_name; ?>">恢复</a> <a class="btn btn-mini btn-success" href="#" onclick="ajax_post('<?php echo $filen_name; ?>','suspic_reimg')">恢复</a>
<a class="btn btn-mini btn-danger" href="<?php echo $unlink_img; ?>" target="_blank">删除</a> <a class="btn btn-mini btn-danger" href="#" onclick="ajax_post('<?php echo $file_path; ?>','delete')">删除</a>
</td> </td>
</tr> </tr>
<?php endfor; ?> <?php endfor; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="delDir" value="/suspic/" readonly="">
<a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path']; ?>suspic" target="_blank">管理可疑</a> <a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path']; ?>suspic" target="_blank">管理可疑</a>
<button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button> <button class="btn btn-mini btn-danger" onclick="ajax_post('/suspic/','delDir')"><?php echo $cache_num; ?>张 | 删除全部</button>
</form>
</div> </div>
<div class=" tab-pane fade" id="Content8"> <div class=" tab-pane fade" id="Content8">
<div class="alert alert-primary"> <div class="alert alert-primary">
<h5>系统信息</h5> <h5>系统信息</h5>
<hr /> <hr />
<p class="text-ellipsis">服务系统: <?PHP echo php_uname('s') . ' <small class="text-muted">' . php_uname() . '</small>'; ?></p> <p class="text-ellipsis">服务系统: <?PHP echo php_uname('s'); ?> <small class="text-muted text-ellipsis"><?PHP echo php_uname(); ?></small></p>
<p class="text-ellipsis">Web服务: <?PHP echo $_SERVER['SERVER_SOFTWARE']; ?></p> <p class="text-ellipsis">Web服务: <?PHP echo $_SERVER['SERVER_SOFTWARE']; ?></p>
<p class="text-ellipsis">服务器IP: <?PHP echo $_SERVER["SERVER_ADDR"] ?></p> <p class="text-ellipsis">服务器IP: <?PHP echo $_SERVER["SERVER_ADDR"] . ip2region($_SERVER["SERVER_ADDR"]) ?></p>
<p class="text-ellipsis">系统时间: <?PHP echo date("Y-m-d H:i:s"); ?></p> <p class="text-ellipsis">图床时间: <?PHP echo date("Y-m-d H:i:s"); ?></p>
<p class="text-ellipsis"><span class="label label-dot label-success" data-toggle="tooltip" title="当前页面占用内存"></span> 页面占用: <?php echo getDistUsed(memory_get_usage()); ?></p> <p class="text-ellipsis"><span class="label label-dot label-success" data-toggle="tooltip" title="当前页面占用内存"></span> 页面占用: <?php echo getDistUsed(memory_get_usage()); ?></p>
<p class="text-ellipsis"><span class="label label-dot label-danger" data-toggle="tooltip" title="本页面占用内存最高峰"></span> 占用峰值: <?php echo getDistUsed(memory_get_peak_usage()); ?></p> <p class="text-ellipsis"><span class="label label-dot label-danger" data-toggle="tooltip" title="本页面占用内存最高峰"></span> 占用峰值: <?php echo getDistUsed(memory_get_peak_usage()); ?></p>
<p class="text-ellipsis">占用磁盘: <?php echo getDistUsed(disk_total_space(__DIR__) - disk_free_space(__DIR__)) ?></p> <p class="text-ellipsis">占用磁盘: <?php echo getDistUsed(disk_total_space(__DIR__) - disk_free_space(__DIR__)) ?></p>
@ -948,11 +896,10 @@ auto_delete(); //定时删除
<p class="text-ellipsis">运行时间限制: <?PHP echo get_cfg_var("max_execution_time") . "s"; ?></p> <p class="text-ellipsis">运行时间限制: <?PHP echo get_cfg_var("max_execution_time") . "s"; ?></p>
<p class="text-ellipsis">最大占用内存: <?PHP echo get_cfg_var("memory_limit"); ?></p> <p class="text-ellipsis">最大占用内存: <?PHP echo get_cfg_var("memory_limit"); ?></p>
<p class="text-ellipsis">POST上传限制: <?php echo ini_get('post_max_size'); ?></p> <p class="text-ellipsis">POST上传限制: <?php echo ini_get('post_max_size'); ?></p>
<p class="text-ellipsis">GD版本: <?php echo (gd_info()["GD Version"]); ?> <p class="text-ellipsis">GD版本: <?php echo (gd_info()["GD Version"]); ?></p>
</p>
<h5>我的信息</h5> <h5>我的信息</h5>
<hr /> <hr />
<p class="text-ellipsis">IP: <?php echo real_ip(); ?></p> <p class="text-ellipsis">IP: <?php echo real_ip() . ip2region(real_ip()); ?></p>
<p class="text-ellipsis">Browser: <?php echo $_SERVER['HTTP_USER_AGENT']; ?></p> <p class="text-ellipsis">Browser: <?php echo $_SERVER['HTTP_USER_AGENT']; ?></p>
<h5>图床信息</h5> <h5>图床信息</h5>
<hr /> <hr />
@ -1007,20 +954,17 @@ auto_delete(); //定时删除
<h5 class="header-dividing"><span class="label label-success">New</span> <?php echo getVersion('name'); ?></h5> <h5 class="header-dividing"><span class="label label-success">New</span> <?php echo getVersion('name'); ?></h5>
<pre style="background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);">更新内容: <br /><?php echo getVersion('body'); ?></pre> <pre style="background-color: rgba(0, 0, 0, 0);border-color:rgba(0, 0, 0, 0);">更新内容: <br /><?php echo getVersion('body'); ?></pre>
<h6>* 更新日期: <?php echo getVersion('created_at'); ?> 下载新版本上传至网站升级 <a href="<?php echo is_file(APP_ROOT . '/docs/index.html') ? '../docs' : 'https://icret.github.io/EasyImages2.0/#/'; ?>" target="_blank" data-toggle="tooltip" title="升级方法"><i class="icon icon-question"></i></a> 然后点击更新版本号。</h6> <h6>* 更新日期: <?php echo getVersion('created_at'); ?> 下载新版本上传至网站升级 <a href="<?php echo is_file(APP_ROOT . '/docs/index.html') ? '../docs' : 'https://icret.github.io/EasyImages2.0/#/'; ?>" target="_blank" data-toggle="tooltip" title="升级方法"><i class="icon icon-question"></i></a> 然后点击更新版本号。</h6>
<form action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="del_version_file" value="/admin/logs/version/version.json" readonly>
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-mini btn-primary" href="https://github.com/icret/EasyImages2.0/releases" target="_blank" data-toggle="tooltip" title="Releases Info">Github</a> <a class="btn btn-mini btn-primary" href="https://github.com/icret/EasyImages2.0/releases" target="_blank" data-toggle="tooltip" title="Releases Info">Github</a>
<a class="btn btn-mini btn-primary" href="<?php echo getVersion('zipball_url'); ?>" target="_blank" data-toggle="tooltip" title="① 下载后上传至网站更新">下载新版本</a> <a class="btn btn-mini btn-primary" href="<?php echo getVersion('zipball_url'); ?>" target="_blank" data-toggle="tooltip" title="① 下载后上传至网站更新">下载新版本</a>
<button class="btn btn-mini btn-danger" data-toggle="tooltip" title="② 升级后获取新的版本信息">更新版本号</button> <a class="btn btn-mini btn-danger" href="#" id="post" onclick="ajax_post('/admin/logs/version/version.json','del_version_file')" data-toggle="tooltip" title="② 升级后获取新的版本信息">更新版本号</a>
</div> </div>
</form>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="tab-pane fade" id="Content9"> <div class="tab-pane fade" id="Content9">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="form-group"> <div class="form-group col-md-12">
<h5>上传后首选显示</h5> <h5>上传后首选显示</h5>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="upload_first_show" value="1" data-toggle="tooltip" title="图片直链" <?php if ($config['upload_first_show'] == 1) echo 'checked'; ?>> <input type="radio" name="upload_first_show" value="1" data-toggle="tooltip" title="图片直链" <?php if ($config['upload_first_show'] == 1) echo 'checked'; ?>>
@ -1047,7 +991,7 @@ auto_delete(); //定时删除
<i class="icon icon-trash"></i> <i class="icon icon-trash"></i>
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group col-md-12">
<label data-toggle="tooltip" title="选择网站对外展示的一些功能和页面">对外功能页面展示</label><br /> <label data-toggle="tooltip" title="选择网站对外展示的一些功能和页面">对外功能页面展示</label><br />
<div class="switch switch-inline" data-toggle="tooltip" title="暗黑模式切换"> <div class="switch switch-inline" data-toggle="tooltip" title="暗黑模式切换">
<input type="hidden" name="dark-mode" value="0"> <input type="hidden" name="dark-mode" value="0">
@ -1075,14 +1019,15 @@ auto_delete(); //定时删除
<label style="font-weight: bold">随机图片</label> <label style="font-weight: bold">随机图片</label>
</div> </div>
</div> </div>
<div class="form-group col-md-3"> <div class="col-md-12">
<div class="form-group col-md-2">
<label data-toggle="tooltip" title="暂支持中文简繁体转换">界面语言</label> <label data-toggle="tooltip" title="暂支持中文简繁体转换">界面语言</label>
<select class="chosen-select form-control" name="language"> <select class="chosen-select form-control" name="language">
<option value="0" <?php if ($config['language'] == '0') echo 'selected'; ?>>简体中文</option> <option value="0" <?php if ($config['language'] == '0') echo 'selected'; ?>>简体中文</option>
<option value="1" <?php if ($config['language'] == '1') echo 'selected'; ?>>繁體中文</option> <option value="1" <?php if ($config['language'] == '1') echo 'selected'; ?>>繁體中文</option>
</select> </select>
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-2">
<label data-toggle="tooltip" title="配色样式文件夹位置: /public/static/zui/theme/">网站配色</label> <label data-toggle="tooltip" title="配色样式文件夹位置: /public/static/zui/theme/">网站配色</label>
<select class="chosen-select form-control" name="theme"> <select class="chosen-select form-control" name="theme">
<option value="default" style="background: #3280fc;" <?php if ($config['theme'] == 'default') echo 'selected'; ?>>默认配色</option> <option value="default" style="background: #3280fc;" <?php if ($config['theme'] == 'default') echo 'selected'; ?>>默认配色</option>
@ -1098,24 +1043,31 @@ auto_delete(); //定时删除
<option value="grey" style="background: grey;" <?php if ($config['theme'] == 'grey') echo 'selected'; ?>>纪念灰</option> <option value="grey" style="background: grey;" <?php if ($config['theme'] == 'grey') echo 'selected'; ?>>纪念灰</option>
</select> </select>
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-2">
<label for="login_bg" data-toggle="tooltip" title="图片地址可以是相对路径或网址">登录背景</label> <label for="login_bg" data-toggle="tooltip" title="图片地址可以是相对路径或网址">登录背景</label>
<input type="text" class="form-control" id="login_bg" name="login_bg" value="<?php if ($config['login_bg']) echo $config['login_bg']; ?>" required="required" placeholder="图片地址可以是相对路径或网址" onkeyup="this.value=this.value.replace(/\s/g,'')"> <input type="text" class="form-control" id="login_bg" name="login_bg" value="<?php if ($config['login_bg']) echo $config['login_bg']; ?>" required="required" placeholder="图片地址可以是相对路径或网址" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div> </div>
<div class="form-group"> <div class="form-group col-md-2">
<label data-toggle="tooltip" title="默认进度条颜色 RGB|HSL|HEX">默认进度条颜色</label>
<input type="color" class="form-control" name="NProgress_default" value="<?php echo $config['NProgress_default']; ?>">
</div>
<div class="form-group col-md-2">
<label data-toggle="tooltip" title="上传过程中进度条颜色 RGB|HSL|HEX">上传过程进度条颜色</label>
<input type="color" class="form-control" name="NProgress_Progress" value="<?php echo $config['NProgress_Progress']; ?>">
</div>
</div>
<div class="col-md-12">
<div class="col-md-9"> <div class="col-md-9">
<label data-toggle="tooltip" title="可在网址后填写参数更改预览数量 eg: /list.php?num=3">广场默认浏览数量 | 当前: </label> <label data-toggle="tooltip" title="可在网址后填写参数更改预览数量 eg: /list.php?num=3">广场默认浏览数量 | 当前: </label>
<label id="listNumber"><?php echo $config['listNumber']; ?>张</label> <label id="listNumber"><?php echo $config['listNumber']; ?>张</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"> <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">
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<label id="listDate" data-toggle="tooltip" title="广场往日浏览限制<br />有助于防爬虫抓取<br />建议不超10天,否则页面导致排版混乱">广场限制 | 当前: <?php echo $config['listDate']; ?>天</label> <label id="listDate" data-toggle="tooltip" title="广场往日浏览限制<br />有助于防爬虫抓取<br />建议不超10天,否则页面导致排版混乱">广场浏览历史限制 | 当前: <?php echo $config['listDate']; ?>天</label>
<input type="number" class="form-control" id="listDate" name="listDate" value="<?php if ($config['listDate']) echo $config['listDate']; ?>" min="1" max="100" required="required" placeholder="有助于防爬虫抓取 建议不超10天" onkeyup="this.value=this.value.replace(/\s/g,'')"> <input type="number" class="form-control" id="listDate" name="listDate" value="<?php if ($config['listDate']) echo $config['listDate']; ?>" min="1" max="100" required="required" placeholder="有助于防爬虫抓取 建议不超10天" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div> </div>
</div> </div>
<div class="form-group col-md-12">
<input type="hidden" class="form-control" name="update" value="<?php echo date("Y-m-d H:i:s"); ?>" placeholder="隐藏的保存"> <input type="hidden" class="form-control" name="update" value="<?php echo date("Y-m-d H:i:s"); ?>" placeholder="隐藏的保存">
</div>
<button type="submit" class="btn btn-primary">保存</button> <button type="submit" class="btn btn-primary">保存</button>
</form> </form>
</div> </div>
@ -1142,6 +1094,7 @@ auto_delete(); //定时删除
<button type="submit" class="btn btn-primary">更改管理员 账号|密码</button> <button type="submit" class="btn btn-primary">更改管理员 账号|密码</button>
</div> </div>
</div> </div>
</form>
<div class="alert alert-primary with-icon col-xs-8"> <div class="alert alert-primary with-icon col-xs-8">
<i class="icon-info-sign"></i> <i class="icon-info-sign"></i>
<div class="content"> <div class="content">
@ -1154,7 +1107,6 @@ auto_delete(); //定时删除
</ul> </ul>
</div> </div>
</div> </div>
</form>
<!-- 上传用户管理 start--> <!-- 上传用户管理 start-->
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" onsubmit="return uploader_md5_post()"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" onsubmit="return uploader_md5_post()">
<h5 class="header-dividing">上传者账号<small> 账户只能用于上传</small></h5> <h5 class="header-dividing">上传者账号<small> 账户只能用于上传</small></h5>
@ -1184,6 +1136,7 @@ auto_delete(); //定时删除
<button type="submit" class="btn btn-danger">添加|更改 上传者 账号|密码</button> <button type="submit" class="btn btn-danger">添加|更改 上传者 账号|密码</button>
</div> </div>
</div> </div>
</form>
<div class="alert alert-primary with-icon col-xs-8"> <div class="alert alert-primary with-icon col-xs-8">
<i class="icon-info-sign"></i> <i class="icon-info-sign"></i>
<div class="content"> <div class="content">
@ -1196,7 +1149,6 @@ auto_delete(); //定时删除
</ul> </ul>
</div> </div>
</div> </div>
</form>
<h5>* 开启用户分离后删除上传按钮激活, 删除后不可恢复</h5> <h5>* 开启用户分离后删除上传按钮激活, 删除后不可恢复</h5>
<div id="guest" class="datagrid table-bordered"> <div id="guest" class="datagrid table-bordered">
<div class="input-control search-box search-box-circle has-icon-left has-icon-right" id="searchboxExample2" style="margin-bottom: 10px;"> <div class="input-control search-box search-box-circle has-icon-left has-icon-right" id="searchboxExample2" style="margin-bottom: 10px;">
@ -1247,7 +1199,7 @@ auto_delete(); //定时删除
$file_size = getDistUsed(filesize($file_cache_path)); // 大小 $file_size = getDistUsed(filesize($file_cache_path)); // 大小
$filen_name = $cache_file[$i]; // 名称 $filen_name = $cache_file[$i]; // 名称
$url = $config['domain'] . $file_path; // 网络连接 $url = $config['domain'] . $file_path; // 网络连接
$unlink_img = $config['domain'] . '/app/del.php?url=' . $file_path; // 删除连接 // $unlink_img = $config['domain'] . '/app/del.php?url=' . $file_path; // 删除连接
?> ?>
<tr> <tr>
<td><?php echo $i; ?></td> <td><?php echo $i; ?></td>
@ -1257,19 +1209,16 @@ auto_delete(); //定时删除
<td> <td>
<a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">查看</a> <a class="btn btn-mini" href="<?php echo $url; ?>" target="_blank">查看</a>
<a class="btn btn-mini" href="/app/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a> <a class="btn btn-mini" href="/app/info.php?img=<?php echo $file_path; ?>" target="_blank">信息</a>
<a class="btn btn-mini btn-success" href="?recycle_reimg=<?php echo $filen_name; ?>">恢复</a> <a class="btn btn-mini btn-success" href="#" onclick="ajax_post('<?php echo $filen_name; ?>','recycle_reimg')">恢复</a>
<a class="btn btn-mini btn-danger" href="<?php echo $unlink_img; ?>" target="_blank">删除</a> <a class="btn btn-mini btn-danger" href="#" onclick="ajax_post('<?php echo $file_path; ?>','delete')">删除</a>
</td> </td>
</tr> </tr>
<?php endfor; ?> <?php endfor; ?>
</tbody> </tbody>
</table> </table>
</div> </div>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post">
<input class="form-control" type="hidden" name="delDir" value="/recycle/" readonly="">
<a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path']; ?>recycle" target="_blank">管理回收</a> <a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path']; ?>recycle" target="_blank">管理回收</a>
<button class="btn btn-mini btn-danger"><?php echo $cache_num; ?>张 | 删除全部</button> <button class="btn btn-mini btn-danger" onclick="ajax_post('/recycle/','delDir')"><?php echo $cache_num; ?>张 | 删除全部</button>
</form>
</div> </div>
<div class="tab-pane fade" id="Content12"> <div class="tab-pane fade" id="Content12">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
@ -1310,7 +1259,7 @@ auto_delete(); //定时删除
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label data-toggle="tooltip" title="格式RGBA 末尾为透明度0-127 0为不透明,仅支持文字水印">文字水印颜色</label> <label data-toggle="tooltip" title="格式RGBA 末尾为透明度0-127 0为不透明,仅支持文字水印">文字水印颜色</label>
<input type="text" name="textColor" class="form-control" value="" readonly data-jscolor="{preset:'myPreset'}"> <input type="text" name="textColor" class="form-control" value="" data-jscolor="{preset:'myPreset'}" readonly required="required">
</div> </div>
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label>文字水印大小 | 当前: </label><label id="textSize"><?php echo $config['textSize']; ?></label><label>px</label> <label>文字水印大小 | 当前: </label><label id="textSize"><?php echo $config['textSize']; ?></label><label>px</label>
@ -1325,39 +1274,45 @@ auto_delete(); //定时删除
<div class="tab-pane fade" id="Content13"> <div class="tab-pane fade" id="Content13">
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<h5 class="header-dividing">前端裁剪/压缩 <small>优点:服务器无压力 缺点:PC配置低的会导致浏览器卡顿,偶现丢失方向信息,仅支持JPG</small></h5> <h5 class="header-dividing">前端裁剪/压缩 <small>优点:服务器无压力 缺点:PC配置低的会导致浏览器卡顿,偶现丢失方向信息,仅支持JPG</small></h5>
<div class="form-group"> <div class="col-md-12">
<div class="form-group col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="控制以下五项 不开启不生效"> <div class="switch switch-inline" data-toggle="tooltip" title="控制以下五项 不开启不生效">
<input type="hidden" name="imgRatio" value="0"> <input type="hidden" name="imgRatio" value="0">
<input type="checkbox" name="imgRatio" value="1" <?php if ($config['imgRatio']) echo 'checked="checked"'; ?>> <input type="checkbox" name="imgRatio" value="1" <?php if ($config['imgRatio']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">前端修改图片</label> <label style="font-weight: bold">前端修改图片</label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group col-md-2">
<label>压缩后的宽度 | 当前: </label><label id="image_x"><?php echo $config['image_x']; ?></label><label>px (0为不生效)</label>
<input type="range" class="form-control" name="image_x" value="<?php echo $config['image_x']; ?>" min="0" max="4096" step="100" onchange="document.getElementById('image_x').innerHTML=value">
</div>
<div class="form-group">
<label>压缩后的高度 | 当前: </label><label id="image_y"><?php echo $config['image_y']; ?></label><label>px (0为不生效)</label>
<input type="range" class="form-control" name="image_y" value="<?php echo $config['image_y']; ?>" min="0" max="4096" step="100" onchange="document.getElementById('image_y').innerHTML=value">
</div>
<div class="form-group">
<div class="switch switch-inline"> <div class="switch switch-inline">
<input type="hidden" name="imgRatio_crop" value="0"> <input type="hidden" name="imgRatio_crop" value="0">
<input type="checkbox" name="imgRatio_crop" value="1" <?php if ($config['imgRatio_crop']) echo 'checked="checked"'; ?>> <input type="checkbox" name="imgRatio_crop" value="1" <?php if ($config['imgRatio_crop']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">上传前裁剪</label> <label style="font-weight: bold">上传前裁剪</label>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group col-md-3">
<div class="switch switch-inline"> <div class="switch switch-inline">
<input type="hidden" name="imgRatio_preserve_headers" value="0"> <input type="hidden" name="imgRatio_preserve_headers" value="0">
<input type="checkbox" name="imgRatio_preserve_headers" value="1" <?php if ($config['imgRatio_preserve_headers']) echo 'checked="checked"'; ?>> <input type="checkbox" name="imgRatio_preserve_headers" value="1" <?php if ($config['imgRatio_preserve_headers']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">保留图片原始数据</label> <label style="font-weight: bold">保留图片原始数据</label>
</div> </div>
</div> </div>
<div class="form-group"> </div>
<div class="col-md-12">
<div class="form-group col-md-4">
<label>压缩后的宽度 | 当前: </label><label id="image_x"><?php echo $config['image_x']; ?></label><label>px (0为不生效)</label>
<input type="range" class="form-control" name="image_x" value="<?php echo $config['image_x']; ?>" min="0" max="4096" step="100" onchange="document.getElementById('image_x').innerHTML=value">
</div>
<div class="form-group col-md-4">
<label>压缩后的高度 | 当前: </label><label id="image_y"><?php echo $config['image_y']; ?></label><label>px (0为不生效)</label>
<input type="range" class="form-control" name="image_y" value="<?php echo $config['image_y']; ?>" min="0" max="4096" step="100" onchange="document.getElementById('image_y').innerHTML=value">
</div>
<div class="form-group col-md-4">
<label>前端压缩率(仅支持JPG) | 当前: </label><label id="imgRatio_quality"><?php echo $config['imgRatio_quality']; ?></label><label>%</label> <label>前端压缩率(仅支持JPG) | 当前: </label><label id="imgRatio_quality"><?php echo $config['imgRatio_quality']; ?></label><label>%</label>
<input type="range" class="form-control" name="imgRatio_quality" value="<?php echo $config['imgRatio_quality']; ?>" min="10" max="100" step="5" onchange="document.getElementById('imgRatio_quality').innerHTML=value"> <input type="range" class="form-control" name="imgRatio_quality" value="<?php echo $config['imgRatio_quality']; ?>" min="10" max="100" step="5" onchange="document.getElementById('imgRatio_quality').innerHTML=value">
</div> </div>
</div>
<h5 class="header-dividing">后端压缩 <small data-toggle="tooltip" title=" 有一定概率改变图片方向,有可能使图片变大(特别是小图片) !<br />开启转换图片格式后不建议开启此选项,可能会导致图片变大!">优点:避免用户端欺骗,效果更好 缺点:增加服务器压力</small></h5> <h5 class="header-dividing">后端压缩 <small data-toggle="tooltip" title=" 有一定概率改变图片方向,有可能使图片变大(特别是小图片) !<br />开启转换图片格式后不建议开启此选项,可能会导致图片变大!">优点:避免用户端欺骗,效果更好 缺点:增加服务器压力</small></h5>
<div class="form-group"> <div class="form-group">
<div class="switch switch-inline"> <div class="switch switch-inline">
@ -1381,20 +1336,104 @@ auto_delete(); //定时删除
<a class="btn btn-mini btn-primary" href="/admin/manager.php?p=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用Tinyfilemanager管理文件"><i class="icon icon-folder-open"> 文件管理</i></a> <a class="btn btn-mini btn-primary" href="/admin/manager.php?p=<?php echo date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用Tinyfilemanager管理文件"><i class="icon icon-folder-open"> 文件管理</i></a>
<a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path'] . date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用web-indexr管理文件"><i class="icon icon-folder-close"> 文件管理</i></a> <a class="btn btn-mini btn-primary" href="filer.php?path=<?php echo $config['path'] . date('Y/m/d'); ?> " target="_blank" data-toggle="tooltip" title="使用web-indexr管理文件"><i class="icon icon-folder-close"> 文件管理</i></a>
<h5 class="header-dividing">删除文件 <small>* 删除后不可恢复</small></h5> <h5 class="header-dividing">删除文件 <small>* 删除后不可恢复</small></h5>
<form class="form-inline" method="get" action="../app/del.php" id="form" name="delForm" target="_blank" style="margin-bottom: 5px;"> <form class="form-inline" method="POST" style="margin-bottom: 5px;">
<p id="delimgurl"></p> <p id="delimgurl"></p>
<div class="form-group"> <div class="form-group">
<label for="del" class="text-warning">删除单张图片文件: </label> <label for="delSingle" class="text-warning">删除单张图片文件: </label>
<input type="url" name="url_admin_inc" class="form-control input-sm" id="del" required="required" placeholder="请输入图片链接"> <input type="url" name="url_admin_inc" class="form-control input-sm" id="delSingle" required="required" placeholder="请输入图片链接">
</div> </div>
<button type="submit" class="btn btn-sm btn-warning" onClick="return confirm('确认要删除?\n* 删除文件后将无法恢复! ');">删除</button> <button type="submit" class="btn btn-sm btn-warning" onclick="ajax_post($('#delSingle').val(),'delete')">删除</button>
</form> </form>
<form class="form-inline" action="<?php $_SERVER['SCRIPT_NAME']; ?>" method="post"> <form class="form-inline" method="POST">
<div class="form-group"> <div class="form-group">
<label for="delDir" class="text-danger">删除指定日期文件: </label> <label for="delDir" class="text-danger">删除指定日期文件: </label>
<input type="text" class="form-control form-date input-sm" name="delDir" value="<?php echo date('Y/m/d/'); ?>" readonly> <input type="text" class="form-control form-date input-sm" id="dateDir" name="dateDir" value="<?php echo date('Y/m/d/'); ?>" readonly>
</div> </div>
<button type="submit" class="btn btn-sm btn-danger" onClick="return confirm('确认要删除?\n* 删除文件夹后将无法恢复! ');">删除</button> <button type="submit" class="btn btn-sm btn-danger" onclick="ajax_post($('#dateDir').val(),'delDir')">删除</button>
</form>
</div>
<div class="tab-pane fade" id="Content15">
<div class="alert alert-primary with-icon">
<i class="icon-info-sign"></i>
<div class="content">
<ol>
<li>慎用,正在实验中</li>
<li>已回收的图片无法再还原到FTP</li>
<li>效果: 开启后上传|删除等受网络影响</li>
<li>流程: 客户端->图床服务器->远程附件</li>
<li>网络影响: 当前服务器->远程附件服务器速度</li>
</ol>
</div>
</div>
<h5 class="header-dividing">远程附件 <small> 将文件以FTP方式上传到第三方</small></h5>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<div class="col-md-12">
<div class="form-group col-md-2">
<div class="switch switch-inline">
<input type="hidden" name="ftp_status" value="0">
<input type="checkbox" name="ftp_status" value="1" <?php if ($config['ftp_status']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">启用远程附件</label>
</div>
</div>
<div class="form-group col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="一般情况下被动模式即可<br/>如果存在上传失败可尝试开启">
<input type="hidden" name="ftp_pasv" value="0">
<input type="checkbox" name="ftp_pasv" value="1" <?php if ($config['ftp_pasv']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">主动模式</label>
</div>
</div>
<div class="form-group col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="注意: FTP服务器需开启SSL">
<input type="hidden" name="ftp_ssl" value="0">
<input type="checkbox" name="ftp_ssl" value="1" <?php if ($config['ftp_ssl']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">启用SSL</label>
</div>
</div>
<div class="form-group col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="FTP上传完毕删除本地文件<br/>非自用不建议开启此选项<br/>没有SQL无法管理远程文件">
<input type="hidden" name="ftp_complete_del_local" value="0">
<input type="checkbox" name="ftp_complete_del_local" value="1" <?php if ($config['ftp_complete_del_local']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">完成删除</label>
</div>
</div>
<div class="form-group col-md-2">
<div class="switch switch-inline" data-toggle="tooltip" title="删除本地文件时同步删除远程附件">
<input type="hidden" name="ftp_delloc_sync" value="0">
<input type="checkbox" name="ftp_delloc_sync" value="1" <?php if ($config['ftp_delloc_sync']) echo 'checked="checked"'; ?>>
<label style="font-weight: bold">同步删除</label>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group col-md-3">
<label data-toggle="tooltip" title="域名/IP地址, 可以先测试FTP软件是否能正常登录">FTP 服务器地址</label>
<input type="text" class="form-control" name="ftp_host" value="<?php echo $config['ftp_host']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" placeholder="FTP 服务器地址">
</div>
<div class="form-group col-md-1">
<label data-toggle="tooltip" title="FTP 链接端口, 默认:21">端口</label>
<input type="number" class="form-control" name="ftp_port" required="required" value="<?php echo $config['ftp_port']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div>
<div class="form-group col-md-1">
<label data-toggle="tooltip" title="FTP 传输超时时间<br/> 单位:秒, 0为服务器默认时间">超时时间</label>
<input type="number" class="form-control" name="ftp_time" required="required" value="<?php echo $config['ftp_time']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div>
<div class="form-group col-md-2">
<label data-toggle="tooltip" title="FTP 账号,该账户需要有以下权限: 读取/写入/删除文件、创建/继承目录">账号</label>
<input type="text" class="form-control" name="ftp_user" value="<?php echo $config['ftp_user']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" placeholder="FTP 账号">
</div>
<div class="form-group col-md-2">
<label data-toggle="tooltip" title="FTP 密码">密码</label>
<input type="password" class="form-control" name="ftp_pass" value="<?php echo $config['ftp_pass']; ?>" onkeyup="this.value=this.value.replace(/\s/g,'')" placeholder="FTP 密码">
</div>
<div class="form-group col-md-3">
<label data-toggle="tooltip" title="网址与图片域名一致, 末尾不加'/'">远程图片域名</label>
<input type="url" class="form-control" name="imgurl" value="<?php echo $config['imgurl']; ?>" required="required" readonly="readonly" onkeyup="this.value=this.value.replace(/\s/g,'')">
</div>
</div>
<div class="form-group">
<input type="hidden" class="form-control" name="update" value="<?php echo date("Y-m-d H:i:s"); ?>" placeholder="隐藏的保存">
</div>
<button type="submit" class="btn btn-primary">保存</button>
</form> </form>
</div> </div>
</div> </div>
@ -1402,10 +1441,60 @@ auto_delete(); //定时删除
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.css"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.css"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.css">
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/crypto/SHA256.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/crypto/SHA256.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/crypto/SHA256.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/jscolor/jscolor.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/jscolor/jscolor.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script> <script>
// POST 更新数据
function update_post(cid, url = "update.php") {
$.ajax({
//几个参数需要注意一下
type: "POST", //方法类型
dataType: "json", //预期服务器返回的数据类型
url: url, //url
data: $("#" + cid).serialize(),
success: function(res) {
console.log(res); //打印服务端返回的数据(调试用)
// if (res.code === 200) {};
new $.zui.Messager(res.msg, {
type: res.type, // 定义颜色主题
icon: res.icon // 定义消息图标
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 1500)
},
error: function() {
confirm("保存异常,请使用浏览器F12查看控制台信息");
console.log(res); //打印服务端返回的数据(调试用)
}
});
}
// POST提交
function ajax_post(url, mode) {
$.post("../app/del.php", {
url: url,
mode: mode
},
function(data, status) {
let res = JSON.parse(data);
new $.zui.Messager(res.msg, {
type: res.type,
icon: res.icon
}).show();
if (res.code === 200) {
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 2000)
}
});
}
// 水印字体颜色 // 水印字体颜色
jscolor.presets.myPreset = { jscolor.presets.myPreset = {
value: '<?php echo $config['textColor']; ?>', value: '<?php echo $config['textColor']; ?>',
@ -1465,7 +1554,7 @@ auto_delete(); //定时删除
} }
// 动态显示要删除的图片 // 动态显示要删除的图片
var oBtn = document.getElementById('del'); var oBtn = document.getElementById('delSingle');
var oTi = document.getElementById('title'); var oTi = document.getElementById('title');
if ('oninput' in oBtn) { if ('oninput' in oBtn) {
oBtn.addEventListener("input", getWord, false); oBtn.addEventListener("input", getWord, false);
@ -1490,7 +1579,7 @@ auto_delete(); //定时删除
endDate: new Date() // 只能选当前日期之前 endDate: new Date() // 只能选当前日期之前
}); });
// log日期选择 // viewlog日期选择
$(".logDate").datetimepicker({ $(".logDate").datetimepicker({
format: 'yyyy-mm', format: 'yyyy-mm',
@ -1552,12 +1641,13 @@ auto_delete(); //定时删除
add_time: '<?php echo date('Y-m-d H:i:s', $value['add_time']); ?>', add_time: '<?php echo date('Y-m-d H:i:s', $value['add_time']); ?>',
expired: '<?php echo $expired; ?>', expired: '<?php echo $expired; ?>',
number: <?php echo get_file_by_glob(APP_ROOT . $config['path'] . $value['id'], $type = 'number'); ?>, number: <?php echo get_file_by_glob(APP_ROOT . $config['path'] . $value['id'], $type = 'number'); ?>,
manage: "<a href='/admin/manager.php?p=<?php echo $value['id']; ?>' target='_blank' class='btn btn-mini btn-success <?php if (!$config['token_path_status']) echo 'disabled'; ?>'>文件</a> <a href='admin.inc.php?stop_token=<?php echo $key; ?>' class='btn btn-mini btn-danger'>禁用</a> <a href='admin.inc.php?delete_token=<?php echo $key; ?>' class='btn btn-mini btn-danger'>删除</a> <a href='admin.inc.php?delDir=<?php echo $value['id']; ?>' class='btn btn-mini btn-primary <?php if (!$config['token_path_status']) echo 'disabled'; ?>'>删除上传</a>" manage: "<a href='/admin/manager.php?p=<?php echo $value['id']; ?>' target='_blank' class='btn btn-mini btn-success <?php if (!$config['token_path_status']) echo 'disabled'; ?>'>文件</a> <a href='admin.inc.php?stop_token=<?php echo $key; ?>' class='btn btn-mini btn-danger'>禁用</a> <a href='admin.inc.php?delete_token=<?php echo $key; ?>' class='btn btn-mini btn-danger'>删除</a> <a href='#' onclick=\"ajax_post('<?php echo $value['id']; ?>','delDir')\" class='btn btn-mini btn-primary <?php if (!$config['token_path_status']) echo 'disabled'; ?>'>删除上传</a>"
}, },
<?php endforeach; ?> <?php endforeach; ?>
] ]
}, },
sortable: true, sortable: true,
storage: true,
hoverCell: true, hoverCell: true,
showRowIndex: false, showRowIndex: false,
responsive: true, responsive: true,
@ -1629,12 +1719,13 @@ auto_delete(); //定时删除
add_time: '<?php echo date('Y-m-d H:i:s', $v['add_time']); ?>', add_time: '<?php echo date('Y-m-d H:i:s', $v['add_time']); ?>',
expired: '<?php echo $expired; ?>', expired: '<?php echo $expired; ?>',
files: <?php echo get_file_by_glob(APP_ROOT . $config['path'] . $k, $type = 'number'); ?>, files: <?php echo get_file_by_glob(APP_ROOT . $config['path'] . $k, $type = 'number'); ?>,
manage: "<a href='/admin/manager.php?p=<?php echo $k; ?>' target='_blank' class='btn btn-mini btn-success <?php if (!$config['guest_path_status']) echo 'disabled'; ?>'>文件</a> <a href='admin.inc.php?stop_guest=<?php echo $k; ?>' class='btn btn-mini btn-danger'>禁用</a> <a class='btn btn-mini btn-danger' href='admin.inc.php?delete_guest=<?php echo $k; ?>'>删除</a> <a class='btn btn-mini btn-primary <?php if (!$config['guest_path_status']) echo 'disabled'; ?>' href='admin.inc.php?delDir=<?php echo $k; ?>'>删除上传</a>", manage: "<a href='/admin/manager.php?p=<?php echo $k; ?>' target='_blank' class='btn btn-mini btn-success <?php if (!$config['guest_path_status']) echo 'disabled'; ?>'>文件</a> <a href='admin.inc.php?stop_guest=<?php echo $k; ?>' class='btn btn-mini btn-danger'>禁用</a> <a class='btn btn-mini btn-danger' href='admin.inc.php?delete_guest=<?php echo $k; ?>'>删除</a> <a class='btn btn-mini btn-primary <?php if (!$config['guest_path_status']) echo 'disabled'; ?>' href='#' onclick=\"ajax_post('<?php echo $k; ?>','delDir')\">删除上传</a>",
}, },
<?php endforeach; ?> <?php endforeach; ?>
] ]
}, },
sortable: true, sortable: true,
storage: true,
hoverCell: true, hoverCell: true,
showRowIndex: true, showRowIndex: true,
responsive: true, responsive: true,
@ -1657,7 +1748,7 @@ auto_delete(); //定时删除
guestMyDataGrid.sortBy('add_time', 'desc'); guestMyDataGrid.sortBy('add_time', 'desc');
/** 引入设置页面检测文件 */ /** 引入设置页面检测文件 */
<?php if ($config['checkEnv']) require_once APP_ROOT . '/app/check_admin.inc.php'; ?> <?php if ($config['checkEnv']) require_once __DIR__ . '/inc.check.php'; ?>
// 更改网页标题 // 更改网页标题
document.title = "图床设置 - <?php echo $config['title']; ?>" document.title = "图床设置 - <?php echo $config['title']; ?>"

View File

@ -52,9 +52,9 @@ session_start();
<meta name="keywords" content="<?php echo $config['keywords']; ?>" /> <meta name="keywords" content="<?php echo $config['keywords']; ?>" />
<meta name="description" content="<?php echo $config['description']; ?>" /> <meta name="description" content="<?php echo $config['description']; ?>" />
<link rel="shortcut icon" href="<?php static_cdn(); ?>/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="<?php static_cdn(); ?>/favicon.ico" type="image/x-icon" />
<link href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script>
<style type="text/css"> <style type="text/css">
body { body {
font-size: 14px; font-size: 14px;

197
admin/inc.check.php Normal file
View File

@ -0,0 +1,197 @@
<?php
/** 禁止直接访问 */
defined('APP_ROOT') ?: exit;
// 开启 DEBUG 2023-04-03
if (!ini_get('display_errors')) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
// 检查当前PHP版本是否大于7.0
if (PHP_VERSION < 7) {
echo '
new $.zui.Messager("当前PHP版本<7.0, 部分功能受限!",{
type: "primary", // 定义颜色主题
time:2000
}).show();
';
}
// 扩展检测
$expand = array('fileinfo', 'iconv', 'gd', 'mbstring', 'openssl',);
foreach ($expand as $val) {
if (!extension_loaded($val)) {
echo '
new $.zui.Messager("扩展:' . $val . '- 未安装,可能导致图片上传失败! 请尽快修复。",{
type: "black", // 定义颜色主题
icon: "exclamation-sign", // 定义消息图标
time:2200
}).show();
';
}
}
// 检测是否修改默认密码
if ($config['password'] === '7676aaafb027c825bd9abab78b234070e702752f625b752e55e55b48e607e358') {
echo '
new $.zui.Messager("请修改默认密码,否则会有泄露风险! ",{
type: "warning", // 定义颜色主题
time:2400
}).show();
';
}
// 检测是否局域网访问
if (is_local($config['domain']) || is_local($config['imgurl'])) {
echo '
new $.zui.Messager("当前使用局域网,可能会导致外网访问异常!",{
type: "black", // 定义颜色主题
time:2600
}).show();
';
}
// 检测是否存在.user.ini
if (file_exists(APP_ROOT . '/.user.ini')) {
echo '
new $.zui.Messager("请关闭防跨目录读写或删除.user.ini文件",{
type: "danger", // 定义颜色主题
time:2700
}).show();
';
}
// 检测是否存在 IP数据库文件 ip2region.xdb
if (!file_exists(APP_ROOT . '/app/ip2region/ip2region.xdb')) {
echo '
new $.zui.Messager("IP 数据库不存在, 请在系统信息中查看 Ip2region",{
type: "danger", // 定义颜色主题
time:2900
}).show();
';
}
// 检查当前版本与GitHub版本
if (getVersion() !== APP_VERSION) {
echo '
new $.zui.Messager("当前版本与GitHub不一致,请检查当前是否最新版本!",{
type: "danger", // 定义颜色主题
time:3100
}).show();
';
}
// 检测是否开启登录上传
if ($config['mustLogin']) {
echo '
$.zui.browser.tip("请注意: 当前已开启登录上传,游客不能上传图片!");
';
}
// 检测水印图片是否存在
if (!is_file(APP_ROOT . $config['waterImg'])) {
echo '
new $.zui.Messager("水印图片不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题
time:3300
}).show();
';
}
// 检测水印字体是否存在
if (!is_file(APP_ROOT . $config['textFont'])) {
echo '
new $.zui.Messager("水印字体不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题
time:3500
}).show();
';
}
// 检测监黄接口是否可以访问
if ($config['checkImg'] !== 0) {
if ($config['checkImg'] === 1) {
if (!@IP_URL_Ping('api.moderatecontent.com', 80, 1)) {
echo '
new $.zui.Messager("moderatecontent 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:3700
}).show();
';
}
}
if ($config['checkImg'] === 2) {
$ip = parse_url($config['nsfwjs_url'])['host'];
$port = parse_url($config['nsfwjs_url'])['port'];
if (filter_var($ip, FILTER_VALIDATE_IP)) {
if (!@IP_URL_Ping($ip, $port, 1)) {
echo '
new $.zui.Messager("' . $ip . $port . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:3700
}).show();
';
}
} else {
if (!@IP_URL_Ping($ip, 80, 1)) {
echo '
new $.zui.Messager("' . $ip . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题
time:3700
}).show();
';
}
}
}
}
if (!function_exists('fastcgi_finish_request')) {
echo '
new $.zui.Messager("开启 fastcgi_finish_request 处理数据会更快喔!",{
type: "primary", // 定义颜色主题
time:3900
}).show();
';
}
// FTP检测
if ($config['ftp_status']) {
if (!extension_loaded('ftp')) { // 检测FTP扩展是否开启
echo '
new $.zui.Messager("FTP 错误: FTP 扩展未开启, 无法使用远程附件",{
type: "info", // 定义颜色主题
time:4000
}).show();
';
} else {
// 登录FTP
require_once APP_ROOT . '/app/Ftp.php';
try {
$ftp = new Ftp;
if ($config['ftp_ssl'] === 1) {
$ftp->sslConnect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
} else {
$ftp->connect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
}
$ftp->login($config['ftp_user'], $config['ftp_pass']);
$ftp->pasv($config['ftp_pasv']);
} catch (FtpException $e) {
echo '
new $.zui.Messager("FTP 错误:' . $e->getMessage() . '",{
type: "info", // 定义颜色主题
time:4300
}).show();
';
}
}
}

View File

@ -95,7 +95,7 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
write_login_log($_POST['user'], $_POST['password'], $login["messege"]); write_login_log($_POST['user'], $_POST['password'], $login["messege"]);
} }
?> ?>
<link href="<?php static_cdn(); ?>/public/static/login.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/login.css">
<!-- 忘记密码 --> <!-- 忘记密码 -->
<div class="modal fade" id="fogot"> <div class="modal fade" id="fogot">
<div class="modal-dialog "> <div class="modal-dialog ">
@ -128,8 +128,7 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
<h2>登录</h2> <h2>登录</h2>
<label for="account" class="col-sm-2"></label> <label for="account" class="col-sm-2"></label>
<input type="text" name="user" id="account" class="form-control" value="" placeholder="输入登录账号" autocomplete="off" required="required"> <input type="text" name="user" id="account" class="form-control" value="" placeholder="输入登录账号" autocomplete="off" required="required">
<input type="password" name="password" id="password" class="form-control" value="" placeholder="输入登录密码" autocomplete="off" required="required"> <input type="password" name="password" id="password" class="form-control" value="" placeholder="输入登录密码" autocomplete="off" required="required"><input type="hidden" name="password" id="md5_password">
<input type="hidden" name="password" id="md5_password">
<?php if ($config['captcha']) : ?> <?php if ($config['captcha']) : ?>
<input class="form-control" type="text" name="code" value="" placeholder="请输入验证码" autocomplete="off" required="required" /> <input class="form-control" type="text" name="code" value="" placeholder="请输入验证码" autocomplete="off" required="required" />
<div class="form-group"> <div class="form-group">
@ -161,13 +160,15 @@ if (isset($_POST['password']) and isset($_POST['user'])) {
</div> </div>
</section> </section>
</form> </form>
<script src="<?php static_cdn(); ?>/public/static/crypto/SHA256.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/crypto/SHA256.js"></script>
<script> <script>
function md5_post() { function md5_post() {
var password = document.getElementById('password'); var password = document.getElementById('password');
var md5pwd = document.getElementById('md5_password'); var md5pwd = document.getElementById('md5_password');
md5pwd.value = SHA256(password.value); md5pwd.value = SHA256(password.value);
//可以校验判断表单内容true就是通过提交false阻止提交 // fix https://github.com/icret/EasyImages2.0/pull/163
password.value = "Null";
// 可以校验判断表单内容true就是通过提交false阻止提交
return true; return true;
} }

View File

@ -1258,7 +1258,7 @@ if (isset($_GET['upload']) && !FM_READONLY) {
return ''; return '';
} }
?> ?>
<link href="<?php static_cdn(); ?>/public/static/tinyfilemanager/dropzone.min.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/tinyfilemanager/dropzone.min.css">
<div class="path"> <div class="path">
<div class="card mb-2 fm-upload-wrapper <?php echo fm_get_theme(); ?>"> <div class="card mb-2 fm-upload-wrapper <?php echo fm_get_theme(); ?>">
@ -3838,10 +3838,10 @@ $isStickyNavBar = $sticky_navbar ? 'navbar-fixed' : 'navbar-normal';
{ {
?> ?>
</div> </div>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/tinyfilemanager/bootstrap.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/tinyfilemanager/bootstrap.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/tinyfilemanager/jquery.dataTables.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/tinyfilemanager/jquery.dataTables.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/tinyfilemanager/ekko-lightbox.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/tinyfilemanager/ekko-lightbox.min.js"></script>
<?php if (FM_USE_HIGHLIGHTJS): ?> <?php if (FM_USE_HIGHLIGHTJS): ?>
<script src="<?php static_cdn(); ?>/public/static/tinyfilemanager/highlight.min.js"></script> <script src="<?php static_cdn(); ?>/public/static/tinyfilemanager/highlight.min.js"></script>
<script>hljs.highlightAll(); var isHighlightingEnabled = true;</script> <script>hljs.highlightAll(); var isHighlightingEnabled = true;</script>

1
admin/version.php Normal file
View File

@ -0,0 +1 @@
2.8.4

View File

@ -5,7 +5,7 @@
require_once '../app/header.php'; require_once '../app/header.php';
require_once APP_ROOT . '/app/chart.php'; require_once APP_ROOT . '/app/chart.php';
// 检测是否开启统计 // 检测登录和是否开启统计
if (!$config['chart_on'] || !is_who_login('admin')) exit(header('Location: ' . $config['domain'] . '?hart#closed')); if (!$config['chart_on'] || !is_who_login('admin')) exit(header('Location: ' . $config['domain'] . '?hart#closed'));
// 检测登录 // 检测登录
@ -140,10 +140,7 @@ 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="https://cdn.jsdelivr.net/gh/icret/EasyImages2.0@2.4.0/public/static/zui/lib/chart/zui.chart.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/chart/zui.chart.min.js"></script>
<!--[if lt IE 9]>
<script src="https://cdn.jsdelivr.net/gh/icret/EasyImages2.0@2.4.0/public/static/zui/lib/chart/excanvas.js"></script>
<![endif]-->
<script> <script>
// 文件统计-柱状图 // 文件统计-柱状图
var data = { var data = {

View File

@ -1,5 +1,6 @@
<?php <?php
namespace Verot\Upload; namespace Verot\Upload;
require_once __DIR__ . '/../app/function.php'; require_once __DIR__ . '/../app/function.php';
@ -22,7 +23,8 @@ if (empty($_FILES['image'])) {
"result" => "failed", "result" => "failed",
"code" => 204, "code" => 204,
"message" => "没有选择上传的文件", "message" => "没有选择上传的文件",
) ),
JSON_UNESCAPED_UNICODE
)); ));
} }
@ -34,21 +36,28 @@ if ($config['check_ip']) {
"result" => "failed", "result" => "failed",
"code" => 205, "code" => 205,
"message" => "黑名单内或白名单外用户不允许上传", "message" => "黑名单内或白名单外用户不允许上传",
))); ), JSON_UNESCAPED_UNICODE));
} }
} }
$token = preg_replace('/[\W]/', '', $_POST['token']); // 获取Token并过滤非字母数字删除空格; // 获取Token并过滤非字母数字, 删除空格
$token = preg_replace('/[\W]/', '', $_POST['token']);
// 检查api合法性 // 检查api合法性
check_api($token); check_api($token);
$tokenID = $tokenList[$token]['id']; $tokenID = $tokenList[$token]['id'];
$handle = new Upload($_FILES['image'], 'zh_CN'); // 分片上传
if (!$config['chunks']) {
$handle = new Upload($_FILES['image'], 'zh_CN');
} else {
$chunk = chunk($_POST['name']);
$handle = new Upload($chunk, 'zh_CN');
}
if ($handle->uploaded) { if ($handle->uploaded) {
// 允许上传的mime类型 // 允许上传的mime类型
if ($config['allowed'] === 1) { if ($config['allowed']) {
$handle->allowed = array('image/*'); $handle->allowed = array('image/*');
} }
@ -61,7 +70,8 @@ if ($handle->uploaded) {
"result" => "failed", "result" => "failed",
"code" => 205, "code" => 205,
"message" => "请勿上传非法文件", "message" => "请勿上传非法文件",
) ),
JSON_UNESCAPED_UNICODE
)); ));
} }
} }
@ -90,25 +100,12 @@ if ($handle->uploaded) {
$handle->webp_quality = $config['compress_ratio']; $handle->webp_quality = $config['compress_ratio'];
// JPEG 图像的压缩质量 1-100 // JPEG 图像的压缩质量 1-100
$handle->jpeg_quality = $config['compress_ratio']; $handle->jpeg_quality = $config['compress_ratio'];
/* 等比例缩减图片 放到前端了*/
/*
if ($config['imgRatio']) {
$handle->image_resize = true;
$handle->image_x = $config['image_x'];
$handle->image_y = $config['image_y'];
// 如果调整后的图像大于原始图像,则取消调整大小,以防止放大
$handle->image_no_enlarging = true;
}
*/
// 默认目录 // 默认目录
$Img_path = config_path(); $Img_path = config_path();
//Token分离
if ($config['token_path_status'] == 1) { if ($config['token_path_status']) {
$Img_path = config_path($tokenID . date('/Y/m/d/')); $Img_path = config_path($tokenID . date('/Y/m/d/'));
} }
// 存储图片路径:images/201807/ // 存储图片路径:images/201807/
$handle->process(APP_ROOT . $Img_path); $handle->process(APP_ROOT . $Img_path);
@ -120,27 +117,23 @@ if ($handle->uploaded) {
$imageUrl = rand_imgurl() . $pathIMG; $imageUrl = rand_imgurl() . $pathIMG;
// 后续处理地址 // 后续处理地址
$processUrl = $config['domain'] . $pathIMG; $processUrl = $config['domain'] . $pathIMG;
// 隐藏config文件中的path目录,需要搭配网站设置 // 隐藏config文件中的path目录,需要搭配网站设置
if ($config['hide_path'] == 1) { if ($config['hide_path']) {
$imageUrl = str_replace($config['path'], '/', $imageUrl); $imageUrl = str_replace($config['path'], '/', $imageUrl);
} }
// 源图保护 key值是由crc32加密的hide_key // 源图保护 key值是由crc32加密的hide_key
if ($config['hide'] == 1) { if ($config['hide']) {
$imageUrl = $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])); $imageUrl = $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
} }
// 删除文件链接 // 删除文件链接
if ($config['show_user_hash_del']) { if ($config['show_user_hash_del']) {
$delUrl = $config['domain'] . '/app/del.php?hash=' . urlHash($pathIMG, 0); $delUrl = $config['domain'] . '/app/del.php?hash=' . urlHash($pathIMG, 0);
} else { } else {
$delUrl = "Admin closed user delete"; $delUrl = "Admin closed user delete";
} }
// 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30 // 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30
$handleThumb = $config['domain'] . '/app/thumb.php?img=' . $pathIMG; $handleThumb = $config['domain'] . '/app/thumb.php?img=' . $pathIMG;
if ($config['thumbnail'] == 2) { if ($config['thumbnail'] === 2) {
// 自定义缩略图长宽 // 自定义缩略图长宽
$handle->image_resize = true; $handle->image_resize = true;
$handle->image_x = $config['thumbnail_w']; $handle->image_x = $config['thumbnail_w'];
@ -160,8 +153,8 @@ if ($handle->uploaded) {
"srcName" => $handle->file_src_name_body, "srcName" => $handle->file_src_name_body,
"thumb" => $handleThumb, "thumb" => $handleThumb,
"del" => $delUrl, "del" => $delUrl,
"ID" => $tokenID, // 202-02-11 增加返回Token ID "id" => $tokenID, // 2023-02-11 增加返回Token ID
"message" => "success", "message" => "success", // 2023-04-22 增加返回信息
// "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12 // "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
); );
echo json_encode($reJson, JSON_UNESCAPED_UNICODE); echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
@ -171,6 +164,8 @@ if ($handle->uploaded) {
$reJson = array( $reJson = array(
"result" => "failed", "result" => "failed",
"code" => 206, "code" => 206,
"srcName" => $handle->file_src_name_body, // 2023-04-03 原始上传文件名称
"id" => $tokenID, // 2023-04-03 增加 Token ID
"message" => $handle->error, "message" => $handle->error,
"memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12 "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
// 'log' => $handle->log, // 仅用作调试用 // 'log' => $handle->log, // 仅用作调试用
@ -180,8 +175,6 @@ if ($handle->uploaded) {
} }
/** 后续处理 */ /** 后续处理 */
// 上传至其他位置
// @any_upload($pathIMG, APP_ROOT . $pathIMG, 'upload');
// 使用fastcgi_finish_request操作 // 使用fastcgi_finish_request操作
if (function_exists('fastcgi_finish_request')) fastcgi_finish_request(); if (function_exists('fastcgi_finish_request')) fastcgi_finish_request();
// 同IP上传日志 // 同IP上传日志
@ -194,6 +187,8 @@ if ($handle->uploaded) {
@water($handle->file_dst_pathname); @water($handle->file_dst_pathname);
// 压缩 // 压缩
@process_compress($handle->file_dst_pathname); @process_compress($handle->file_dst_pathname);
// 上传至其他位置
@any_upload($pathIMG, APP_ROOT . $pathIMG, 'upload');
unset($handle); unset($handle);
} }

View File

@ -5,11 +5,10 @@
* 2022年2月22日11:41:38 * 2022年2月22日11:41:38
* @author Icret * @author Icret
*/ */
require_once '../app/function.php';
require_once '../app/chart.php'; require_once '../app/chart.php';
// 检查是否开启查询 // 检查是否开启查询
if ($config['public'] == 0) die('开放数据接口已关闭!'); if ($config['public'] === 0) die('开放数据接口已关闭!');
// 获得get值 // 获得get值
$show = (empty($_GET['show'])) ? die('没有参数!') : htmlspecialchars($_GET['show']); $show = (empty($_GET['show'])) ? die('没有参数!') : htmlspecialchars($_GET['show']);

28
app/DMCA.php Normal file
View File

@ -0,0 +1,28 @@
<?php
/*
* 使用条款页面
*/
require_once __DIR__ . '/header.php';
/** 顶部广告 */
if ($config['ad_top']) echo $config['ad_top_info'];
/** 加载使用条款 */
if (empty($config['terms'])) {
echo '<div class="alert alert-danger">Terms not set!<br />未设置使用条款</div>';
} else {
echo $config['terms'];
// echo '<div style="margin-bottom: 80px;"></div>';
}
/** 底部广告 */
if ($config['ad_bot']) echo $config['ad_bot_info'];
?>
<script>
// Title
document.title = '使用条款 - <?php echo $config['title']; ?>'
</script>
<?php
require_once __DIR__ . '/footer.php';

View File

@ -1,968 +0,0 @@
<?php
/*
* This file is part of the `nicolab/php-ftp-client` package.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Nicolas Tallefourtane http://nicolab.net
*/
// namespace FtpClient;
// use \Countable;
/**
* The FTP and SSL-FTP client for PHP.
*
* @method bool alloc(int $filesize, string &$result = null) Allocates space for a file to be uploaded
* @method bool append(string $remote_file, string $local_file, int $mode = FTP_BINARY) Append the contents of a file to another file on the FTP server
* @method bool cdup() Changes to the parent directory
* @method bool chdir(string $directory) Changes the current directory on a FTP server
* @method int chmod(int $mode, string $filename) Set permissions on a file via FTP
* @method bool delete(string $path) Deletes a file on the FTP server
* @method bool exec(string $command) Requests execution of a command on the FTP server
* @method bool fget(resource $handle, string $remote_file, int $mode, int $resumepos = 0) Downloads a file from the FTP server and saves to an open file
* @method bool fput(string $remote_file, resource $handle, int $mode, int $startpos = 0) Uploads from an open file to the FTP server
* @method mixed get_option(int $option) Retrieves various runtime behaviours of the current FTP stream
* @method bool get(string $local_file, string $remote_file, int $mode, int $resumepos = 0) Downloads a file from the FTP server
* @method int mdtm(string $remote_file) Returns the last modified time of the given file
* @method array mlsd(string $remote_dir) Returns a list of files in the given directory
* @method int nb_continue() Continues retrieving/sending a file (non-blocking)
* @method int nb_fget(resource $handle, string $remote_file, int $mode, int $resumepos = 0) Retrieves a file from the FTP server and writes it to an open file (non-blocking)
* @method int nb_fput(string $remote_file, resource $handle, int $mode, int $startpos = 0) Stores a file from an open file to the FTP server (non-blocking)
* @method int nb_get(string $local_file, string $remote_file, int $mode, int $resumepos = 0) Retrieves a file from the FTP server and writes it to a local file (non-blocking)
* @method int nb_put(string $remote_file, string $local_file, int $mode, int $startpos = 0) Stores a file on the FTP server (non-blocking)
* @method bool pasv(bool $pasv) Turns passive mode on or off
* @method bool put(string $remote_file, string $local_file, int $mode, int $startpos = 0) Uploads a file to the FTP server
* @method string pwd() Returns the current directory name
* @method bool quit() Closes an FTP connection
* @method array raw(string $command) Sends an arbitrary command to an FTP server
* @method bool rename(string $oldname, string $newname) Renames a file or a directory on the FTP server
* @method bool set_option(int $option, mixed $value) Set miscellaneous runtime FTP options
* @method bool site(string $command) Sends a SITE command to the server
* @method int size(string $remote_file) Returns the size of the given file
* @method string systype() Returns the system type identifier of the remote FTP server
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/
class FtpClient implements Countable
{
/**
* The connection with the server.
*
* @var resource
*/
protected $conn;
/**
* PHP FTP functions wrapper.
*
* @var FtpWrapper
*/
private $ftp;
/**
* Constructor.
*
* @param resource|null $connection
* @throws FtpException If FTP extension is not loaded.
*/
public function __construct($connection = null)
{
if (!extension_loaded('ftp')) {
throw new FtpException('FTP extension is not loaded!');
}
if ($connection) {
$this->conn = $connection;
}
$this->setWrapper(new FtpWrapper($this->conn));
}
/**
* Close the connection when the object is destroyed.
*/
public function __destruct()
{
if ($this->conn) {
$this->ftp->close();
}
}
/**
* Call an internal method or a FTP method handled by the wrapper.
*
* Wrap the FTP PHP functions to call as method of FtpClient object.
* The connection is automaticaly passed to the FTP PHP functions.
*
* @param string $method
* @param array $arguments
* @return mixed
* @throws FtpException When the function is not valid
*/
public function __call($method, array $arguments)
{
return $this->ftp->__call($method, $arguments);
}
/**
* Overwrites the PHP limit
*
* @param string|null $memory The memory limit, if null is not modified
* @param int $time_limit The max execution time, unlimited by default
* @param bool $ignore_user_abort Ignore user abort, true by default
* @return FtpClient
*/
public function setPhpLimit($memory = null, $time_limit = 0, $ignore_user_abort = true)
{
if (null !== $memory) {
ini_set('memory_limit', $memory);
}
ignore_user_abort($ignore_user_abort);
set_time_limit($time_limit);
return $this;
}
/**
* Get the help information of the remote FTP server.
*
* @return array
*/
public function help()
{
return $this->ftp->raw('help');
}
/**
* Open a FTP connection.
*
* @param string $host
* @param bool $ssl
* @param int $port
* @param int $timeout
*
* @return FtpClient
* @throws FtpException If unable to connect
*/
public function connect($host, $ssl = false, $port = 21, $timeout = 90)
{
if ($ssl) {
$this->conn = $this->ftp->ssl_connect($host, $port, $timeout);
} else {
$this->conn = $this->ftp->connect($host, $port, $timeout);
}
if (!$this->conn) {
throw new FtpException('Unable to connect');
}
return $this;
}
/**
* Closes the current FTP connection.
*
* @return bool
*/
public function close()
{
if ($this->conn) {
$this->ftp->close();
$this->conn = null;
}
}
/**
* Get the connection with the server.
*
* @return resource
*/
public function getConnection()
{
return $this->conn;
}
/**
* Get the wrapper.
*
* @return FtpWrapper
*/
public function getWrapper()
{
return $this->ftp;
}
/**
* Logs in to an FTP connection.
*
* @param string $username
* @param string $password
*
* @return FtpClient
* @throws FtpException If the login is incorrect
*/
public function login($username = 'anonymous', $password = '')
{
$result = $this->ftp->login($username, $password);
if ($result === false) {
throw new FtpException('Login incorrect');
}
return $this;
}
/**
* Returns the last modified time of the given file.
* Return -1 on error
*
* @param string $remoteFile
* @param string|null $format
*
* @return int
*/
public function modifiedTime($remoteFile, $format = null)
{
$time = $this->ftp->mdtm($remoteFile);
if ($time !== -1 && $format !== null) {
return date($format, $time);
}
return $time;
}
/**
* Changes to the parent directory.
*
* @throws FtpException
* @return FtpClient
*/
public function up()
{
$result = $this->ftp->cdup();
if ($result === false) {
throw new FtpException('Unable to get parent folder');
}
return $this;
}
/**
* Returns a list of files in the given directory.
*
* @param string $directory The directory, by default is "." the current directory
* @param bool $recursive
* @param callable $filter A callable to filter the result, by default is asort() PHP function.
* The result is passed in array argument,
* must take the argument by reference !
* The callable should proceed with the reference array
* because is the behavior of several PHP sorting
* functions (by reference ensure directly the compatibility
* with all PHP sorting functions).
*
* @return array
* @throws FtpException If unable to list the directory
*/
public function nlist($directory = '.', $recursive = false, $filter = 'sort')
{
if (!$this->isDir($directory)) {
throw new FtpException('"'.$directory.'" is not a directory');
}
$files = $this->ftp->nlist($directory);
if ($files === false) {
throw new FtpException('Unable to list directory');
}
$result = array();
$dir_len = strlen($directory);
// if it's the current
if (false !== ($kdot = array_search('.', $files))) {
unset($files[$kdot]);
}
// if it's the parent
if(false !== ($kdot = array_search('..', $files))) {
unset($files[$kdot]);
}
if (!$recursive) {
$result = $files;
// working with the reference (behavior of several PHP sorting functions)
$filter($result);
return $result;
}
// utils for recursion
$flatten = function (array $arr) use (&$flatten) {
$flat = [];
foreach ($arr as $k => $v) {
if (is_array($v)) {
$flat = array_merge($flat, $flatten($v));
} else {
$flat[] = $v;
}
}
return $flat;
};
foreach ($files as $file) {
$file = $directory.'/'.$file;
// if contains the root path (behavior of the recursivity)
if (0 === strpos($file, $directory, $dir_len)) {
$file = substr($file, $dir_len);
}
if ($this->isDir($file)) {
$result[] = $file;
$items = $flatten($this->nlist($file, true, $filter));
foreach ($items as $item) {
$result[] = $item;
}
} else {
$result[] = $file;
}
}
$result = array_unique($result);
$filter($result);
return $result;
}
/**
* Creates a directory.
*
* @see FtpClient::rmdir()
* @see FtpClient::remove()
* @see FtpClient::put()
* @see FtpClient::putAll()
*
* @param string $directory The directory
* @param bool $recursive
* @return bool
*/
public function mkdir($directory, $recursive = false)
{
if (!$recursive or $this->isDir($directory)) {
return $this->ftp->mkdir($directory);
}
$result = false;
$pwd = $this->ftp->pwd();
$parts = explode('/', $directory);
foreach ($parts as $part) {
if ($part == '') {
continue;
}
if (!@$this->ftp->chdir($part)) {
$result = $this->ftp->mkdir($part);
$this->ftp->chdir($part);
}
}
$this->ftp->chdir($pwd);
return $result;
}
/**
* Remove a directory.
*
* @see FtpClient::mkdir()
* @see FtpClient::cleanDir()
* @see FtpClient::remove()
* @see FtpClient::delete()
* @param string $directory
* @param bool $recursive Forces deletion if the directory is not empty
* @return bool
* @throws FtpException If unable to list the directory to remove
*/
public function rmdir($directory, $recursive = true)
{
if ($recursive) {
$files = $this->nlist($directory, false, 'rsort');
// remove children
foreach ($files as $file) {
$this->remove($file, true);
}
}
// remove the directory
return $this->ftp->rmdir($directory);
}
/**
* Empty directory.
*
* @see FtpClient::remove()
* @see FtpClient::delete()
* @see FtpClient::rmdir()
*
* @param string $directory
* @return bool
*/
public function cleanDir($directory)
{
if (!$files = $this->nlist($directory)) {
return $this->isEmpty($directory);
}
// remove children
foreach ($files as $file) {
$this->remove($file, true);
}
return $this->isEmpty($directory);
}
/**
* Remove a file or a directory.
*
* @see FtpClient::rmdir()
* @see FtpClient::cleanDir()
* @see FtpClient::delete()
* @param string $path The path of the file or directory to remove
* @param bool $recursive Is effective only if $path is a directory, {@see FtpClient::rmdir()}
* @return bool
*/
public function remove($path, $recursive = false)
{
if ($path == '.' || $path == '..') {
return false;
}
try {
if (@$this->ftp->delete($path)
or ($this->isDir($path)
and $this->rmdir($path, $recursive))) {
return true;
} else {
// in special cases the delete can fail (for example, at Symfony's "r+e.gex[c]a(r)s" directory)
$newPath = preg_replace('/[^A-Za-z0-9\/]/', '', $path);
if ($this->rename($path, $newPath)) {
if (@$this->ftp->delete($newPath)
or ($this->isDir($newPath)
and $this->rmdir($newPath, $recursive))) {
return true;
}
}
}
return false;
} catch (\Exception $e) {
return false;
}
}
/**
* Check if a directory exist.
*
* @param string $directory
* @return bool
* @throws FtpException
*/
public function isDir($directory)
{
$pwd = $this->ftp->pwd();
if ($pwd === false) {
throw new FtpException('Unable to resolve the current directory');
}
if (@$this->ftp->chdir($directory)) {
$this->ftp->chdir($pwd);
return true;
}
$this->ftp->chdir($pwd);
return false;
}
/**
* Check if a directory is empty.
*
* @param string $directory
* @return bool
*/
public function isEmpty($directory)
{
return $this->countItems($directory, null, false) === 0 ? true : false;
}
/**
* Scan a directory and returns the details of each item.
*
* @see FtpClient::nlist()
* @see FtpClient::rawlist()
* @see FtpClient::parseRawList()
* @see FtpClient::dirSize()
* @param string $directory
* @param bool $recursive
* @return array
*/
public function scanDir($directory = '.', $recursive = false)
{
return $this->parseRawList($this->rawlist($directory, $recursive));
}
/**
* Returns the total size of the given directory in bytes.
*
* @param string $directory The directory, by default is the current directory.
* @param bool $recursive true by default
* @return int The size in bytes.
*/
public function dirSize($directory = '.', $recursive = true)
{
$items = $this->scanDir($directory, $recursive);
$size = 0;
foreach ($items as $item) {
$size += (int) $item['size'];
}
return $size;
}
/**
* Count the items (file, directory, link, unknown).
*
* @param string $directory The directory, by default is the current directory.
* @param string|null $type The type of item to count (file, directory, link, unknown)
* @param bool $recursive true by default
* @return int
*/
public function countItems($directory = '.', $type = null, $recursive = true)
{
$items = (null === $type ? $this->nlist($directory, $recursive)
: $this->scanDir($directory, $recursive));
$count = 0;
foreach ($items as $item) {
if (null === $type or $item['type'] == $type) {
$count++;
}
}
return $count;
}
/**
* Count the items (file, directory, link, unknown).
* This method call `countItems()` with the default arguments.
*
* @see countItems
* @return int
*/
public function count(): int
{
return $this->countItems();
}
/**
* Downloads a file from the FTP server into a string
*
* @param string $remote_file
* @param int $mode
* @param int $resumepos
* @return string|null
*/
public function getContent($remote_file, $mode = FTP_BINARY, $resumepos = 0)
{
$handle = fopen('php://temp', 'r+');
if ($this->ftp->fget($handle, $remote_file, $mode, $resumepos)) {
rewind($handle);
return stream_get_contents($handle);
}
return null;
}
/**
* Uploads a file to the server from a string.
*
* @param string $remote_file
* @param string $content
* @return FtpClient
* @throws FtpException When the transfer fails
*/
public function putFromString($remote_file, $content)
{
$handle = fopen('php://temp', 'w');
fwrite($handle, $content);
rewind($handle);
if ($this->ftp->fput($remote_file, $handle, FTP_BINARY)) {
return $this;
}
throw new FtpException('Unable to put the file "'.$remote_file.'"');
}
/**
* Uploads a file to the server.
*
* @param string $local_file
* @return FtpClient
* @throws FtpException When the transfer fails
*/
public function putFromPath($local_file)
{
$remote_file = basename($local_file);
$handle = fopen($local_file, 'r');
if ($this->ftp->fput($remote_file, $handle, FTP_BINARY)) {
rewind($handle);
return $this;
}
throw new FtpException(
'Unable to put the remote file from the local file "'.$local_file.'"'
);
}
/**
* Upload files.
*
* @param string $source_directory
* @param string $target_directory
* @param int $mode
* @return FtpClient
*/
public function putAll($source_directory, $target_directory, $mode = FTP_BINARY)
{
$d = dir($source_directory);
// do this for each file in the directory
while ($file = $d->read()) {
// to prevent an infinite loop
if ($file != "." && $file != "..") {
// do the following if it is a directory
if (is_dir($source_directory.'/'.$file)) {
if (!$this->isDir($target_directory.'/'.$file)) {
// create directories that do not yet exist
$this->ftp->mkdir($target_directory.'/'.$file);
}
// recursive part
$this->putAll(
$source_directory.'/'.$file, $target_directory.'/'.$file,
$mode
);
} else {
// put the files
$this->ftp->put(
$target_directory.'/'.$file, $source_directory.'/'.$file,
$mode
);
}
}
}
$d->close();
return $this;
}
/**
* Downloads all files from remote FTP directory
*
* @param string $source_directory The remote directory
* @param string $target_directory The local directory
* @param int $mode
* @return FtpClient
*/
public function getAll($source_directory, $target_directory, $mode = FTP_BINARY)
{
if ($source_directory != ".") {
if ($this->ftp->chdir($source_directory) == false) {
throw new FtpException("Unable to change directory: ".$source_directory);
}
if (!(is_dir($target_directory))) {
mkdir($target_directory);
}
chdir($target_directory);
}
$contents = $this->ftp->nlist(".");
foreach ($contents as $file) {
if ($file == '.' || $file == '..') {
continue;
}
$this->ftp->get($target_directory."/".$file, $file, $mode);
}
$this->ftp->chdir("..");
chdir("..");
return $this;
}
/**
* Returns a detailed list of files in the given directory.
*
* @see FtpClient::nlist()
* @see FtpClient::scanDir()
* @see FtpClient::dirSize()
* @param string $directory The directory, by default is the current directory
* @param bool $recursive
* @return array
* @throws FtpException
*/
public function rawlist($directory = '.', $recursive = false)
{
if (!$this->isDir($directory)) {
throw new FtpException('"'.$directory.'" is not a directory.');
}
if (strpos($directory, " ") > 0) {
$ftproot = $this->ftp->pwd();
$this->ftp->chdir($directory);
$list = $this->ftp->rawlist("");
$this->ftp->chdir($ftproot);
} else {
$list = $this->ftp->rawlist($directory);
}
$items = array();
if (!$list) {
return $items;
}
if (false == $recursive) {
foreach ($list as $path => $item) {
$chunks = preg_split("/\s+/", $item);
// if not "name"
if (!isset($chunks[8]) || strlen($chunks[8]) === 0 || $chunks[8] == '.' || $chunks[8] == '..') {
continue;
}
$path = $directory.'/'.$chunks[8];
if (isset($chunks[9])) {
$nbChunks = count($chunks);
for ($i = 9; $i < $nbChunks; $i++) {
$path .= ' '.$chunks[$i];
}
}
if (substr($path, 0, 2) == './') {
$path = substr($path, 2);
}
$items[ $this->rawToType($item).'#'.$path ] = $item;
}
return $items;
}
$path = '';
foreach ($list as $item) {
$len = strlen($item);
if (!$len
// "."
|| ($item[$len-1] == '.' && $item[$len-2] == ' '
// ".."
or $item[$len-1] == '.' && $item[$len-2] == '.' && $item[$len-3] == ' ')
) {
continue;
}
$chunks = preg_split("/\s+/", $item);
// if not "name"
if (!isset($chunks[8]) || strlen($chunks[8]) === 0 || $chunks[8] == '.' || $chunks[8] == '..') {
continue;
}
$path = $directory.'/'.$chunks[8];
if (isset($chunks[9])) {
$nbChunks = count($chunks);
for ($i = 9; $i < $nbChunks; $i++) {
$path .= ' '.$chunks[$i];
}
}
if (substr($path, 0, 2) == './') {
$path = substr($path, 2);
}
$items[$this->rawToType($item).'#'.$path] = $item;
if ($item[0] == 'd') {
$sublist = $this->rawlist($path, true);
foreach ($sublist as $subpath => $subitem) {
$items[$subpath] = $subitem;
}
}
}
return $items;
}
/**
* Parse raw list.
*
* @see FtpClient::rawlist()
* @see FtpClient::scanDir()
* @see FtpClient::dirSize()
* @param array $rawlist
* @return array
*/
public function parseRawList(array $rawlist)
{
$items = array();
$path = '';
foreach ($rawlist as $key => $child) {
$chunks = preg_split("/\s+/", $child, 9);
if (isset($chunks[8]) && ($chunks[8] == '.' or $chunks[8] == '..')) {
continue;
}
if (count($chunks) === 1) {
$len = strlen($chunks[0]);
if ($len && $chunks[0][$len-1] == ':') {
$path = substr($chunks[0], 0, -1);
}
continue;
}
// Prepare for filename that has space
$nameSlices = array_slice($chunks, 8, true);
$item = [
'permissions' => $chunks[0],
'number' => $chunks[1],
'owner' => $chunks[2],
'group' => $chunks[3],
'size' => $chunks[4],
'month' => $chunks[5],
'day' => $chunks[6],
'time' => $chunks[7],
'name' => implode(' ', $nameSlices),
'type' => $this->rawToType($chunks[0]),
];
if ($item['type'] == 'link' && isset($chunks[10])) {
$item['target'] = $chunks[10]; // 9 is "->"
}
// if the key is not the path, behavior of ftp_rawlist() PHP function
if (is_int($key) || false === strpos($key, $item['name'])) {
array_splice($chunks, 0, 8);
$key = $item['type'].'#'
.($path ? $path.'/' : '')
.implode(' ', $chunks);
if ($item['type'] == 'link') {
// get the first part of 'link#the-link.ext -> /path/of/the/source.ext'
$exp = explode(' ->', $key);
$key = rtrim($exp[0]);
}
$items[$key] = $item;
} else {
// the key is the path, behavior of FtpClient::rawlist() method()
$items[$key] = $item;
}
}
return $items;
}
/**
* Convert raw info (drwx---r-x ...) to type (file, directory, link, unknown).
* Only the first char is used for resolving.
*
* @param string $permission Example : drwx---r-x
*
* @return string The file type (file, directory, link, unknown)
* @throws FtpException
*/
public function rawToType($permission)
{
if (!is_string($permission)) {
throw new FtpException('The "$permission" argument must be a string, "'
.gettype($permission).'" given.');
}
if (empty($permission[0])) {
return 'unknown';
}
switch ($permission[0]) {
case '-':
return 'file';
case 'd':
return 'directory';
case 'l':
return 'link';
default:
return 'unknown';
}
}
/**
* Set the wrapper which forward the PHP FTP functions to use in FtpClient instance.
*
* @param FtpWrapper $wrapper
* @return FtpClient
*/
protected function setWrapper(FtpWrapper $wrapper)
{
$this->ftp = $wrapper;
return $this;
}
}

View File

@ -1,20 +0,0 @@
<?php
/*
* This file is part of the `nicolab/php-ftp-client` package.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Nicolas Tallefourtane http://nicolab.net
*/
// namespace FtpClient;
/**
* The FtpException class.
* Exception thrown if an error on runtime of the FTP client occurs.
* @inheritDoc
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/
class FtpException extends \Exception {}

View File

@ -1,116 +0,0 @@
<?php
/*
* This file is part of the `nicolab/php-ftp-client` package.
*
* (c) Nicolas Tallefourtane <dev@nicolab.net>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @copyright Nicolas Tallefourtane http://nicolab.net
*/
// namespace FtpClient;
/**
* Wrap the PHP FTP functions
*
* @method bool alloc(int $filesize, string &$result = null) Allocates space for a file to be uploaded
* @method bool cdup() Changes to the parent directory
* @method bool chdir(string $directory) Changes the current directory on a FTP server
* @method int chmod(int $mode, string $filename) Set permissions on a file via FTP
* @method bool close() Closes an FTP connection
* @method bool delete(string $path) Deletes a file on the FTP server
* @method bool exec(string $command) Requests execution of a command on the FTP server
* @method bool fget(resource $handle, string $remote_file, int $mode, int $resumepos = 0) Downloads a file from the FTP server and saves to an open file
* @method bool fput(string $remote_file, resource $handle, int $mode, int $startpos = 0) Uploads from an open file to the FTP server
* @method mixed get_option(int $option) Retrieves various runtime behaviours of the current FTP stream
* @method bool get(string $local_file, string $remote_file, int $mode, int $resumepos = 0) Downloads a file from the FTP server
* @method bool login(string $username, string $password) Logs in to an FTP connection
* @method int mdtm(string $remote_file) Returns the last modified time of the given file
* @method bool mkdir(string $directory) Creates a directory
* @method array mlsd(string $remote_dir) Returns a list of files in the given directory
* @method int nb_continue() Continues retrieving/sending a file (non-blocking)
* @method int nb_fget(resource $handle, string $remote_file, int $mode, int $resumepos = 0) Retrieves a file from the FTP server and writes it to an open file (non-blocking)
* @method int nb_fput(string $remote_file, resource $handle, int $mode, int $startpos = 0) Stores a file from an open file to the FTP server (non-blocking)
* @method int nb_get(string $local_file, string $remote_file, int $mode, int $resumepos = 0) Retrieves a file from the FTP server and writes it to a local file (non-blocking)
* @method int nb_put(string $remote_file, string $local_file, int $mode, int $startpos = 0) Stores a file on the FTP server (non-blocking)
* @method array nlist(string $directory) Returns a list of file names in the given directory; remote_dir parameter may also include arguments
* @method bool pasv(bool $pasv) Turns passive mode on or off
* @method bool put(string $remote_file, string $local_file, int $mode, int $startpos = 0) Uploads a file to the FTP server
* @method string pwd() Returns the current directory name
* @method bool quit() Closes an FTP connection
* @method array raw(string $command) Sends an arbitrary command to an FTP server
* @method array rawlist(string $directory, bool $recursive = false) Returns a detailed list of files in the given directory
* @method bool rename(string $oldname, string $newname) Renames a file or a directory on the FTP server
* @method bool rmdir(string $directory) Removes a directory
* @method bool set_option(int $option, mixed $value) Set miscellaneous runtime FTP options
* @method bool site(string $command) Sends a SITE command to the server
* @method int size(string $remote_file) Returns the size of the given file
* @method string systype() Returns the system type identifier of the remote FTP server
*
* @author Nicolas Tallefourtane <dev@nicolab.net>
*/
class FtpWrapper
{
/**
* The connection with the server
*
* @var resource
*/
protected $conn;
/**
* Constructor.
*
* @param resource &$connection The FTP (or SSL-FTP) connection (takes by reference).
*/
public function __construct(&$connection)
{
$this->conn = &$connection;
}
/**
* Forward the method call to FTP functions
*
* @param string $function
* @param array $arguments
* @return mixed
* @throws FtpException When the function is not valid
*/
public function __call($function, array $arguments)
{
$function = 'ftp_' . $function;
if (function_exists($function)) {
array_unshift($arguments, $this->conn);
return @call_user_func_array($function, $arguments);
}
throw new FtpException("{$function} is not a valid FTP function");
}
/**
* Opens a FTP connection
*
* @param string $host
* @param int $port
* @param int $timeout
* @return resource
*/
public function connect($host, $port = 21, $timeout = 90)
{
return @ftp_connect($host, $port, $timeout);
}
/**
* Opens a Secure SSL-FTP connection
* @param string $host
* @param int $port
* @param int $timeout
* @return resource
*/
public function ssl_connect($host, $port = 21, $timeout = 90)
{
return @ftp_ssl_connect($host, $port, $timeout);
}
}

199
app/Ubench.php Normal file
View File

@ -0,0 +1,199 @@
<?php
/*
* https://github.com/devster/ubench
*
* Copyright (c) 2012 Jeremy Perret
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
class Ubench
{
protected $start_time;
protected $end_time;
protected $memory_usage;
/**
* Sets start microtime
*
* @return void
*/
public function start()
{
$this->start_time = microtime(true);
}
/**
* Sets end microtime
*
* @return $this
* @throws Exception
*/
public function end()
{
if (!$this->hasStarted())
{
throw new LogicException("You must call start()");
}
$this->end_time = microtime(true);
$this->memory_usage = memory_get_usage(true);
return $this;
}
/**
* Returns the elapsed time, readable or not
*
* @param bool $raw
* @param string $format The format to display (printf format)
* @return float|string
* @throws Exception
*/
public function getTime($raw = false, $format = null)
{
if (!$this->hasStarted())
{
throw new LogicException("You must call start()");
}
if (!$this->hasEnded())
{
throw new LogicException("You must call end()");
}
$elapsed = $this->end_time - $this->start_time;
return $raw ? $elapsed : self::readableElapsedTime($elapsed, $format);
}
/**
* Returns the memory usage at the end checkpoint
*
* @param boolean $readable Whether the result must be human readable
* @param string $format The format to display (printf format)
* @return string|float
*/
public function getMemoryUsage($raw = false, $format = null)
{
return $raw ? $this->memory_usage : self::readableSize($this->memory_usage, $format);
}
/**
* Returns the memory peak, readable or not
*
* @param boolean $readable Whether the result must be human readable
* @param string $format The format to display (printf format)
* @return string|float
*/
public function getMemoryPeak($raw = false, $format = null)
{
$memory = memory_get_peak_usage(true);
return $raw ? $memory : self::readableSize($memory, $format);
}
/**
* Wraps a callable with start() and end() calls
*
* Additional arguments passed to this method will be passed to
* the callable.
*
* @param callable $callable
* @return mixed
*/
public function run(callable $callable)
{
$arguments = func_get_args();
array_shift($arguments);
$this->start();
$result = call_user_func_array($callable, $arguments);
$this->end();
return $result;
}
/**
* Returns a human readable memory size
*
* @param int $size
* @param string $format The format to display (printf format)
* @param int $round
* @return string
*/
public static function readableSize($size, $format = null, $round = 3)
{
$mod = 1024;
if (is_null($format)) {
$format = '%.2f%s';
}
$units = explode(' ','B Kb Mb Gb Tb');
for ($i = 0; $size > $mod; $i++) {
$size /= $mod;
}
if (0 === $i) {
$format = preg_replace('/(%.[\d]+f)/', '%d', $format);
}
return sprintf($format, round($size, $round), $units[$i]);
}
/**
* Returns a human readable elapsed time
*
* @param float $microtime
* @param string $format The format to display (printf format)
* @return string
*/
public static function readableElapsedTime($microtime, $format = null, $round = 3)
{
if (is_null($format)) {
$format = '%.3f%s';
}
if ($microtime >= 1) {
$unit = 's';
$time = round($microtime, $round);
} else {
$unit = 'ms';
$time = round($microtime*1000);
$format = preg_replace('/(%.[\d]+f)/', '%d', $format);
}
return sprintf($format, $time, $unit);
}
public function hasEnded()
{
return isset($this->end_time);
}
public function hasStarted()
{
return isset($this->start_time);
}
}

38
app/base.php Normal file
View File

@ -0,0 +1,38 @@
<?php
/**
* @author icret
* @link https://png.cm
* @email lemonim@qq.com
* @project EasyImage2.0 - 简单图床
* @Github https://github.com/icret/easyImages2.0
* @Telegram https://t.me/Easy_Image
* QQ Group 954441002
* @Last 2024-01-20
* 上传服务器后第一次打开会检查运行环境,请根据提示操作;
* 检查环境仅会在第一开始开始出现并在config目录下生成EasyImage.lock文件如需再次查看请删除此文件。
* 敬请注意本程序为开源程序你可以使用本程序在任何非商业项目或者网站中。但请你务必保留代码中相关信息页面logo和页面上必要的链接可以更改
* 本人仅为程序开源创作,如非法网站与本人无关,请勿用于非法用途
* 请为本人网站 (https://png.cm) 加上网址链接,谢谢支持。作为开发者你可以对相应的后台功能进行扩展(增删改相应代码),但请保留代码中相关来源信息(例如:本人博客,邮箱等)
* 如果因安装问题或其他问题可以给我发邮件。
*/
/*---------------基础配置开始-------------------*/
// 设置html为utf8
header('Content-Type:text/html;charset=utf-8');
// 定义根目录
define('APP_ROOT', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
// 时区设置 https://www.php.net/manual/zh/timezones.php
require_once APP_ROOT . '/config/config.php';
empty($config['timezone']) ? date_default_timezone_set('Asia/Shanghai') : date_default_timezone_set($config['timezone']);
// 修改内存限制 根据服务器配置选择低于128M容易出现上传失败你懂得图片挺占用内存的
ini_set('memory_limit', '512M');
// 判断当前系统是否为windows
define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0);
// 定义程序版本
define('APP_VERSION', '2.8.4');
/*---------------基础配置结束-------------------*/

View File

@ -15,6 +15,7 @@ file_put_contents(APP_ROOT . '/config/EasyIamge.lock', '安装环境检测锁定
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">x</span><span class="sr-only">关闭</span></button>
<h4 class="modal-title"> <h4 class="modal-title">
<i class="icon icon-heart"> </i><a href="https://github.com/icret/EasyImages2.0" target="_blank">简单图床-EasyImage2.0</a> 安装环境检测 <i class="icon icon-heart"> </i><a href="https://github.com/icret/EasyImages2.0" target="_blank">简单图床-EasyImage2.0</a> 安装环境检测
</h4> </h4>
@ -92,6 +93,12 @@ file_put_contents(APP_ROOT . '/config/EasyIamge.lock', '安装环境检测锁定
backdrop: "static", //点击空白处不关闭对话框 backdrop: "static", //点击空白处不关闭对话框
show: true show: true
}) })
} else {
new $.zui.Messager("取消查看 - 如需再次展示请删除config/EasyIamge.lock文件", {
type: "info", // 定义颜色主题
time: 6000,
icon: "info-sign" // 定义消息图标
}).show();
} }
console.log('EasyIamge.lock 生成完毕!') console.log('EasyIamge.lock 生成完毕!')
</script> </script>

View File

@ -1,19 +1,20 @@
<?php <?php
/** 禁止直接访问 */ // 开启 DEBUG 2023-04-03
defined('APP_ROOT') ?: exit; if (!ini_get('display_errors')) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
/*
// 检查当前PHP版本是否大于7.0 // 检查当前PHP版本是否大于7.0
if (PHP_VERSION < 7) { if (PHP_VERSION < 7) {
echo ' echo '
new $.zui.Messager("当前PHP版本<7.0, 部分功能受限!",{ new $.zui.Messager("当前PHP版本<7.0, 部分功能受限!",{
type: "primary", // 定义颜色主题 type: "primary", // 定义颜色主题
time:3000 time:2000
}).show(); }).show();
'; ';
} }
*/
// 扩展检测 // 扩展检测
$expand = array('fileinfo', 'iconv', 'gd', 'mbstring', 'openssl',); $expand = array('fileinfo', 'iconv', 'gd', 'mbstring', 'openssl',);
@ -23,7 +24,7 @@ foreach ($expand as $val) {
new $.zui.Messager("扩展:' . $val . '- 未安装,可能导致图片上传失败! 请尽快修复。",{ new $.zui.Messager("扩展:' . $val . '- 未安装,可能导致图片上传失败! 请尽快修复。",{
type: "black", // 定义颜色主题 type: "black", // 定义颜色主题
icon: "exclamation-sign", // 定义消息图标 icon: "exclamation-sign", // 定义消息图标
time:3500 time:2200
}).show(); }).show();
'; ';
} }
@ -34,7 +35,7 @@ if ($config['password'] === '7676aaafb027c825bd9abab78b234070e702752f625b752e55e
echo ' echo '
new $.zui.Messager("请修改默认密码,否则会有泄露风险! ",{ new $.zui.Messager("请修改默认密码,否则会有泄露风险! ",{
type: "warning", // 定义颜色主题 type: "warning", // 定义颜色主题
time:4000 time:2400
}).show(); }).show();
'; ';
} }
@ -44,7 +45,7 @@ if (is_local($config['domain']) || is_local($config['imgurl'])) {
echo ' echo '
new $.zui.Messager("当前使用局域网,可能会导致外网访问异常!",{ new $.zui.Messager("当前使用局域网,可能会导致外网访问异常!",{
type: "black", // 定义颜色主题 type: "black", // 定义颜色主题
time:4500 time:2600
}).show(); }).show();
'; ';
} }
@ -54,7 +55,7 @@ if (file_exists(APP_ROOT . '/.user.ini')) {
echo ' echo '
new $.zui.Messager("请关闭防跨目录读写或删除.user.ini文件",{ new $.zui.Messager("请关闭防跨目录读写或删除.user.ini文件",{
type: "danger", // 定义颜色主题 type: "danger", // 定义颜色主题
time:5000 time:2700
}).show(); }).show();
'; ';
} }
@ -64,7 +65,7 @@ if (!file_exists(__DIR__ . '/ip2region/ip2region.xdb')) {
echo ' echo '
new $.zui.Messager("IP 数据库不存在, 请在系统信息中查看 Ip2region",{ new $.zui.Messager("IP 数据库不存在, 请在系统信息中查看 Ip2region",{
type: "danger", // 定义颜色主题 type: "danger", // 定义颜色主题
time:5500 time:2900
}).show(); }).show();
'; ';
} }
@ -74,7 +75,7 @@ if (getVersion() !== APP_VERSION) {
echo ' echo '
new $.zui.Messager("当前版本与GitHub不一致,请检查当前是否最新版本!",{ new $.zui.Messager("当前版本与GitHub不一致,请检查当前是否最新版本!",{
type: "danger", // 定义颜色主题 type: "danger", // 定义颜色主题
time:6000 time:3100
}).show(); }).show();
'; ';
} }
@ -91,7 +92,7 @@ if (!is_file(APP_ROOT . $config['waterImg'])) {
echo ' echo '
new $.zui.Messager("水印图片不存在,请检测路径或者文件是否存在!",{ new $.zui.Messager("水印图片不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题 type: "danger", // 定义颜色主题
time:6500 time:3300
}).show(); }).show();
'; ';
} }
@ -101,7 +102,7 @@ if (!is_file(APP_ROOT . $config['textFont'])) {
echo ' echo '
new $.zui.Messager("水印字体不存在,请检测路径或者文件是否存在!",{ new $.zui.Messager("水印字体不存在,请检测路径或者文件是否存在!",{
type: "danger", // 定义颜色主题 type: "danger", // 定义颜色主题
time:6500 time:3500
}).show(); }).show();
'; ';
} }
@ -115,7 +116,7 @@ if ($config['checkImg'] !== 0) {
echo ' echo '
new $.zui.Messager("moderatecontent 鉴黄接口无法ping通! ",{ new $.zui.Messager("moderatecontent 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题 type: "warning", // 定义颜色主题
time:7000 time:3700
}).show(); }).show();
'; ';
} }
@ -131,7 +132,7 @@ if ($config['checkImg'] !== 0) {
echo ' echo '
new $.zui.Messager("' . $ip . $port . ' 鉴黄接口无法ping通! ",{ new $.zui.Messager("' . $ip . $port . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题 type: "warning", // 定义颜色主题
time:7000 time:3700
}).show(); }).show();
'; ';
} }
@ -140,7 +141,7 @@ if ($config['checkImg'] !== 0) {
echo ' echo '
new $.zui.Messager("' . $ip . ' 鉴黄接口无法ping通! ",{ new $.zui.Messager("' . $ip . ' 鉴黄接口无法ping通! ",{
type: "warning", // 定义颜色主题 type: "warning", // 定义颜色主题
time:7000 time:3700
}).show(); }).show();
'; ';
} }
@ -152,7 +153,32 @@ if (!function_exists('fastcgi_finish_request')) {
echo ' echo '
new $.zui.Messager("开启 fastcgi_finish_request 处理数据会更快喔!",{ new $.zui.Messager("开启 fastcgi_finish_request 处理数据会更快喔!",{
type: "primary", // 定义颜色主题 type: "primary", // 定义颜色主题
time:7000 time:3900
}).show(); }).show();
'; ';
} }
// FTP检测
if ($config['ftp_status']) {
require_once __DIR__ . '/Ftp.php';
// 登录FTP
try {
$ftp = new Ftp;
if ($config['ftp_ssl'] === 1) {
$ftp->sslConnect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
} else {
$ftp->connect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
}
$ftp->login($config['ftp_user'], $config['ftp_pass']);
$ftp->pasv($config['ftp_pasv']);
} catch (FtpException $e) {
echo '
new $.zui.Messager("FTP 错误:' . $e->getMessage() . '",{
type: "primary", // 定义颜色主题
time:4000
}).show();
';
}
}

View File

@ -25,7 +25,7 @@
// | This script is free to use, don't abuse. | // | This script is free to use, don't abuse. |
// +------------------------------------------------------------------------+ // +------------------------------------------------------------------------+
namespace Verot\Upload; namespace Verot\Upload;
if (!defined('IMG_WEBP')) define('IMG_WEBP', 32); if (!defined('IMG_WEBP')) define('IMG_WEBP', 32);
@ -1892,6 +1892,8 @@ class Upload {
'bat', 'bat',
'phar', 'phar',
'wsdl', 'wsdl',
'html',
'htm',
); );
$this->forbidden = array_merge($this->dangerous, array( $this->forbidden = array_merge($this->dangerous, array(
@ -2118,7 +2120,7 @@ class Upload {
*/ */
function upload($file, $lang = 'en_GB') { function upload($file, $lang = 'en_GB') {
$this->version = '09/12/2022'; $this->version = '07/12/2023';
$this->file_src_name = ''; $this->file_src_name = '';
$this->file_src_name_body = ''; $this->file_src_name_body = '';
@ -5239,5 +5241,3 @@ class Upload {
return true; return true;
} }
} }
?>

View File

@ -1,25 +1,24 @@
<?php <?php
/** /**
* 删除文件页面 * 删除/回收文件页面
* @author Icret
* 2023-3-15 11:01:52
*/ */
require_once __DIR__ . '/header.php';
require __DIR__ . '/function.php';
if (empty($_REQUEST)) { if (empty($_REQUEST)) {
echo ' exit(json_encode(array(
<script> 'code' => 200,
new $.zui.Messager("没有要删除的图片!", { 'msg' => '无效请求',
type: "danger", // 定义颜色主题 'type' => 'success',
icon: "exclamation-sign" // 定义消息图标 'icon' => 'exclamation-sign',
}).show(); 'mode' => 'get',
</script> 'url' => null
'; ), JSON_UNESCAPED_UNICODE));
} }
$img = rand_imgurl() . '/public/images/404.png';
if (isset($_GET['url'])) {
$img = strip_tags($_GET['url']);
}
// 解密删除 // 解密删除
if (isset($_GET['hash'])) { if (isset($_GET['hash'])) {
@ -28,111 +27,331 @@ if (isset($_GET['hash'])) {
if ($config['image_recycl']) { if ($config['image_recycl']) {
// 如果开启回收站则进入回收站 // 如果开启回收站则进入回收站
if (checkImg($delHash, 3, 'recycle/') == true) { if (checkImg($delHash, 3, 'recycle/') === true) {
echo '
<script> any_upload($delHash, $delHash, 'delete'); // FTP删除
new $.zui.Messager("删除成功", {
type: "success", // 定义颜色主题 exit(json_encode(array(
icon: "ok-sign" // 定义消息图标 'code' => 200,
}).show(); 'msg' => '删除成功',
</script> 'type' => 'success',
'; 'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $delHash
), JSON_UNESCAPED_UNICODE));
} else { } else {
echo ' exit(json_encode(array(
<script> 'code' => 200,
new $.zui.Messager("文件不存在!", { 'msg' => '文件不存在',
type: "danger", // 定义颜色主题 'type' => 'danger',
icon: "exclamation-sign" // 定义消息图标 'icon' => 'exclamation-sign',
}).show(); 'mode' => 'delete',
</script> 'url' => $delHash
'; ), JSON_UNESCAPED_UNICODE));
} }
} else { } else {
// 否则直接删除 getDel($delHash, 'url'); // 直接删除
getDel($delHash, 'url');
any_upload($delHash, $delHash, 'delete'); // FTP删除
exit(json_encode(array(
'code' => 200,
'msg' => '删除成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $delHash
), JSON_UNESCAPED_UNICODE));
}
exit(json_encode(array(
'code' => 200,
'msg' => '删除失败',
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $delHash
), JSON_UNESCAPED_UNICODE));
}
// 非管理员不可访问
if (!is_who_login('admin')) exit('Permission denied');
// 广场 - 批量删除文件
if (isset($_POST['del_url_array'])) {
$del_url_array = $_POST['del_url_array'];
$del_num = count($del_url_array);
for ($i = 0; $i < $del_num; $i++) {
getDel($del_url_array[$i], 'url');
// FTP删除
any_upload($del_url_array[$i], $del_url_array[$i], 'delete');
} }
} }
// 检查登录后再处理url删除请求 // 广场 - 批量回收文件
if (is_who_login('admin')) { if (isset($_POST['recycle_url_array'])) {
$recycle_url_array = $_POST['recycle_url_array'];
// 广场页面删除 $del_num = count($recycle_url_array);
if (isset($_GET['url'])) { for ($i = 0; $i < $del_num; $i++) {
getDel($img, 'url'); checkImg($recycle_url_array[$i], 3);
} }
}
// 从管理页面删除 if (isset($_POST['url'])) $postURL = strip_tags($_POST['url']);
if (isset($_GET['url_admin_inc'])) {
$del_url = $_GET['url_admin_inc']; // 广场|日志 - 单文件删除
if (isset($_POST['mode']) && $_POST['mode'] === 'delete') {
$reslut = easyimage_delete($postURL, 'url');
// FTP删除
any_upload($postURL, $postURL, 'delete');
if ($reslut) {
exit(json_encode(array(
'code' => 200,
'msg' => '删除成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE));
} else {
exit(json_encode(array(
'code' => 200,
'msg' => '删除失败',
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE));
}
}
// 广场|日志 - 回收文件
if (isset($_POST['mode']) && $_POST['mode'] === 'recycle') {
if (is_file(APP_ROOT . $postURL)) {
checkImg($postURL, 3);
exit(json_encode(array(
'code' => 200,
'msg' => '回收成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'recycle',
'url' => $postURL
), JSON_UNESCAPED_UNICODE));
} else {
exit(json_encode(array(
'code' => 200,
'msg' => '回收失败',
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE));
}
}
// 管理页面 - 删除版本信息文件
if (isset($_POST['mode']) && $_POST['mode'] === 'del_version_file') {
try {
@unlink(APP_ROOT . $postURL);
$re = json_encode(array(
'code' => 200,
'msg' => '删除成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
throw new Exception('更新版本号失败');
} catch (Exception $e) {
$re = json_encode(array(
'code' => 404,
'msg' => $e->getMessage(),
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} finally {
exit($re);
}
}
// 管理页面 - 回收站恢复文件
if (isset($_POST['mode']) && $_POST['mode'] === 'recycle_reimg') {
try {
if (re_checkImg($postURL, 'recycle/') === true) {
$re = json_encode(array(
'code' => 200,
'msg' => '恢复成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} else {
throw new Exception('恢复失败');
}
} catch (Exception $e) {
$re = json_encode(array(
'code' => 404,
'msg' => $e->getMessage(),
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} finally {
exit($re);
}
}
// 管理页面 - 监黄恢复文件
if (isset($_POST['mode']) && $_POST['mode'] === 'suspic_reimg') {
try {
if (re_checkImg($postURL, 'suspic/') === true) {
$re = json_encode(array(
'code' => 200,
'msg' => '恢复成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} else {
throw new Exception('恢复失败');
}
} catch (Exception $e) {
$re = json_encode(array(
'code' => 404,
'msg' => $e->getMessage(),
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} finally {
exit($re);
}
}
// 管理页面 - 删除非空目录
if (isset($_POST['mode']) && $_POST['mode'] === 'delDir') {
try {
$delDir = APP_ROOT . $config['path'] . $postURL; // 限制删除目录
if (deldir($delDir)) {
$re = json_encode(array(
'code' => 200,
'msg' => '删除文件夹成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} else {
throw new Exception('删除文件夹失败');
}
} catch (Exception $e) {
$re = json_encode(array(
'code' => 404,
'msg' => $e->getMessage(),
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
'url' => $postURL
), JSON_UNESCAPED_UNICODE);
} finally {
exit($re);
}
}
// 管理页面 - 删除指定日期文件夹
if (isset($_POST['dateDir'])) {
$delDir = APP_ROOT . $config['path'] . $_POST['dateDir'];
if (deldir($delDir)) {
echo json_encode(array(
'code' => 200,
'msg' => '删除成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delDir',
'url' => $delDir
), JSON_UNESCAPED_UNICODE);
exit;
} else {
exit(json_encode(array(
'code' => 404,
'msg' => '删除失败',
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delDir',
'url' => $delDir
), JSON_UNESCAPED_UNICODE));
}
}
// 管理页面 - 删除指定文件
if (isset($_POST['url_admin_inc'])) {
$del_url = $_POST['url_admin_inc'];
if ($config['hide_path']) { if ($config['hide_path']) {
$del_url = $config['domain'] . $config['path'] . parse_url($del_url)['path']; $del_url = $config['domain'] . $config['path'] . parse_url($del_url)['path'];
} }
getDel($del_url, 'url');
if (easyimage_delete($del_url, 'url') === TRUE) {
exit(json_encode(array(
'code' => 200,
'msg' => '删除成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
'url' => $del_url
), JSON_UNESCAPED_UNICODE));
} }
// 回收
if (isset($_GET['recycle_url'])) { exit(json_encode(array(
$recycle_url = $_GET['recycle_url']; 'code' => 404,
$recycle_url = parse_url($recycle_url)['path']; 'msg' => '删除失败',
if (file_exists(APP_ROOT . $recycle_url)) { 'type' => 'danger',
checkImg($recycle_url, 3); 'icon' => 'exclamation-sign',
echo ' 'mode' => 'delete',
<script> 'url' => $del_url
new $.zui.Messager("已放入回收站!", { ), JSON_UNESCAPED_UNICODE));
type: "success", // 定义颜色主题 }
icon: "ok" // 定义消息图标
}).show(); // 管理页面 - 重置OPcache缓存
</script> if (isset($_POST['mode']) && $_POST['mode'] === 'OPcache') {
';
if (!function_exists('opcache_reset')) {
exit(json_encode(array(
'code' => 404,
'msg' => '未开启OPcache',
'type' => 'danger',
'icon' => 'exclamation-sign',
'mode' => 'delete',
), JSON_UNESCAPED_UNICODE));
}
try {
if (opcache_reset() === true) {
$re = json_encode(array(
'code' => 200,
'msg' => '重置缓存成功',
'type' => 'success',
'icon' => 'ok-sign',
'mode' => 'delete',
), JSON_UNESCAPED_UNICODE);
} else { } else {
echo ' throw new Exception('重置缓存失败');
<script>
new $.zui.Messager("文件不存在!", {
type: "danger", // 定义颜色主题
icon: "exclamation-sign" // 定义消息图标
}).show();
</script>
';
} }
} } catch (Exception $e) {
} else { $re = json_encode(array(
if (isset($_GET['url'])) { 'code' => 404,
echo ' 'msg' => $e->getMessage(),
<script> 'type' => 'danger',
new $.zui.Messager("请使用管理员账号登录再删除!", { 'icon' => 'exclamation-sign',
type: "danger", // 定义颜色主题 'mode' => 'delete',
icon: "exclamation-sign" // 定义消息图标 ), JSON_UNESCAPED_UNICODE);
}).show(); } finally {
// 延时2s跳转 exit($re);
window.setTimeout("window.location=\'/../admin/index.php \'",3000);
</script>
';
} }
} }
?>
<div class="col-md-4 col-md-offset-4">
<a href="<?php echo $img; ?>" target="_blank"><img src="<?php echo $img; ?>" alt="简单图床-EasyImage" class="img-thumbnail"></a>
<form class="form-inline" method="get" action="<?php $_SERVER['SCRIPT_NAME']; ?>" id="form" name="delForm" onSubmit="getStr();">
<div class="form-group">
<label for="exampleInputInviteCode3">删除图片-格式:</label>
<input type="text" class="form-control" id="exampleInputInviteCode3" name="url" placeholder="https://i1.100024.xyz/i/2021/05/04/10fn9ei.jpg">
</div>
<button type="submit" class="btn btn-danger">删除</button>
</form>
</div>
<script>
// 修改网页标题
document.title = "删除图片 - <?php echo $config['title']; ?>";
var oBtn = document.getElementById('del');
var oTi = document.getElementById('title');
if ('oninput' in oBtn) {
oBtn.addEventListener("input", getWord, false);
} else {
oBtn.onpropertychange = getWord;
}
function getWord() {
oTi.innerHTML = '<img src="' + oBtn.value + '" width="200" class="img-rounded" /><br />';
}
</script>
<?php require_once __DIR__ . '/footer.php';

View File

@ -2,7 +2,6 @@
/** 禁止直接访问 */ /** 禁止直接访问 */
defined('APP_ROOT') ?: exit; defined('APP_ROOT') ?: exit;
/** 弹窗公告 */ /** 弹窗公告 */
if ($config['notice_status'] > 0) : ?> if ($config['notice_status'] > 0) : ?>
<div class="modal fade" id="notice"> <div class="modal fade" id="notice">
@ -19,7 +18,7 @@ if ($config['notice_status'] > 0) : ?>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-mini btn-primary" data-dismiss="modal"></button> <button type="button" class="btn btn-mini btn-primary" data-dismiss="modal">知道</button>
</div> </div>
</div> </div>
</div> </div>
@ -47,9 +46,9 @@ if ($config['notice_status'] > 0) : ?>
<?php /** 页脚自定义代码 */ echo $config['footer']; ?> <?php /** 页脚自定义代码 */ echo $config['footer']; ?>
<p> <p>
<!-- 页脚信息 --> <!-- 页脚信息 -->
<a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Github">© Since 2018</a> <a href="https://github.com/icret/EasyImages2.0" target="_blank" rel="nofollow" data-toggle="tooltip" title="Github Releases">© Since 2018</a>
<a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="EasyImage2.0 简单图床">EasyImage</a> <a href="https://png.cm/" target="_blank" data-toggle="tooltip" title="简单图床官网">EasyImage</a>
<a href="/admin/terms.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a> <a href="/app/DMCA.php" target="_blank" data-toggle="tooltip" title="使用协议">DMCA</a>
<!-- 二维码按钮 --> <!-- 二维码按钮 -->
<a data-toggle="modal" href="#qr"><i class="icon icon-qrcode hidden-xs inline-block" data-toggle="tooltip" title="二维码"></i></a> <a data-toggle="modal" href="#qr"><i class="icon icon-qrcode hidden-xs inline-block" data-toggle="tooltip" title="二维码"></i></a>
<?php /** 暗黑模式 */ if ($config['dark-mode']) : ?> <?php /** 暗黑模式 */ if ($config['dark-mode']) : ?>
@ -62,18 +61,20 @@ if ($config['notice_status'] > 0) : ?>
<?php endif; ?> <?php endif; ?>
</p> </p>
</footer> </footer>
<link href="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.css" rel="stylesheet"> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/qrcode/qrcode.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/qrcode/qrcode.min.js"></script>
<script> <script>
// NProgress // NProgress
NProgress.configure({
barColor: '<?php echo $config['NProgress_default']; ?>'
});
NProgress.start(); NProgress.start();
NProgress.done(); NProgress.done();
// 导航状态 // 导航状态
$('.nav-pills').find('a').each(function() { $('.nav-pills').find('a').each(function() {
// console.log(document.location); // console.log(document.location);
if (this.pathname == document.location.pathname) { if (this.pathname === location.pathname) {
$(this).parent().addClass('active'); $(this).parent().addClass('active');
} }
}); });

View File

@ -1,60 +1,8 @@
<?php <?php
require_once __DIR__ . '/base.php';
/**
* @author icret
* @link https://png.cm
* @email lemonim@qq.com
* @project EasyImage2.0 - 简单图床
* @Github https://github.com/icret/easyImages2.0
* QQ Group 954441002
* @Last 2023-03-09 17:38:57
* 上传服务器后第一次打开会检查运行环境,请根据提示操作;
* 检查环境仅会在第一开始开始出现并在config目录下生成EasyImage.lock文件如需再次查看请删除此文件。
* 敬请注意本程序为开源程序你可以使用本程序在任何非商业项目或者网站中。但请你务必保留代码中相关信息页面logo和页面上必要的链接可以更改
* 本人仅为程序开源创作,如非法网站与本人无关,请勿用于非法用途
* 请为本人网站 (https://png.cm) 加上网址链接,谢谢支持。作为开发者你可以对相应的后台功能进行扩展(增删改相应代码),但请保留代码中相关来源信息(例如:本人博客,邮箱等)
* 如果因安装问题或其他问题可以给我发邮件。
*/
/*---------------基础配置开始-------------------*/
// 设置html为utf8
header('Content-Type:text/html;charset=utf-8');
//将时区设置为中国·上海
ini_set('date.timezone', 'Asia/Shanghai');
date_default_timezone_set('Asia/Shanghai');
// 修改内存限制 根据服务器配置选择低于128M容易出现上传失败你懂得图片挺占用内存的
ini_set('memory_limit', '512M');
// 定义根目录
define('APP_ROOT', str_replace('\\', '/', realpath(dirname(__FILE__) . '/../')));
// 判断当前的系统类型是否为windows
define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0);
// 定义当前版本
define('APP_VERSION', '2.8.3');
/*---------------基础配置结束-------------------*/
require_once APP_ROOT . '/config/config.php';
require_once APP_ROOT . '/config/config.guest.php';
require_once __DIR__ . '/WaterMask.php'; require_once __DIR__ . '/WaterMask.php';
require_once APP_ROOT . '/config/config.guest.php';
/**
* 开启DEBUG
* 2023-03-09
*/
function easyimage_debug()
{
global $config;
if ($config['checkEnv']) {
if (!ini_get('display_errors')) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
}
}
/** /**
* 判断GIF图片是否为动态 * 判断GIF图片是否为动态
* @param $filename string 文件 * @param $filename string 文件
@ -154,7 +102,7 @@ function _login($user = null, $password = null)
if ($browser_cookie[0] === $config['user'] && $browser_cookie[1] === $config['password']) return json_encode(array('code' => 200, 'level' => 1, 'messege' => '尊敬的管理员')); if ($browser_cookie[0] === $config['user'] && $browser_cookie[1] === $config['password']) return json_encode(array('code' => 200, 'level' => 1, 'messege' => '尊敬的管理员'));
// 判断是否上传者 // 判断是否上传者
if (array_key_exists($browser_cookie[0], $guestConfig) && $browser_cookie[1] === $guestConfig[$browser_cookie[0]]['password']) { if (array_key_exists($browser_cookie[0], $guestConfig) && $browser_cookie[1] === $guestConfig[$browser_cookie[0]]['password']) {
// 判断上者是否过期 // 判断上者是否过期
if ($guestConfig[$browser_cookie[0]]['expired'] < time()) { if ($guestConfig[$browser_cookie[0]]['expired'] < time()) {
// 上传者账户密码正确,但是账户过期 // 上传者账户密码正确,但是账户过期
return json_encode(array('code' => 400, 'level' => 0, 'messege' => $browser_cookie[0] . '账号已过期')); return json_encode(array('code' => 400, 'level' => 0, 'messege' => $browser_cookie[0] . '账号已过期'));
@ -682,6 +630,39 @@ function getDel($url, $type)
clearstatcache(); clearstatcache();
} }
/**
* 删除指定文件
* @param $url string 文件
* @param $type string 模式
*/
function easyimage_delete($url, $type)
{
global $config;
// url本地化
$url = htmlspecialchars(str_replace($config['domain'], '', $url)); // 过滤html 获取url path
$url = urldecode(trim($url));
if ($type == 'url') {
$url = $_SERVER['DOCUMENT_ROOT'] . $url;
}
if ($type == 'hash') {
$url = APP_ROOT . $url;
}
// 文件是否存在 限制删除目录
if (is_file($url) && strrpos($url, $config['path'])) {
// 执行删除
if (@unlink($url)) {
return TRUE;
} else {
return FALSE;
}
}
return FALSE;
// 清除查询
clearstatcache();
}
/** /**
* 判断是否此用户登录 * 判断是否此用户登录
* @param string $user 判断登录者权限 $user=null 时检查是否登录, 不区分身份 * @param string $user 判断登录者权限 $user=null 时检查是否登录, 不区分身份
@ -778,7 +759,7 @@ function getVersion($name = 'tag_name')
global $config; global $config;
if ($config['checkEnv']) { if ($config['checkEnv']) {
require_once APP_ROOT . '/app/class.version.php'; require_once __DIR__ . '/class.version.php';
$url = "https://api.github.com/repositories/188228357/releases/latest"; // 获取版本地址 $url = "https://api.github.com/repositories/188228357/releases/latest"; // 获取版本地址
$getVersion = new getVersion($url); $getVersion = new getVersion($url);
try { try {
@ -898,7 +879,7 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
global $config; global $config;
/** # 使用moderatecontent */ /** # 使用moderatecontent */
if ($type == 1) { if ($type === 1) {
$response = moderatecontent_json($imageUrl); $response = moderatecontent_json($imageUrl);
if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult) if ($response['rating_index'] == 3 or $response['predictions']['adult'] > $config['checkImg_value']) { // (1 = everyone, 2 = teen, 3 = adult)
$bad_pic = true; $bad_pic = true;
@ -906,7 +887,7 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
} }
/** # 使用nsfwjs */ /** # 使用nsfwjs */
if ($type == 2) { if ($type === 2) {
/** /**
* probability概率 * probability概率
* className类型 * className类型
@ -956,13 +937,13 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
} }
// 移入回收站 // 移入回收站
if ($type == 3) { if ($type === 3) {
$bad_pic = true; $bad_pic = true;
$dir = 'recycle/'; $dir = 'recycle/';
} }
/** # 如果违规则移动图片到违规文件夹 */ /** # 如果违规则移动图片到违规文件夹 */
if ($bad_pic == true) { if ($bad_pic === true) {
$old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png $old_path = APP_ROOT . parse_url($imageUrl)['path']; // 提交网址中的文件路径 /i/2021/10/29/p8vypd.png
$name = parse_url($imageUrl)['path']; // 获得图片的相对地址 $name = parse_url($imageUrl)['path']; // 获得图片的相对地址
$name = str_replace($config['path'], '', $name); // 去除 path目录 $name = str_replace($config['path'], '', $name); // 去除 path目录
@ -975,6 +956,12 @@ function checkImg($imageUrl, $type = 1, $dir = 'suspic/')
} }
if (is_file($old_path)) { if (is_file($old_path)) {
rename($old_path, $new_path); rename($old_path, $new_path);
// FTP
if ($config['ftp_status'] === 1) {
any_upload(parse_url($imageUrl)['path'], $config['path'] . $dir . $name, 'rename');
}
return true; return true;
} else { } else {
return false; return false;
@ -995,6 +982,10 @@ function re_checkImg($name, $dir = 'suspic/')
if (is_file($now_path_file)) { if (is_file($now_path_file)) {
$to_file = APP_ROOT . $config['path'] . $fileToPath; // 要还原图片的绝对位置 */i/2021/10/30/p8vypd.png $to_file = APP_ROOT . $config['path'] . $fileToPath; // 要还原图片的绝对位置 */i/2021/10/30/p8vypd.png
rename($now_path_file, $to_file); // 移动文件 rename($now_path_file, $to_file); // 移动文件
// FTP
if ($config['ftp_status'] === 1) {
any_upload($config['path'] . $dir . $name, $config['path'] . $fileToPath, 'rename');
}
return true; return true;
} }
} }
@ -1389,7 +1380,6 @@ function check_api($token)
} }
} }
/** /**
* 根据URL判断是否本地局域网访问(PHP代码函数) * 根据URL判断是否本地局域网访问(PHP代码函数)
* https://blog.csdn.net/monxinmonxin0/article/details/44854383 * https://blog.csdn.net/monxinmonxin0/article/details/44854383
@ -1398,9 +1388,8 @@ function check_api($token)
*/ */
function is_local($url) function is_local($url)
{ {
if (stristr($url, 'localhost') || stristr($url, '127.') || stristr($url, '192.')) { if (stristr($url, '://localhost') || stristr($url, '://127.') || stristr($url, '://192.') || stristr($url, '://10.')) return true;
return true;
}
return false; return false;
} }
@ -1422,7 +1411,6 @@ function rand_imgurl($text = null)
* @param String $file 文件相对路径 * @param String $file 文件相对路径
* @return String 内容信息 * @return String 内容信息
*/ */
function get_current_version($file = '/admin/version.php') function get_current_version($file = '/admin/version.php')
{ {
$file = APP_ROOT . $file; $file = APP_ROOT . $file;
@ -1463,8 +1451,13 @@ function water($source)
{ {
global $config; global $config;
// 判断是否图片格式
// 文字水印 // 文字水印
if ($config['watermark'] == 1) { if ($config['watermark'] === 1) {
// 过滤gif // 过滤gif
if (!is_Gif_Webp_Animated($source)) { if (!is_Gif_Webp_Animated($source)) {
$arr = [ $arr = [
@ -1483,7 +1476,7 @@ function water($source)
} }
// 图片水印 // 图片水印
if ($config['watermark'] == 2) { if ($config['watermark'] === 2) {
// 过滤gif // 过滤gif
if (!is_Gif_Webp_Animated($source)) { if (!is_Gif_Webp_Animated($source)) {
$arr = [ $arr = [
@ -1598,21 +1591,19 @@ function write_upload_logs($filePath, $sourceName, $absolutePath, $fileSize, $fr
*/ */
function ip2region($IP) function ip2region($IP)
{ {
$db = __DIR__ . '/ip2region/ip2region.xdb'; if (!is_file(__DIR__ . '/ip2region/ip2region.xdb')) return '<a href="https://raw.githubusercontent.com/lionsoul2014/ip2region/master/data/ip2region.xdb" target="_blank"><span class="label label-primary" data-toggle="tooltip" title="点击下载 IP数据库 并上传到<br/><code>/app/ip2region/</code>">IP数据库不存在</span></a>';
if (!is_file($db)) {
return '<a href="https://raw.githubusercontent.com/lionsoul2014/ip2region/master/data/ip2region.xdb" target="_blank"><span class="label label-primary" data-toggle="tooltip" title="点击下载 IP数据库 并上传到<br/><code>/app/ip2region/</code>">IP数据库不存在</span></a>';
}
try { try {
require_once __DIR__ . '/ip2region/Ip2Region.php'; require_once __DIR__ . '/ip2region/Ip2Region.php';
$ip2region = new Ip2Region(); $ip2region = new Ip2Region();
/* 显示完整信息
$location = $ip2region->memorySearch($IP); $location = $ip2region->memorySearch($IP);
$location = $location['region']; $location = $location['region'];
$location = str_replace(array('0', '||'), '', $location); $location = str_replace(array('0', '||'), '', $location);
return $location; */
return $ip2region->simple($IP); // 显示简易信息
} catch (Exception $e) { } catch (Exception $e) {
return '查询失败: ' . $e->getMessage(); return $e->getMessage();
} }
} }
@ -1716,12 +1707,11 @@ function auto_delete()
} }
/** /**
* 记录登录日志 * 登录日志
* @param String $user 登录用户 * @param String $user 用户
* @param String $pass 登录密码 * @param String $pass 密码
* @param String $msg 登录提示 * @param String $msg 提示
*/ */
function write_login_log($user, $pass, $msg) function write_login_log($user, $pass, $msg)
{ {
$log_path = APP_ROOT . '/admin/logs/login/'; $log_path = APP_ROOT . '/admin/logs/login/';
@ -1732,53 +1722,32 @@ function write_login_log($user, $pass, $msg)
if (!is_file($log_file)) file_put_contents($log_file, '<?php /** 登录日志 */ exit; ?>' . PHP_EOL, FILE_APPEND | LOCK_EX); if (!is_file($log_file)) file_put_contents($log_file, '<?php /** 登录日志 */ exit; ?>' . PHP_EOL, FILE_APPEND | LOCK_EX);
/** 写入日志 */ /** 写入日志 */
$log = htmlentities('时间: ' . date('Y-m-d H:i:s') . ' IP: ' . real_ip() . ' 账号: ' . $user . ' 密码: ' . $pass . ' 消息: ' . $msg); $log = htmlentities(date('Y-m-d H:i:s') . ' IP: ' . real_ip() . ' 账号: ' . $user . ' 密码: ' . $pass . ' 提示: ' . $msg);
file_put_contents($log_file, $log . PHP_EOL, FILE_APPEND | LOCK_EX); file_put_contents($log_file, $log . PHP_EOL, FILE_APPEND | LOCK_EX);
} }
/** /**
* 其他上传 * curl检查远程链接是否有效
* 支持: FTP * @param String $url
* @param String $remoteFile 远程地址 * @param return boll
* @param String $localFile 本地地址
* @param String $way 使用方式 upload 上传 | delete 删除
*/ */
function validUrl($url)
function FTP_upload($remoteFile = null, $localFile = null, $way = 'upload')
{ {
global $config; $ch = curl_init();
$timeout = 10;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1); //将文件的信息作为数据流输出
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //将获取的信息以字符串返回
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); //设置等待时间
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //禁止验证对等证书
$contents = curl_exec($ch);
if (!$config['ftp_status']) exit; $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //获取请求状态码
curl_close($ch);
require_once __DIR__ . '/FtpClient/FtpClient.php'; if ($http_code != '200') {
require_once __DIR__ . '/FtpClient/FtpException.php'; return false;
require_once __DIR__ . '/FtpClient/FtpWrapper.php'; }
$ftp = new FtpClient();
// FTP 基本信息
$ftp->connect($config['ftp_host'], $config['ftp_ssl'], $config['ftp_port'], $config['ftp_time']);
// FTP账号密码
$ftp->login($config['ftp_user'], $config['ftp_pass']);
// FTP主动|被动
$ftp->pasv($config['ftp_pasv']);
switch ($way) {
case 'upload':
// 创建文件夹
$ftp->mkdir(pathinfo($remoteFile, PATHINFO_DIRNAME), 0755, true);
// 上传文件 远端->本地
$ftp->put($remoteFile, $localFile);
break;
case 'delete':
$ftp->delete($remoteFile);
return true; return true;
break;
}
$ftp->close();
// 上传完毕是否删除本地文件
if ($config['ftped_del_local']) {
@unlink($localFile);
}
} }
/** /**
@ -1789,48 +1758,111 @@ function FTP_upload($remoteFile = null, $localFile = null, $way = 'upload')
* @param String $localFile 本地地址 * @param String $localFile 本地地址
* @param String $way 使用方式 upload 上传 | delete 删除 * @param String $way 使用方式 upload 上传 | delete 删除
*/ */
function any_upload($remoteFile = null, $localFile = null, $way = 'upload') function any_upload($remoteFile = null, $localFile = null, $way = 'upload')
{ {
global $config; global $config;
if (!$config['ftp_status']) exit; if (!$config['ftp_status']) return null;
require_once __DIR__ . '/Ftp.php'; require_once __DIR__ . '/Ftp.php';
// 登录FTP // 登录FTP
try { try {
$ftp = new Ftp; $ftp = new Ftp;
if ($config['ftp_ssl'] === 1) {
$ftp->sslConnect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
} else {
$ftp->connect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']); $ftp->connect($config['ftp_host'], $config['ftp_port'], $config['ftp_time']);
}
$ftp->login($config['ftp_user'], $config['ftp_pass']); $ftp->login($config['ftp_user'], $config['ftp_pass']);
$ftp->pasv($config['ftp_pasv']); $ftp->pasv($config['ftp_pasv']);
} catch (FtpException $e) { } catch (FtpException $e) {
echo 'Error: ', $e->getMessage(); echo 'Error: ', $e->getMessage();
} }
// 获取文件相对目录
$dir = pathinfo($remoteFile, PATHINFO_DIRNAME);
// 隐藏上传目录
if ($config['hide_path']) {
$dir = str_replace($config['path'], '', $dir);
$remoteFile = str_replace($config['path'], '', $remoteFile);
}
switch ($way) { switch ($way) {
case 'upload': case 'upload':
try { try {
// 创建文件夹 // 递归创建目录
$dir = pathinfo($remoteFile, PATHINFO_DIRNAME);
if (!$ftp->isDir($dir)) { if (!$ftp->isDir($dir)) {
$ftp->mkDir($dir); $ftp->mkDirRecursive($dir);
} }
// 上传文件 远端->本地 模式: $config['ftp_mode']
// 上传文件 远端->本地 $ftp->put($remoteFile, $localFile, 2);
$ftp->put($remoteFile, $localFile);
} catch (FtpException $e) { } catch (FtpException $e) {
echo 'Error: ', $e->getMessage(); echo 'Error: ', $e->getMessage();
} }
break; break;
case 'delete': case 'delete':
if ($config['ftp_delloc_sync'] === 0) return true;
$ftp->tryDelete($remoteFile); $ftp->tryDelete($remoteFile);
break; break;
case 'list':
return $ftp->nList($remoteFile);
break;
case 'rename':
try {
// 获取文件相对目录
$dir = pathinfo($localFile, PATHINFO_DIRNAME);
// 隐藏上传目录
if ($config['hide_path']) {
$dir = str_replace($config['path'], '', $dir);
$localFile = str_replace($config['path'], '', $localFile);
}
// 递归创建目录
if (!$ftp->isDir($dir)) {
$ftp->mkDirRecursive($dir);
}
// 此处 $remoteFile为源文件名及路径 $localFile为新文件名及路径
$ftp->rename($remoteFile, $localFile);
} catch (FtpException $e) {
echo 'Error: ', $e->getMessage();
}
break;
} }
// 关闭FTP // 关闭FTP
$ftp->close(); $ftp->close();
// FTP上传后是否删除本地文件 // FTP上传后是否删除本地文件
if ($config['ftp_del_local']) { if ($config['ftp_complete_del_local']) {
@unlink($localFile); @unlink($localFile);
} }
} }
/**
* 分片上传
* @param $target_name 名称
* @return Sting $target_name
*/
function chunk($target_name)
{
global $config;
// 分片缓存目录
$temp_dir = APP_ROOT . $config['path'] . 'cache/' . $target_name . '/';
// 分片合并后的文件
$target_file = APP_ROOT . $config['path'] . 'cache/' . $target_name;
// 储存分片
if (!is_dir($temp_dir)) mkdir($temp_dir, 0755, true);
// 移动缓存分片
move_uploaded_file($_FILES['file']['tmp_name'], $temp_dir . $_REQUEST['chunk']);
// 合并分片
if ($_REQUEST['chunk'] == $_REQUEST['chunks'] - 1) { // 最后一个分片
if (!is_dir($target_file)) mkdir($target_file, 0755, true);
$handle = fopen($target_name, 'x+');
for ($i = 0; $i < $_REQUEST['chunks']; $i++) {
fwrite($handle, file_get_contents($temp_dir . $i));
}
fclose($handle);
deldir($temp_dir); // 删除临时目录
}
return $target_name;
}

View File

@ -12,15 +12,16 @@
<title><?php echo $config['title']; ?></title> <title><?php echo $config['title']; ?></title>
<meta name="keywords" content="<?php echo $config['keywords']; ?>" /> <meta name="keywords" content="<?php echo $config['keywords']; ?>" />
<meta name="description" content="<?php echo $config['description']; ?>" /> <meta name="description" content="<?php echo $config['description']; ?>" />
<link rel="shortcut icon" href="<?php static_cdn(); ?>/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" type="image/x-icon" href="<?php static_cdn(); ?>/favicon.ico" />
<link href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/css/zui.min.css">
<link href="<?php static_cdn(); ?>/public/static/zui/theme/zui-theme-<?php echo $config['theme']; ?>.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/nprogress/nprogress.min.css">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.0.min.js"></script> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/theme/zui-theme-<?php echo $config['theme']; ?>.css">
<script src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/jquery/jquery-3.6.4.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/js/zui.min.js"></script>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/html5shiv.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/html5shiv.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/respond.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/respond.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/excanvas.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/ieonly/excanvas.js"></script>
<![endif]--> <![endif]-->
<?php /** 页头自定义代码 */ echo $config['customize']; ?> <?php /** 页头自定义代码 */ echo $config['customize']; ?>
</head> </head>
@ -34,7 +35,7 @@
</div> </div>
<div class="collapse navbar-collapse navbar-collapse-EasyImage"> <div class="collapse navbar-collapse navbar-collapse-EasyImage">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<li><a href="<?php echo $config['domain']; ?>/index.php"><i class="icon icon-home"></i> 首页</a></li> <li><a href="<?php echo $config['domain']; ?>"><i class="icon icon-home"></i> 首页</a></li>
<?php /** 非管理或未开启不显示广场 */ if ($config['showSwitch'] || is_who_login('admin')) : ?> <?php /** 非管理或未开启不显示广场 */ if ($config['showSwitch'] || is_who_login('admin')) : ?>
<li><a href="<?php echo $config['domain']; ?>/app/list.php"><i class="icon icon-th"></i> 广场<span class="label label-badge label-primary"><?php echo get_file_by_glob(APP_ROOT . config_path(), 'number'); ?></span></a></li> <li><a href="<?php echo $config['domain']; ?>/app/list.php"><i class="icon icon-th"></i> 广场<span class="label label-badge label-primary"><?php echo get_file_by_glob(APP_ROOT . config_path(), 'number'); ?></span></a></li>
<?php endif; ?> <?php endif; ?>

View File

@ -14,7 +14,7 @@ include_once __DIR__ . "/header.php";
</div> </div>
<div class="col-md-12 history_clear"> <div class="col-md-12 history_clear">
</div> </div>
<script src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>

View File

@ -7,20 +7,16 @@ if (!$config['show_exif_info'] && !is_who_login('admin')) exit(header('Location:
if (isset($_GET['img'])) { if (isset($_GET['img'])) {
// 过滤特殊符号 // 过滤特殊符号
$getIMG = strip_tags($_GET['img']); $getIMG = strip_tags($_GET['img']);
$del_url = $config['domain'] . $getIMG;
} elseif (isset($_GET['history'])) { } elseif (isset($_GET['history'])) {
// 过滤特殊符号 // 过滤特殊符号
if ($config['hide_path']) { if ($config['hide_path']) {
$getIMG = $config['path'] . ltrim(strip_tags($_GET['history']), '/'); $getIMG = $config['path'] . ltrim(strip_tags($_GET['history']), '/');
} else { } else {
$getIMG = strip_tags($_GET['history']); $getIMG = strip_tags($_GET['history']);
} }
$del_url = $config['domain'] . $getIMG;
} else { } else {
// 未获取到图片地址 // 未获取到图片地址
$getIMG = "/public/images/404.png"; $getIMG = "/public/images/404.png";
$del_url = "#";
} }
@ -63,11 +59,11 @@ $upTime = filemtime($imgABPath);
// 广告 // 广告
if ($config['ad_top']) echo $config['ad_top_info']; if ($config['ad_top']) echo $config['ad_top_info'];
?> ?>
<div class="col-md-12"> <div class="col-md-12" style="margin-bottom:10px;">
<div class="col-md-5" style="text-align: center;"> <div class="col-md-6">
<img data-toggle="lightbox" src="<?php echo $img_url; ?>" id="img1" class="img-rounded" height="432px" data-caption="<?php echo pathinfo($img_url, PATHINFO_FILENAME); ?>的详细信息" alt="<?php echo $img_url; ?>" /> <img src="<?php echo $img_url; ?>" class="img-rounded" height="436px" width="540px" data-toggle="lightbox" id="img1" data-caption="<?php echo pathinfo($img_url, PATHINFO_FILENAME); ?>的详细信息" alt="<?php echo $img_url; ?>" />
</div> </div>
<div class="col-md-6 table-responsive table-condensed" style="margin-top: 10px;"> <div class="col-md-6 table-responsive table-condensed">
<table class="table table-hover table-striped table-bordered text-nowrap"> <table class="table table-hover table-striped table-bordered text-nowrap">
<tbody> <tbody>
<tr> <tr>
@ -86,6 +82,10 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<td>图片宽高</td> <td>图片宽高</td>
<td><span id="wh"></span>px</td> <td><span id="wh"></span>px</td>
</tr> </tr>
<!-- <tr>
<td>使用设备</td>
<td id="makeAndModel"></td>
</tr> -->
<tr> <tr>
<td>上传时间</td> <td>上传时间</td>
<td><?php echo $logs[$logsName]['date']; ?></td> <td><?php echo $logs[$logsName]['date']; ?></td>
@ -128,19 +128,23 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<td>文件操作</td> <td>文件操作</td>
<td> <td>
<a class="btn btn-mini btn-primary" href="<?php echo $img_url; ?>" target="_blank"><i class="icon icon-picture"> 查看</i></a> <a class="btn btn-mini btn-primary" href="<?php echo $img_url; ?>" target="_blank"><i class="icon icon-picture"> 查看</i></a>
<!-- <a class="btn btn-mini btn-primary" data-toggle="collapse" data-target="#collapseExample"><i class="icon icon-caret-down"> Exif</i></a> -->
<a class="btn btn-mini btn-primary" href="" onclick="window.location.replace;"><i class="icon icon-spin icon-refresh"></i> 刷新</a> <a class="btn btn-mini btn-primary" href="" onclick="window.location.replace;"><i class="icon icon-spin icon-refresh"></i> 刷新</a>
<a class="btn btn-mini btn-primary" href="/app/down.php?dw=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-cloud-download"> 下载</i></a> <a class="btn btn-mini btn-primary" href="/app/down.php?dw=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-cloud-download"> 下载</i></a>
<?php if (!empty($config['report']) && !is_who_login('admin')) : ?> <?php if (!empty($config['report']) && !is_who_login('admin')) : ?>
<a class="btn btn-mini btn-warning" href="<?php echo $config['report'] . '?Website1=' . $img_url; ?>" target="_blank"><i class="icon icon-question-sign"> 举报</i></a> <a class="btn btn-mini btn-warning" href="<?php echo $config['report'] . '?Website1=' . $img_url; ?>" target="_blank"><i class="icon icon-question-sign"> 举报</i></a>
<?php endif; ?> <?php endif; ?>
<?php if (is_who_login('admin')) : ?> <?php if (is_who_login('admin')) : ?>
<a class="btn btn-mini btn-warning" href="/app/del.php?recycle_url=<?php echo $getIMG; ?>" target="_blank"><i class="icon icon-undo"> 回收</i></a> <a class="btn btn-mini btn-warning" href="#" onclick="ajax_post('<?php echo $getIMG; ?>','recycle')"><i class="icon icon-undo"> 回收</i></a>
<a class="btn btn-mini btn-warning" href="/app/del.php?url=<?php echo $del_url; ?>" target="_blank"><i class="icon icon-trash"> 删除</i></a> <a class="btn btn-mini btn-warning" href="#" onclick="ajax_post('<?php echo $getIMG; ?>')"><i class="icon icon-trash"> 删除</i></a>
<?php endif; ?> <?php endif; ?>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="collapse" id="collapseExample">
<pre style="background-color: rgba(0, 0, 0, 0);" id="allMetaDataSpan"></pre>
</div>
<h4 class="with-padding hl-gray"><i class="icon icon-info-sign"> 此图片来自网友上传, 不代表<a href="/admin/terms.php" target="_blank">本站立场</a>, 若有侵权, 请举报或联系管理员!</i></h4> <h4 class="with-padding hl-gray"><i class="icon icon-info-sign"> 此图片来自网友上传, 不代表<a href="/admin/terms.php" target="_blank">本站立场</a>, 若有侵权, 请举报或联系管理员!</i></h4>
</div> </div>
</div> </div>
@ -148,15 +152,15 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<div class="col-md-6" style="padding-bottom: 10px;"> <div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="icon icon-link"></i> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="input-group-addon"><i class="icon icon-link"></i> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="links" onclick="copyText()" value="<?php echo $img_url; ?>"> <input type="text" class="form-control" id="links" value="<?php echo $img_url; ?>">
<span class="input-group-btn"><button class="btn btn-default copyBtn1" type="button">复制</button></span> <span class="input-group-btn"><button class="btn btn-default btnLinks" onclick="uploadCopy('links','.btnLinks')" type="button">复制</button></span>
</div> </div>
</div> </div>
<div class="col-md-6" style="padding-bottom: 10px;"> <div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="icon icon-chat"></i> 论坛代码&nbsp;&nbsp;&nbsp;</span> <span class="input-group-addon"><i class="icon icon-chat"></i> 论坛代码&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="bbscode" value="[img]<?php echo $img_url; ?>[/img]"> <input type="text" class="form-control" id="bbscode" value="[img]<?php echo $img_url; ?>[/img]">
<span class="input-group-btn"><button class="btn btn-default copyBtn2" type="button">复制</button></span> <span class="input-group-btn"><button class="btn btn-default btnBbscode" onclick="uploadCopy('bbscode','.btnBbscode')" type="button">复制</button></span>
</div> </div>
</div> </div>
</div> </div>
@ -165,14 +169,14 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="icon icon-code"></i> MarkDown</span> <span class="input-group-addon"><i class="icon icon-code"></i> MarkDown</span>
<input type="text" class="form-control" id="markdown" value="![简单图床 - EasyImage](<?php echo $img_url; ?>)"> <input type="text" class="form-control" id="markdown" value="![简单图床 - EasyImage](<?php echo $img_url; ?>)">
<span class="input-group-btn"><button class="btn btn-default copyBtn3" type="button">复制</button></span> <span class="input-group-btn"><button class="btn btn-default btnMarkDown" onclick="uploadCopy('markdown','.btnMarkDown')" type="button">复制</button></span>
</div> </div>
</div> </div>
<div class="col-md-6" style="padding-bottom: 10px;"> <div class="col-md-6" style="padding-bottom: 10px;">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="icon icon-html5"></i> HTML&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="input-group-addon"><i class="icon icon-html5"></i> HTML&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<input type="text" class="form-control" id="html" value='<img src="<?php echo $img_url; ?>" alt="简单图床 - EasyImage" />'> <input type="text" class="form-control" id="html" value='<img src="<?php echo $img_url; ?>" alt="简单图床 - EasyImage" />'>
<span class="input-group-btn"><button class="btn btn-default copyBtn4" type="button">复制</button></span> <span class="input-group-btn"><button class="btn btn-default btnHtml" onclick="uploadCopy('html','.btnHtml')" type="button">复制</button></span>
</div> </div>
</div> </div>
</div> </div>
@ -183,9 +187,10 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<h4 class="header-dividing">当月随机图片:</h4> <h4 class="header-dividing">当月随机图片:</h4>
<div class="cards cards-borderless"> <div class="cards cards-borderless">
<?php if ($logs[$logsName]['port'] != 0) : for ($i = 0; $i <= 7; $i++) : $randName = array_rand($logs, 1) ?> <?php if ($logs[$logsName]['port'] != 0) : for ($i = 0; $i <= 7; $i++) : $randName = array_rand($logs, 1) ?>
<div class="col-md-4 col-sm-6 col-lg-3">
<div class="col-md-3">
<a class="card" href="?img=<?php echo $logs[$randName]['path']; ?>" target="_blank"> <a class="card" href="?img=<?php echo $logs[$randName]['path']; ?>" target="_blank">
<img src="thumb.php?img=<?php echo $logs[$randName]['path']; ?>"> <img src="thumb.php?img=<?php echo $logs[$randName]['path']; ?>" width="100%">
<div class="caption"><?php echo $logs[$randName]['source']; ?></div> <div class="caption"><?php echo $logs[$randName]['source']; ?></div>
</a> </a>
</div> </div>
@ -196,100 +201,54 @@ if ($config['ad_top']) echo $config['ad_top_info'];
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<script src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script>
<script src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/imgready/imgready.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<!-- <script type="application/javascript" src="https://fastly.jsdelivr.net/gh/icret/EasyImages2.0@2.6.5/public/static/exif/exif.js"></script> -->
<script> <script>
// 获取图片长宽 https://www.cnblogs.com/houxianzhou/p/14807983.html // POST 删除提交
var imgReady = (function() { function ajax_post(url, mode = 'delete') {
var list = [], $.post("del.php", {
intervalId = null, url: url,
// 用来执行队列 mode: mode
tick = function() {
var i = 0;
for (; i < list.length; i++) {
list[i].end ? list.splice(i--, 1) : list[i]();
};
!list.length && stop();
}, },
// 停止所有定时器队列 function(data, status) {
stop = function() { console.log(data)
clearInterval(intervalId); let res = JSON.parse(data);
intervalId = null; new $.zui.Messager(res.msg, {
}; type: res.type,
return function(url, ready, load, error) { icon: res.icon
var onready, width, height, newWidth, newHeight, }).show();
img = new Image(); // 延时2秒刷新
img.src = url; window.setTimeout(function() {
// 如果图片被缓存,则直接返回缓存数据 window.location.reload();
if (img.complete) { }, 2000)
ready.call(img);
load && load.call(img);
return;
};
width = img.width;
height = img.height;
// 加载错误后的事件
img.onerror = function() {
error && error.call(img);
onready.end = true;
img = img.onload = img.onerror = null;
};
// 图片尺寸就绪
onready = function() {
newWidth = img.width;
newHeight = img.height;
if (newWidth !== width || newHeight !== height || newWidth * newHeight > 1024) {
// 如果图片已经在其他地方加载可使用面积检测
ready.call(img);
onready.end = true;
};
};
onready();
// 完全加载完毕的事件
img.onload = function() {
// onload在定时器时间差范围内可能比onready快
// 这里进行检查并保证onready优先执行
!onready.end && onready();
load && load.call(img);
// IE gif动画会循环执行onload置空onload即可
img = img.onload = img.onerror = null;
};
// 加入队列中定期执行
if (!onready.end) {
list.push(onready);
// 无论何时只允许出现一个定时器,减少浏览器性能损耗
if (intervalId === null) intervalId = setInterval(tick, 40);
};
};
})();
imgReady('<?php echo $img_url; ?>', function() {
// alert('size ready: width=' + this.width + '; height=' + this.height);
var hw = document.getElementById("wh");
hw.innerHTML = this.width + "x" + this.height
});
// Exif信息
/*
window.onload = getExif;
function getExif() {
var img1 = document.getElementById("img1");
EXIF.getData(img1, function() {
var make = EXIF.getTag(this, "Make");
var model = EXIF.getTag(this, "Model");
var makeAndModel = document.getElementById("makeAndModel");
makeAndModel.innerHTML = `${make} ${model}`;
});
var img2 = document.getElementById("img1");
EXIF.getData(img2, function() {
var allMetaData = EXIF.getAllTags(this);
var allMetaDataSpan = document.getElementById("allMetaDataSpan");
allMetaDataSpan.innerHTML = EXIF.pretty(this);;
}); });
} }
*/
// 获取图片长宽
$.zui.imgReady($('#img1')[0].src, function() {
$('#wh').text(this.width + "x" + this.height);
});
// // Exif信息
// window.onload = getExif;
// function getExif() {
// var img1 = document.getElementById("img1");
// EXIF.getData(img1, function() {
// var make = EXIF.getTag(this, "Make");
// var model = EXIF.getTag(this, "Model");
// var makeAndModel = document.getElementById("makeAndModel");
// makeAndModel.innerHTML = `${make} ${model}`;
// });
// var img2 = document.getElementById("img1");
// EXIF.getData(img2, function() {
// var allMetaData = EXIF.getAllTags(this);
// var allMetaDataSpan = document.getElementById("allMetaDataSpan");
// allMetaDataSpan.innerHTML = EXIF.pretty(this);;
// });
// }
//禁用右键 //禁用右键
document.onkeydown = function() { document.onkeydown = function() {

View File

@ -20,7 +20,7 @@ class Ip2Region
*/ */
public function __construct() public function __construct()
{ {
class_exists('XdbSearcher') || include(__DIR__ . '/XdbSearcher.php'); class_exists('XdbSearcher') or include __DIR__ . '/XdbSearcher.php';
$this->searcher = XdbSearcher::newWithFileOnly(__DIR__ . '/ip2region.xdb'); $this->searcher = XdbSearcher::newWithFileOnly(__DIR__ . '/ip2region.xdb');
} }
@ -57,6 +57,20 @@ class Ip2Region
return $this->memorySearch($ip); return $this->memorySearch($ip);
} }
/**
* 直接查询并返回名称
* @param string $ip
* @return string
* @throws \Exception
*/
public function simple($ip)
{
$geo = $this->memorySearch($ip);
$arr = explode('|', str_replace(['0|'], '|', isset($geo['region']) ? $geo['region'] : ''));
if (($last = array_pop($arr)) === '内网IP') $last = '';
return join('', $arr) . (empty($last) ? '' : "[{$last}]");
}
/** /**
* destruct method * destruct method
* resource destroy * resource destroy

View File

@ -74,8 +74,8 @@ if ($config['ad_top']) echo $config['ad_top_info'];
<a href="<?php echo $config['report'] . '?Website1=' . $linkUrl; ?>" target="_blank"><i class="icon icon-question-sign" data-toggle="tooltip" title="举报文件" style="margin-left:10px;"></i></a> <a href="<?php echo $config['report'] . '?Website1=' . $linkUrl; ?>" target="_blank"><i class="icon icon-question-sign" data-toggle="tooltip" title="举报文件" style="margin-left:10px;"></i></a>
<?php endif; ?> <?php endif; ?>
<?php if (is_who_login('admin')) : ?> <?php if (is_who_login('admin')) : ?>
<a href="/app/del.php?recycle_url=<?php echo $relative_path; ?>" target="_blank" data-toggle="tooltip" title="回收文件" style="margin-left:10px;"><i class="icon icon-undo"></i></a> <a href="#" onclick="ajax_post('<?php echo $relative_path; ?>','recycle')" data-toggle="tooltip" title="回收文件" style="margin-left:10px;"><i class="icon icon-undo"></i></a>
<a href="/app/del.php?url=<?php echo $relative_path; ?>" target="_blank" data-toggle="tooltip" title="删除文件" style="margin-left:10px;"><i class="icon icon-trash"></i></a> <a href="#" onclick="ajax_post('<?php echo $relative_path; ?>')" data-toggle="tooltip" title="删除文件" style="margin-left:10px;"><i class="icon icon-trash"></i></a>
<label class="text-primary"><input type="checkbox" id="url" name="checkbox" value="<?php echo $relative_path; ?>"> 选择</label> <label class="text-primary"><input type="checkbox" id="url" name="checkbox" value="<?php echo $relative_path; ?>"> 选择</label>
<?php endif; ?> <?php endif; ?>
</div> </div>
@ -160,30 +160,11 @@ if ($config['ad_top']) echo $config['ad_top_info'];
</div> </div>
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/EasyImage.css"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/EasyImage.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.css"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.css">
<link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.css"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.css">
<style> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.css">
/* 返回顶部 */
.btn-back-to-top {
padding: 0.5rem 1rem;
position: fixed;
right: 2rem;
bottom: 1rem;
z-index: 2;
-webkit-transition: -webkit-transform 0.2s ease;
transition: transform 0.2s ease;
-webkit-transform: translateY(200%);
transform: translateY(200%);
}
.btn-back-to-top.scrolled {
-webkit-transform: translateY(0);
transform: translateY(0);
}
</style>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/viewjs/viewer.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/lazyload/lazyload.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/bootbox/bootbox.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/clipboard/clipboard.min.js"></script>
<script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datetimepicker/datetimepicker.min.js"></script>
<script> <script>
@ -192,6 +173,49 @@ if ($config['ad_top']) echo $config['ad_top_info'];
url: 'data-original', url: 'data-original',
}); });
// POST 删除提交
function ajax_post(url, mode = 'delete') {
bootbox.confirm({
message: "确认执行 " + mode + " 操作?",
buttons: {
confirm: {
label: '确定',
className: 'btn-success'
},
cancel: {
label: '取消',
className: 'btn-danger'
}
},
callback: function(result) {
if (result == true) {
$.post("del.php", {
url: url,
mode: mode
},
function(data, status) {
console.log(data)
let res = JSON.parse(data);
new $.zui.Messager(res.msg, {
type: res.type,
icon: res.icon
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 2000)
});
} else {
new $.zui.Messager("取消 " + mode, {
type: "primary", // 定义颜色主题
icon: "info-sign" // 定义消息图标
}).show();
}
}
});
}
// 复制url // 复制url
var clipboard = new Clipboard('.copy'); var clipboard = new Clipboard('.copy');
clipboard.on('success', function(e) { clipboard.on('success', function(e) {
@ -251,7 +275,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
check_val.push(obj[k].value); check_val.push(obj[k].value);
console.log(check_val); console.log(check_val);
} }
$.post("./post_del.php", { $.post("del.php", {
'recycle_url_array': check_val 'recycle_url_array': check_val
}, ); }, );
new $.zui.Messager("放入回收站成功", { new $.zui.Messager("放入回收站成功", {
@ -298,7 +322,7 @@ if ($config['ad_top']) echo $config['ad_top_info'];
check_val.push(obj[k].value); check_val.push(obj[k].value);
console.log(check_val); console.log(check_val);
} }
$.post("./post_del.php", { $.post("del.php", {
'del_url_array': check_val 'del_url_array': check_val
}, },
function(data) { function(data) {
@ -331,6 +355,14 @@ if ($config['ad_top']) echo $config['ad_top_info'];
}); });
} }
//懒加载
var lazy = new Lazy({
onload: function(elem) {
console.log(elem)
},
delay: 300,
})
// 返回顶部 // 返回顶部
var back_to_top_button = jQuery('.btn-back-to-top'); var back_to_top_button = jQuery('.btn-back-to-top');
jQuery(window).scroll(function() { jQuery(window).scroll(function() {
@ -350,14 +382,6 @@ if ($config['ad_top']) echo $config['ad_top_info'];
return false; return false;
}); });
//懒加载
var lazy = new Lazy({
onload: function(elem) {
console.log(elem)
},
delay: 300,
})
// 按日期浏览 // 按日期浏览
$(".form-date").datetimepicker({ $(".form-date").datetimepicker({
weekStart: 1, weekStart: 1,

View File

@ -1,32 +0,0 @@
<?php
/**
* 删除/回收文件页面
* @author Icret
* 2022-2-23 11:01:52
*/
require_once __DIR__ . '/function.php';
if (!is_who_login('admin')) {
exit('Not Logged!');
}
// 删除文件
if (isset($_POST['del_url_array'])) {
$del_url_array = $_POST['del_url_array'];
$del_num = count($del_url_array);
for ($i = 0; $i < $del_num; $i++) {
getDel($del_url_array[$i], 'url');
// FTP
// any_upload($del_url_array[$i], null, 'delete');
}
}
// 回收文件
if (isset($_POST['recycle_url_array'])) {
$recycle_url_array = $_POST['recycle_url_array'];
$del_num = count($recycle_url_array);
for ($i = 0; $i < $del_num; $i++) {
checkImg($recycle_url_array[$i], 3);
}
}

View File

@ -1,11 +0,0 @@
<?php
/**
* 2023-01-29
* 随机图片显示
*/
$img_array = glob('../public/images/*.{gif,jpg,png,jpeg,webp,bmp}', GLOB_BRACE);
if (count($img_array) == 0) die('没找到图片文件。请先上传一些图片到 ' . dirname(__FILE__) . '/images/ 文件夹');
header('Content-Type: image/png');
echo (file_get_contents($img_array[array_rand($img_array)]));

View File

@ -55,7 +55,7 @@ define('MEMORY_LIMIT', '256M');
define('DEFAULT_WIDTH', $config['thumbnail_w']); define('DEFAULT_WIDTH', $config['thumbnail_w']);
define('DEFAULT_HEIGHT', $config['thumbnail_h']); define('DEFAULT_HEIGHT', $config['thumbnail_h']);
define('FILE_CACHE_PREFIX', 'EasyImage'); define('FILE_CACHE_PREFIX', 'EasyImage');
define('DEFAULT_ZC', 1); define('DEFAULT_ZC', 0);
define('MAX_WIDTH', 10240); define('MAX_WIDTH', 10240);
define('MAX_HEIGHT', 10240); define('MAX_HEIGHT', 10240);

View File

@ -4,15 +4,20 @@ namespace Verot\Upload;
require __DIR__ . '/function.php'; require __DIR__ . '/function.php';
require __DIR__ . '/class.upload.php'; require __DIR__ . '/class.upload.php';
// 定义返回头信息为Json
header("Content-type: application/json; charset=utf-8");
// 检查登录 // 检查登录
if ($config['mustLogin']) { if ($config['mustLogin']) {
if (!is_who_login('status')) { if (!is_who_login('status')) {
exit(json_encode(array( exit(json_encode(
array(
"result" => "failed", "result" => "failed",
"code" => 401, "code" => 401,
"message" => "本站已开启登陆上传,您尚未登陆", "message" => "本站已开启登陆上传,您尚未登陆",
))); ),
JSON_UNESCAPED_UNICODE
));
} }
} }
@ -23,50 +28,65 @@ if (empty($_FILES['file'])) {
"result" => "failed", "result" => "failed",
"code" => 204, "code" => 204,
"message" => "没有选择上传的文件", "message" => "没有选择上传的文件",
) ),
JSON_UNESCAPED_UNICODE
)); ));
} }
// sign : 前端生成的时间戳 time() - $_POST['sign'] = 从选择文件到上传完毕的耗费时间 // sign : 前端生成的时间戳 time() - $_POST['sign'] = 从选择文件到上传完毕的耗费时间
if (empty($_POST['sign']) || time() - $_POST['sign'] > 12306) { if (empty($_POST['sign']) || time() - $_POST['sign'] > 12306) {
exit(json_encode(array( exit(json_encode(
array(
"result" => "failed", "result" => "failed",
"code" => 403, "code" => 403,
"systime" => time(), "systime" => time(),
"message" => "上传签名错误,请刷新重试", "message" => "上传签名错误,请刷新重试",
))); ),
JSON_UNESCAPED_UNICODE
));
} }
// 黑/白IP名单上传 // 黑/白IP名单上传
if ($config['check_ip']) { if ($config['check_ip']) {
if (checkIP(null, $config['check_ip_list'], $config['check_ip_model'])) { if (checkIP(null, $config['check_ip_list'], $config['check_ip_model'])) {
// 上传错误 code:403 未授权IP // 上传错误 code:403 未授权IP
exit(json_encode(array( exit(json_encode(
array(
"result" => "failed", "result" => "failed",
"code" => 403, "code" => 403,
"message" => "黑名单内或白名单外用户不允许上传", "message" => "你不能上传任何文件",
))); ),
JSON_UNESCAPED_UNICODE
));
} }
} }
// 根据IP限制游客每日上传数量 // 根据IP限制游客每日上传数量
if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) { if ($config['ip_upload_counts'] > 0 && !is_who_login('status')) {
if (false == get_ip_upload_log_counts(real_ip())) { if (false === get_ip_upload_log_counts(real_ip())) {
exit(json_encode( exit(json_encode(
array( array(
"result" => "failed", "result" => "failed",
"code" => 403, "code" => 403,
"message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']), "message" => sprintf("游客限制每日上传 %d 张", $config['ip_upload_counts']),
) ),
JSON_UNESCAPED_UNICODE
)); ));
} }
} }
$handle = new Upload($_FILES['file'], 'zh_CN'); // 分片上传
if ($config['chunks']) {
$chunk = chunk($_POST['name']);
// exit($chunk);
$handle = new Upload($chunk, 'zh_CN');
} else {
$handle = new Upload($_FILES['file'], 'zh_CN');
}
if ($handle->uploaded) { if ($handle->uploaded) {
// 允许上传的mime类型 // 允许上传的mime类型
if ($config['allowed'] === 1) { if ($config['allowed']) {
$handle->allowed = array('image/*'); $handle->allowed = array('image/*');
} }
@ -79,14 +99,14 @@ if ($handle->uploaded) {
"result" => "failed", "result" => "failed",
"code" => 205, "code" => 205,
"message" => "请勿上传非法文件", "message" => "请勿上传非法文件",
) ),
JSON_UNESCAPED_UNICODE
)); ));
} }
} }
// 文件命名 // 文件命名
$handle->file_new_name_body = imgName($handle->file_src_name_body); $handle->file_new_name_body = imgName($handle->file_src_name_body);
// 最大上传限制 // 最大上传限制
$handle->file_max_size = $config['maxSize']; $handle->file_max_size = $config['maxSize'];
// 最大宽度 // 最大宽度
@ -108,8 +128,7 @@ if ($handle->uploaded) {
// JPEG 图像的压缩质量 1-100 // JPEG 图像的压缩质量 1-100
$handle->jpeg_quality = $config['compress_ratio']; $handle->jpeg_quality = $config['compress_ratio'];
/* 等比例缩减图片 放到前端了*/ /* 等比例缩减图片 放到前端了
/*
if ($config['imgRatio']) { if ($config['imgRatio']) {
$handle->image_resize = true; $handle->image_resize = true;
$handle->image_x = $config['image_x']; $handle->image_x = $config['image_x'];
@ -128,17 +147,15 @@ if ($handle->uploaded) {
// 默认目录 // 默认目录
$Img_path = config_path(); $Img_path = config_path();
// 开启管理员自定义目录 // 开启管理员自定义目录
if ($config['admin_path_status']) { if ($config['admin_path_status']) {
if (checkLogin() == 204) { if (checkLogin() === 204) {
$Img_path = config_path($config['admin_path'] . date('/Y/m/d/')); $Img_path = config_path($config['admin_path'] . date('/Y/m/d/'));
} }
} }
// 开启上传者单独目录 // 开启上传者单独目录
if ($config['guest_path_status']) { if ($config['guest_path_status']) {
if (checkLogin() == 205) { if (checkLogin() === 205) {
$getCok = json_decode($_COOKIE['auth']); $getCok = json_decode($_COOKIE['auth']);
$Img_path = config_path($getCok[0] . date('/Y/m/d/')); $Img_path = config_path($getCok[0] . date('/Y/m/d/'));
} }
@ -149,8 +166,6 @@ if ($handle->uploaded) {
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg // 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
if ($handle->processed) { if ($handle->processed) {
header('Content-type:text/json');
// 图片相对路径 // 图片相对路径
$pathIMG = $Img_path . $handle->file_dst_name; $pathIMG = $Img_path . $handle->file_dst_name;
// 图片访问网址 // 图片访问网址
@ -159,13 +174,13 @@ if ($handle->uploaded) {
$processUrl = $config['domain'] . $pathIMG; $processUrl = $config['domain'] . $pathIMG;
// 隐藏config文件中的path目录,需要搭配网站设置 // 隐藏config文件中的path目录,需要搭配网站设置
if ($config['hide_path'] == 1) { if ($config['hide_path'] === 1) {
$imageUrl = str_replace($config['path'], '/', $imageUrl); $imageUrl = str_replace($config['path'], '/', $imageUrl);
} }
// 源图保护 key值是由crc32加密的hide_key // 源图保护 key值是由crc32加密的hide_key
// $hide_original = $config['hide'] == 1 ? $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])) : $imageUrl; // $hide_original = $config['hide'] == 1 ? $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])) : $imageUrl;
if ($config['hide'] == 1) { if ($config['hide'] === 1) {
$imageUrl = $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])); $imageUrl = $config['domain'] . '/app/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
} }
@ -178,7 +193,7 @@ if ($handle->uploaded) {
// 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30 // 当设置访问生成缩略图时自动生成 2022-12-30 修正 2023-01-30
$handleThumb = $config['domain'] . '/app/thumb.php?img=' . $pathIMG; $handleThumb = $config['domain'] . '/app/thumb.php?img=' . $pathIMG;
if ($config['thumbnail'] == 2) { if ($config['thumbnail'] === 2) {
// 自定义缩略图长宽 // 自定义缩略图长宽
$handle->image_resize = true; $handle->image_resize = true;
$handle->image_x = $config['thumbnail_w']; $handle->image_x = $config['thumbnail_w'];
@ -200,10 +215,9 @@ if ($handle->uploaded) {
"del" => $delUrl, "del" => $delUrl,
// "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12 // "memory" => getDistUsed(memory_get_peak_usage()), // 占用内存 2023-02-12
); );
echo json_encode($reJson); echo json_encode($reJson, JSON_UNESCAPED_UNICODE);
$handle->clean(); // 如果取消上传生成缩略图需要恢复此选项功能 $handle->clean(); // 如果取消上传生成缩略图需要恢复此选项功能
} else { } else { // 上传错误 code:206 客户端文件有问题
// 上传错误 code:206 客户端文件有问题
$reJson = array( $reJson = array(
"result" => "failed", "result" => "failed",
"code" => 206, "code" => 206,
@ -212,13 +226,10 @@ if ($handle->uploaded) {
// 'log' => $handle->log, // 仅用作调试用 // 'log' => $handle->log, // 仅用作调试用
); );
unset($handle); unset($handle);
header('Content-Type:application/json; charset=utf-8');
exit(json_encode($reJson, JSON_UNESCAPED_UNICODE)); exit(json_encode($reJson, JSON_UNESCAPED_UNICODE));
} }
/** 后续处理 */ /** 后续处理 */
// 上传至其他位置
// @any_upload($pathIMG, APP_ROOT . $pathIMG, 'upload');
// 使用fastcgi_finish_request操作 // 使用fastcgi_finish_request操作
if (function_exists('fastcgi_finish_request')) fastcgi_finish_request(); if (function_exists('fastcgi_finish_request')) fastcgi_finish_request();
// 同IP上传日志 // 同IP上传日志
@ -231,6 +242,8 @@ if ($handle->uploaded) {
@water($handle->file_dst_pathname); @water($handle->file_dst_pathname);
// 压缩 // 压缩
@process_compress($handle->file_dst_pathname); @process_compress($handle->file_dst_pathname);
// 上传至其他位置
@any_upload($pathIMG, APP_ROOT . $pathIMG, 'upload');
unset($handle); unset($handle);
} }

View File

@ -58,14 +58,34 @@ try {
</div> </div>
<p class="text-muted" style="font-size:10px;"><i class="modal-icon icon-info"></i> 建议使用分辨率 1366*768px; 当前日志文件: <?php echo $logFile; ?></p> <p class="text-muted" style="font-size:10px;"><i class="modal-icon icon-info"></i> 建议使用分辨率 1366*768px; 当前日志文件: <?php echo $logFile; ?></p>
</div> </div>
<link href="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.css">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/datagrid/zui.datagrid.min.js"></script>
<script> <script>
// 更改页面布局 // 更改页面布局
$(document).ready(function() { $(document).ready(function() {
$("body").removeClass("container").addClass("container-fixed-lg"); $("body").removeClass("container").addClass("container-fixed-lg");
}); });
// POST 删除提交
function ajax_post(url, mode = 'delete') {
$.post("del.php", {
url: url,
mode: mode
},
function(data, status) {
console.log(data)
let res = JSON.parse(data);
new $.zui.Messager(res.msg, {
type: res.type,
icon: res.icon
}).show();
// 延时2秒刷新
window.setTimeout(function() {
window.location.reload();
}, 2000)
});
}
// logs 数据表格 // logs 数据表格
$('#logs').datagrid({ $('#logs').datagrid({
dataSource: { dataSource: {
@ -155,7 +175,7 @@ try {
size: '<?php echo $v['size']; ?>', size: '<?php echo $v['size']; ?>',
checkImg: '<?php echo strstr('OFF', $v['checkImg']) ? '' : ''; ?>', checkImg: '<?php echo strstr('OFF', $v['checkImg']) ? '' : ''; ?>',
from: '<?php echo is_string($v['from']) ? "网页" : 'API: ' . $v['from']; ?>', from: '<?php echo is_string($v['from']) ? "网页" : 'API: ' . $v['from']; ?>',
manage: "<div class='btn-group'><a href='<?php echo $config['domain'] . $v['path']; ?>' target='_blank' class='btn btn-mini btn-success'>查看</a> <a href='/app/info.php?img=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini'>信息</a> <a href='/app/del.php?recycle_url=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini btn-info'>回收</a> <a href='/app/del.php?url=<?php echo $v['path']; ?>' target='_blank' class='btn btn-mini btn-danger'>删除</a></div>", manage: '<div class="btn-group"><a href="<?php echo rand_imgurl() . $v['path']; ?>" target="_blank" class="btn btn-mini btn-success">查看</a> <a href="/app/info.php?img=<?php echo $v['path']; ?>" target="_blank" class="btn btn-mini">信息</a><a href="#" onclick="ajax_post(\'<?php echo $v['path']; ?>\',\'recycle\')" class="btn btn-mini btn-info">回收</a> <a href="#" onclick="ajax_post(\'<?php echo $v['path']; ?>\',\'delete\')" class="btn btn-mini btn-danger">删除</a></div>',
}, },
<?php endforeach; ?> <?php endforeach; ?>
] ]

View File

@ -1,16 +1,16 @@
<?php <?php
$tokenList=Array $tokenList=Array
( (
'd5edb4e962a017bd99d1b71195f39fa9'=>Array
(
'id'=>0,
'expired'=>1678456553,
'add_time'=>1678456540
),
'1c17b11693cb5ec63859b091c5b9c1b2'=>Array '1c17b11693cb5ec63859b091c5b9c1b2'=>Array
(
'id'=>0,
'expired'=>2544411528,
'add_time'=>1680497928
),
'833c5611862efcaa9955205ee96125e9'=>Array
( (
'id'=>2, 'id'=>2,
'expired'=>2542384054, 'expired'=>1680584583,
'add_time'=>1678470454 'add_time'=>1680498183
) )
); );

View File

@ -4,7 +4,7 @@ $guestConfig=Array
'guest'=>Array 'guest'=>Array
( (
'password'=>'84983c60f7daadc1cb8698621f802c0d9f9a3c3c295c810748fb048115c186ec', 'password'=>'84983c60f7daadc1cb8698621f802c0d9f9a3c3c295c810748fb048115c186ec',
'expired'=>1680497325, 'expired'=>1765301956,
'add_time'=>1677905325 'add_time'=>1678988356
) )
); );

File diff suppressed because one or more lines are too long

3
docs/FTP.md Normal file
View File

@ -0,0 +1,3 @@
- 远程文件夹权限问题
- FTP用户权限
- 主动被动问题

View File

@ -1,3 +1,16 @@
* 2024-01-20 v2.8.4
- Fix [#163](https://github.com/icret/EasyImages2.0/pull/163)
- 增加检测FTP
- 增加自定义时区
- 增加大文件分片上传
- 增加重置OPcache缓存
- 增加自定义NProgress颜色
- 优化-IP数据基于内存的查询
- 优化-删除类操作统一
- 优化-修改配置统一
- 优化-页面
- 更新组件
* 2023-05-30 v2.8.3 * 2023-05-30 v2.8.3
- FIX [#118](https://github.com/icret/EasyImages2.0/issues/118) - FIX [#118](https://github.com/icret/EasyImages2.0/issues/118)

View File

@ -1,3 +1,6 @@
- 登录图床后台->图床安全->高级设置->开启API上传 - 登录图床后台->图床安全->高级设置->开启API上传
- 访问下面链接即可: - 访问下面链接即可:
[https://www.icloud.com/shortcuts/857b1921c1aa4d679470fcfed583cb1c](https://www.icloud.com/shortcuts/857b1921c1aa4d679470fcfed583cb1c) [https://www.icloud.com/shortcuts/857b1921c1aa4d679470fcfed583cb1c](https://www.icloud.com/shortcuts/857b1921c1aa4d679470fcfed583cb1c)
- [RashidaKAKU](https://github.com/RashidaKAKU)提供
[https://www.icloud.com/shortcuts/5f5fc7a047d9464ea95554246ba21c74](https://www.icloud.com/shortcuts/5f5fc7a047d9464ea95554246ba21c74)

File diff suppressed because one or more lines are too long

View File

@ -55,42 +55,42 @@ mustLogin();
<div class="tab-content" style="text-align:right;"> <div class="tab-content" style="text-align:right;">
<div class="tab-pane fade <?php if ($config['upload_first_show'] == 1) echo 'active in'; ?>" id="tab2Content1"> <div class="tab-pane fade <?php if ($config['upload_first_show'] == 1) echo 'active in'; ?>" id="tab2Content1">
<textarea class="form-control" rows="5" id="links" readonly></textarea> <textarea class="form-control" rows="5" id="links" readonly></textarea>
<button class="btn btn-primary" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-undo"></i> 刷新</button> <button class="btn btn-primary" data-toggle="tooltip" data-original-title="刷新" style="margin-top:5px;" onclick="location.reload()"><i class="icon icon-refresh"></i></button>
<button id="btnLinks" class="btn btn-primary copyBtn1" data-loading-text="复制链接..." style="margin-top:10px;"><i class="icon icon-copy"></i> 复制</button> <button class="btn btn-primary btnLinks" onclick="uploadCopy('links','.btnLinks')" data-toggle="tooltip" data-original-title="复制" data-loading-text="复制" style="margin-top:5px;"><i class="icon icon-copy"></i></button>
</div> </div>
<div class="tab-pane fade <?php if ($config['upload_first_show'] == 2) echo 'active in'; ?>" id="tab2Content2"> <div class="tab-pane fade <?php if ($config['upload_first_show'] == 2) echo 'active in'; ?>" id="tab2Content2">
<textarea class="form-control" rows="5" id="bbscode" readonly></textarea> <textarea class="form-control" rows="5" id="bbscode" readonly></textarea>
<button class="btn btn-primary" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-undo"></i> 刷新</button> <button class="btn btn-primary" data-toggle="tooltip" data-original-title="刷新" style="margin-top:5px;" onclick="location.reload()"><i class="icon icon-refresh"></i></button>
<button id="btnBbscode" class="btn btn-primary copyBtn2" data-loading-text="复制链接..." style="margin-top:10px;"><i class="icon icon-copy"></i> 复制</button> <button class="btn btn-primary btnBbscode" onclick="uploadCopy('bbscode','.btnBbscode')" data-toggle="tooltip" data-original-title="复制" data-loading-text="复制" style="margin-top:5px;"><i class="icon icon-copy"></i></button>
</div> </div>
<div class="tab-pane fade <?php if ($config['upload_first_show'] == 3) echo 'active in'; ?>" id="tab2Content3"> <div class="tab-pane fade <?php if ($config['upload_first_show'] == 3) echo 'active in'; ?>" id="tab2Content3">
<textarea class="form-control" rows="5" id="markdown" readonly></textarea> <textarea class="form-control" rows="5" id="markdown" readonly></textarea>
<button class="btn btn-primary" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-undo"></i> 刷新</button> <button class="btn btn-primary" data-toggle="tooltip" data-original-title="刷新" style="margin-top:5px;" onclick="location.reload()"><i class="icon icon-refresh"></i></button>
<button id="btnMarkDown" class="btn btn-primary copyBtn3" data-loading-text="复制链接..." style="margin-top:10px;"><i class="icon icon-copy"></i> 复制</button> <button class="btn btn-primary btnMarkDown" onclick="uploadCopy('markdown','.btnMarkDown')" data-toggle="tooltip" data-original-title="复制" data-loading-text="复制" style="margin-top:5px;"><i class="icon icon-copy"></i></button>
</div> </div>
<div class="tab-pane fade <?php if ($config['upload_first_show'] == 4) echo 'active in'; ?>" id="tab2Content4"> <div class="tab-pane fade <?php if ($config['upload_first_show'] == 4) echo 'active in'; ?>" id="tab2Content4">
<textarea class="form-control" rows="5" id="html" readonly></textarea> <textarea class="form-control" rows="5" id="html" readonly></textarea>
<button class="btn btn-primary" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-undo"></i> 刷新</button> <button class="btn btn-primary" data-toggle="tooltip" data-original-title="刷新" style="margin-top:5px;" onclick="location.reload()"><i class="icon icon-refresh"></i></button>
<button id="btnHtml" class="btn btn-primary copyBtn4" data-loading-text="复制链接..." style="margin-top:10px;"><i class="icon icon-copy"></i> 复制</button> <button class="btn btn-primary btnHtml" onclick="uploadCopy('html','.btnHtml')" data-toggle="tooltip" data-original-title="复制" data-loading-text="复制" style="margin-top:5px;"><i class="icon icon-copy"></i></button>
</div> </div>
<div class="tab-pane fade <?php if ($config['upload_first_show'] == 5) echo 'active in'; ?>" id="tab2Content5"> <div class="tab-pane fade <?php if ($config['upload_first_show'] == 5) echo 'active in'; ?>" id="tab2Content5">
<textarea class="form-control" rows="5" id="thumb" readonly></textarea> <textarea class="form-control" rows="5" id="thumb" readonly></textarea>
<button class="btn btn-primary" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-undo"></i> 刷新</button> <button class="btn btn-primary" data-toggle="tooltip" data-original-title="刷新" style="margin-top:5px;" onclick="location.reload()"><i class="icon icon-refresh"></i></button>
<button id="btnThumb" class="btn btn-primary copyBtn5" data-loading-text="复制链接..." style="margin-top:10px;"><i class="icon icon-copy"></i> 复制</button> <button class="btn btn-primary btnThumb" onclick="uploadCopy('thumb','.btnThumb')" data-toggle="tooltip" data-original-title="复制" data-loading-text="复制" style="margin-top:5px;"><i class="icon icon-copy"></i></button>
</div> </div>
<div class="tab-pane fade <?php if ($config['upload_first_show'] == 6) echo 'active in'; ?>" id="tab2Content6"> <div class="tab-pane fade <?php if ($config['upload_first_show'] == 6) echo 'active in'; ?>" id="tab2Content6">
<textarea class="form-control" rows="5" id="del" readonly></textarea> <textarea class="form-control" rows="5" id="del" readonly></textarea>
<button class="btn btn-primary" style="margin-top:10px;" onclick="location.reload()"><i class="icon icon-undo"></i> 刷新</button> <button class="btn btn-primary" data-toggle="tooltip" data-original-title="刷新" style="margin-top:5px;" onclick="location.reload()"><i class="icon icon-refresh"></i></button>
<button id="btnDel" class="btn btn-primary copyBtn6" data-loading-text="复制链接..." style="margin-top:10px;"><i class="icon icon-copy"></i> 复制</button> <button class="btn btn-primary btnDel" onclick="uploadCopy('del','.btnDel')" data-toggle="tooltip" data-original-title="复制" data-loading-text="复制" style="margin-top:5px;"><i class="icon icon-copy"></i></button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<link href="<?php static_cdn(); ?>/public/static/marquee/marquee.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/marquee/marquee.css">
<link href="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.css" rel="stylesheet"> <link rel="stylesheet" href="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.css">
<script src="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/zui/lib/uploader/zui.uploader.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/marquee/marquee.min.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/marquee/marquee.min.js"></script>
<script src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script> <script type="application/javascript" src="<?php static_cdn(); ?>/public/static/EasyImage.js"></script>
<script> <script>
// 公告 // 公告
(function() { (function() {
@ -121,7 +121,7 @@ mustLogin();
// 最大支持的上传文件 // 最大支持的上传文件
max_file_size: <?php echo $config['maxSize']; ?>, max_file_size: <?php echo $config['maxSize']; ?>,
// 分片上传 0为不分片 分片容易使图片上传失败 // 分片上传 0为不分片 分片容易使图片上传失败
chunk_size: 0, chunk_size: <?php echo $config['chunks']; ?>,
// 点击文件列表上传文件 // 点击文件列表上传文件
browseByClickList: true, browseByClickList: true,
// flash 上传组件地址 // flash 上传组件地址
@ -130,7 +130,7 @@ mustLogin();
flash_swf_url: '<?php static_cdn(); ?>/public/static/zui/lib/uploader/Moxie.xap', flash_swf_url: '<?php static_cdn(); ?>/public/static/zui/lib/uploader/Moxie.xap',
// sign // sign
multipart_params: { multipart_params: {
'sign': Date.now() / 1000, 'sign': new Date().getTime() / 1000 | 0,
}, },
// 预览图尺寸 // 预览图尺寸
previewImageSize: { previewImageSize: {
@ -152,37 +152,67 @@ mustLogin();
}, },
// 限制文件上传数目 // 限制文件上传数目
limitFilesCount: <?php echo $config['maxUploadFiles']; ?>, limitFilesCount: <?php echo $config['maxUploadFiles']; ?>,
// 移除文件进行确认
deleteConfirm: true,
// 重置上传失败的文件 // 重置上传失败的文件
autoResetFails: true, autoResetFails: true,
// 当文件上传进度发送变化时触发,此回调函数会在上传文件的过程中反复触发
onUploadProgress: function(file) {
NProgress.configure({
barColor: '<?php echo $config['NProgress_Progress']; ?>'
});
NProgress.set(0)
NProgress.set(file.percent / 100)
},
// 显示上传成功消息
uploadedMessage: '已上传 {uploaded} 个文件,{failed} 个文件上传失败',
// 当启用分片上传选项后,每个文件片段上传完成时触发
onChunkUploaded: function(file, responseObject) {
NProgress.set(responseObject.offset / responseObject.total);
},
<?php echo imgRatio(); ?>, <?php echo imgRatio(); ?>,
responseHandler: function(responseObject, file) { responseHandler: function(responseObject, file) {
var obj = JSON.parse(responseObject.response); //由JSON字符串转换为JSON对象 var obj = JSON.parse(responseObject.response); //由JSON字符串转换为JSON对象
console.log(file); // 输出上传log console.log(file); // 输出上传log
console.log(obj); // 输出回传log console.log(obj); // 输出回传log
if (obj.result === 'success') { if (obj.code === 200) {
document.getElementById("links").innerHTML += obj.url + "\r\n"; $("#links").append(obj.url + "\r\n");
document.getElementById("bbscode").innerHTML += "[img]" + obj.url + "[/img]\r\n"; $("#bbscode").append("[img]" + obj.url + "[/img]\r\n");
document.getElementById("markdown").innerHTML += "![" + obj.srcName + "](" + obj.url + ")\r\n"; $("#markdown").append("![" + obj.srcName + "](" + obj.url + ")\r\n");
document.getElementById("html").innerHTML += '<img src="' + obj.url + '" alt="' + obj.srcName + '" />\r\n'; $("#html").append('&lt;img src="' + obj.url + '" alt="' + obj.srcName + '" /&gt;\r\n');
document.getElementById("thumb").innerHTML += obj.thumb + "\r\n"; $("#thumb").append(obj.thumb + "\r\n");
document.getElementById("del").innerHTML += obj.del + "\r\n"; $("#del").append(obj.del + "\r\n");
new $.zui.Messager(obj.srcName + "上传成功", { // 上传成功提示
type: "primary", // 定义颜色主题 new $.zui.Messager(obj.srcName + " 上传成功", {
type: "primary",
placement: 'bottom-right', placement: 'bottom-right',
icon: "check" // 定义消息图标 icon: "check"
}).show(); }).show();
} else {
return '上传失败,错误信息:' + obj.message;
}
try { // 储存上传历史 try { // 储存上传历史
console.log('localStorage ok!'); console.log('history localStorage success');
$.zui.store.set(obj.srcName, obj) $.zui.store.set(obj.srcName, obj)
} catch (err) { } catch (err) {
// 失败提示
$.zui.messager.show('存储上传记录失败' + err, {
icon: 'bell',
time: 4000,
type: 'danger',
placement: 'top'
});
console.log('localStorage failed:' + err); console.log('localStorage failed:' + err);
} }
} else {
// 上传失败提示
new $.zui.Messager(obj.message, {
type: "danger",
placement: 'bottom-right',
icon: "times"
}).show();
return;
} }
},
}); });
</script> </script>
<?php <?php

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
install/README/chmod.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
install/README/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

BIN
install/README/log.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -50,13 +50,13 @@ function checkPASS($name)
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="EasyIamge 2.0 安装环境检测" /> <meta name="keywords" content="EasyIamge 2.0 安装环境检测" />
<meta name="description" content="EasyIamge 2.0 安装环境检测" /> <meta name="description" content="EasyIamge 2.0 安装环境检测" />
<link rel="shortcut icon" href="./../favicon.ico" type="image/x-icon" /> <link rel="stylesheet" rel="shortcut icon" href="./../favicon.ico" type="image/x-icon" />
<link href="./../public/static/zui/css/zui.min.css?v1.10.0" rel="stylesheet"> <link rel="stylesheet" href="./../public/static/zui/css/zui.min.css?v1.10.0">
<link href="./../public/static/nprogress/nprogress.min.css?v1.10.0" rel="stylesheet"> <link rel="stylesheet" href="./../public/static/nprogress/nprogress.min.css?v1.10.0">
<script src="./../public/static/zui/lib/jquery/jquery-3.6.0.min.js?v3.4.1"></script> <script type="application/javascript" src="./../public/static/zui/lib/jquery/jquery-3.6.0.min.js?v3.4.1"></script>
<script src="./../public/static/zui/js/zui.min.js?v1.10.0"></script> <script type="application/javascript" src="./../public/static/zui/js/zui.min.js?v1.10.0"></script>
<script src="./../public/static/qrcode/qrcode.min.js?v2.0"></script> <script type="application/javascript" src="./../public/static/qrcode/qrcode.min.js?v2.0"></script>
<script src="./../public/static/nprogress/nprogress.min.js"></script> <script type="application/javascript" src="./../public/static/nprogress/nprogress.min.js"></script>
</head> </head>
<body class="container"> <body class="container">

View File

@ -23,12 +23,12 @@ if ($state !== 'checked') {
<meta name="keywords" content="EasyIamge 2.0 即将完成安装!" /> <meta name="keywords" content="EasyIamge 2.0 即将完成安装!" />
<meta name="description" content="EasyIamge 2.0 即将完成安装!" /> <meta name="description" content="EasyIamge 2.0 即将完成安装!" />
<link rel="shortcut icon" href="./../favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="./../favicon.ico" type="image/x-icon" />
<link href="./../public/static/zui/css/zui.min.css?v1.10.0" rel="stylesheet"> <link rel="stylesheet" href="./../public/static/zui/css/zui.min.css?v1.10.0">
<link href="./../public/static/nprogress/nprogress.min.css?v1.10.0" rel="stylesheet"> <link rel="stylesheet" href="./../public/static/nprogress/nprogress.min.css?v1.10.0">
<script src="./../public/static/zui/lib/jquery/jquery-3.6.0.min.js?v3.4.1"></script> <script type="application/javascript" src="./../public/static/zui/lib/jquery/jquery-3.6.0.min.js?v3.4.1"></script>
<script src="./../public/static/zui/js/zui.min.js?v1.10.0"></script> <script type="application/javascript" src="./../public/static/zui/js/zui.min.js?v1.10.0"></script>
<script src="./../public/static/qrcode/qrcode.min.js?v2.0"></script> <script type="application/javascript" src="./../public/static/qrcode/qrcode.min.js?v2.0"></script>
<script src="./../public/static/nprogress/nprogress.min.js"></script> <script type="application/javascript" src="./../public/static/nprogress/nprogress.min.js"></script>
<style> <style>
.message { .message {
font-size: 12px; font-size: 12px;

View File

@ -1,5 +1,22 @@
/** 图片列表*/ /* 返回顶部 */
.btn-back-to-top {
padding: 0.5rem 1rem;
position: fixed;
right: 2rem;
bottom: 1rem;
z-index: 2;
-webkit-transition: -webkit-transform 0.2s ease;
transition: transform 0.2s ease;
-webkit-transform: translateY(200%);
transform: translateY(200%);
}
.btn-back-to-top.scrolled {
-webkit-transform: translateY(0);
transform: translateY(0);
}
/** 图片列表*/
@media screen and (min-width:960px) { @media screen and (min-width:960px) {
.listNum img { .listNum img {
width: 258px; width: 258px;
@ -13,53 +30,6 @@
height: 258px; height: 258px;
} }
} }
/** 返回顶部*/
* {
list-style: none;
border: 0;
}
#rocket-to-top div {
left: 0;
margin: 0;
overflow: hidden;
padding: 0;
position: absolute;
top: 0;
width: 110px;
}
#rocket-to-top .level-2 {
background: url("../images/rocket_button_up.png") no-repeat scroll -149px 0 transparent;
display: none;
height: 250px;
opacity: 0;
z-index: 1;
}
#rocket-to-top .level-3 {
background: none repeat scroll 0 0 transparent;
cursor: pointer;
display: block;
height: 150px;
z-index: 2;
}
#rocket-to-top {
background: url("../images/rocket_button_up.png") no-repeat scroll 0 0 transparent;
cursor: default;
display: block;
height: 250px;
margin: -125px 0 0;
overflow: hidden;
padding: 0;
position: fixed;
right: 0;
top: 80%;
width: 110px;
z-index: 11;
}
.cards { .cards {
padding-top: 0px; padding-top: 0px;

View File

@ -1,213 +1,56 @@
/** /**
* 来自于copy_btn.js paste.js合并 * 来自于copy_btn.js paste.js合并
* 简单图床-复制链接 * 简单图床-复制链接
* 2023-01-30 * 2023-04-20
* @param {*} copyID 传入的ID
* @param {*} loadClass 传入的class
*/ */
document.getElementsByClassName('copyBtn1')[0].onclick = function () { function uploadCopy(copyID, loadClass) {
var copyVal = document.getElementById("links"); var copyVal = document.getElementById(copyID);
copyVal.select(); copyVal.select();
// 复制内容为空时的提示
if (copyVal.value.length === 0) { new $.zui.Messager("复制内容为空", { type: "danger", icon: "bell" }).show(); return; }
if (navigator.clipboard && window.isSecureContext) { if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(copyVal.value).then(function () { navigator.clipboard.writeText(copyVal.value).then(function () {
//success info //success
new $.zui.Messager("复制成功", { new $.zui.Messager("复制成功", { type: "primary", icon: "ok-sign" }).show();
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
}, function () { }, function () {
//fail info //fail
alert("复制失败"); new $.zui.Messager("复制失败, 请手动复制", { type: "danger", icon: "bell" }).show();
}); });
} else { } else {
if (document.execCommand('copy', false, null)) { if (document.execCommand('copy', false, null)) {
//success info //success
new $.zui.Messager("复制成功", { new $.zui.Messager("复制成功", { type: "primary", icon: "ok-sign" }).show();
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
} else { } else {
//fail info //fail
alert("复制失败"); new $.zui.Messager("复制失败, 请手动复制", { type: "danger", icon: "bell" }).show();
} }
} }
}
document.getElementsByClassName('copyBtn2')[0].onclick = function () { // 复制按钮状态
var copyVal = document.getElementById("bbscode"); var $btn = $(loadClass);
copyVal.select(); $btn.addClass('btn-success');
if (navigator.clipboard && window.isSecureContext) { // $btn.addClass('btn-success load-indicator loading');
navigator.clipboard.writeText(copyVal.value).then(function () {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
}, function () {
//fail info
alert("复制失败");
});
} else {
if (document.execCommand('copy', false, null)) {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
}
}
document.getElementsByClassName('copyBtn3')[0].onclick = function () {
var copyVal = document.getElementById("markdown");
copyVal.select();
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(copyVal.value).then(function () {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
}, function () {
//fail info
alert("复制失败");
});
} else {
if (document.execCommand('copy', false, null)) {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
}
}
document.getElementsByClassName('copyBtn4')[0].onclick = function () {
var copyVal = document.getElementById("html");
copyVal.select();
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(copyVal.value).then(function () {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
}, function () {
//fail info
alert("复制失败");
});
} else {
if (document.execCommand('copy', false, null)) {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
}
}
document.getElementsByClassName('copyBtn5')[0].onclick = function () {
var copyVal = document.getElementById("thumb");
copyVal.select();
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(copyVal.value).then(function () {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
}, function () {
//fail info
alert("复制失败");
});
} else {
if (document.execCommand('copy', false, null)) {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
}
}
document.getElementsByClassName('copyBtn6')[0].onclick = function () {
var copyVal = document.getElementById("del");
copyVal.select();
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(copyVal.value).then(function () {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
}, function () {
//fail info
alert("复制失败");
});
} else {
if (document.execCommand('copy', false, null)) {
//success info
new $.zui.Messager("复制成功", {
type: "primary", // 定义颜色主题
icon: "ok-sign" // 定义消息图标
}).show();
console.log("复制成功");
} else {
//fail info
alert("复制失败");
}
}
}
// 复制按钮状态
$('#btnLinks, #btnBbscode, #btnMarkDown, #btnHtml, #btnThumb, #btnDel').on('click', function () {
var $btn = $(this);
$btn.addClass('btn-success load-indicator loading');
$btn.remove('data-toggle data-original-title'); $btn.remove('data-toggle data-original-title');
$btn.button('loading'); $btn.button('loading');
// 此处使用 setTimeout 来模拟复杂功能逻辑 // 此处使用 setTimeout 来模拟复杂功能逻辑
setTimeout(function () { setTimeout(function () {
$btn.removeClass('btn-success load-indicator loading'); $btn.removeClass('btn-success');
// $btn.removeClass('btn-success load-indicator loading');
$btn.button('reset'); $btn.button('reset');
}, 666); }, 666);
}); }
/** 粘贴上传 2023-01-30 */ /** 粘贴上传 2023-01-30 */
(function () { (function () {
document.addEventListener('paste', function (e) { document.addEventListener('paste', function (e) {
var items = ((e.clipboardData || window.clipboardData).items) || []; var items = ((e.clipboardData || window.clipboardData).items) || [];
console.log(e)
var file = null; var file = null;
$("#upShowID").addClass("load-indicator loading"); // 增加正在上传状态 2-1
if (items && items.length) { if (items && items.length) {
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) { if (items[i].type.indexOf('image') !== -1) {
@ -217,109 +60,69 @@ $('#btnLinks, #btnBbscode, #btnMarkDown, #btnHtml, #btnThumb, #btnDel').on('clic
} }
} }
// 未找到图片
if (!file) { if (!file) {
$.zui.messager.show('粘贴内容非图片!', { $("#upShowID").removeClass("load-indicator loading"); // 移除正在上传状态 2-2
icon: 'bell', $.zui.messager.show('粘贴内容非图片!', { icon: 'bell', time: 3000, type: 'danger', placement: 'top' }); return;
time: 3000,
type: 'danger',
placement: 'top'
});
return;
} }
var formData = new FormData(); var formData = new FormData();
formData.append('file', file); formData.append('file', file);
formData.append('sign', Date.now()); formData.append('sign', new Date().getTime() / 1000 | 0);
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 1) { if (xhr.readyState === 1) {
$.zui.messager.show('粘贴上传中...', { $.zui.messager.show('粘贴上传中...', { icon: 'bell', time: 3000, type: 'primary', placement: 'top' });
icon: 'bell',
time: 3000,
type: 'primary',
placement: 'top'
});
$(".uploader").addClass("load-indicator loading"); // 增加正在上传状态
}
if (xhr.readyState >= 4) {
$.zui.messager.show('粘贴上传中...', {
icon: 'bell',
time: 3000,
type: 'primary',
placement: 'top'
});
$(".uploader").removeClass("load-indicator loading"); // 移除正在上传状态
} }
} }
xhr.onload = function () { xhr.onload = function () {
var result = JSON.parse(this.responseText); var obj = JSON.parse(this.responseText);
if (result.result === 'success') { if (obj.code === 200) {
document.getElementById("links").innerHTML += result.url + "\r\n"; $("#links").append(obj.url + "\r\n");
document.getElementById("bbscode").innerHTML += "[img]" + result.url + "[/img]\r\n"; $("#bbscode").append("[img]" + obj.url + "[/img]\r\n");
document.getElementById("markdown").innerHTML += "![" + result.srcName + "](" + result.url + ")\r\n"; $("#markdown").append("![" + obj.srcName + "](" + obj.url + ")\r\n");
document.getElementById("html").innerHTML += '<img src="' + result.url + '" alt="' + result.srcName + '" />\r\n'; $("#html").append('&lt;img src="' + obj.url + '" alt="' + obj.srcName + '" /&gt;\r\n');
document.getElementById("thumb").innerHTML += result.thumb + "\r\n"; $("#thumb").append(obj.thumb + "\r\n");
document.getElementById("del").innerHTML += result.del + "\r\n"; $("#del").append(obj.del + "\r\n");
// 上传成功提示 原始文件名称obj.srcName + 提示
$.zui.messager.show(/** result.srcName + */'粘贴上传成功', { $.zui.messager.show('粘贴上传成功', { icon: 'bell', time: 4000, type: 'success', placement: 'top' });
icon: 'bell', // 移除正在上传状态 2-3
time: 4000, $("#upShowID").removeClass("load-indicator loading");
type: 'success',
placement: 'top'
});
try { // 储存上传记录 try { // 储存上传记录
console.log('localStorage ok!'); console.log('history localStorage success');
$.zui.store.set(result.srcName, result) $.zui.store.set(obj.srcName, obj)
} catch (err) { } catch (err) {
console.log('localStorage failed:' + err); // 存储上传记录失败提示
$.zui.messager.show('存储上传记录失败' + err, { icon: 'bell', time: 4000, type: 'danger', placement: 'top' });
console.log('history localStorage failed:' + err);
} }
} else { } else {
$.zui.messager.show('上传失败...' + result.message, { $("#upShowID").removeClass("load-indicator loading"); // 移除正在上传状态 2-4
icon: 'bell', $.zui.messager.show(obj.message, { icon: 'bell', time: 4000, type: 'danger', placement: 'top' });
time: 4000,
type: 'danger',
placement: 'top'
});
} }
}; };
xhr.onerror = function () { xhr.onerror = function () {
$.zui.messager.show('因网络问题导致的上传失败...', { $("#upShowID").removeClass("load-indicator loading"); // 移除正在上传状态 2-5
icon: 'bell', $.zui.messager.show('因网络问题导致的上传失败...', { icon: 'bell', time: 4000, type: 'primary', placement: 'top' });
time: 4000,
type: 'primary',
placement: 'top'
});
}; };
xhr.open('POST', 'app/upload.php', true); xhr.open('POST', 'app/upload.php', true);
xhr.send(formData); xhr.send(formData);
}); });
})(); })();
// 检测浏览器是否支持cookie
if (navigator.cookieEnabled === false) {
new $.zui.Messager('浏览器不支持cookie, 无法保存登录信息', {
type: 'black',
icon: 'bell',
time: 4500,
placement: 'top'
}).show();
/** 检测浏览器是否支持cookie */
if (navigator.cookieEnabled === false) {
new $.zui.Messager('浏览器不支持cookie, 无法保存登录信息', { type: 'black', icon: 'bell', time: 4500, placement: 'top' }).show();
console.log('浏览器不支持cookie'); console.log('浏览器不支持cookie');
} }
// 检测浏览器是否支持本地存储 /** 检测浏览器是否支持本地存储 */
if ($.zui.store.enable === false) { if ($.zui.store.enable === false) {
new $.zui.Messager('浏览器不支持本地存储, 无法保存上传历史记录', { new $.zui.Messager('浏览器不支持本地存储, 无法保存上传历史记录', { icon: 'bell', time: 4000, type: 'primary', placement: 'top' }).show();
icon: 'bell',
time: 4000,
type: 'primary',
placement: 'top'
}).show();
console.log('浏览器不支持本地存储'); console.log('浏览器不支持本地存储');
} }
@ -339,7 +142,6 @@ if ($.zui.store.enable === false) {
* myURL.protocol; // = 'http' * myURL.protocol; // = 'http'
* myURL.source; // = 'http://abc.com:8080/dir/index.html?id=255&m=hello#top' * myURL.source; // = 'http://abc.com:8080/dir/index.html?id=255&m=hello#top'
*/ */
function parseURL(url) { function parseURL(url) {
var a = document.createElement('a'); var a = document.createElement('a');
a.href = url; a.href = url;
@ -368,7 +170,10 @@ function parseURL(url) {
}; };
} }
/** jQuery 读取文件 readTxt('../admin/version.php'); */ /**
* jQuery 读取文件 readTxt('../admin/version.php');
* @param {*} filePath
*/
function readTxt(filePath = '../admin/version.php') { function readTxt(filePath = '../admin/version.php') {
$.get(filePath, function (data) { $.get(filePath, function (data) {
var lines = data.split("\n"); //按行读取 var lines = data.split("\n"); //按行读取
@ -377,3 +182,15 @@ function readTxt(filePath = '../admin/version.php') {
}); });
}); });
} }
/**
* JS验证是否为URL 这是提取自npm包 async-validator的源码
* 参考: https://www.cnblogs.com/lanleiming/p/14250497.html
* @param {*} str
* @returns
* @example isUrl('http://www.baidu.com') // true
*/
function isUrl(str) {
var v = new RegExp('^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', 'i');
return v.test(str);
}

6
public/static/md5/md5.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
/*! TangBin: image.ready.js http://www.planeart.cn/?p=1121 */
!function(n){"use strict";n.zui.imgReady=function(){var n=[],l=null,e=function(){for(var l=0;l<n.length;l++)n[l].end?n.splice(l--,1):n[l]();!n.length&&o()},o=function(){clearInterval(l),l=null};return function(o,r,t,u){var c,i,a,d,f,h=new Image;return h.src=o,h.complete?(r.call(h),void(t&&t.call(h))):(i=h.width,a=h.height,h.onerror=function(){u&&u.call(h),c.end=!0,h=h.onload=h.onerror=null},c=function(){d=h.width,f=h.height,(d!==i||f!==a||d*f>1024)&&(r.call(h),c.end=!0)},c(),h.onload=function(){!c.end&&c(),t&&t.call(h),h=h.onload=h.onerror=null},void(c.end||(n.push(c),null===l&&(l=setInterval(e,40)))))}}()}(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long