Feat: file type filter &Fix: cannot create torrent remote download in onedrive policy
This commit is contained in:
parent
c94e17a4da
commit
2e2357e794
6 changed files with 89 additions and 16 deletions
|
@ -87,9 +87,11 @@ class File extends Controller{
|
|||
}
|
||||
|
||||
public function Share(){
|
||||
$reqPath = json_decode(file_get_contents("php://input"),true)['item'];
|
||||
$shareType = json_decode(file_get_contents("php://input"),true)['shareType'];
|
||||
ShareHandler::createShare($reqPath,$shareType,$this->userObj->getSQLData(),$this->userObj->getGroupData());
|
||||
$reqData = json_decode(file_get_contents("php://input"),true);
|
||||
$reqPath = $reqData['item'];
|
||||
$shareType = $reqData['shareType'];
|
||||
$sharePwd = $reqData['pwd'];
|
||||
ShareHandler::createShare($reqPath,$shareType,$sharePwd,$this->userObj->getSQLData(),$this->userObj->getGroupData());
|
||||
}
|
||||
|
||||
public function gerSource(){
|
||||
|
|
|
@ -63,8 +63,8 @@ class RemoteDownload extends Controller{
|
|||
|
||||
public function AddTorrent(){
|
||||
$policyData = Db::name("policy")->where("id",$this->userObj->groupData["policy_name"])->find();
|
||||
if(!$this->checkPerimission(0) || $policyData["policy_type"] != "local"){
|
||||
return json(['error'=>1,'message'=>'您当前的无用户无法执行此操作']);
|
||||
if(!$this->checkPerimission(0) || $policyData["policy_type"] != "local" && $policyData["policy_type"] != "onedrive"){
|
||||
return json(["result"=>['success'=>false,'error'=>"您当前的无用户无法执行此操作"]]);
|
||||
}
|
||||
$downloadingLength = Db::name("download")
|
||||
->where("owner",$this->userObj->uid)
|
||||
|
|
|
@ -542,11 +542,79 @@ class FileManage extends Model{
|
|||
])->setDec('used_storage', $size);
|
||||
}
|
||||
|
||||
static function filterFile($keyWords,$uid){
|
||||
switch ($keyWords) {
|
||||
case '{filterType:video}':
|
||||
$fileList = Db::name('files')
|
||||
->where('upload_user',$uid)
|
||||
->where('orign_name',"like","%.mp4")
|
||||
->whereOr('orign_name',"like","%.flv")
|
||||
->whereOr('orign_name',"like","%.avi")
|
||||
->whereOr('orign_name',"like","%.wmv")
|
||||
->whereOr('orign_name',"like","%.mkv")
|
||||
->whereOr('orign_name',"like","%.rm")
|
||||
->whereOr('orign_name',"like","%.rmvb")
|
||||
->whereOr('orign_name',"like","%.mov")
|
||||
->whereOr('orign_name',"like","%.ogv")
|
||||
->select();
|
||||
break;
|
||||
case '{filterType:audio}':
|
||||
$fileList = Db::name('files')
|
||||
->where('upload_user',$uid)
|
||||
->where('orign_name',"like","%.mp3")
|
||||
->whereOr('orign_name',"like","%.flac")
|
||||
->whereOr('orign_name',"like","%.ape")
|
||||
->whereOr('orign_name',"like","%.wav")
|
||||
->whereOr('orign_name',"like","%.acc")
|
||||
->whereOr('orign_name',"like","%.ogg")
|
||||
->select();
|
||||
break;
|
||||
case '{filterType:image}':
|
||||
$fileList = Db::name('files')
|
||||
->where('upload_user',$uid)
|
||||
->where('orign_name',"like","%.bmp")
|
||||
->whereOr('orign_name',"like","%.flac")
|
||||
->whereOr('orign_name',"like","%.iff")
|
||||
->whereOr('orign_name',"like","%.png")
|
||||
->whereOr('orign_name',"like","%.gif")
|
||||
->whereOr('orign_name',"like","%.jpg")
|
||||
->whereOr('orign_name',"like","%.jpge")
|
||||
->whereOr('orign_name',"like","%.psd")
|
||||
->whereOr('orign_name',"like","%.svg")
|
||||
->whereOr('orign_name',"like","%.webp")
|
||||
->select();
|
||||
break;
|
||||
case '{filterType:doc}':
|
||||
$fileList = Db::name('files')
|
||||
->where('upload_user',$uid)
|
||||
->where('orign_name',"like","%.txt")
|
||||
->whereOr('orign_name',"like","%.md")
|
||||
->whereOr('orign_name',"like","%.pdf")
|
||||
->whereOr('orign_name',"like","%.doc")
|
||||
->whereOr('orign_name',"like","%.docx")
|
||||
->whereOr('orign_name',"like","%.ppt")
|
||||
->whereOr('orign_name',"like","%.pptx")
|
||||
->whereOr('orign_name',"like","%.xls")
|
||||
->whereOr('orign_name',"like","%.xlsx")
|
||||
->select();
|
||||
break;
|
||||
default:
|
||||
$fileList = [];
|
||||
break;
|
||||
}
|
||||
return $fileList;
|
||||
}
|
||||
|
||||
static function searchFile($keyWords,$uid){
|
||||
$fileList = Db::name('files')
|
||||
->where('upload_user',$uid)
|
||||
->where('orign_name',"like","%$keyWords%")
|
||||
->select();
|
||||
if (0 === strpos($keyWords, '{filterType:')) {
|
||||
$fileList = self::filterFile($keyWords,$uid);
|
||||
}else{
|
||||
$fileList = Db::name('files')
|
||||
->where('upload_user',$uid)
|
||||
->where('orign_name',"like","%$keyWords%")
|
||||
->select();
|
||||
}
|
||||
|
||||
$count= 0;
|
||||
$fileListData=[
|
||||
"result"=>[],
|
||||
|
|
|
@ -235,7 +235,7 @@ class ShareHandler extends Model{
|
|||
}
|
||||
}
|
||||
|
||||
static function createShare($fname,$type,$user,$group){
|
||||
static function createShare($fname,$type,$pwd,$user,$group){
|
||||
if(!$group["allow_share"]){
|
||||
self::setError("您当前的用户组无权分享文件");
|
||||
}
|
||||
|
@ -243,9 +243,9 @@ class ShareHandler extends Model{
|
|||
$fnameTmp = FileManage::getFileName($fname)[0];
|
||||
$fileRecord = Db::name('files')->where('upload_user',$user["id"])->where('orign_name',$fnameTmp)->where('dir',$path)->find();
|
||||
if(empty($fileRecord)){
|
||||
self::createDirShare($fname,$type,$user,$group);
|
||||
self::createDirShare($fname,$type,$pwd,$user,$group);
|
||||
}else{
|
||||
self::createFileShare($fileRecord,$type,$user,$group);
|
||||
self::createFileShare($fileRecord,$type,$pwd,$user,$group);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,13 +257,13 @@ class ShareHandler extends Model{
|
|||
die('{ "result": "'.$text.'" }');
|
||||
}
|
||||
|
||||
static function createDirShare($fname,$type,$user,$group){
|
||||
static function createDirShare($fname,$type,$pwd,$user,$group){
|
||||
$dirRecord = Db::name('folders')->where('owner',$user["id"])->where('position_absolute',$fname)->find();
|
||||
if(empty($dirRecord)){
|
||||
self::setError("目录不存在");
|
||||
}
|
||||
$shareKey = self::getRandomKey(8);
|
||||
$sharePwd = $type=="public" ? "0" : self::getRandomKey(6);
|
||||
$sharePwd = $type=="public" ? "0" : $pwd;
|
||||
$SQLData = [
|
||||
'type' => $type=="public" ? "public" : "private",
|
||||
'share_time' => date("Y-m-d H:i:s"),
|
||||
|
@ -285,9 +285,9 @@ class ShareHandler extends Model{
|
|||
}
|
||||
}
|
||||
|
||||
static function createFileShare($file,$type,$user,$group){
|
||||
static function createFileShare($file,$type,$pwd,$user,$group){
|
||||
$shareKey = self::getRandomKey(8);
|
||||
$sharePwd = $type=="public" ? "0" : self::getRandomKey(6);
|
||||
$sharePwd = $type=="public" ? "0" : $pwd;
|
||||
$SQLData = [
|
||||
'type' => $type=="public" ? "public" : "private",
|
||||
'share_time' => date("Y-m-d H:i:s"),
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
apiURL={
|
||||
imgThumb:"/File/Thumb",
|
||||
preview:"/File/Preview",
|
||||
download:"/File/Download",
|
||||
docPreiview:'/File/DocPreview',
|
||||
};
|
||||
mediaType = {}
|
||||
</script>
|
||||
|
|
1
static/media/default-skin.b257fa9c.svg
Normal file
1
static/media/default-skin.b257fa9c.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg width="264" height="88" viewBox="0 0 264 88" xmlns="http://www.w3.org/2000/svg"><title>default-skin 2</title><g fill="none" fill-rule="evenodd"><g><path d="M67.002 59.5v3.768c-6.307.84-9.184 5.75-10.002 9.732 2.22-2.83 5.564-5.098 10.002-5.098V71.5L73 65.585 67.002 59.5z" id="Shape" fill="#fff"/><g fill="#fff"><path d="M13 29v-5h2v3h3v2h-5zM13 15h5v2h-3v3h-2v-5zM31 15v5h-2v-3h-3v-2h5zM31 29h-5v-2h3v-3h2v5z" id="Shape"/></g><g fill="#fff"><path d="M62 24v5h-2v-3h-3v-2h5zM62 20h-5v-2h3v-3h2v5zM70 20v-5h2v3h3v2h-5zM70 24h5v2h-3v3h-2v-5z"/></g><path d="M20.586 66l-5.656-5.656 1.414-1.414L22 64.586l5.656-5.656 1.414 1.414L23.414 66l5.656 5.656-1.414 1.414L22 67.414l-5.656 5.656-1.414-1.414L20.586 66z" fill="#fff"/><path d="M111.785 65.03L110 63.5l3-3.5h-10v-2h10l-3-3.5 1.785-1.468L117 59l-5.215 6.03z" fill="#fff"/><path d="M152.215 65.03L154 63.5l-3-3.5h10v-2h-10l3-3.5-1.785-1.468L147 59l5.215 6.03z" fill="#fff"/><g><path id="Rectangle-11" fill="#fff" d="M160.957 28.543l-3.25-3.25-1.413 1.414 3.25 3.25z"/><path d="M152.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" id="Oval-1" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M150 21h5v1h-5z"/></g><g><path d="M116.957 28.543l-1.414 1.414-3.25-3.25 1.414-1.414 3.25 3.25z" fill="#fff"/><path d="M108.5 27c3.038 0 5.5-2.462 5.5-5.5s-2.462-5.5-5.5-5.5-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5z" stroke="#fff" stroke-width="1.5"/><path fill="#fff" d="M106 21h5v1h-5z"/><path fill="#fff" d="M109.043 19.008l-.085 5-1-.017.085-5z"/></g></g></g></svg>
|
After Width: | Height: | Size: 1.5 KiB |
Loading…
Add table
Reference in a new issue