切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
Karson
8 years ago
提交
2bc34f575f7d9c0dd2eb715712cf4d29f1234739
1 个父辈
ed231a03
上传又拍云时可扩展参数
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
38 行增加
和
32 行删除
application/common/controller/Backend.php
application/common/model/Configvalue.php
application/common/controller/Backend.php
查看文件 @
2bc34f5
...
...
@@ -117,26 +117,13 @@ class Backend extends Controller
$this
->
view
->
engine
->
layout
(
'layout/'
.
$this
->
layout
);
}
// 上传参数配置配置
$uploadcfg
=
Configvalue
::
upload
();
$upload
=
[
'uploadurl'
=>
$uploadcfg
[
'uploadurl'
],
'cdnurl'
=>
$uploadcfg
[
'cdnurl'
],
'multipart'
=>
[
'policy'
=>
$uploadcfg
[
'policy'
],
'signature'
=>
$uploadcfg
[
'signature'
]
],
'maxsize'
=>
$uploadcfg
[
'maxsize'
],
'mimetype'
=>
$uploadcfg
[
'mimetype'
],
];
// 语言检测
$lang
=
Lang
::
detect
();
// 配置信息
$config
=
[
'site'
=>
Config
::
get
(
"site"
),
'upload'
=>
$upload
,
'upload'
=>
Configvalue
::
upload
()
,
'modulename'
=>
$modulename
,
'controllername'
=>
$controllername
,
'actionname'
=>
$actionname
,
...
...
application/common/model/Configvalue.php
查看文件 @
2bc34f5
...
...
@@ -21,34 +21,53 @@ class Configvalue extends Model
/**
* 加载上传配置
*
* @param string $savekey 保存路径 例:/{year}/{mon}/{day}/{filemd5}{.suffix}
* @param mixed $mimetype 上传类型 例:image/*,application/zip
* @param int $maxsize 上传文件大小 例:10mb
* @param array $params 扩展参数,常用字段savekey,mimetype,maxsize,ext-param,notify-url,return-url<br>
* 更多字段可参考http://docs.upyun.com/api/form_api/#_2
*
* @return array
*/
public
static
function
upload
(
$
savekey
=
''
,
$mimetype
=
''
,
$maxsize
=
''
)
public
static
function
upload
(
$
params
=
[]
)
{
$uploadcfg
=
Config
::
get
(
'upload'
);
$uploadcfg
=
$uploadcfg
?
$uploadcfg
:
[];
$bucket
=
isset
(
$uploadcfg
[
'bucket'
])
?
$uploadcfg
[
'bucket'
]
:
''
;
$savekey
=
$savekey
?
$savekey
:
(
isset
(
$uploadcfg
[
'savekey'
])
?
$uploadcfg
[
'savekey'
]
:
''
);
$expiration
=
time
()
+
(
isset
(
$uploadcfg
[
'expire'
])
?
$uploadcfg
[
'expire'
]
:
0
);
$options
=
[
'bucket'
=>
$bucket
,
'save-key'
=>
$savekey
,
'expiration'
=>
$expiration
$uploadcfg
=
array_merge
(
$uploadcfg
,
$params
);
$uploadcfg
[
'bucket'
]
=
isset
(
$uploadcfg
[
'bucket'
])
?
$uploadcfg
[
'bucket'
]
:
''
;
$savekey
=
isset
(
$uploadcfg
[
'savekey'
])
?
$uploadcfg
[
'savekey'
]
:
''
;
$uploadcfg
[
'save-key'
]
=
isset
(
$uploadcfg
[
'save-key'
])
?
$uploadcfg
[
'save-key'
]
:
$savekey
;
$expiration
=
time
()
+
(
isset
(
$uploadcfg
[
'expire'
])
?
$uploadcfg
[
'expire'
]
:
600
);
$uploadcfg
[
'expiration'
]
=
isset
(
$uploadcfg
[
'expiration'
])
?
$uploadcfg
[
'expiration'
]
:
$expiration
;
$notifyurl
=
isset
(
$uploadcfg
[
'notifyurl'
])
?
$uploadcfg
[
'notifyurl'
]
:
''
;
$returnurl
=
isset
(
$uploadcfg
[
'returnurl'
])
?
$uploadcfg
[
'returnurl'
]
:
''
;
if
(
$notifyurl
)
$uploadcfg
[
'notify-url'
]
=
$notifyurl
;
else
unset
(
$uploadcfg
[
'notify-url'
]);
if
(
$returnurl
)
$uploadcfg
[
'return-url'
]
=
$returnurl
;
else
unset
(
$uploadcfg
[
'return-url'
]);
//设置允许的附加字段
$allowfields
=
[
'bucket'
,
'save-key'
,
'expiration'
,
'date'
,
'content-md5'
,
'notify-url'
,
'return-url'
,
'content-secret'
,
'content-type'
,
'allow-file-type'
,
'content-length-range'
,
'image-width-range'
,
'image-height-range'
,
'x-gmkerl-thumb'
,
'x-gmkerl-type'
,
'apps'
,
'b64encoded'
,
'ext-param'
];
$policy
=
base64_encode
(
json_encode
(
$options
));
$params
=
array_intersect_key
(
$uploadcfg
,
array_flip
(
$allowfields
));
$policy
=
base64_encode
(
json_encode
(
$params
));
$signature
=
md5
(
$policy
.
'&'
.
(
isset
(
$uploadcfg
[
'formkey'
])
?
$uploadcfg
[
'formkey'
]
:
''
));
$multipart
=
[
'policy'
=>
$policy
,
'signature'
=>
$signature
,
];
$multipart
=
array_merge
(
$multipart
,
$params
);
return
[
'cdnurl'
=>
isset
(
$uploadcfg
[
'cdnurl'
])
?
$uploadcfg
[
'cdnurl'
]
:
''
,
'uploadurl'
=>
isset
(
$uploadcfg
[
'uploadurl'
])
?
$uploadcfg
[
'uploadurl'
]
:
url
(
'ajax/upload'
),
'bucket'
=>
isset
(
$uploadcfg
[
'bucket'
])
?
$uploadcfg
[
'bucket'
]
:
''
,
'maxsize'
=>
$maxsize
?
$maxsize
:
(
isset
(
$uploadcfg
[
'maxsize'
])
?
$uploadcfg
[
'maxsize'
]
:
''
),
'mimetype'
=>
$mimetype
?
$mimetype
:
(
isset
(
$uploadcfg
[
'mimetype'
])
?
$uploadcfg
[
'mimetype'
]
:
''
),
'policy'
=>
$policy
,
'signature'
=>
$signature
,
'bucket'
=>
$uploadcfg
[
'bucket'
],
'maxsize'
=>
isset
(
$uploadcfg
[
'maxsize'
])
?
$uploadcfg
[
'maxsize'
]
:
''
,
'mimetype'
=>
isset
(
$uploadcfg
[
'mimetype'
])
?
$uploadcfg
[
'mimetype'
]
:
''
,
'multipart'
=>
$multipart
,
];
}
...
...
请
注册
或
登录
后发表评论