Browse Source

修复探索发现BUG

dev
xiaoz 6 years ago
parent
commit
70c703ecdd
  1. 20
      application/controllers/Found.php
  2. 47
      application/models/Query.php
  3. 49
      application/views/user/multiple.php
  4. 2
      data/version.txt
  5. 13
      static/embed.js

20
application/controllers/Found.php

@ -29,45 +29,33 @@
$siteinfo = $this->query->site_setting(); $siteinfo = $this->query->site_setting();
$siteinfo = $siteinfo->values; $siteinfo = $siteinfo->values;
$siteinfo = json_decode($siteinfo); $siteinfo = json_decode($siteinfo);
//每页显示16张图片
$limit = 16;
//echo $page; //echo $page;
$siteinfo->title = '探索发现 - '.$siteinfo->title; $siteinfo->title = '探索发现 - '.$siteinfo->title;
//SQL语句
$sql_header = "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 AND a.user = 'visitor' AND a.level = 'everyone' ";
//根据条件生成不同的SQL语句 //根据条件生成不同的SQL语句
switch($type){ switch($type){
case 'all': case 'all':
//查询游客上传图片总数 //查询游客上传图片总数
$num = $this->query->count_num('visitor')->num;
$config['base_url'] = "/found/all/"; $config['base_url'] = "/found/all/";
$sql = $sql_header."ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break; break;
case 'gif': case 'gif':
$num = $this->query->count_num('gif')->num;
$config['base_url'] = "/found/gif/"; $config['base_url'] = "/found/gif/";
$sql = $sql_header."AND b.ext = '.gif' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break; break;
case 'views': case 'views':
$num = $this->query->count_num('visitor')->num;
$config['base_url'] = "/found/views/"; $config['base_url'] = "/found/views/";
$sql = $sql_header."ORDER BY b.views DESC LIMIT $limit OFFSET $page";
break; break;
case 'large': case 'large':
$num = $this->query->count_num('large')->num;
$config['base_url'] = "/found/large/"; $config['base_url'] = "/found/large/";
$sql = $sql_header."AND b.width >= 1920 AND b.height >= 1080 ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break; break;
default: default:
//查询游客上传图片总数
$num = $this->query->count_num('visitor')->num;
$config['base_url'] = "/found/all/"; $config['base_url'] = "/found/all/";
$sql = $sql_header."ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break; break;
} }
//查询图片信息,返回对象 //查询图片信息,返回对象
//$data['imgs'] = $this->query->found(96); //$data['imgs'] = $this->query->found(96);
$data['imgs'] = $this->db->query($sql)->result_array(); //$data['imgs'] = $this->db->query($sql)->result_array();
$data['imgs'] = $this->query->found_img($type,$page);
//查询域名 //查询域名
$data['domain'] = $this->query->domain('localhost'); $data['domain'] = $this->query->domain('localhost');

47
application/models/Query.php

@ -277,10 +277,51 @@
//先获取img id //先获取img id
$sql = "SELECT a.*,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.id = $id AND a.imgid = b.imgid"; $sql = "SELECT a.*,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.id = $id AND a.imgid = b.imgid";
$imginfo = $this->db->query($sql)->row(); $imginfo = $this->db->query($sql)->row();
return $imginfo; return $imginfo;
}
//各种条件的图片查询
public function found_img($type,$page){
//探索发现每页显示16张图片
$limit = 16;
//通用的SQL语句头部
$sql_header = "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
AND a.user = 'visitor'
AND (a.level = 'everyone' OR a.level = 'unknown') ";
//根据条件生成不同的SQL语句
switch($type){
case 'all':
//查询游客上传图片总数
$num = $this->count_num('visitor')->num;
//$config['base_url'] = "/found/all/";
$sql = $sql_header."ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break;
case 'gif':
$num = $this->count_num('gif')->num;
//$config['base_url'] = "/found/gif/";
$sql = $sql_header."AND b.ext = '.gif' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break;
case 'views':
$num = $this->count_num('visitor')->num;
//$config['base_url'] = "/found/views/";
$sql = $sql_header."ORDER BY b.views DESC LIMIT $limit OFFSET $page";
break;
case 'large':
$num = $this->count_num('large')->num;
//$config['base_url'] = "/found/large/";
$sql = $sql_header."AND b.width >= 1920 AND b.height >= 1080 ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break;
default:
//查询游客上传图片总数
$num = $this->count_num('visitor')->num;
//$config['base_url'] = "/found/all/";
$sql = $sql_header."ORDER BY a.id DESC LIMIT $limit OFFSET $page";
break;
}
$datas = $this->db->query($sql)->result_array();
return $datas;
} }
} }
?> ?>

49
application/views/user/multiple.php

@ -20,31 +20,34 @@
<!-- 多图上传结果 --> <!-- 多图上传结果 -->
<div class="layui-col-lg12" id = "multiple-re"> <div class="layui-col-lg12" id = "multiple-re">
<div class="layui-tab layui-tab-brief"> <div class="layui-tab layui-tab-brief">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
<li class="layui-this">URL</li> <li class="layui-this">URL</li>
<li>HTML</li> <li>HTML</li>
<li>Markdown</li> <li>Markdown</li>
<li>BBCode</li> <li>BBCode</li>
</ul> </ul>
<div class="layui-tab-content" style="height: 100px;"> <div class="layui-tab-content" style="height: 100px;">
<!-- 第一个选显卡结果 --> <!-- 第一个选显卡结果 -->
<div class="layui-tab-item layui-show" id = "re-url"> <div class="layui-tab-item layui-show" id = "re-url">
<pre></pre> <pre></pre>
</div>
<!-- 返回HTML结果 -->
<div class="layui-tab-item" id = "re-html">
<pre></pre>
</div>
<!-- 返回Markdown结果 -->
<div class="layui-tab-item" id = "re-md">
<pre></pre>
</div>
<!-- 返回BBCode结果 -->
<div class="layui-tab-item" id = "re-bbc">
<pre></pre>
</div>
</div> </div>
<!-- 返回HTML结果 -->
<div class="layui-tab-item" id = "re-html">
<pre></pre>
</div>
<!-- 返回Markdown结果 -->
<div class="layui-tab-item" id = "re-md">
<pre></pre>
</div>
<!-- 返回BBCode结果 -->
<div class="layui-tab-item" id = "re-bbc">
<pre></pre>
</div>
</div>
</div> </div>
<!-- 导出txt按钮 -->
<!-- <a href="" class="layui-btn layui-btn-sm"><i class="layui-icon layui-icon-download-circle"></i> 导出txt</a> -->
<!-- 导出txt按钮end -->
</div> </div>
<!-- 多图上传结果END --> <!-- 多图上传结果END -->
<!-- 首页主要区域END --> <!-- 首页主要区域END -->

2
data/version.txt

@ -1 +1 @@
v2.1.1-20190323 v2.1.2-20190406

13
static/embed.js

@ -248,3 +248,16 @@ function del_img(id,imgid,path,thumbnail_path){
layer.close(index); layer.close(index);
}); });
} }
/**
* 创建并下载文件
* @param {String} fileName 文件名
* @param {String} content 文件内容
*/
function createAndDownloadFile(fileName, content) {
var aTag = document.createElement('a');
var blob = new Blob([content]);
aTag.download = fileName;
aTag.href = URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
Loading…
Cancel
Save