diff --git a/application/index/controller/Share.php b/application/index/controller/Share.php index 61733de7..59f2902d 100644 --- a/application/index/controller/Share.php +++ b/application/index/controller/Share.php @@ -35,9 +35,10 @@ class Share extends Controller{ 'dirData' => $shareObj->dirData, 'shareData' => $shareObj->shareData, 'loginStatus' => $this->userObj->loginStatus, - 'userData' => $this->userObj->userSQLData, + 'userData' => $this->userObj->getInfo(), 'groupData' => $shareObj->shareOwner->groupData, 'allowPreview' => Option::getValue("allowdVisitorDownload"), + 'path' => empty(input("get.path"))?"/":input("get.path"), ]); }else{ return view('share_single', [ @@ -85,6 +86,20 @@ class Share extends Controller{ } } + public function Content(){ + $shareId = input('param.key'); + $filePath = input('get.path'); + $shareObj = new ShareHandler($shareId,false); + if(empty($filePath)){ + //todo 单文件时 + }else{ + $contentHandller = $shareObj->getContent($this->userObj,$filePath); + } + if(!$contentHandller[0]){ + return json(["result"=>["success"=>false,"error"=>$contentHandller[1]]]); + } + } + public function chekPwd(){ $shareId = input('key'); $inputPwd = input('password'); @@ -122,7 +137,7 @@ class Share extends Controller{ $shareId = input('param.key'); $reqPathTo = stripslashes(json_decode(file_get_contents("php://input"),true)['path']); $shareObj = new ShareHandler($shareId,false); - return $shareObj->ListFile($reqPathTo); + return json($shareObj->ListFile($reqPathTo)); } public function ListPic(){ @@ -133,8 +148,8 @@ class Share extends Controller{ } public function Thumb(){ - $shareId = input('get.shareKey'); - $filePath = input('get.path'); + $shareId = input('param.key'); + $filePath = urldecode(input('get.path')); if(input("get.isImg") != "true"){ return ""; } @@ -147,6 +162,23 @@ class Share extends Controller{ } } + public function DocPreview(){ + $shareId = input('param.key'); + $filePath = urldecode(input('get.path')); + $shareObj = new ShareHandler($shareId,false); + if(empty($filePath)){ + //TODO 单文件时 + }else{ + $Redirect = $shareObj->getDocPreview($this->userObj,$filePath); + } + + if($Redirect[0]){ + $this->redirect($Redirect[1],302); + }else{ + $this->error($Redirect[1],403,$this->siteOptions); + } + } + public function Delete(){ $shareId = input('post.id'); $shareObj = new ShareHandler($shareId,false); diff --git a/application/index/controller/Viewer.php b/application/index/controller/Viewer.php index 014bf946..94ae7a39 100644 --- a/application/index/controller/Viewer.php +++ b/application/index/controller/Viewer.php @@ -7,6 +7,7 @@ use \app\index\model\Option; use \app\index\model\User; use think\Session; use \app\index\model\FileManage; +use \app\index\model\ShareHandler; class Viewer extends Controller{ @@ -26,12 +27,17 @@ class Viewer extends Controller{ $pathSplit = explode("/",urldecode($path)); $userInfo = $this->userObj->getInfo(); $groupData = $this->userObj->getGroupData(); + $url = "/File/Preview?action=preview&path=".$path; + if(input("get.share")==true){ + $url = "/Share/Preview/".input("get.shareKey")."/?path=".$path; + } return view('video', [ 'options' => Option::getValues(['basic']), 'userInfo' => $userInfo, 'groupData' => $groupData, - 'url' => "/File/Preview?action=preview&path=".$path, + 'url' => $url, 'fileName' => end($pathSplit), + 'isSharePage' => input("?get.share")?"true":"false", ]); } @@ -40,13 +46,18 @@ class Viewer extends Controller{ $pathSplit = explode("/",urldecode($path)); $userInfo = $this->userObj->getInfo(); $groupData = $this->userObj->getGroupData(); + $url = "/File/Content?action=preview&path=".$path; + if(input("get.share")==true){ + $url = "/Share/Content/".input("get.shareKey")."/?path=".$path; + } return view('markdown', [ 'options' => Option::getValues(['basic']), 'userInfo' => $userInfo, 'groupData' => $groupData, - 'url' => "/File/Content?action=preview&path=".$path, + 'url' => $url, 'fileName' => end($pathSplit), 'path' => urldecode($path), + 'isSharePage' => input("?get.share")?"true":"false", ]); } diff --git a/application/index/model/FileManage.php b/application/index/model/FileManage.php index 8b9f9aac..473d6ca4 100644 --- a/application/index/model/FileManage.php +++ b/application/index/model/FileManage.php @@ -636,11 +636,14 @@ class FileManage extends Model{ } /** - * [List description] - * @param [type] $path [description] - * @param [type] $uid [description] + * 列出文件 + * + * @param 路径 $path + * @param 用户UID $uid + * @param boolean $isShare 是否为分享模式下列出文件 + * @return void */ - static function ListFile($path,$uid){ + static function ListFile($path,$uid,$isShare=false,$originPath=null){ $fileList = Db::name('files')->where('upload_user',$uid)->where('dir',$path)->select(); $dirList = Db::name('folders')->where('owner',$uid)->where('position',$path)->select(); $count= 0; @@ -657,6 +660,12 @@ class FileManage extends Model{ $fileListData['result'][$count]['id'] = $value['id']; $fileListData['result'][$count]['pic'] = ""; $fileListData['result'][$count]['path'] = $value['position']; + if($isShare){ + if (substr($value['position'], 0, strlen($originPath)) == $originPath) { + $value['position'] = substr($value['position'], strlen($originPath)); + } + $fileListData['result'][$count]['path'] = ($value['position']=="")?"/":$value['position']; + } $count++; } foreach ($fileList as $key => $value) { @@ -665,10 +674,15 @@ class FileManage extends Model{ $fileListData['result'][$count]['size'] = $value['size']; $fileListData['result'][$count]['date'] = $value['upload_date']; $fileListData['result'][$count]['type'] = 'file'; - $fileListData['result'][$count]['name2'] = $value["dir"]; $fileListData['result'][$count]['id'] = $value["id"]; $fileListData['result'][$count]['pic'] = $value["pic_info"]; $fileListData['result'][$count]['path'] = $value['dir']; + if($isShare){ + if (substr($value['dir'], 0, strlen($originPath)) == $originPath) { + $value['dir'] = substr($value['dir'], strlen($originPath)); + } + $fileListData['result'][$count]['path'] = ($value['dir']=="")?"/":$value['dir']; + } $count++; } diff --git a/application/index/model/ShareHandler.php b/application/index/model/ShareHandler.php index fb59a8db..3305e076 100644 --- a/application/index/model/ShareHandler.php +++ b/application/index/model/ShareHandler.php @@ -95,6 +95,28 @@ class ShareHandler extends Model{ return $fileObj->getThumb(); } + public function getDocPreview($user,$path){ + $checkStatus = $this->checkSession($user); + if(!$checkStatus[0]){ + return [$checkStatus[0],$checkStatus[1]]; + } + $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); + $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + $tmpUrl = $fileObj->signTmpUrl(); + return[true,"http://view.officeapps.live.com/op/view.aspx?src=".urlencode($tmpUrl)]; + } + + public function getContent($user,$path=null){ + $checkStatus = $this->checkSession($user); + if(!$checkStatus[0]){ + return [$checkStatus[0],$checkStatus[1]]; + } + $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); + $fileObj = new FileManage($reqPath["position_absolute"].$path,$this->shareData["owner"]); + $fileObj->getContent(); + exit(); + } + public function checkSession($user){ if($this->lockStatus){ return [false,"会话过期,请刷新页面"]; @@ -146,7 +168,7 @@ class ShareHandler extends Model{ } $reqPath = Db::name('folders')->where('position_absolute',$this->shareData["source_name"])->find(); $path = $path == "/"?"":$path; - return FileManage::ListFile($this->shareData["source_name"].$path,$this->shareData["owner"]); + return FileManage::ListFile($this->shareData["source_name"].$path,$this->shareData["owner"],true,$this->shareData["source_name"]); } public function Preview($user){ diff --git a/application/index/view/error.html b/application/index/view/error.html index c7e74ff2..806ca31d 100644 --- a/application/index/view/error.html +++ b/application/index/view/error.html @@ -1,6 +1,4 @@ -{extend name="header_public" /} -{block name="title"}错误提示 - {$options.siteName}{/block} -{block name="content"} + @@ -19,6 +17,4 @@ -{$options.js_code} -{/block} \ No newline at end of file diff --git a/application/index/view/home/home.html b/application/index/view/home/home.html index 41d59e95..06a53f5d 100644 --- a/application/index/view/home/home.html +++ b/application/index/view/home/home.html @@ -1,6 +1,7 @@ - + + @@ -8,7 +9,7 @@ manifest.json provides metadata used when your web app is added to the homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> - + 我的文件 - {$options.siteName} - - - + colorTheme = { + "palette": { + "common": { + "black": "#000", + "white": "#fff" + }, + "background": { + "paper": "#fff", + "default": "#fafafa" + }, + "primary": { + "light": "#7986cb", + "main": "#3f51b5", + "dark": "#303f9f", + "contrastText": "#fff" + }, + "secondary": { + "light": "#ff4081", + "main": "#f50057", + "dark": "#c51162", + "contrastText": "#fff" + }, + "error": { + "light": "#e57373", + "main": "#f44336", + "dark": "#d32f2f", + "contrastText": "#fff" + }, + "text": { + "primary": "rgba(0, 0, 0, 0.87)", + "secondary": "rgba(0, 0, 0, 0.54)", + "disabled": "rgba(0, 0, 0, 0.38)", + "hint": "rgba(0, 0, 0, 0.38)" + }, + "explorer": { + "filename": "#474849", + "icon": "#8f8f8f", + "bgSelected": "#D5DAF0", + "emptyIcon": "#e8e8e8", + } + } + }; + isHomePage = true; + isSharePage = false; + uploadConfig = { + saveType: "{$policyData.policy_type}", + maxSize: "{$policyData.max_size}mb", + allowedType: [{$extLimit}], + allowSource: "{$policyData.origin_link}", + upUrl: "{$policyData.server}", + allowShare: "{$groupData.allow_share}", + allowRemoteDownload: "{:explode(",",$groupData.aria2)[0]}", + allowTorrentDownload: "{:explode(",",$groupData.aria2)[1]}", + }; + apiURL = { + imgThumb: "/File/Thumb", + preview: "/File/Preview", + download: "/File/Download", + docPreiview: '/File/DocPreview', + listFile:"/File/ListFile" + }; + userInfo = { + uid: {$userInfo.uid}, + nick: "{$userInfo.userNick}", + email: "{$userInfo.userMail}", + group: "{$userInfo.groupData.group_name}", + groupId: {$userInfo.groupData.id}, + groupColor: "{$userInfo.groupData.color}", + }; + siteInfo = { + mainTitle: "{$options.siteName}", + }; + path = "{$path}"; + mediaType = {}, + isMobile = window.innerWidth < 600; + + + + + @@ -71,10 +115,13 @@ To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/application/index/view/home/home1.html b/application/index/view/home/home1.html deleted file mode 100644 index 76332275..00000000 --- a/application/index/view/home/home1.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - 我的文件 - {$options.siteName} - - - - - - - - - - - - - - - - - -
- {include file="navbar_home" /} - - -
- -
-
- - - - - -{$options.js_code} - diff --git a/application/index/view/share/share_dir.html b/application/index/view/share/share_dir.html index 7dddde73..8337ff77 100644 --- a/application/index/view/share/share_dir.html +++ b/application/index/view/share/share_dir.html @@ -1,80 +1,95 @@ -{extend name="header_dir_share" /} -{block name="title"}{$dirData.folder_name} - {$options.siteName}{/block} -{block name="content"} - - - - - - - - + + + + + + + + + + {$dirData.folder_name} - {$options.siteName} + - - - - - - - - - - {$options.js_code} -{/block} \ No newline at end of file + mediaType = {}, + isMobile = window.innerWidth < 600; + + + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/application/index/view/share/share_dir_old.html b/application/index/view/share/share_dir_old.html new file mode 100644 index 00000000..7dddde73 --- /dev/null +++ b/application/index/view/share/share_dir_old.html @@ -0,0 +1,105 @@ +{extend name="header_dir_share" /} +{block name="title"}{$dirData.folder_name} - {$options.siteName}{/block} +{block name="content"} + + + + + + + + + + + + + + + + + + + + + + {$options.js_code} +{/block} \ No newline at end of file diff --git a/application/index/view/viewer/markdown.html b/application/index/view/viewer/markdown.html index d0ac0ec6..a253493e 100644 --- a/application/index/view/viewer/markdown.html +++ b/application/index/view/viewer/markdown.html @@ -21,7 +21,50 @@ --> {$fileName} - {$options.siteName} - - + + diff --git a/application/route.php b/application/route.php index 183ce4c9..87882181 100644 --- a/application/route.php +++ b/application/route.php @@ -24,4 +24,7 @@ Route::rule([ 'Member/Avatar/:uid/:size' => ['Member/Avatar',[],['uid'=>'\d+']], 'Profile/:uid' => ['Profile/index',[],['uid'=>'\d+']], 'Callback/Payment/Jinshajiang' => 'index/Callback/Jinshajiang', + 'Share/Thumb/:key' => 'index/Share/Thumb', + 'Share/DocPreview/:key' => 'index/Share/DocPreview', + 'Share/Content/:key' => 'index/Share/Content', ]); \ No newline at end of file