Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix: Browse files from all users in filter mode (#148)
  • Loading branch information
HFO4 committed Mar 28, 2019
1 parent 7a530f5 commit 8e7704e
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 38 deletions.
92 changes: 54 additions & 38 deletions application/index/model/FileManage.php
Expand Up @@ -546,56 +546,72 @@ 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")
->where(function ($query)use($uid) {
$query->where('upload_user',$uid);
})
->where(function ($query) {
$query->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")
->where(function ($query)use($uid) {
$query->where('upload_user',$uid);
})
->where(function ($query) {
$query->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")
->where(function ($query)use($uid) {
$query->where('upload_user',$uid);
})
->where(function ($query) {
$query->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")
->where(function ($query)use($uid) {
$query->where('upload_user',$uid);
})
->where(function ($query) {
$query->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:
Expand Down
26 changes: 26 additions & 0 deletions application/index/model/UploadHandler.php
Expand Up @@ -26,6 +26,8 @@ class UploadHandler extends Model{
public $upyunPolicy;
public $s3Policy;
public $s3Sign;
public $cosPolicy;
public $cosSign;
public $dirName;
public $s3Credential;
public $siteUrl;
Expand Down Expand Up @@ -319,6 +321,9 @@ public function getToken(){
case 'remote':
return $this->getRemoteToken();
break;
case 'cos':
return $this->getCosToken();
break;
default:
# code...
break;
Expand Down Expand Up @@ -514,6 +519,27 @@ public function getS3Token(){
$this->callBackKey = $callbackKey;
}

public function getCosToken(){
$callbackKey = $this->getRandomKey();
$sqlData = [
'callback_key' => $callbackKey,
'pid' => $this->policyId,
'uid' => $this->userId
];
Db::name('callback')->insert($sqlData);
$dirName = $this->getObjName($this->policyContent['dirrule']);
$returnValu["expiration"] = date("Y-m-d",time()+1800)."T".date("H:i:s",time()+1800).".000Z";
$returnValu["conditions"][0]["bucket"] = $this->policyContent['bucketname'];
$returnValu["conditions"][1][0]="starts-with";
$returnValu["conditions"][1][1]='$key';
if($this->policyContent["autoname"]){
$this->ossFileName = $dirName.(empty($dirName)?"":"/").$this->getObjName($this->policyContent['namerule'],"oss");;
}else{
$this->ossFileName = $dirName.(empty($dirName)?"":"/").'${filename}';
}
$returnValu["conditions"][2]=["content-length-range",1,(int)$this->policyContent['max_size']];
}

public function getOssToken(){
$dirName = $this->getObjName($this->policyContent['dirrule']);
$returnValu["expiration"] = date("Y-m-d",time()+1800)."T".date("H:i:s",time()+1800).".000Z";
Expand Down

0 comments on commit 8e7704e

Please sign in to comment.