<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class album_uqcms extends control { function __construct(){ $this->aid = $_SESSION['admin']['aid']; parent::__construct(); } public function index(){ $type = isset($_GET['type'])?$_GET['type']:''; $page = isset($_GET['page'])?$_GET['page']:'1'; $page_size = isset($_GET['page_size'])?$_GET['page_size']:'20'; if($type == '0'){ $wsql = ' type = 0 and '; }elseif($type){ $wsql = ' type = '.$type.' and '; } if(isset($wsql)){ $wsql = ' where '.trim($wsql,' and '); }else{ $wsql = ''; } $type = $this->module('album')->path_type_cn(); $query = $this->db->get_all("select * from ".table('album').$wsql." order by id desc limit ".($page-1)*$page_size.",".$page_size.""); if($query){ foreach($query as $k=>$v){ $v['type'] = $type[$v['type']]; $v['size'] = format_bytes($v['size']); $v['addtime'] = _date($v['addtime']); $list[] = $v; } $data['list'] = $list; $total = $this->db->get_one("select count(id) as total from ".table('album').$wsql); if($page_size < $total['total']){ $data['page'] = $this->uqcms_page(array('page'=>$page,'page_size'=>$page_size,'total'=>$total['total'])); } $this->assign('data',$data); } $this->display(); } public function del(){ $id = !empty($_POST['id'])?$_POST['id']:error_json('提交错误'); if(!empty($id)){ $arr = explode(',',$id); foreach($arr as $k=>$v){ $row = $this->db->get_one("select * from ".table("album")." where id = ".$v); if($row['id']){ $q1 = $this->module('album')->del($row['url']); if($q1){ $count[] = ''; } } } if(count($arr) == count($count)){ right_json(); }else{ error_json('删除失败或者部分删除成功'); } }else{ error_json('提交不能为空'); } } public function upload(){ $path = !empty($_GET['path'])?$_GET['path']:'temp'; $data = $this->module('album')->upload($path); echo json_encode($data); } public function upload_edit($path){ $path = !empty($_GET['path'])?$_GET['path']:'temp'; $result = $this->module('album')->upload($path); if($result['error'] == '0'){ exit(json_encode(array('error'=>0, 'url' =>$result['url']))); }else{ exit(json_encode(array('error'=>1, 'message'=>$result['msg']))); } } function remove_file(){ $id = isset($_GET['id'])?$_GET['id']:showmsg('提交错误'); $row = $this->db->get_one("select * from ".table('album')." where id = ".$id); if($row['id']){ $this->module('album')->upload_move($row['url'], '', '', $row['url']); showmsg('移动成功'); } } }