1 Star 0 Fork 5

Mihok/ecshop大商创商城

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
oss.php 2.44 KB
一键复制 编辑 原始数据 按行查看 历史
baobeihuaidan 提交于 2017-10-24 10:04 . 初始化
<?php
//源码由旺旺:ecshop2012所有 未经允许禁止倒卖 一经发现停止任何服务
define('IN_ECS', true);
require dirname(__FILE__) . '/includes/init.php';
require dirname(__FILE__) . '/plugins/aliyunoss/autoload.php';
include 'includes/cls_json.php';
$json = new JSON();
$res = array('err_msg' => '', 'err_no' => 0, 'result' => '');
$rootPath = ROOT_PATH;
$act = (isset($_REQUEST['act']) ? addslashes_deep($_REQUEST['act']) : 'upload');
$bucket = (isset($_REQUEST['bucket']) ? addslashes_deep($_REQUEST['bucket']) : '');
$keyid = (isset($_REQUEST['keyid']) ? addslashes_deep($_REQUEST['keyid']) : '');
$keysecret = (isset($_REQUEST['keysecret']) ? addslashes_deep($_REQUEST['keysecret']) : '');
$endpoint = (isset($_REQUEST['endpoint']) ? addslashes_deep($_REQUEST['endpoint']) : '');
$is_cname = (isset($_REQUEST['is_cname']) ? intval($_REQUEST['is_cname']) : 1);
$object = (isset($_REQUEST['object']) ? $_REQUEST['object'] : array());
$file = '';
$type = (isset($_REQUEST['type']) && !empty($_REQUEST['type']) ? intval($_REQUEST['type']) : 0);
if ($is_cname == 1) {
$is_cname = true;
}
else {
$is_cname = false;
}
$ossClient = new \OSS\OssClient($keyid, $keysecret, $endpoint, $is_cname);
if ($act == 'upload') {
if (is_array($object)) {
foreach ($object as $row) {
if ($row) {
$file = $rootPath . $row;
$objects = $row;
$ossClient->putObject($bucket, $objects, '{$row}');
$res_oss = $ossClient->uploadFile($bucket, $objects, $file);
if ($res_oss['is_ok'] && $type) {
dsc_unlink($file);
}
}
}
}
else {
$file = $rootPath . $object;
$ossClient->putObject($bucket, $object, '{$object}');
$res_oss = $ossClient->uploadFile($bucket, $object, $file);
if ($res_oss['is_ok'] && $type) {
dsc_unlink($file);
}
}
}
else if ($act == 'del_file') {
$ossClient->deleteObjects($bucket, $object);
}
else if ($act == 'list_file') {
$ossClient = new \OSS\OssClient($keyid, $keysecret, $endpoint, $is_cname);
$list = $ossClient->listObjects($bucket, $object);
$list = object_array($list);
$arr = array();
foreach ($list as $key => $row) {
if (is_array($row)) {
$key = str_replace(array('OSS\\Model\\ObjectListInfo', 'List'), '', $key);
foreach ($row as $kr => $krow) {
$row[$kr] = array_values($krow);
}
$arr[$key] = $row;
}
}
$res['list'] = $arr;
}
$res['object'] = $object;
$res['type'] = $type;
exit($json->encode($res));
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/Mihok/www.sc.com.git
git@gitee.com:Mihok/www.sc.com.git
Mihok
www.sc.com
ecshop大商创商城
master

搜索帮助