Browse Source

v2.24

master
xiaoz 6 years ago
parent
commit
f8895a44e2
  1. 9
      application/controllers/Found.php
  2. 2
      application/controllers/Img.php
  3. 55
      application/controllers/Manage.php
  4. 66
      application/views/admin/images.php
  5. 2
      data/version.txt
  6. 54
      static/js/admin.js
  7. 18
      web.config

9
application/controllers/Found.php

@ -37,31 +37,38 @@ @@ -37,31 +37,38 @@
$siteinfo->title = $siteinfo->title.',探索发现';
}
else{
$siteinfo->title = $siteinfo->title.',探索发现 - '."第{$page}页";
$page_num = $page / 16 + 1;
$siteinfo->title = $siteinfo->title.',探索发现 - '."第{$page_num}页";
}
//出于安全性考虑,最多显示160张图片
//根据条件生成不同的SQL语句
switch($type){
case 'all':
//查询游客上传图片总数
$num = $this->query->count_num('visitor')->num;
$num = ($num >= 160) ? 160 : $num;
$config['base_url'] = "/found/all/";
break;
case 'gif':
$num = $this->query->count_num('gif')->num;
$num = ($num >= 160) ? 160 : $num;
$config['base_url'] = "/found/gif/";
break;
case 'views':
$num = $this->query->count_num('visitor')->num;
$num = ($num >= 160) ? 160 : $num;
$config['base_url'] = "/found/views/";
break;
case 'large':
$num = $this->query->count_num('large')->num;
$num = ($num >= 160) ? 160 : $num;
$config['base_url'] = "/found/large/";
break;
default:
$num = $this->query->count_num('visitor')->num;
$num = ($num >= 160) ? 160 : $num;
$config['base_url'] = "/found/all/";
break;
}

2
application/controllers/Img.php

@ -67,6 +67,8 @@ @@ -67,6 +67,8 @@
);
$datas['img_info'] = $conf->img_info;
//检测用户是否登录
$datas['is_login'] = $this->basic->is_login();
// $data['title'] = '图片浏览';
// $data['url'] = $domain.$imginfo->path;
// $data['date'] = $imginfo->date;

55
application/controllers/Manage.php

@ -19,29 +19,84 @@ @@ -19,29 +19,84 @@
}
//管理员上传
public function images($type = 'all',$page = 0){
//获取传入的值
@$value = $this->input->get('value',TRUE);
//获取传入的时间
@$date = $this->input->get('date',TRUE);
//把时间分割为数组
$tmp_date = explode("|",$date);
//开始时间
$start_time = $tmp_date[0];
//结束时间
$end_time = $tmp_date[1];
//获取类型
$type = strip_tags($type);
//获取分页
$page = (int)strip_tags($page);
$limit = 16; //要查询的条数
$data['admin_title'] = '图片管理';
$sql1 = "SELECT a.id,a.imgid,a.path,a.thumb_path,a.date,a.compression,a.level,b.mime,b.width,b.height,b.views,b.ext,b.client_name FROM img_images AS a INNER JOIN img_imginfo AS b ON a.imgid = b.imgid ";
//根据不同的条件生成不同的SQL语句
switch ($type) {
//所有图片
case 'all':
//如果存在时间,则按时间筛选
if( (isset($date)) && ($date != '') ){
$sql = $sql1."AND (Date(a.date) BETWEEN '{$start_time}' AND '{$end_time}') ORDER BY a.id DESC";
}
else{
$sql = $sql1."ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$num = $this->db->count_all("images");
}
break;
//管理员上传
case 'admin':
//如果存在时间,则按时间筛选
if( (isset($date)) && ($date != '') ){
$sql = $sql1."AND a.user = 'admin' AND (Date(a.date) BETWEEN '{$start_time}' AND '{$end_time}') ORDER BY a.id DESC";
}
else{
$sql = $sql1."AND a.user = 'admin' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$num = $this->query->count_num('admin')->num;
}
break;
//游客上传
case 'visitor':
//如果存在时间,则按时间筛选
if( (isset($date)) && ($date != '') ){
$sql = $sql1."AND a.user = 'visitor' AND (Date(a.date) BETWEEN '{$start_time}' AND '{$end_time}') ORDER BY a.id DESC";
}
else{
$sql = $sql1."AND a.user = 'visitor' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$num = $this->query->count_num('visitor')->num;
}
break;
//可疑图片
case 'dubious':
$sql = $sql1."AND a.level = 'adult' ORDER BY a.id DESC";
//$num = $this->query->count_num('visitor')->num;
break;
case 'id':
$value = (int)$value;
if( $value === 0 ){
//echo $value;
exit("不是有效的ID,请重新输入!");
}
$sql = $sql1."AND a.id = {$value}";
//$num = 1;
break;
case 'imgid':
if( strlen($value) != 16){
exit("不是有效的ImgID,请重新输入!");
}
$sql = $sql1."AND a.imgid = '{$value}'";
break;
case 'ip':
if( ! filter_var($value, FILTER_VALIDATE_IP)){
exit('不是有效的IP地址,请重新输入!');
}
$sql = $sql1."AND a.ip = '{$value}'";
break;
default:
$sql = $sql1."AND a.user = '$type' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break;

66
application/views/admin/images.php

@ -1,4 +1,68 @@ @@ -1,4 +1,68 @@
<div class="layui-container" style = "margin-top:2em;margin-bottom:6em;">
<div class="layui-container" style = "margin-top:1em;margin-bottom:6em;">
<div class="layui-row layui-col-space10" >
<div class="layui-col-lg12">
<!-- 条件筛选 -->
<!-- 先来一个选项卡 -->
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this">常规筛选</li>
<li>时间筛选</li>
</ul>
<div class="layui-tab-content">
<!-- 常规筛选内容 -->
<div class="layui-tab-item layui-show">
<table class="layui-table layui-form" lay-even="" lay-skin="nob">
<tbody>
</tbody><thead>
<tr>
<th width="85%">
<input id="value" type="text" required="" lay-verify="required" placeholder="可输入 ID/IP/imgid 进行查询" autocomplete="off" class="layui-input" data-cip-id="url" data-kpxc-id="ip">
</th>
<th width="15%">
<select id="type" lay-verify="required">
<option value="">请选择条件</option>
<option value="id">ID</option>
<option value="imgid">ImgID</option>
<option value="ip">IP</option>
</select>
</th>
<th width="10%"><button type="submit" class="layui-btn layui-btn" onclick="findimg()"><i class="layui-icon"></i> 查 询</button></th>
</tr>
</thead>
</table>
</div>
<!-- 常规筛选内容END -->
<!-- 时间筛选 -->
<div class="layui-tab-item">
<table class="layui-table layui-form" lay-even="" lay-skin="nob">
<tbody>
</tbody><thead>
<tr>
<th width="30%">
<input id = "start-time" type="text" class="layui-input" id="start-time">
</th>
<th width = "5%"> ------ </th>
<th width="30%">
<input id = "end-time" type="text" class="layui-input" id="end-time">
</th>
<th width="15%">
<select id="user" lay-verify="required">
<option value="all">默认</option>
<option value="admin">管理员</option>
<option value="visitor">游客</option>
</select>
</th>
<th width="10%"><button type="submit" class="layui-btn layui-btn" onclick="find_date_img()"><i class="layui-icon"></i> 查 询</button></th>
</tr>
</thead>
</table>
</div>
<!-- 时间筛选END -->
</div>
</div>
<!-- 条件筛选END -->
</div>
</div>
<div class="layui-row layui-col-space10 showimgs" id = "showimgs">
<?php
foreach ($imgs as $img)

2
data/version.txt

@ -1 +1 @@ @@ -1 +1 @@
v2.23-20190429
v2.24-20190530

54
static/js/admin.js

@ -1,7 +1,22 @@ @@ -1,7 +1,22 @@
layui.use(['form','element','layer'], function(){
layui.use(['form','element','layer','laydate'], function(){
var form = layui.form;
var element = layui.element;
var layer = layui.layer;
var laydate = layui.laydate;
//执行一个laydate实例
laydate.render({
elem: '#start-time' //指定元素
,done: function(value, date, endDate){
start_time = value;
}
});
laydate.render({
elem: '#end-time' //指定元素
,done: function(value, date, endDate){
end_time = value;
}
});
//监听提交
// form.on('submit(formDemo)', function(data){
@ -230,3 +245,40 @@ $("#checkAll").click(function() { @@ -230,3 +245,40 @@ $("#checkAll").click(function() {
})
}
})
//根据条件查找图片
function findimg(){
var value = $("#value").val();
var type = $("#type").val();
if( type == ''){
layer.msg('请选择筛选条件!');
return false;
}
else if( value == ''){
layer.msg('请输入值!');
return false;
}
window.location.href = '/manage/images/' + type + '/?value=' + value;
}
//根据时间查找图片
function find_date_img(){
//获取上传者
var user = $("#user").val();
//时间组合
var date = start_time + '|' + end_time;
if( user == ''){
layer.msg('请选择筛选条件!');
return FALSE;
}
else if( start_time == ''){
layer.msg('请选择开始日期!');
return FALSE;
}
else if(end_time == ''){
layer.msg('请选择结束日期!');
return FALSE;
}
window.location.href = '/manage/images/' + user + '/?date=' + date;
}

18
web.config

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Loading…
Cancel
Save