Skip to content

Commit

Permalink
Fix: Browse files from all users in filter mode (#148)
Browse files Browse the repository at this point in the history
  • 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) { switch ($keyWords) {
case '{filterType:video}': case '{filterType:video}':
$fileList = Db::name('files') $fileList = Db::name('files')
->where('upload_user',$uid) ->where(function ($query)use($uid) {
->where('orign_name',"like","%.mp4") $query->where('upload_user',$uid);
->whereOr('orign_name',"like","%.flv") })
->whereOr('orign_name',"like","%.avi") ->where(function ($query) {
->whereOr('orign_name',"like","%.wmv") $query->where('orign_name',"like","%.mp4")
->whereOr('orign_name',"like","%.mkv") ->whereOr('orign_name',"like","%.flv")
->whereOr('orign_name',"like","%.rm") ->whereOr('orign_name',"like","%.avi")
->whereOr('orign_name',"like","%.rmvb") ->whereOr('orign_name',"like","%.wmv")
->whereOr('orign_name',"like","%.mov") ->whereOr('orign_name',"like","%.mkv")
->whereOr('orign_name',"like","%.ogv") ->whereOr('orign_name',"like","%.rm")
->whereOr('orign_name',"like","%.rmvb")
->whereOr('orign_name',"like","%.mov")
->whereOr('orign_name',"like","%.ogv");
})
->select(); ->select();
break; break;
case '{filterType:audio}': case '{filterType:audio}':
$fileList = Db::name('files') $fileList = Db::name('files')
->where('upload_user',$uid) ->where(function ($query)use($uid) {
->where('orign_name',"like","%.mp3") $query->where('upload_user',$uid);
->whereOr('orign_name',"like","%.flac") })
->whereOr('orign_name',"like","%.ape") ->where(function ($query) {
->whereOr('orign_name',"like","%.wav") $query->where('orign_name',"like","%.mp3")
->whereOr('orign_name',"like","%.acc") ->whereOr('orign_name',"like","%.flac")
->whereOr('orign_name',"like","%.ogg") ->whereOr('orign_name',"like","%.ape")
->whereOr('orign_name',"like","%.wav")
->whereOr('orign_name',"like","%.acc")
->whereOr('orign_name',"like","%.ogg");
})
->select(); ->select();
break; break;
case '{filterType:image}': case '{filterType:image}':
$fileList = Db::name('files') $fileList = Db::name('files')
->where('upload_user',$uid) ->where(function ($query)use($uid) {
->where('orign_name',"like","%.bmp") $query->where('upload_user',$uid);
->whereOr('orign_name',"like","%.flac") })
->whereOr('orign_name',"like","%.iff") ->where(function ($query) {
->whereOr('orign_name',"like","%.png") $query->where('orign_name',"like","%.bmp")
->whereOr('orign_name',"like","%.gif") ->whereOr('orign_name',"like","%.flac")
->whereOr('orign_name',"like","%.jpg") ->whereOr('orign_name',"like","%.iff")
->whereOr('orign_name',"like","%.jpge") ->whereOr('orign_name',"like","%.png")
->whereOr('orign_name',"like","%.psd") ->whereOr('orign_name',"like","%.gif")
->whereOr('orign_name',"like","%.svg") ->whereOr('orign_name',"like","%.jpg")
->whereOr('orign_name',"like","%.webp") ->whereOr('orign_name',"like","%.jpge")
->whereOr('orign_name',"like","%.psd")
->whereOr('orign_name',"like","%.svg")
->whereOr('orign_name',"like","%.webp");
})
->select(); ->select();
break; break;
case '{filterType:doc}': case '{filterType:doc}':
$fileList = Db::name('files') $fileList = Db::name('files')
->where('upload_user',$uid) ->where(function ($query)use($uid) {
->where('orign_name',"like","%.txt") $query->where('upload_user',$uid);
->whereOr('orign_name',"like","%.md") })
->whereOr('orign_name',"like","%.pdf") ->where(function ($query) {
->whereOr('orign_name',"like","%.doc") $query->where('orign_name',"like","%.txt")
->whereOr('orign_name',"like","%.docx") ->whereOr('orign_name',"like","%.md")
->whereOr('orign_name',"like","%.ppt") ->whereOr('orign_name',"like","%.pdf")
->whereOr('orign_name',"like","%.pptx") ->whereOr('orign_name',"like","%.doc")
->whereOr('orign_name',"like","%.xls") ->whereOr('orign_name',"like","%.docx")
->whereOr('orign_name',"like","%.xlsx") ->whereOr('orign_name',"like","%.ppt")
->whereOr('orign_name',"like","%.pptx")
->whereOr('orign_name',"like","%.xls")
->whereOr('orign_name',"like","%.xlsx");
})
->select(); ->select();
break; break;
default: 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 $upyunPolicy;
public $s3Policy; public $s3Policy;
public $s3Sign; public $s3Sign;
public $cosPolicy;
public $cosSign;
public $dirName; public $dirName;
public $s3Credential; public $s3Credential;
public $siteUrl; public $siteUrl;
Expand Down Expand Up @@ -319,6 +321,9 @@ public function getToken(){
case 'remote': case 'remote':
return $this->getRemoteToken(); return $this->getRemoteToken();
break; break;
case 'cos':
return $this->getCosToken();
break;
default: default:
# code... # code...
break; break;
Expand Down Expand Up @@ -514,6 +519,27 @@ public function getS3Token(){
$this->callBackKey = $callbackKey; $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(){ public function getOssToken(){
$dirName = $this->getObjName($this->policyContent['dirrule']); $dirName = $this->getObjName($this->policyContent['dirrule']);
$returnValu["expiration"] = date("Y-m-d",time()+1800)."T".date("H:i:s",time()+1800).".000Z"; $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.