mirror of https://github.com/helloxz/imgurl
parent
42f7966364
commit
fad9d0645e
@ -1,13 +1,27 @@
|
||||
<?php
|
||||
error_reporting(E_ALL^E_NOTICE^E_WARNING^E_DEPRECATED);
|
||||
include_once("../functions/class/class.admin.php");
|
||||
//获取图片ID
|
||||
$id = $_GET['id'];
|
||||
$id = (int) $id;
|
||||
//获取类型
|
||||
$type = $_GET['type'];
|
||||
|
||||
if((!isset($id) || ($id == ''))) {
|
||||
echo 'ID错误';
|
||||
exit;
|
||||
}
|
||||
//删除图片
|
||||
$pic->delete($id);
|
||||
|
||||
// 判断类型
|
||||
switch ($type) {
|
||||
case 'sm':
|
||||
$pic->deletesm($id);
|
||||
break;
|
||||
|
||||
default:
|
||||
//删除图片
|
||||
$pic->delete($id);
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
$title = "后台管理 - ImgURL";
|
||||
include_once("../functions/class/class.admin.php");
|
||||
// 载入头部
|
||||
include_once("../tpl/admin/header.php");
|
||||
|
||||
// 获取类型
|
||||
$type = $_GET['type'];
|
||||
//获取页数
|
||||
$page = $_GET['page'];
|
||||
//查询sm.ms图片
|
||||
$imgs = $pic->querysm($page);
|
||||
//var_dump($imgs);
|
||||
|
||||
$up = (int)$page - 1;
|
||||
if($up <= 0){
|
||||
$up = 1;
|
||||
}
|
||||
$down = (int)$page +1;
|
||||
?>
|
||||
|
||||
<div class="layui-container" style = "margin-top:2em;">
|
||||
<div class="layui-row layui-col-space20">
|
||||
<div class="layui-col-lg3">
|
||||
<!-- 载入左侧导航栏 -->
|
||||
<?php include_once("../tpl/admin/left.php"); ?>
|
||||
</div>
|
||||
<!-- 后台内容部分 -->
|
||||
<div id = "adminpic">
|
||||
<div class="layui-col-lg9">
|
||||
<?php if($type == 'preview') { ?>
|
||||
<!-- 预览图片 -->
|
||||
<div class="layui-col-lg9 layui-col-space10">
|
||||
<?php foreach ($imgs as $img) {
|
||||
?>
|
||||
<div class="layui-col-lg4 picadmin">
|
||||
<a id = "imgid<?php echo $img['id']; ?>" href="javascript:;" onclick = "smshow('<?php echo $img['url'] ?>',<?php echo $img['id']; ?>)"><img src="<?php echo $img['url'] ?>"></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php }else{ ?>
|
||||
<!-- 预览图片END -->
|
||||
<!-- 表格 -->
|
||||
<table class="layui-table">
|
||||
<colgroup>
|
||||
<col width="60">
|
||||
<col width="380">
|
||||
<col width="150">
|
||||
<col width="120">
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>图片路径(点击可查看)</th>
|
||||
<th>IP</th>
|
||||
<th>日期</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($imgs as $img) {
|
||||
|
||||
?>
|
||||
<tr id = "imgid<?php echo $img['id']; ?>">
|
||||
<td><?php echo $img['id']; ?></td>
|
||||
<td><a id = "imgid<?php echo $img['id']; ?>" href="javascript:;" onclick = "smshow('<?php echo $img['url'] ?>',<?php echo $img['id']; ?>)"><?php echo $img['url']; ?></a></td>
|
||||
<td><a href="javascript:;" onclick = "ipquery('<?php echo $img['ip']; ?>')"><?php echo $img['ip']; ?></a></td>
|
||||
<td><?php echo $img['date']; ?></td>
|
||||
<td>
|
||||
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-normal" onclick = "copyurl('<?php echo $img['url']; ?>')">复制</a>
|
||||
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger" onclick = "deletesm(<?php echo $img['id']; ?>)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<!-- 表格END -->
|
||||
</div>
|
||||
<!-- 翻页按钮 -->
|
||||
<div class="layui-col-lg9 layui-col-md-offset3">
|
||||
<div class="page">
|
||||
<a href="?type=<?php echo $type; ?>&page=<?php echo $up; ?>" class="layui-btn">上一页</a>
|
||||
<a href="?type=<?php echo $type; ?>&page=<?php echo $down; ?>" class="layui-btn">下一页</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 翻页按钮END -->
|
||||
|
||||
<!-- 后台内容部分END -->
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
// 载入页脚
|
||||
// 载入头部
|
||||
include_once("../tpl/admin/footer.php");
|
||||
?>
|
Binary file not shown.
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
//载入类
|
||||
include_once("./class/class.user.php");
|
||||
//获取sm.ms API返回数据
|
||||
$data = $_POST['data'];
|
||||
//获取访客IP
|
||||
$sm['ip'] = $basis->getip();
|
||||
//获取访客UA
|
||||
$sm['ua'] = $_SERVER['HTTP_USER_AGENT'];
|
||||
//获取当前时间
|
||||
$sm['date'] = date('Y-m-d',time());
|
||||
//获取图片URL
|
||||
$sm['url'] = $data['url'];
|
||||
//获取删除链接
|
||||
$sm['delete'] = $data['delete'];
|
||||
|
||||
//进行基本的判断
|
||||
if((!isset($data)) || ($data == '') || (!is_array($data))) {
|
||||
echo '获取数据失败!';
|
||||
exit;
|
||||
}
|
||||
//再次判断地址是否合法
|
||||
if(!filter_var($sm['url'], FILTER_VALIDATE_URL)) {
|
||||
echo '不是合法的地址!';
|
||||
exit;
|
||||
}
|
||||
if(!filter_var($sm['delete'], FILTER_VALIDATE_URL)) {
|
||||
echo '不是合法的地址!';
|
||||
exit;
|
||||
}
|
||||
|
||||
//写入数据库
|
||||
$last_user_id = $database->insert("sm", [
|
||||
"ip" => $sm['ip'],
|
||||
"ua" => $sm['ua'],
|
||||
"date" => $sm['date'],
|
||||
"url" => $sm['url'],
|
||||
"delete"=> $sm['delete']
|
||||
]);
|
||||
//返回ID
|
||||
$smid = $database->id();
|
||||
if($last_user_id) {
|
||||
$redata = array(
|
||||
"code" => 1,
|
||||
"id" => $smid,
|
||||
"msg" => "写入成功!"
|
||||
);
|
||||
echo json_encode($redata);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$redata = array(
|
||||
"code" => 0,
|
||||
"id" => $smid,
|
||||
"msg" => "该图片可能已经上传过!"
|
||||
);
|
||||
echo json_encode($redata);
|
||||
}
|
||||
?>
|
@ -1 +1 @@
|
||||
v1.0(20180502)
|
||||
v1.1(20180504)
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
$title = "ImgURL - 简单、纯粹的图床程序。";
|
||||
include_once("./tpl/user/header.php");
|
||||
?>
|
||||
|
||||
<div class="layui-container">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-lg12 layui-col-xs10">
|
||||
<div class="msg"><i class="layui-icon"></i> 该功能可以将图片上传至SM.MS图床。</div>
|
||||
<!-- 上传图片表单 -->
|
||||
<div class = "smfile">
|
||||
<a href="javascript:;" class="file">
|
||||
<input type="file" name="smfile" id="sm">
|
||||
<i class="layui-icon" style = "font-size:6em;"></i>
|
||||
</a>
|
||||
</div>
|
||||
<!-- 上传图片表单END -->
|
||||
</div>
|
||||
</div>
|
||||
<div style = "clear:both;"></div>
|
||||
<!-- 图片上传成功 -->
|
||||
<div class="layui-row" id = "upok">
|
||||
<div>
|
||||
<div id="showpic" class = "layui-col-lg5"><a href="" target = "_blank"><img src=""></a></div>
|
||||
<div id="piclink" class = "layui-col-lg6 layui-col-md-offset1">
|
||||
<table class="layui-table" lay-skin="nob">
|
||||
<colgroup>
|
||||
<col width="80">
|
||||
<col width="400">
|
||||
<col>
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>URL</td>
|
||||
<td><input type="text" class="layui-input" id = "url"></td>
|
||||
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('url')">复制</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HTML</td>
|
||||
<td><input type="text" class="layui-input" id = "html"></td>
|
||||
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('html')">复制</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>MarkDown</td>
|
||||
<td><input type="text" class="layui-input" id = "markdown"></td>
|
||||
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('markdown')">复制</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>BBcode</td>
|
||||
<td><input type="text" class="layui-input" id = "bbcode"></td>
|
||||
<td><a href="javascript:;" class = "layui-btn layui-btn-sm" onclick = "copy('bbcode')">复制</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 图片上传成功END -->
|
||||
</div>
|
||||
|
||||
<?php
|
||||
include_once("./tpl/user/footer.php");
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("#smfile input:text").attr("name",'smfile');
|
||||
});
|
||||
</script>
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
//载入配置文件
|
||||
include_once("./config.php");
|
||||
//获取要升级的版本
|
||||
$v = $_GET['v'];
|
||||
|
||||
//如果版本为空或不存在
|
||||
if(($v == '') || (!isset($v))) {
|
||||
echo '版本号错误!';
|
||||
exit;
|
||||
}
|
||||
|
||||
//判断版本号
|
||||
switch ( $v )
|
||||
{
|
||||
case "1.1":
|
||||
//增加表
|
||||
$sql = 'CREATE TABLE "main"."sm" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"ip" TEXT NOT NULL,
|
||||
"ua" TEXT NOT NULL,
|
||||
"date" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"delete" TEXT NOT NULL,
|
||||
CONSTRAINT "delete" UNIQUE ("delete")
|
||||
)
|
||||
;'; $data = $database->query($sql);
|
||||
if($data) {
|
||||
echo '数据表创建成功!';
|
||||
}
|
||||
else{
|
||||
echo '数据表创建失败,可能是数据库不可写或已经升级过!';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
echo '未知的版本号!';
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
?>
|
Loading…
Reference in new issue