diff --git a/application/controllers/Found.php b/application/controllers/Found.php index f9bd748..57a80ee 100644 --- a/application/controllers/Found.php +++ b/application/controllers/Found.php @@ -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; } diff --git a/application/controllers/Img.php b/application/controllers/Img.php index e4ffa71..449b42d 100644 --- a/application/controllers/Img.php +++ b/application/controllers/Img.php @@ -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; diff --git a/application/controllers/Manage.php b/application/controllers/Manage.php index 152ec3f..a61411a 100644 --- a/application/controllers/Manage.php +++ b/application/controllers/Manage.php @@ -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': - $sql = $sql1."ORDER BY a.id DESC LIMIT $limit OFFSET $page"; - $num = $this->db->count_all("images"); + //如果存在时间,则按时间筛选 + 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': - $sql = $sql1."AND a.user = 'admin' ORDER BY a.id DESC LIMIT $limit OFFSET $page"; - $num = $this->query->count_num('admin')->num; + //如果存在时间,则按时间筛选 + 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': - $sql = $sql1."AND a.user = 'visitor' ORDER BY a.id DESC LIMIT $limit OFFSET $page"; - $num = $this->query->count_num('visitor')->num; + //如果存在时间,则按时间筛选 + 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; diff --git a/application/views/admin/images.php b/application/views/admin/images.php index 003433f..d18ff51 100644 --- a/application/views/admin/images.php +++ b/application/views/admin/images.php @@ -1,4 +1,68 @@ -
+
+
+
+ + +
+
    +
  • 常规筛选
  • +
  • 时间筛选
  • +
+
+ +
+ + + + + + + + + +
+ + + +
+
+ + +
+ + + + + + + + + + + +
+ + ------ + + + +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + \ No newline at end of file