Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hexbee
Cloudreve
提交
f2d94ea4
C
Cloudreve
项目概览
hexbee
/
Cloudreve
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cloudreve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f2d94ea4
编写于
9月 11, 2018
作者:
H
HFO4
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add: policy adding form for Onedrive
上级
ca30b650
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
318 addition
and
6 deletion
+318
-6
application/index/controller/Admin.php
application/index/controller/Admin.php
+6
-4
application/index/model/AdminHandler.php
application/index/model/AdminHandler.php
+3
-2
application/index/view/admin/add_policy.html
application/index/view/admin/add_policy.html
+10
-0
application/index/view/admin/add_policy_onedrive.html
application/index/view/admin/add_policy_onedrive.html
+155
-0
application/index/view/admin/edit_policy.html
application/index/view/admin/edit_policy.html
+122
-0
application/index/view/admin/policy_list.html
application/index/view/admin/policy_list.html
+4
-0
static/img/onedrive.png
static/img/onedrive.png
+0
-0
static/js/admin/add_policy.js
static/js/admin/add_policy.js
+18
-0
未找到文件。
application/index/controller/Admin.php
浏览文件 @
f2d94ea4
...
...
@@ -451,6 +451,12 @@ class Admin extends Controller{
]);
}
public
function
PolicyAddOnedrive
(){
return
view
(
'add_policy_onedrive'
,
[
'options'
=>
$this
->
siteOptions
,
]);
}
public
function
About
(){
$verison
=
json_decode
(
file_get_contents
(
ROOT_PATH
.
"application/version.json"
),
true
);
return
view
(
'about'
,
[
...
...
@@ -524,9 +530,5 @@ class Admin extends Controller{
$code
=
input
(
"get.code"
);
$this
->
adminObj
->
oneDriveCalllback
(
$code
);
}
public
function
uploadTest
(){
$this
->
adminObj
->
oneDriveTest
();
}
}
application/index/model/AdminHandler.php
浏览文件 @
f2d94ea4
...
...
@@ -147,7 +147,7 @@ class AdminHandler extends Model{
}
catch
(
Exception
$e
)
{
return
[
"error"
=>
1
,
"msg"
=>
$e
->
getMessage
()];
}
return
[
"error"
=>
200
,
"msg"
=>
"设置已保存"
];
return
[
"error"
=>
200
,
"msg"
=>
"设置已保存"
,
"id"
=>
Db
::
name
(
'policy'
)
->
getLastInsID
()
];
}
public
function
editPolicy
(
$options
){
...
...
@@ -724,7 +724,7 @@ class AdminHandler extends Model{
'offline_access'
,
'files.readwrite.all'
,
],
Option
::
getValue
(
"siteURL"
)
.
"Admin/oneDriveCalllback"
);
echo
"<
a href='
$url
'>继续绑定账号</a>
"
;
echo
"<
script>location.href='"
.
$url
.
"'</script>正在跳转至Onedrive账号授权页面,如果没有跳转,请<a href='
$url
'>点击这里</a>。
"
;
Db
::
name
(
"policy"
)
->
where
(
"id"
,
$policyId
)
->
update
([
"sk"
=>
json_encode
(
$onedrive
->
getState
()),
...
...
@@ -754,6 +754,7 @@ class AdminHandler extends Model{
Db
::
name
(
"policy"
)
->
where
(
"id"
,
$policyId
)
->
update
([
"sk"
=>
json_encode
(
$onedrive
->
getState
()),
]);
echo
"<script>location.href='/Admin/PolicyList?page=1'</script>"
;
}
}
...
...
application/index/view/admin/add_policy.html
浏览文件 @
f2d94ea4
...
...
@@ -82,6 +82,16 @@
</div>
</div>
</div>
<div
class=
"col-md-3 mt-2 md-2"
>
<div
class=
"card cloud"
>
<img
class=
"card-img-top"
src=
"/static/img/onedrive.png"
alt=
"Card image cap"
>
<div
class=
"card-body"
>
<h5
class=
"card-title"
>
Onedrive
<span
class=
"badge badge-warning"
>
中转
</span></h5>
<p
class=
"card-text"
>
支持 Onedrive Bussiness 和个人版。
<a
href=
"https://github.com/HFO4/Cloudreve/wiki/Onedrive%E5%AF%B9%E6%8E%A5%E8%AF%B4%E6%98%8E"
>
配置说明
</a></p>
<a
href=
"/Admin/PolicyAddOnedrive"
class=
"btn btn-primary"
>
添加
</a>
</div>
</div>
</div>
</div>
</div>
...
...
application/index/view/admin/add_policy_onedrive.html
0 → 100644
浏览文件 @
f2d94ea4
{extend name="header_admin" /}
{block name="title"}添加上传策略- {$options.siteName}{/block}
{block name="content"}
<div
class=
"content-wrapper"
>
<div
class=
"container-fluid"
>
<!-- Breadcrumbs-->
<ol
class=
"breadcrumb"
>
<li
class=
"breadcrumb-item"
>
<a
href=
"/Admin"
>
管理面板
</a>
</li>
<li
class=
"breadcrumb-item"
>
<a
href=
"/Admin/PolicyAdd"
>
上传策略
</a>
</li>
<li
class=
"breadcrumb-item active"
>
添加
</li>
</ol>
<!-- Area Chart Example-->
<div
class=
"row"
>
<div
class=
"col-12"
>
<h2>
添加上传策略
</h2>
<br>
<div
class=
"alert alert-warning"
role=
"alert"
>
<strong>
添加Onedrive上传策略前请确保阅读完下面内容!
</strong>
<ul>
<li>
Onedrive策略无法直传,上传文件时,Cloudreve会先将文件暂存在服务器,之后再由任务队列上传至Onedrive;
</li>
<li>
使用本策略前,请先配置并运行
<a
href=
"https://github.com/HFO4/Cloudreve/wiki/Onedrive%E5%AF%B9%E6%8E%A5%E8%AF%B4%E6%98%8E"
>
Cloudreve任务队列
</a>
,否则正常无法使用;
</li>
<li>
用户上传文件后不能立马看到所上传的文件,需要等待任务队列处理完毕;
</li>
<li>
请确保已经正确配置好Cloudreve的Cron定时任务,以便用于刷新AccessToken信息。
</li>
</ul>
</div>
<div
class=
"card"
id=
"s3"
>
<div
class=
"card-header"
>
添加Onedrive上传策略
</div>
<div
class=
"card-body"
>
<form
id=
"onedrivePolicy"
>
<input
type=
"text"
class=
"form-control"
name=
"policy_type"
value=
"onedrive"
style=
"display: none"
>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"policy_name"
class=
"col-form-label col-form-label-sm"
>
上传策略名称
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"policy_name"
required
></div>
<div
class=
"col-md-4 option-des"
>
上传策略的名称,用于区别不同策略
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"bucketname"
class=
"col-form-label col-form-label-sm"
>
应用 ID(Client ID)
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"bucketname"
required
></div>
<div
class=
"col-md-4 option-des"
>
请
<a
href=
"https://apps.dev.microsoft.com/?referrer=https%3a%2f%2fdeveloper.microsoft.com%2fzh-CN%2fgraph%2fquick-start#/quickstart/graphIO?publicClientSupport=false&appName=Cloudreve&redirectUrl={:urlencode($options.siteURL)}Admin%2FoneDriveCalllback&allowImplicitFlow=false&ru=https:%2F%2Fdeveloper.microsoft.com%2Fzh-CN%2Fgraph%2Fquick-start%3FappID%3D_appId_%26appName%3D_appName_%26redirectUrl%3D{$options.siteURL}Admin/oneDriveCalllback%26platform%3Doption-php"
target=
"_blank"
>
点击这里
</a>
获取下一步要用到的应用机密和此处的应用ID
</div>
</div>
<input
type=
"text"
class=
"form-control"
name=
"sk"
value=
"0"
style=
"display: none"
required
>
<input
type=
"text"
name=
"bucket_private"
value=
"1"
style=
"display: none"
>
<input
type=
"text"
name=
"origin_link"
value=
"0"
style=
"display: none"
>
<input
type=
"text"
name=
"url"
value=
"0"
style=
"display: none"
>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"url"
class=
"col-form-label col-form-label-sm"
>
应用机密(密码/公钥)
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"ak"
required
>
</div>
<div
class=
"col-md-4 option-des"
>
同上一项一起获取
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"filetype"
class=
"col-form-label col-form-label-sm"
>
单文件最大大小
</label>
</div>
<div
class=
"col-md-4 input-group mb-3"
>
<input
type=
"number"
class=
"form-control"
name=
"max_size"
spellcheck=
"false"
min=
"0"
value=
"10"
required
>
<div
class=
"input-group-append"
>
<span
class=
"input-group-text"
id=
"basic-addon2"
>
<select
name=
"sizeTimes"
class=
"selectIn"
>
<option
value=
"1"
>
B
</option>
<option
value=
"1024"
>
KB
</option>
<option
value=
"1048576"
selected
>
MB
</option>
<option
value=
"1073741824"
>
GB
</option>
</select>
</span>
</div>
</div>
<div
class=
"col-md-4 option-des"
>
允许上传的单个文件的最大尺寸
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"filetype"
class=
"col-form-label col-form-label-sm"
>
文件重命名
</label>
</div>
<div
class=
"col-md-4"
>
<input
class=
""
type=
"radio"
name=
"autoname"
id=
"autoname1"
value=
"1"
checked
>
<label
class=
""
for=
"autoname1"
>
开启
</label>
<input
class=
""
type=
"radio"
name=
"autoname"
id=
"autoname2"
value=
"0"
>
<label
class=
""
for=
"autoname2"
>
关闭
</label>
</div>
<div
class=
"col-md-4 option-des"
>
是否对存储的文件自动重命名。推荐开启,重命名不会影响用户端文件名展示,开启后可以避免文件重名
</div>
</div>
<div
class=
"row form-setting"
id=
"autoname_form"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"url"
class=
"col-form-label col-form-label-sm"
>
重命名规则
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"namerule"
value=
"{uid}_{randomkey8}_{originname}"
spellcheck=
"false"
required
>
</div>
<div
class=
"col-md-4 option-des"
>
你可以使用变量对照表中的字段填写
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"filetype"
class=
"col-form-label col-form-label-sm"
>
存储目录
</label>
</div>
<div
class=
"col-md-4 input-group mb-3"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
id=
"basic-addon2"
>
Onedrive根目录
</span>
</div>
<input
type=
"text"
class=
"form-control"
name=
"dirrule"
spellcheck=
"false"
value=
"{date}/{uid}"
required
>
</div>
<div
class=
"col-md-4 option-des"
>
文件存放的目录,你可以使用目录变量对照表中的字段填写
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
</div>
<div
class=
"col-md-4"
>
<button
type=
"submit"
class=
"btn btn-primary"
id=
"saveQiniu"
>
保存并继续
</button></div>
<div
class=
"col-md-4 option-des"
>
</div>
<br>
<br>
</div>
</form>
</div>
<bn>
</div>
<br>
</div>
</div>
<!-- Example DataTables Card-->
</div>
<!-- /.container-fluid-->
</div>
{/block}
{block name="js"}
<script
src=
"/static/js/admin/add_policy.js"
></script>
{/block}
\ No newline at end of file
application/index/view/admin/edit_policy.html
浏览文件 @
f2d94ea4
...
...
@@ -928,6 +928,128 @@
</div>
{/case}
{case value="onedrive"}
<div
class=
"alert alert-warning"
role=
"alert"
>
<strong>
添加Onedrive上传策略前请确保阅读完下面内容!
</strong>
<ul>
<li>
Onedrive策略无法直传,上传文件时,Cloudreve会先将文件暂存在服务器,之后再由任务队列上传至Onedrive;
</li>
<li>
使用本策略前,请先配置并运行
<a
href=
"https://github.com/HFO4/Cloudreve/wiki/Onedrive%E5%AF%B9%E6%8E%A5%E8%AF%B4%E6%98%8E"
>
Cloudreve任务队列
</a>
,否则正常无法使用;
</li>
<li>
用户上传文件后不能立马看到所上传的文件,需要等待任务队列处理完毕;
</li>
<li>
请确保已经正确配置好Cloudreve的Cron定时任务,以便用于刷新AccessToken信息。
</li>
</ul>
</div>
<div
class=
"card"
id=
"s3"
>
<div
class=
"card-header"
>
添加Onedrive上传策略
</div>
<div
class=
"card-body"
>
<form
id=
"Policy"
>
<input
type=
"text"
value=
"{$policy.id}"
name=
"id"
style=
"display: none"
>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"policy_name"
class=
"col-form-label col-form-label-sm"
>
上传策略名称
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
value=
"{$policy.policy_name}"
name=
"policy_name"
required
></div>
<div
class=
"col-md-4 option-des"
>
上传策略的名称,用于区别不同策略
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"bucketname"
class=
"col-form-label col-form-label-sm"
>
应用 ID(Client ID)
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"bucketname"
value=
"{$policy.bucketname}"
required
></div>
<div
class=
"col-md-4 option-des"
>
请
<a
href=
"https://apps.dev.microsoft.com/?referrer=https%3a%2f%2fdeveloper.microsoft.com%2fzh-CN%2fgraph%2fquick-start#/quickstart/graphIO?publicClientSupport=false&appName=Cloudreve&redirectUrl={:urlencode($options.siteURL)}Admin%2FoneDriveCalllback&allowImplicitFlow=false&ru=https:%2F%2Fdeveloper.microsoft.com%2Fzh-CN%2Fgraph%2Fquick-start%3FappID%3D_appId_%26appName%3D_appName_%26redirectUrl%3D{$options.siteURL}Admin/oneDriveCalllback%26platform%3Doption-php"
target=
"_blank"
>
点击这里
</a>
获取下一步要用到的应用机密和此处的应用ID
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"url"
class=
"col-form-label col-form-label-sm"
>
应用机密(密码/公钥)
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"ak"
value=
"{$policy.ak}"
required
>
</div>
<div
class=
"col-md-4 option-des"
>
同上一项一起获取
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"filetype"
class=
"col-form-label col-form-label-sm"
>
单文件最大大小
</label>
</div>
<div
class=
"col-md-4 input-group mb-3"
>
<input
type=
"number"
class=
"form-control"
name=
"max_size"
spellcheck=
"false"
min=
"0"
value=
"{:countSize($policy.max_size,true)[0]}"
required
>
<div
class=
"input-group-append"
>
<span
class=
"input-group-text"
id=
"basic-addon2"
>
<select
name=
"sizeTimes"
class=
"selectIn"
data-value=
"{:countSize($policy.max_size,true)[1]}"
>
<option
value=
"1"
>
B
</option>
<option
value=
"1024"
>
KB
</option>
<option
value=
"1048576"
>
MB
</option>
<option
value=
"1073741824"
>
GB
</option>
</select>
</span>
</div>
</div>
<div
class=
"col-md-4 option-des"
>
允许上传的单个文件的最大尺寸
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"filetype"
class=
"col-form-label col-form-label-sm"
>
文件重命名
</label>
</div>
<div
class=
"col-md-4"
>
{eq name="$policy.autoname" value="1"}
<input
class=
""
type=
"radio"
name=
"autoname"
id=
"autoname1"
value=
"1"
checked
>
<label
class=
""
for=
"autoname1"
>
开启
</label>
<input
class=
""
type=
"radio"
name=
"autoname"
id=
"autoname2"
value=
"0"
>
<label
class=
""
for=
"autoname2"
>
关闭
</label>
{else/}
<input
class=
""
type=
"radio"
name=
"autoname"
id=
"autoname1"
value=
"1"
>
<label
class=
""
for=
"autoname1"
>
开启
</label>
<input
class=
""
type=
"radio"
name=
"autoname"
id=
"autoname2"
value=
"0"
checked
>
<label
class=
""
for=
"autoname2"
>
关闭
</label>
{/eq}
</div>
<div
class=
"col-md-4 option-des"
>
是否对存储的文件自动重命名。推荐开启,重命名不会影响用户端文件名展示,开启后可以避免文件重名
</div>
</div>
<div
class=
"row form-setting"
id=
"autoname_form"
style=
" {eq name="
$
policy.autoname
"
value=
"0"
}
display:none
{/
eq
}"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"url"
class=
"col-form-label col-form-label-sm"
>
重命名规则
</label>
</div>
<div
class=
"col-md-4"
>
<input
type=
"text"
class=
"form-control"
name=
"namerule"
value=
"{$policy.namerule}"
spellcheck=
"false"
required
>
</div>
<div
class=
"col-md-4 option-des"
>
你可以使用
<a
href=
"javascript:void()"
data-toggle=
"modal"
data-target=
"#varTable"
>
变量对照表
</a>
中的字段填写
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
<label
for=
"filetype"
class=
"col-form-label col-form-label-sm"
>
存储目录
</label>
</div>
<div
class=
"col-md-4 input-group mb-3"
>
<div
class=
"input-group-prepend"
>
<span
class=
"input-group-text"
id=
"basic-addon2"
>
Onedrive根目录/
</span>
</div>
<input
type=
"text"
class=
"form-control"
name=
"dirrule"
spellcheck=
"false"
value=
"{$policy.dirrule}"
required
>
</div>
<div
class=
"col-md-4 option-des"
>
文件存放的目录,你可以使用
<a
href=
"javascript:void()"
data-toggle=
"modal"
data-target=
"#varTableFolder"
>
目录变量对照表
</a>
中的字段填写
</div>
</div>
<div
class=
"row form-setting"
>
<div
class=
"col-md-1 form-label "
>
</div>
<div
class=
"col-md-4"
>
<button
type=
"submit"
class=
"btn btn-primary"
id=
"saveQiniu"
>
保存
</button>
<a
class=
"btn btn-danger"
href=
"/Admin/UpdateOnedriveToken?id={$policy.id}"
id=
"saveQiniu"
>
重新授权账号(请先保存)
</a></div>
<div
class=
"col-md-4 option-des"
>
</div>
<br>
<br>
</div>
</form>
</div>
<bn>
</div>
{/case}
{/switch}
<br>
</div>
...
...
application/index/view/admin/policy_list.html
浏览文件 @
f2d94ea4
...
...
@@ -45,6 +45,9 @@
<li
class=
"nav-item"
>
<a
class=
"nav-link selectLab"
href=
"javascript:void()"
data-policy=
"remote"
>
远程
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link selectLab"
href=
"javascript:void()"
data-policy=
"onedrive"
>
Onedrive
</a>
</li>
</ul>
</div>
</div>
...
...
@@ -82,6 +85,7 @@
{case value="upyun"}又拍云{/case}
{case value="s3"}Amazon S3{/case}
{case value="remote"}远程{/case}
{case value="onedrive"}Onedrive{/case}
{default /}其他
{/switch}
</td>
...
...
static/img/onedrive.png
0 → 100644
浏览文件 @
f2d94ea4
26.4 KB
static/js/admin/add_policy.js
浏览文件 @
f2d94ea4
...
...
@@ -56,6 +56,24 @@ $("#localPolicy").submit(function() {
});
return
false
;
})
$
(
"
#onedrivePolicy
"
).
submit
(
function
()
{
$
(
"
#savePolicy
"
).
attr
(
"
disabled
"
,
"
true
"
);
$
.
post
(
"
/Admin/SavePolicy
"
,
$
(
"
#onedrivePolicy
"
).
serialize
()
,
function
(
data
)
{
if
(
data
.
error
==
"
1
"
)
{
toastr
[
"
warning
"
](
data
.
msg
);
$
(
"
#savePolicy
"
).
removeAttr
(
"
disabled
"
);
}
else
if
(
data
.
error
==
"
200
"
)
{
toastr
[
"
success
"
](
"
上传策略已添加
"
);
location
.
href
=
"
/Admin/UpdateOnedriveToken?id=
"
+
data
.
id
;
}
else
{
toastr
[
"
warning
"
](
"
未知错误
"
);
$
(
"
#savePolicy
"
).
removeAttr
(
"
disabled
"
);
}
});
return
false
;
})
$
(
"
#qiniuPolicy
"
).
submit
(
function
()
{
$
(
"
#saveQiniu
"
).
attr
(
"
disabled
"
,
"
true
"
);
$
.
post
(
"
/Admin/SavePolicy
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录