$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 ";
$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语句
//根据不同的条件生成不同的SQL语句
switch ($type) {
switch ($type) {
//所有图片
case 'all':
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";
$sql = $sql1."ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$num = $this->db->count_all("images");
$num = $this->db->count_all("images");
}
break;
break;
//管理员上传
case 'admin':
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";
$sql = $sql1."AND a.user = 'admin' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$num = $this->query->count_num('admin')->num;
$num = $this->query->count_num('admin')->num;
}
break;
break;
//游客上传
case 'visitor':
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";
$sql = $sql1."AND a.user = 'visitor' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$num = $this->query->count_num('visitor')->num;
$num = $this->query->count_num('visitor')->num;
}
break;
break;
//可疑图片
case 'dubious':
case 'dubious':
$sql = $sql1."AND a.level = 'adult' ORDER BY a.id DESC";
$sql = $sql1."AND a.level = 'adult' ORDER BY a.id DESC";
//$num = $this->query->count_num('visitor')->num;
//$num = $this->query->count_num('visitor')->num;
break;
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:
default:
$sql = $sql1."AND a.user = '$type' ORDER BY a.id DESC LIMIT $limit OFFSET $page";
$sql = $sql1."AND a.user = '$type' ORDER BY a.id DESC LIMIT $limit OFFSET $page";