diff --git a/application/controllers/Found.php b/application/controllers/Found.php index 8d01f63..9600ab3 100644 --- a/application/controllers/Found.php +++ b/application/controllers/Found.php @@ -29,45 +29,33 @@ $siteinfo = $this->query->site_setting(); $siteinfo = $siteinfo->values; $siteinfo = json_decode($siteinfo); - //每页显示16张图片 - $limit = 16; + //echo $page; $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语句 switch($type){ case 'all': //查询游客上传图片总数 - $num = $this->query->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->query->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->query->count_num('visitor')->num; + case 'views': $config['base_url'] = "/found/views/"; - $sql = $sql_header."ORDER BY b.views DESC LIMIT $limit OFFSET $page"; break; case 'large': - $num = $this->query->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->query->count_num('visitor')->num; $config['base_url'] = "/found/all/"; - $sql = $sql_header."ORDER BY a.id DESC LIMIT $limit OFFSET $page"; break; } //查询图片信息,返回对象 //$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'); diff --git a/application/models/Query.php b/application/models/Query.php index e37916b..dd190ca 100644 --- a/application/models/Query.php +++ b/application/models/Query.php @@ -277,10 +277,51 @@ //先获取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"; $imginfo = $this->db->query($sql)->row(); - - 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; } } ?> \ No newline at end of file diff --git a/application/views/user/multiple.php b/application/views/user/multiple.php index e423711..7d06627 100644 --- a/application/views/user/multiple.php +++ b/application/views/user/multiple.php @@ -20,31 +20,34 @@
- -
- -
-

+                
    +
  • URL
  • +
  • HTML
  • +
  • Markdown
  • +
  • BBCode
  • +
+
+ +
+

+                    
+ +
+

+                    
+ +
+

+                    
+ +
+

+                    
- -
-

-                
- -
-

-                
- -
-

-                
-
+ + +
diff --git a/data/version.txt b/data/version.txt index 88792c3..3b7a444 100644 --- a/data/version.txt +++ b/data/version.txt @@ -1 +1 @@ -v2.1.1-20190323 \ No newline at end of file +v2.1.2-20190406 \ No newline at end of file diff --git a/static/embed.js b/static/embed.js index 2e846fe..0ac6e13 100644 --- a/static/embed.js +++ b/static/embed.js @@ -247,4 +247,17 @@ function del_img(id,imgid,path,thumbnail_path){ 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); } \ No newline at end of file