├── .gitignore ├── Ads ├── Action.php ├── Form.php ├── ManageAds.php ├── Plugin.php ├── README.md └── deploy │ ├── mysql.sql │ └── upgrade_mysql.sql ├── CHANGELOG.md ├── Cors ├── Plugin.php └── README.md ├── GetRealIP ├── Plugin.php └── README.md ├── LICENSE ├── Makefile ├── Mourn ├── Plugin.php ├── README.md └── snapshot.png ├── PageViews ├── Plugin.php └── README.md ├── README.md ├── RunTime ├── Plugin.php └── README.md ├── TagsList ├── Plugin.php └── README.md ├── Upload ├── Action.php ├── Autoload.php ├── Conf.php ├── Constants.php ├── Database.php ├── Deploy │ ├── mysql.sql │ └── upgrade_mysql.sql ├── Form.php ├── Handle.php ├── Install.php ├── Log.php ├── Media.php ├── ObjectStorage │ ├── ObjectStorage.php │ ├── ObjectStorageFactory.php │ ├── ObjectStorageInterface.php │ └── Oss.php ├── Plugin.php ├── README.md ├── SDK │ └── aliyun-oss-php-sdk-2.6.0 │ │ ├── .coveralls.yml │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── LICENSE.md │ │ ├── README-CN.md │ │ ├── README.md │ │ ├── autoload.php │ │ ├── build-phar.sh │ │ ├── composer.json │ │ ├── example.jpg │ │ ├── index.php │ │ ├── phpunit.xml │ │ ├── samples │ │ ├── Bucket.php │ │ ├── BucketCname.php │ │ ├── BucketCors.php │ │ ├── BucketEncryption.php │ │ ├── BucketLifecycle.php │ │ ├── BucketLogging.php │ │ ├── BucketPayment.php │ │ ├── BucketPolicy.php │ │ ├── BucketReferer.php │ │ ├── BucketStat.php │ │ ├── BucketTags.php │ │ ├── BucketTransferAcceleration.php │ │ ├── BucketVersion.php │ │ ├── BucketWebsite.php │ │ ├── BucketWorm.php │ │ ├── Callback.php │ │ ├── Common.php │ │ ├── Config.php │ │ ├── CredentialsPhp.php │ │ ├── CredentialsProvider.php │ │ ├── Image.php │ │ ├── LiveChannel.php │ │ ├── MultipartUpload.php │ │ ├── Object.php │ │ ├── ObjectTagging.php │ │ ├── RunAll.php │ │ └── Signature.php │ │ ├── src │ │ └── OSS │ │ │ ├── Core │ │ │ ├── MimeTypes.php │ │ │ ├── OssException.php │ │ │ └── OssUtil.php │ │ │ ├── Credentials │ │ │ ├── Credentials.php │ │ │ ├── CredentialsProvider.php │ │ │ └── StaticCredentialsProvider.php │ │ │ ├── Http │ │ │ ├── LICENSE │ │ │ ├── RequestCore.php │ │ │ ├── RequestCore_Exception.php │ │ │ └── ResponseCore.php │ │ │ ├── Model │ │ │ ├── BucketInfo.php │ │ │ ├── BucketListInfo.php │ │ │ ├── BucketStat.php │ │ │ ├── CnameConfig.php │ │ │ ├── CnameTokenInfo.php │ │ │ ├── CorsConfig.php │ │ │ ├── CorsRule.php │ │ │ ├── DeleteMarkerInfo.php │ │ │ ├── DeleteObjectInfo.php │ │ │ ├── DeletedObjectInfo.php │ │ │ ├── ExtendWormConfig.php │ │ │ ├── GetLiveChannelHistory.php │ │ │ ├── GetLiveChannelInfo.php │ │ │ ├── GetLiveChannelStatus.php │ │ │ ├── InitiateWormConfig.php │ │ │ ├── LifecycleAction.php │ │ │ ├── LifecycleConfig.php │ │ │ ├── LifecycleRule.php │ │ │ ├── ListMultipartUploadInfo.php │ │ │ ├── ListPartsInfo.php │ │ │ ├── LiveChannelConfig.php │ │ │ ├── LiveChannelHistory.php │ │ │ ├── LiveChannelInfo.php │ │ │ ├── LiveChannelListInfo.php │ │ │ ├── LoggingConfig.php │ │ │ ├── ObjectInfo.php │ │ │ ├── ObjectListInfo.php │ │ │ ├── ObjectListInfoV2.php │ │ │ ├── ObjectVersionInfo.php │ │ │ ├── ObjectVersionListInfo.php │ │ │ ├── PartInfo.php │ │ │ ├── PrefixInfo.php │ │ │ ├── RefererConfig.php │ │ │ ├── RequestPaymentConfig.php │ │ │ ├── RestoreConfig.php │ │ │ ├── ServerSideEncryptionConfig.php │ │ │ ├── StorageCapacityConfig.php │ │ │ ├── Tag.php │ │ │ ├── TaggingConfig.php │ │ │ ├── TransferAccelerationConfig.php │ │ │ ├── UploadInfo.php │ │ │ ├── VersioningConfig.php │ │ │ ├── WebsiteConfig.php │ │ │ ├── WormConfig.php │ │ │ └── XmlConfig.php │ │ │ ├── OssClient.php │ │ │ └── Result │ │ │ ├── AclResult.php │ │ │ ├── AppendResult.php │ │ │ ├── BodyResult.php │ │ │ ├── CallbackResult.php │ │ │ ├── CopyObjectResult.php │ │ │ ├── CreateBucketCnameTokenResult.php │ │ │ ├── DeleteObjectVersionsResult.php │ │ │ ├── DeleteObjectsResult.php │ │ │ ├── ExistResult.php │ │ │ ├── GetBucketCnameTokenResult.php │ │ │ ├── GetBucketEncryptionResult.php │ │ │ ├── GetBucketInfoResult.php │ │ │ ├── GetBucketRequestPaymentResult.php │ │ │ ├── GetBucketStatResult.php │ │ │ ├── GetBucketTagsResult.php │ │ │ ├── GetBucketTransferAccelerationResult.php │ │ │ ├── GetBucketVersioningResult.php │ │ │ ├── GetBucketWormResult.php │ │ │ ├── GetCnameResult.php │ │ │ ├── GetCorsResult.php │ │ │ ├── GetLifecycleResult.php │ │ │ ├── GetLiveChannelHistoryResult.php │ │ │ ├── GetLiveChannelInfoResult.php │ │ │ ├── GetLiveChannelStatusResult.php │ │ │ ├── GetLocationResult.php │ │ │ ├── GetLoggingResult.php │ │ │ ├── GetRefererResult.php │ │ │ ├── GetStorageCapacityResult.php │ │ │ ├── GetWebsiteResult.php │ │ │ ├── HeaderResult.php │ │ │ ├── InitiateBucketWormResult.php │ │ │ ├── InitiateMultipartUploadResult.php │ │ │ ├── ListBucketsResult.php │ │ │ ├── ListLiveChannelResult.php │ │ │ ├── ListMultipartUploadResult.php │ │ │ ├── ListObjectVersionsResult.php │ │ │ ├── ListObjectsResult.php │ │ │ ├── ListObjectsV2Result.php │ │ │ ├── ListPartsResult.php │ │ │ ├── PutLiveChannelResult.php │ │ │ ├── PutSetDeleteResult.php │ │ │ ├── Result.php │ │ │ ├── SymlinkResult.php │ │ │ └── UploadPartResult.php │ │ └── tests │ │ └── OSS │ │ └── Tests │ │ ├── AclResultTest.php │ │ ├── BodyResultTest.php │ │ ├── BucketCnameTest.php │ │ ├── BucketInfoTest.php │ │ ├── BucketLiveChannelTest.php │ │ ├── CallbackTest.php │ │ ├── CnameConfigTest.php │ │ ├── CnameTokenInfoTest.php │ │ ├── Common.php │ │ ├── ContentTypeTest.php │ │ ├── CopyObjectResult.php │ │ ├── CorsConfigTest.php │ │ ├── DeleteObjectVersionsResultTest.php │ │ ├── ExistResultTest.php │ │ ├── GetBucketEncryptionResultTest.php │ │ ├── GetBucketRequestPaymentResultTest.php │ │ ├── GetBucketStatResultTest.php │ │ ├── GetBucketTagsResultTest.php │ │ ├── GetBucketTransferAccelerationResultTest.php │ │ ├── GetBucketWormResultTest.php │ │ ├── GetCorsResultTest.php │ │ ├── GetLifecycleResultTest.php │ │ ├── GetLoggingResultTest.php │ │ ├── GetRefererResultTest.php │ │ ├── GetWebsiteResultTest.php │ │ ├── HeaderResultTest.php │ │ ├── HttpTest.php │ │ ├── InitiateMultipartUploadResultTest.php │ │ ├── LifecycleConfigTest.php │ │ ├── ListBucketsResultTest.php │ │ ├── ListMultipartUploadResultTest.php │ │ ├── ListObjectVersionsResultTest.php │ │ ├── ListObjectsResultTest.php │ │ ├── ListObjectsV2ResultTest.php │ │ ├── ListPartsResultTest.php │ │ ├── LiveChannelXmlTest.php │ │ ├── LoggingConfigTest.php │ │ ├── MimeTypesTest.php │ │ ├── ObjectAclTest.php │ │ ├── OssClientBucketCnameTest.php │ │ ├── OssClientBucketCorsTest.php │ │ ├── OssClientBucketEncryptionTest.php │ │ ├── OssClientBucketInfoTest.php │ │ ├── OssClientBucketLifecycleTest.php │ │ ├── OssClientBucketLoggingTest.php │ │ ├── OssClientBucketPolicyTest.php │ │ ├── OssClientBucketRefererTest.php │ │ ├── OssClientBucketRequestPaymentTest.php │ │ ├── OssClientBucketStatTestTest.php │ │ ├── OssClientBucketStorageCapacityTest.php │ │ ├── OssClientBucketTagsTest.php │ │ ├── OssClientBucketTest.php │ │ ├── OssClientBucketTransferAccelerationTest.php │ │ ├── OssClientBucketVersioningTest.php │ │ ├── OssClientBucketWebsiteTest.php │ │ ├── OssClientBucketWormTest.php │ │ ├── OssClientImageTest.php │ │ ├── OssClientListObjectsTest.php │ │ ├── OssClientListObjectsV2Test.php │ │ ├── OssClientMultipartUploadTest.php │ │ ├── OssClientObjectRequestPaymentTest.php │ │ ├── OssClientObjectTaggingTest.php │ │ ├── OssClientObjectTest.php │ │ ├── OssClientObjectVersioningTest.php │ │ ├── OssClientRestoreObjectTest.php │ │ ├── OssClientSignatureTest.php │ │ ├── OssClientTest.php │ │ ├── OssExceptionTest.php │ │ ├── OssTrafficLimitTest.php │ │ ├── OssUtilTest.php │ │ ├── PutSetDeleteResultTest.php │ │ ├── RefererConfigTest.php │ │ ├── StorageCapacityConfigTest.php │ │ ├── StorageCapacityTest.php │ │ ├── SymlinkTest.php │ │ ├── TestOssClientBase.php │ │ ├── TransferAccelerationConfigTest.php │ │ ├── UploadPartResultTest.php │ │ └── WebsiteConfigTest.php └── Static │ ├── magnifying_glass.ico │ └── nopic.jpg └── scripts ├── copy.sh └── message.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea 3 | -------------------------------------------------------------------------------- /Ads/README.md: -------------------------------------------------------------------------------- 1 | # 广告投放 2 | 3 | ### 使用方法 4 | 5 | 1. 下载本插件,放在 usr/plugins/ 目录中 6 | 2. 登录管理后台,激活插件 7 | 3. 后台设置添加广告位 8 | 4. 在需要显示的位置,添加显示代码 9 | 10 | ```php 11 | # 显示默认的广告代码位 12 | # 语法: Ads_Plugin::show(); 13 | 14 | # 显示指定ID的广告代码位 15 | # 语法: Ads_Plugin::show(id:1); 16 | 17 | # 显示指定广告位名称的广告代码位 18 | # 语法: Ads_Plugin::show(adName: '广告位名称1'); 19 | 20 | # 显示代码要用放在PHP代码块中,例: 21 | 22 | ``` 23 | 24 | ### Links 25 | 26 | - Blog:https://mayanpeng.cn 27 | - Email: pony#ponycool.com(将#替换为@) 28 | - Github: https://github.com/ponycool 29 | -------------------------------------------------------------------------------- /Ads/deploy/mysql.sql: -------------------------------------------------------------------------------- 1 | create table typecho_ads 2 | ( 3 | id int auto_increment comment '自增长ID' 4 | primary key, 5 | ad_name varchar(50) null comment '广告位名称', 6 | ad_desc varchar(200) null comment '广告位描述', 7 | ad_code text null comment '广告位代码', 8 | view_times int default 0 null comment '点击次数', 9 | sort_index int null comment '排序索引', 10 | created_at datetime null comment '创建时间', 11 | updated_at datetime null comment '更新时间', 12 | deleted_at datetime null comment '删除时间', 13 | deleted bit default b'0' null comment '逻辑删除:0正常,1删除' 14 | ) 15 | comment '广告投放'; 16 | 17 | -------------------------------------------------------------------------------- /Ads/deploy/upgrade_mysql.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponycool/typecho-plugins/6d6e34a71f96a3665ac97e15c6b8671eb0cf17d7/Ads/deploy/upgrade_mysql.sql -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | *** 4 | 5 | ### v1.2(2022-10-29) 6 | 7 | - 适配PHP8 8 | - 适配Typecho v1.2.x 9 | - 新增 TagsList插件 10 | - 新增 Ads 插件 11 | - 新增 Cors 插件 12 | - 新增 RunTime 插件 13 | 14 | *** 15 | 16 | ### v1.1 17 | 18 | - 新增 PageViews 插件 19 | - 新增 GetRealIP 插件 20 | -------------------------------------------------------------------------------- /Cors/README.md: -------------------------------------------------------------------------------- 1 | # 跨域资源共享 2 | 3 | 跨域资源共享(CORS) 是一种机制,它使用额外的 HTTP 头来告诉浏览器 让运行在一个 origin (domain) 4 | 上的Web应用被准许访问来自不同源服务器上的指定的资源。当一个资源从与该资源本身所在的服务器不同的域、协议或端口请求一个资源时,资源会发起一个跨域 5 | HTTP 请求。 6 | 比如,站点 http://domain-a.com 的某 HTML 页面通过 的 src 7 | 请求 http://domain-b.com/image.jpg。网络上的许多页面都会加载来自不同域的CSS样式表,图像和脚本等资源。 8 | 出于安全原因,浏览器限制从脚本内发起的跨源HTTP请求。 例如,XMLHttpRequest和Fetch API遵循同源策略。 9 | 这意味着使用这些API的Web应用程序只能从加载应用程序的同一个域请求HTTP资源,除非响应报文包含了正确CORS响应头。 10 | 11 | *注:这段描述不准确,并不一定是浏览器限制了发起跨站请求,也可能是跨站请求可以正常发起,但是返回结果被浏览器拦截了。* 12 | 13 | 跨域资源共享( CORS )机制允许 Web 应用服务器进行跨域访问控制,从而使跨域数据传输得以安全进行。现代浏览器支持在 API 容器中(例如 14 | XMLHttpRequest 或 Fetch )使用 CORS,以降低跨域 HTTP 请求所带来的风险。 15 | 16 | #### 什么情况下需要 CORS ? 17 | 18 | 跨域资源共享标准( cross-origin sharing standard )允许在下列场景中使用跨域 HTTP 请求: 19 | 20 | - 前文提到的由 XMLHttpRequest 或 Fetch 发起的跨域 HTTP 请求。 21 | - Web 字体 (CSS 中通过 @font-face 使用跨域字体资源), 因此,网站就可以发布 TrueType 字体资源,并只允许已授权网站进行跨站调用。 22 | - WebGL 贴图 23 | - 使用 drawImage 将 Images/video 画面绘制到 canvas 24 | 25 | ### 使用方法 26 | 27 | 1. 下载本插件,放在 usr/plugins/ 目录中 28 | 2. 登录管理后台,激活插件 29 | 30 | ### Links 31 | 32 | - Blog:https://mayanpeng.cn 33 | - Email: pony#ponycool.com(将#替换为@) 34 | - Github: https://github.com/PonyCool 35 | -------------------------------------------------------------------------------- /GetRealIP/Plugin.php: -------------------------------------------------------------------------------- 1 | begin = array('GetRealIP_Plugin', $method); 27 | return '插件安装成功,请进入设置填写代理IP'; 28 | } 29 | 30 | /* 禁用插件方法 */ 31 | public static function deactivate(): string 32 | { 33 | return '插件卸载成功'; 34 | } 35 | 36 | /* 插件配置方法 */ 37 | public static function config(Form $form) 38 | { 39 | //保存接口调用地址 40 | $enableStatus = new Radio('enable_status', array('禁用', '开启'), 0, '禁用/开启:', '启用状态,启用后将获取HTTP_X_FORWARDED_FOR中客户端原始IP'); 41 | $form->addInput($enableStatus); 42 | $proxyIps = new Textarea('proxy_ips', null, null, '代理IP(选填):', '代理IP会自动过滤,请谨慎填写!每行一个IP'); 43 | $form->addInput($proxyIps); 44 | } 45 | 46 | /* 个人用户的配置方法 */ 47 | public static function personalConfig(Form $form) 48 | { 49 | // TODO: Implement personalConfig() method. 50 | } 51 | 52 | /** 53 | * @throws Exception 54 | */ 55 | public static function setRealIP(): void 56 | { 57 | $realIp = '0.0.0.0'; 58 | $options = Helper::options(); 59 | try { 60 | $pluginConfig = $options->plugin('GetRealIP'); 61 | } catch (Exception $exc) { 62 | throw new Exception('GetRealIP插件启用失败,错误代码:' . $exc->getCode()); 63 | } 64 | $proxyIpsStr = $pluginConfig->proxy_ips; 65 | $proxyIps = explode(PHP_EOL, $proxyIpsStr); 66 | $enableStatus = $pluginConfig->enable_status; 67 | if (!$enableStatus) { 68 | return; 69 | } 70 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { 71 | $realList = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); 72 | foreach ($realList as $k => $v) { 73 | if (in_array($v, $proxyIps)) { 74 | unset($realList[$k]); 75 | } 76 | } 77 | if (!is_null($realList[0])) { 78 | $realIp = $realList[0]; 79 | } 80 | $_SERVER['REMOTE_ADDR'] = $realIp; 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /GetRealIP/README.md: -------------------------------------------------------------------------------- 1 | # 获取真实IP 2 | 3 | 如果您的服务器位于反向代理后面,获取的IP为反向代理的IP。如果要获取客户端的真实IP,则必须将代理列入白名单。 4 | 5 | ### 使用方法 6 | 7 | 1. 下载本插件,放在 usr/plugins/ 目录中 8 | 2. 登录管理后台,激活插件 9 | 10 | ### Links 11 | 12 | - Blog:https://mayanpeng.cn 13 | - Email: pony#ponycool.com(将#替换为@) 14 | - Github: https://github.com/PonyCool 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Pony 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: copy 2 | copy: 3 | ./scripts/copy.sh 4 | -------------------------------------------------------------------------------- /Mourn/Plugin.php: -------------------------------------------------------------------------------- 1 | afterRender = array('Mourn_Plugin', $method); 25 | return '插件安装成功'; 26 | } 27 | 28 | /* 禁用插件方法 */ 29 | public static function deactivate(): string 30 | { 31 | return '插件卸载成功'; 32 | } 33 | 34 | /* 插件配置方法 */ 35 | public static function config(Form $form) 36 | { 37 | $enableStatus = new Radio('enabled', ['禁用', '开启'], 0, '禁用/开启:', '启用状态,启用后将开启追悼模式,全站变灰'); 38 | $form->addInput($enableStatus); 39 | } 40 | 41 | /* 个人用户的配置方法 */ 42 | public static function personalConfig(Form $form) 43 | { 44 | // TODO: Implement personalConfig() method. 45 | } 46 | 47 | /** 48 | * 开启追悼模式 49 | */ 50 | public static function mourn(): void 51 | { 52 | $options = Helper::options(); 53 | try { 54 | $pluginConfig = $options->plugin(self::$pluginName); 55 | } catch (Exception) { 56 | return; 57 | } 58 | if ($pluginConfig->enabled === '1') { 59 | self::scriptRender(); 60 | } 61 | } 62 | 63 | 64 | public static function scriptRender(): void 65 | { 66 | $script = <<< EOF 67 | 81 | EOF; 82 | echo $script; 83 | } 84 | } -------------------------------------------------------------------------------- /Mourn/README.md: -------------------------------------------------------------------------------- 1 | # 开启追悼模式 2 | 3 | 开启追悼模式后,网站变灰 4 | 5 | ![snapshot](./snapshot.png) 6 | 7 | ### 使用方法 8 | 9 | 1. 下载本插件,放在 usr/plugins/ 目录中 10 | 2. 登录管理后台,激活插件 11 | 3. 开启追悼模式 12 | 13 | ### Links 14 | 15 | - Blog:https://mayanpeng.cn 16 | - Email: pony#ponycool.com(将#替换为@) 17 | - Github: https://github.com/PonyCool 18 | -------------------------------------------------------------------------------- /Mourn/snapshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponycool/typecho-plugins/6d6e34a71f96a3665ac97e15c6b8671eb0cf17d7/Mourn/snapshot.png -------------------------------------------------------------------------------- /PageViews/README.md: -------------------------------------------------------------------------------- 1 | ## Typecho 文章浏览量统计插件 PageViews v1.2.0 2 | --- 3 | 统计站点内容页面的总浏览量,所谓内容页面,包括文章页、独立页面和附件显示页 4 | 5 | **使用方法** 6 | 7 | 1. 下载本插件,放在 usr/plugins/ 目录中 8 | 2. 登录管理后台,激活插件 9 | 3. 在需要显示的地方调用显示方法 10 | 11 | ```php 12 | 语法: PageViews_Plugin::showPageViews(); 13 | 输出: '本站总访问量 XX 次' 14 | ``` 15 | 16 | ### Logs 17 | 18 | - 1.2.0 19 | - 修改配置方式为后台插件配置 20 | - 适配PHP8 21 | - 新增人类易读模式 22 | - 1.0.1 23 | - 增加起始浏览量 24 | - 简化逻辑 25 | 26 | ### Links 27 | 28 | - Blog:https://mayanpeng.cn 29 | - Email: pony#ponycool.com(将#替换为@) 30 | - Github: https://github.com/PonyCool 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Typecho 插件 2 | --- 3 | 在typecho的使用过程,很多需求没有找到合适的插件,又不想直接修改核心代码影响升级,所以造了一些轮子。 4 | 5 | ### 版本说明 6 | 7 | 插件版本需要和Typecho版本保持一致 8 | 9 | #### 当前版本 V1.2 10 | 11 | 适配了PHP8语法 12 | 13 | 环境要求 14 | 15 | - PHP 8.0 或更高版本 16 | - Typecho v1.2.x 17 | 18 | #### V1.1 19 | 20 | 环境要求 21 | 22 | - PHP 5.6 ~ PHP 7.4 23 | - Typecho v1.1 24 | 25 | ### 插件列表 26 | 27 | 插件说明查看插件内ReadMe说明文档 28 | 29 | 1. [PageViews](https://github.com/ponycool/typecho-plugins/tree/master/PageViews) 文章浏览量统计插件 30 | 2. [GetRealIP](https://github.com/ponycool/typecho-plugins/tree/master/GetRealIP) 获取真实IP 31 | 3. [Cors](https://github.com/ponycool/typecho-plugins/tree/master/Cors) 跨域资源共享 32 | 4. [TagsList](https://github.com/ponycool/typecho-plugins/tree/master/TagsList) 标签选择列表 33 | 5. [Ads](https://github.com/ponycool/typecho-plugins/tree/master/Ads) 广告投放插件 34 | 6. [RunTime](https://github.com/ponycool/typecho-plugins/tree/master/RunTime) 运行时间插件 35 | 7. [Upload](https://github.com/ponycool/typecho-plugins/tree/master/Upload) 文件上传插件 36 | 8. [Mourn](https://github.com/ponycool/typecho-plugins/tree/master/Mourn) 追悼模式插件 37 | 38 | ### Links 39 | 40 | - Blog:https://mayanpeng.cn 41 | - Email: pony#ponycool.com(将#替换为@) 42 | - Github: https://github.com/ponycool 43 | -------------------------------------------------------------------------------- /RunTime/README.md: -------------------------------------------------------------------------------- 1 | ## Typecho 运行时间插件 RunTime v1.2.0 2 | --- 3 | 显示站点运行时间 4 | 5 | **使用方法** 6 | 7 | 1. 下载本插件,放在 usr/plugins/ 目录中 8 | 2. 登录管理后台,激活插件 9 | 3. 在需要显示的地方调用显示方法 10 | 11 | ```php 12 | 语法: RunTime_Plugin::show(); 13 | ``` 14 | 15 | ### Logs 16 | 17 | - 1.2.0 18 | - 适配PHP8 19 | 20 | ### Links 21 | 22 | - Blog:https://mayanpeng.cn 23 | - Email: pony#ponycool.com(将#替换为@) 24 | - Github: https://github.com/PonyCool 25 | -------------------------------------------------------------------------------- /TagsList/Plugin.php: -------------------------------------------------------------------------------- 1 | bottom = array('TagsList_Plugin', $method); 21 | } 22 | 23 | /* 禁用插件方法 */ 24 | public static function deactivate() 25 | { 26 | } 27 | 28 | public static function config(Form $form) 29 | { 30 | 31 | } 32 | 33 | public static function personalConfig(Form $form) 34 | { 35 | } 36 | 37 | 38 | /** 39 | * 标签列表 40 | * @return void 41 | */ 42 | public static function tagsList(): void 43 | { 44 | Widget::widget('Widget_Metas_Tag_Cloud')->to($tags); 45 | if (!$tags->have()) { 46 | return; 47 | } 48 | 49 | $lists = ""; 50 | $id = 0; 51 | while ($tags->next()) { 52 | $name = (string)$tags->name; 53 | $lists .= <<$name 55 | EOF; 56 | $id++; 57 | } 58 | 59 | $html = << 61 | .tags-list a { 62 | cursor: pointer; 63 | padding: 0 6px; 64 | margin: 2px 0; 65 | display: inline-block; 66 | border-radius: 2px; 67 | text-decoration: none; 68 | }.tags-list a:hover { 69 | background: #ccc; 70 | color: #fff; 71 | } 72 | ; 73 | 87 | EOF; 88 | echo $html; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /TagsList/README.md: -------------------------------------------------------------------------------- 1 | ## Typecho 标签选择列表插件 TagsList v1.2.0 2 | --- 3 | 后台编辑文章时增加标签选择列表 4 | 5 | **使用方法** 6 | 7 | 1. 下载本插件,放在 usr/plugins/ 目录中 8 | 2. 登录管理后台,激活插件 9 | 10 | ### Logs 11 | 12 | - 1.2.0 13 | - 适配PHP8 14 | 15 | ### Links 16 | 17 | - Blog:https://mayanpeng.cn 18 | - Email: pony#ponycool.com(将#替换为@) 19 | - Github: https://github.com/PonyCool 20 | -------------------------------------------------------------------------------- /Upload/Autoload.php: -------------------------------------------------------------------------------- 1 | getOssSdkPath(), 39 | default => UPLOAD_PLUGIN_PATH, 40 | }; 41 | if ($filePath === UPLOAD_PLUGIN_PATH) { 42 | $class = str_replace('Typecho/Plugin/Upload/', '', $class); 43 | } 44 | return $filePath . $class . '.php'; 45 | } 46 | 47 | 48 | /** 49 | * 获取OSS SDK的路径 50 | * @return string 51 | */ 52 | function getOssSdkPath(): string 53 | { 54 | $path = SDK_PATH . DIRECTORY_SEPARATOR; 55 | $path .= SDK_OSS . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR; 56 | return $path; 57 | } 58 | -------------------------------------------------------------------------------- /Upload/Database.php: -------------------------------------------------------------------------------- 1 | getCode() 31 | ); 32 | Log::message($err); 33 | return; 34 | } 35 | 36 | $this->setDb($db); 37 | 38 | $adapter = explode('_', $db->getAdapterName()); 39 | $adapter = array_pop($adapter); 40 | $adapter = strtolower($adapter); 41 | 42 | $this->setAdapter($adapter); 43 | 44 | $prefix = $db->getPrefix(); 45 | $this->setTablePrefix($prefix); 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getAdapter(): string 52 | { 53 | return $this->adapter; 54 | } 55 | 56 | /** 57 | * @param string $adapter 58 | */ 59 | public function setAdapter(string $adapter): void 60 | { 61 | $this->adapter = $adapter; 62 | } 63 | 64 | /** 65 | * @return Db 66 | */ 67 | public function getDb(): Db 68 | { 69 | return $this->db; 70 | } 71 | 72 | /** 73 | * @param Db $db 74 | */ 75 | public function setDb(Db $db): void 76 | { 77 | $this->db = $db; 78 | } 79 | 80 | /** 81 | * @return string 82 | */ 83 | public function getTablePrefix(): string 84 | { 85 | return $this->tablePrefix; 86 | } 87 | 88 | /** 89 | * @param string $tablePrefix 90 | */ 91 | public function setTablePrefix(string $tablePrefix): void 92 | { 93 | $this->tablePrefix = $tablePrefix; 94 | } 95 | 96 | /** 97 | * 预处理脚本 98 | * @param string $script 99 | * @return array 100 | */ 101 | public function preScript(string $script): array 102 | { 103 | $script = str_replace(DEFAULT_TABLE_PREFIX, $this->getTablePrefix(), $script); 104 | $script = str_replace('%charset%', 'utf8', $script); 105 | return explode(';', $script); 106 | } 107 | } -------------------------------------------------------------------------------- /Upload/Deploy/mysql.sql: -------------------------------------------------------------------------------- 1 | create table typecho_media 2 | ( 3 | id int auto_increment comment '自增长ID' 4 | primary key, 5 | type varchar(20) null comment '媒体类型:image、video、audio', 6 | file_name varchar(50) null comment '文件名', 7 | file_url varchar(500) null comment '文件路径', 8 | external_url varchar(500) null comment '外网地址', 9 | intranet_url varchar(500) null comment '内网地址', 10 | cdn_url varchar(500) null comment 'CDN地址', 11 | object_storage char(10) null comment '对象存储类型', 12 | size int null comment '文件大小,单位byte', 13 | size_by_unit varchar(50) null comment '大小,单位MB', 14 | ext char(10) null comment '文件扩展名', 15 | mime varchar(20) null comment 'MIME类型', 16 | width int null comment '宽度:如果文件类型为image需要此属性,单位像素', 17 | height int null comment '高度:如果文件类型为image需要此属性,单位像素', 18 | status varchar(10) default '0' null comment '文件状态:normal代表正常,froze代表被冻结,pass代表审核通过', 19 | md5 varchar(50) null comment 'MD5', 20 | hash varchar(1024) null comment '文件hash值', 21 | hash_alg varchar(10) null comment 'HASH算法', 22 | server_replica bit default b'0' null comment '服务器副本:0无,1有', 23 | created_at datetime null comment '创建时间', 24 | updated_at datetime null comment '更新时间', 25 | deleted_at datetime null comment '删除时间', 26 | deleted bit default b'0' null comment '逻辑删除:0正常,1删除' 27 | ) comment '媒体'; 28 | -------------------------------------------------------------------------------- /Upload/Deploy/upgrade_mysql.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponycool/typecho-plugins/6d6e34a71f96a3665ac97e15c6b8671eb0cf17d7/Upload/Deploy/upgrade_mysql.sql -------------------------------------------------------------------------------- /Upload/ObjectStorage/ObjectStorageFactory.php: -------------------------------------------------------------------------------- 1 | check() !== true) { 24 | throw new Exception('Object Storage 配置无效'); 25 | } 26 | $os = new ReflectionClass(__NAMESPACE__ . '\\' . ucfirst($source)); 27 | if (!$os->isSubclassOf(__NAMESPACE__ . '\\ObjectStorageInterface')) { 28 | throw new ReflectionException($source . "未实现ObjectStorage接口类"); 29 | } 30 | return $os->newInstance($objectStorage); 31 | } catch (ReflectionException|Exception $e) { 32 | Log::message(sprintf('%s加载失败,error:%s', $source, $e->getMessage())); 33 | return null; 34 | } 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /Upload/ObjectStorage/ObjectStorageInterface.php: -------------------------------------------------------------------------------- 1 | =5.3" 15 | }, 16 | "require-dev" : { 17 | "phpunit/phpunit": "*", 18 | "satooshi/php-coveralls": "*" 19 | }, 20 | "minimum-stability": "stable", 21 | "autoload": { 22 | "psr-4": {"OSS\\": "src/OSS"} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponycool/typecho-plugins/6d6e34a71f96a3665ac97e15c6b8671eb0cf17d7/Upload/SDK/aliyun-oss-php-sdk-2.6.0/example.jpg -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ./src 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ./tests 16 | ./tests/OSS/Tests/BucketCnameTest.php 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/samples/BucketTransferAcceleration.php: -------------------------------------------------------------------------------- 1 | sfer acceleration 15 | $enabled = true; // set true to enable transfer acceleration; set false to disalbe transfer acceleration 16 | $ossClient->putBucketTransferAcceleration($bucket, $enabled); 17 | printf('putBucketTransferAcceleration SUCCESS' . "\n"); 18 | 19 | 20 | // get transfer acceleration 21 | $result = $ossClient->getBucketTransferAcceleration($bucket); 22 | printf('getBucketTransferAcceleration Status:%s'."\n",$result); 23 | 24 | 25 | //******************************* For complete usage, see the following functions **************************************************** 26 | putBucketTransferAcceleration($ossClient,$bucket); 27 | getBucketTransferAcceleration($bucket); 28 | 29 | /** 30 | * @param $ossClient OssClient 31 | * @param $bucket bucket_name string 32 | * @param $enabled string 33 | */ 34 | function putBucketTransferAcceleration($ossClient, $bucket, $enabled) 35 | { 36 | try{ 37 | $enabled = true; // set true to enable transfer acceleration; set false to disalbe transfer acceleration 38 | $ossClient->putBucketTransferAcceleration($bucket,$enabled); 39 | printf('putBucketTransferAcceleration SUCCESS' . "\n"); 40 | } catch(OssException $e) { 41 | printf($e->getMessage() . "\n"); 42 | return; 43 | } 44 | print(__FUNCTION__ . ": OK" . "\n"); 45 | } 46 | 47 | /** 48 | * @param $ossClient OssClient 49 | * @param $bucket bucket_name string 50 | */ 51 | function getBucketTransferAcceleration($ossClient, $bucket) 52 | { 53 | try{ 54 | $result = $ossClient->getBucketTransferAcceleration($bucket); 55 | printf('getBucketTransferAcceleration Status:%s'."\n",$result); 56 | } catch(OssException $e) { 57 | printf($e->getMessage() . "\n"); 58 | return; 59 | } 60 | print(__FUNCTION__ . ": OK" . "\n"); 61 | } 62 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/samples/Config.php: -------------------------------------------------------------------------------- 1 | warpper = $credential; 24 | } 25 | public function getCredentials(){ 26 | $ak = $this->warpper->getAccessKeyId(); 27 | $sk = $this->warpper->getAccessKeySecret(); 28 | $token = $this->warpper->getSecurityToken(); 29 | return new StaticCredentialsProvider($ak, $sk, $token); 30 | } 31 | } 32 | 33 | $bucket = Common::getBucketName(); 34 | 35 | //AccessKey Credentials demo 36 | $credential = new Credential(array( 37 | 'type' => 'access_key', 38 | 'access_key_id' => '', 39 | 'access_key_secret' => '', 40 | )); 41 | $providerWarpper = new AlibabaCloudCredentialsWrapper($credential); 42 | $config = array( 43 | 'provider' => $providerWarpper, 44 | 'endpoint'=> '' 45 | ); 46 | try { 47 | $ossClient = new OssClient($config); 48 | $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of access key'); 49 | $result = $ossClient->getObject($bucket,'c.file'); 50 | var_dump($result); 51 | } catch (OssException $e) { 52 | printf($e->getMessage() . "\n"); 53 | return; 54 | } 55 | 56 | 57 | // EcsRamRole Credentials demo 58 | $ecsRamRole = new Credential(array( 59 | 'type' => 'ecs_ram_role', 60 | 'role_name' => 'EcsRamRoleOssTest', 61 | )); 62 | $providerWarpper = new AlibabaCloudCredentialsWrapper($ecsRamRole); 63 | $bucket = 'oss-bucket-cd-yp-test'; 64 | $config = array( 65 | 'provider' => $providerWarpper, 66 | 'endpoint'=> '' 67 | ); 68 | try { 69 | $ossClient = new OssClient($config); 70 | $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of EcsRamRole'); 71 | $result = $ossClient->getObject($bucket,'c.file'); 72 | var_dump($result); 73 | } catch (OssException $e) { 74 | printf($e->getMessage() . "\n"); 75 | return; 76 | } 77 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/samples/CredentialsProvider.php: -------------------------------------------------------------------------------- 1 | '; 11 | $secret = ''; 12 | $provider = new StaticCredentialsProvider($id,$secret); 13 | $config = array( 14 | 'provider' => $provider, 15 | 'endpoint'=>'' 16 | ); 17 | try { 18 | $ossClient = new OssClient($config); 19 | $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of access key provider'); 20 | $result = $ossClient->getObject($bucket,'c.file'); 21 | var_dump($result); 22 | } catch (OssException $e) { 23 | printf($e->getMessage() . "\n"); 24 | return; 25 | } 26 | 27 | // Sts provider demo 28 | $id = ''; 29 | $secret = ''; 30 | $token = ''; 31 | $provider = new StaticCredentialsProvider($id,$secret,$token); 32 | $config = array( 33 | 'provider' => $provider, 34 | 'endpoint'=> "" 35 | ); 36 | 37 | try { 38 | $ossClient = new OssClient($config); 39 | $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of sts provider'); 40 | $result = $ossClient->getObject($bucket,'c.file'); 41 | var_dump($result); 42 | } catch (OssException $e) { 43 | printf($e->getMessage() . "\n"); 44 | return; 45 | } 46 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/samples/RunAll.php: -------------------------------------------------------------------------------- 1 | details = $details; 24 | } else { 25 | $message = $details; 26 | parent::__construct($message); 27 | } 28 | } 29 | 30 | public function getHTTPStatus() 31 | { 32 | return isset($this->details['status']) ? $this->details['status'] : ''; 33 | } 34 | 35 | public function getRequestId() 36 | { 37 | return isset($this->details['request-id']) ? $this->details['request-id'] : ''; 38 | } 39 | 40 | public function getErrorCode() 41 | { 42 | return isset($this->details['code']) ? $this->details['code'] : ''; 43 | } 44 | 45 | public function getErrorMessage() 46 | { 47 | return isset($this->details['message']) ? $this->details['message'] : ''; 48 | } 49 | 50 | public function getDetails() 51 | { 52 | return isset($this->details['body']) ? $this->details['body'] : ''; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Credentials/Credentials.php: -------------------------------------------------------------------------------- 1 | key = trim($key); 35 | $this->secret = trim($secret); 36 | $this->token = $token; 37 | } 38 | 39 | 40 | /** 41 | * @return string 42 | */ 43 | public function getAccessKeyId() 44 | { 45 | return $this->key; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getAccessKeySecret() 52 | { 53 | return $this->secret; 54 | } 55 | 56 | /** 57 | * @return string|null 58 | */ 59 | public function getSecurityToken() 60 | { 61 | return $this->token; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Credentials/CredentialsProvider.php: -------------------------------------------------------------------------------- 1 | credentials = new Credentials($key, $secret, $token); 26 | } 27 | 28 | /** 29 | * @return Credentials 30 | */ 31 | public function getCredentials() 32 | { 33 | return $this->credentials; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Http/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are 4 | permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of 7 | conditions and the following disclaimer. 8 | 9 | * Redistributions in binary form must reproduce the above copyright notice, this list 10 | of conditions and the following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 13 | * Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to 14 | endorse or promote products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 19 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 20 | AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Http/RequestCore_Exception.php: -------------------------------------------------------------------------------- 1 | ). 29 | * @param string $body (Required) XML-formatted response from OSS. 30 | * @param integer $status (Optional) HTTP response status code from the request. 31 | * @return Mixed Contains an `header` property (HTTP headers as an associative array), a or `body` property, and an `status` code. 32 | */ 33 | public function __construct($header, $body, $status = null) 34 | { 35 | $this->header = $header; 36 | $this->body = $body; 37 | $this->status = $status; 38 | 39 | return $this; 40 | } 41 | 42 | /** 43 | * Did we receive the status code we expected? 44 | * 45 | * @param integer|array $codes (Optional) The status code(s) to expect. Pass an for a single acceptable value, or an of integers for multiple acceptable values. 46 | * @return boolean Whether we received the expected status code or not. 47 | */ 48 | public function isOK($codes = array(200, 201, 204, 206)) 49 | { 50 | if (is_array($codes)) { 51 | return in_array($this->status, $codes); 52 | } 53 | 54 | return $this->status === $codes; 55 | } 56 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/BucketListInfo.php: -------------------------------------------------------------------------------- 1 | bucketList = $bucketList; 21 | } 22 | 23 | /** 24 | * Get the BucketInfo list 25 | * 26 | * @return BucketInfo[] 27 | */ 28 | public function getBucketList() 29 | { 30 | return $this->bucketList; 31 | } 32 | 33 | /** 34 | * BucketInfo list 35 | * 36 | * @var array 37 | */ 38 | private $bucketList = array(); 39 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/CnameConfig.php: -------------------------------------------------------------------------------- 1 | cnameList = array(); 20 | } 21 | 22 | /** 23 | * @return array 24 | * @example 25 | * array(2) { 26 | * [0]=> 27 | * array(3) { 28 | * ["Domain"]=> 29 | * string(11) "www.foo.com" 30 | * ["Status"]=> 31 | * string(7) "enabled" 32 | * ["LastModified"]=> 33 | * string(8) "20150101" 34 | * } 35 | * [1]=> 36 | * array(3) { 37 | * ["Domain"]=> 38 | * string(7) "bar.com" 39 | * ["Status"]=> 40 | * string(8) "disabled" 41 | * ["LastModified"]=> 42 | * string(8) "20160101" 43 | * } 44 | * } 45 | */ 46 | public function getCnames() 47 | { 48 | return $this->cnameList; 49 | } 50 | 51 | 52 | public function addCname($cname) 53 | { 54 | if (count($this->cnameList) >= self::OSS_MAX_RULES) { 55 | throw new OssException( 56 | "num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES)); 57 | } 58 | $this->cnameList[] = array('Domain' => $cname); 59 | } 60 | 61 | public function parseFromXml($strXml) 62 | { 63 | $xml = simplexml_load_string($strXml); 64 | if (!isset($xml->Cname)) return; 65 | foreach ($xml->Cname as $entry) { 66 | $cname = array(); 67 | foreach ($entry as $key => $value) { 68 | $cname[strval($key)] = strval($value); 69 | } 70 | $this->cnameList[] = $cname; 71 | } 72 | } 73 | 74 | public function serializeToXml() 75 | { 76 | $strXml = << 78 | 79 | 80 | EOF; 81 | $xml = new \SimpleXMLElement($strXml); 82 | foreach ($this->cnameList as $cname) { 83 | $node = $xml->addChild('Cname'); 84 | foreach ($cname as $key => $value) { 85 | $node->addChild($key, $value); 86 | } 87 | } 88 | return $xml->asXML(); 89 | } 90 | 91 | public function __toString() 92 | { 93 | return $this->serializeToXml(); 94 | } 95 | 96 | const OSS_MAX_RULES = 10; 97 | 98 | private $cnameList = array(); 99 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/CnameTokenInfo.php: -------------------------------------------------------------------------------- 1 | bucket; 22 | } 23 | 24 | /** 25 | * Get cname 26 | * 27 | * @return string 28 | */ 29 | public function getCname() 30 | { 31 | return $this->cname; 32 | } 33 | 34 | /** 35 | * Get token. 36 | * 37 | * @return string 38 | */ 39 | public function getToken() 40 | { 41 | return $this->token; 42 | } 43 | 44 | /** 45 | * Get expireTime. 46 | * 47 | * @return string 48 | */ 49 | public function getExpireTime() 50 | { 51 | return $this->expireTime; 52 | } 53 | 54 | /** 55 | * Parse cname token from the xml. 56 | * 57 | * @param string $strXml 58 | * @throws OssException 59 | * @return null 60 | */ 61 | public function parseFromXml($strXml) 62 | { 63 | $xml = simplexml_load_string($strXml); 64 | if (isset($xml->Bucket) ) { 65 | $this->bucket = strval($xml->Bucket); 66 | } 67 | if (isset($xml->Cname) ) { 68 | $this->cname = strval($xml->Cname); 69 | } 70 | if (isset($xml->Token) ) { 71 | $this->token = strval($xml->Token); 72 | } 73 | if (isset($xml->ExpireTime) ) { 74 | $this->expireTime = strval($xml->ExpireTime); 75 | } 76 | } 77 | 78 | /** 79 | * bucket name 80 | * 81 | * @var string 82 | */ 83 | private $bucket; 84 | /** 85 | * cname 86 | * 87 | * @var string 88 | */ 89 | private $cname; 90 | 91 | /** 92 | * token 93 | * 94 | * @var string 95 | */ 96 | private $token; 97 | 98 | /** 99 | * expire time 100 | * 101 | * @var string 102 | */ 103 | private $expireTime; 104 | 105 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/DeleteMarkerInfo.php: -------------------------------------------------------------------------------- 1 | key = $key; 24 | $this->versionId = $versionId; 25 | $this->lastModified = $lastModified; 26 | $this->isLatest = $isLatest; 27 | } 28 | 29 | /** 30 | * @return string 31 | */ 32 | public function getKey() 33 | { 34 | return $this->key; 35 | } 36 | 37 | /** 38 | * @return string 39 | */ 40 | public function getVersionId() 41 | { 42 | return $this->versionId; 43 | } 44 | 45 | /** 46 | * @return string 47 | */ 48 | public function getLastModified() 49 | { 50 | return $this->lastModified; 51 | } 52 | 53 | /** 54 | * @return string 55 | */ 56 | public function getIsLatest() 57 | { 58 | return $this->isLatest; 59 | } 60 | 61 | private $key = ""; 62 | private $versionId = ""; 63 | private $lastModified = ""; 64 | private $isLatest = ""; 65 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/DeleteObjectInfo.php: -------------------------------------------------------------------------------- 1 | key = $key; 20 | $this->versionId = $versionId; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getKey() 27 | { 28 | return $this->key; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getVersionId() 35 | { 36 | return $this->versionId; 37 | } 38 | 39 | private $key = ""; 40 | private $versionId = ""; 41 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/DeletedObjectInfo.php: -------------------------------------------------------------------------------- 1 | key = $key; 22 | $this->versionId = $versionId; 23 | $this->deleteMarker = $deleteMarker; 24 | $this->deleteMarkerVersionId = $deleteMarkerVersionId; 25 | } 26 | 27 | /** 28 | * @return string 29 | */ 30 | public function getKey() 31 | { 32 | return $this->key; 33 | } 34 | 35 | /** 36 | * @return string 37 | */ 38 | public function getVersionId() 39 | { 40 | return $this->versionId; 41 | } 42 | 43 | /** 44 | * @return string 45 | */ 46 | public function getDeleteMarker() 47 | { 48 | return $this->deleteMarker; 49 | } 50 | 51 | /** 52 | * @return string 53 | */ 54 | public function getDeleteMarkerVersionId() 55 | { 56 | return $this->deleteMarkerVersionId; 57 | } 58 | 59 | private $key = ""; 60 | private $versionId = ""; 61 | private $deleteMarker = ""; 62 | private $deleteMarkerVersionId = ""; 63 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/ExtendWormConfig.php: -------------------------------------------------------------------------------- 1 | day = $day; 22 | } 23 | 24 | /** 25 | * Parse ExtendWormConfig from the xml. 26 | * 27 | * @param string $strXml 28 | * @throws OssException 29 | * @return null 30 | */ 31 | public function parseFromXml($strXml) 32 | { 33 | throw new OssException("Not implemented."); 34 | } 35 | 36 | /** 37 | * Serialize the object into xml string. 38 | * 39 | * @return string 40 | */ 41 | public function serializeToXml() 42 | { 43 | $xml = new \SimpleXMLElement(''); 44 | if (isset($this->day)) { 45 | $xml->addChild('RetentionPeriodInDays', $this->day); 46 | } 47 | return $xml->asXML(); 48 | } 49 | 50 | public function __toString() 51 | { 52 | return $this->serializeToXml(); 53 | } 54 | 55 | /** 56 | * @return int 57 | */ 58 | public function getDay() 59 | { 60 | return $this->day; 61 | } 62 | 63 | private $day = 0; 64 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/GetLiveChannelHistory.php: -------------------------------------------------------------------------------- 1 | liveRecordList; 16 | } 17 | 18 | public function parseFromXml($strXml) 19 | { 20 | $xml = simplexml_load_string($strXml); 21 | 22 | if (isset($xml->LiveRecord)) { 23 | foreach ($xml->LiveRecord as $record) { 24 | $liveRecord = new LiveChannelHistory(); 25 | $liveRecord->parseFromXmlNode($record); 26 | $this->liveRecordList[] = $liveRecord; 27 | } 28 | } 29 | } 30 | 31 | public function serializeToXml() 32 | { 33 | throw new OssException("Not implemented."); 34 | } 35 | 36 | private $liveRecordList = array(); 37 | } 38 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/GetLiveChannelInfo.php: -------------------------------------------------------------------------------- 1 | description; 13 | } 14 | 15 | public function getStatus() 16 | { 17 | return $this->status; 18 | } 19 | 20 | public function getType() 21 | { 22 | return $this->type; 23 | } 24 | 25 | public function getFragDuration() 26 | { 27 | return $this->fragDuration; 28 | } 29 | 30 | public function getFragCount() 31 | { 32 | return $this->fragCount; 33 | } 34 | 35 | public function getPlayListName() 36 | { 37 | return $this->playlistName; 38 | } 39 | 40 | public function parseFromXml($strXml) 41 | { 42 | $xml = simplexml_load_string($strXml); 43 | 44 | $this->description = strval($xml->Description); 45 | $this->status = strval($xml->Status); 46 | 47 | if (isset($xml->Target)) { 48 | foreach ($xml->Target as $target) { 49 | $this->type = strval($target->Type); 50 | $this->fragDuration = strval($target->FragDuration); 51 | $this->fragCount = strval($target->FragCount); 52 | $this->playlistName = strval($target->PlaylistName); 53 | } 54 | } 55 | } 56 | 57 | public function serializeToXml() 58 | { 59 | throw new OssException("Not implemented."); 60 | } 61 | 62 | private $description; 63 | private $status; 64 | private $type; 65 | private $fragDuration; 66 | private $fragCount; 67 | private $playlistName; 68 | } 69 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/InitiateWormConfig.php: -------------------------------------------------------------------------------- 1 | day = $day; 22 | } 23 | 24 | /** 25 | * Parse InitiateWormConfig from the xml. 26 | * 27 | * @param string $strXml 28 | * @throws OssException 29 | * @return null 30 | */ 31 | public function parseFromXml($strXml) 32 | { 33 | throw new OssException("Not implemented."); 34 | } 35 | 36 | /** 37 | * Serialize the object into xml string. 38 | * 39 | * @return string 40 | */ 41 | public function serializeToXml() 42 | { 43 | $xml = new \SimpleXMLElement(''); 44 | if (isset($this->day)) { 45 | $xml->addChild('RetentionPeriodInDays', $this->day); 46 | } 47 | return $xml->asXML(); 48 | } 49 | 50 | public function __toString() 51 | { 52 | return $this->serializeToXml(); 53 | } 54 | 55 | /** 56 | * @return int 57 | */ 58 | public function getDay() 59 | { 60 | return $this->day; 61 | } 62 | 63 | private $day = 0; 64 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/LifecycleAction.php: -------------------------------------------------------------------------------- 1 | action = $action; 21 | $this->timeSpec = $timeSpec; 22 | $this->timeValue = $timeValue; 23 | } 24 | 25 | /** 26 | * @return LifecycleAction 27 | */ 28 | public function getAction() 29 | { 30 | return $this->action; 31 | } 32 | 33 | /** 34 | * @param string $action 35 | */ 36 | public function setAction($action) 37 | { 38 | $this->action = $action; 39 | } 40 | 41 | /** 42 | * @return string 43 | */ 44 | public function getTimeSpec() 45 | { 46 | return $this->timeSpec; 47 | } 48 | 49 | /** 50 | * @param string $timeSpec 51 | */ 52 | public function setTimeSpec($timeSpec) 53 | { 54 | $this->timeSpec = $timeSpec; 55 | } 56 | 57 | /** 58 | * @return string 59 | */ 60 | public function getTimeValue() 61 | { 62 | return $this->timeValue; 63 | } 64 | 65 | /** 66 | * @param string $timeValue 67 | */ 68 | public function setTimeValue($timeValue) 69 | { 70 | $this->timeValue = $timeValue; 71 | } 72 | 73 | /** 74 | * Use appendToXml to insert actions into xml. 75 | * 76 | * @param \SimpleXMLElement $xmlRule 77 | */ 78 | public function appendToXml(&$xmlRule) 79 | { 80 | $xmlAction = $xmlRule->addChild($this->action); 81 | $xmlAction->addChild($this->timeSpec, $this->timeValue); 82 | } 83 | 84 | private $action; 85 | private $timeSpec; 86 | private $timeValue; 87 | 88 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/ListPartsInfo.php: -------------------------------------------------------------------------------- 1 | bucket = $bucket; 26 | $this->key = $key; 27 | $this->uploadId = $uploadId; 28 | $this->nextPartNumberMarker = $nextPartNumberMarker; 29 | $this->maxParts = $maxParts; 30 | $this->isTruncated = $isTruncated; 31 | $this->listPart = $listPart; 32 | } 33 | 34 | /** 35 | * @return string 36 | */ 37 | public function getBucket() 38 | { 39 | return $this->bucket; 40 | } 41 | 42 | /** 43 | * @return string 44 | */ 45 | public function getKey() 46 | { 47 | return $this->key; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getUploadId() 54 | { 55 | return $this->uploadId; 56 | } 57 | 58 | /** 59 | * @return int 60 | */ 61 | public function getNextPartNumberMarker() 62 | { 63 | return $this->nextPartNumberMarker; 64 | } 65 | 66 | /** 67 | * @return int 68 | */ 69 | public function getMaxParts() 70 | { 71 | return $this->maxParts; 72 | } 73 | 74 | /** 75 | * @return string 76 | */ 77 | public function getIsTruncated() 78 | { 79 | return $this->isTruncated; 80 | } 81 | 82 | /** 83 | * @return array 84 | */ 85 | public function getListPart() 86 | { 87 | return $this->listPart; 88 | } 89 | 90 | private $bucket = ""; 91 | private $key = ""; 92 | private $uploadId = ""; 93 | private $nextPartNumberMarker = 0; 94 | private $maxParts = 0; 95 | private $isTruncated = ""; 96 | private $listPart = array(); 97 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/LiveChannelHistory.php: -------------------------------------------------------------------------------- 1 | startTime; 18 | } 19 | 20 | public function getEndTime() 21 | { 22 | return $this->endTime; 23 | } 24 | 25 | public function getRemoteAddr() 26 | { 27 | return $this->remoteAddr; 28 | } 29 | 30 | public function parseFromXmlNode($xml) 31 | { 32 | if (isset($xml->StartTime)) { 33 | $this->startTime = strval($xml->StartTime); 34 | } 35 | 36 | if (isset($xml->EndTime)) { 37 | $this->endTime = strval($xml->EndTime); 38 | } 39 | 40 | if (isset($xml->RemoteAddr)) { 41 | $this->remoteAddr = strval($xml->RemoteAddr); 42 | } 43 | } 44 | 45 | public function parseFromXml($strXml) 46 | { 47 | $xml = simplexml_load_string($strXml); 48 | $this->parseFromXmlNode($xml); 49 | } 50 | 51 | public function serializeToXml() 52 | { 53 | throw new OssException("Not implemented."); 54 | } 55 | 56 | private $startTime; 57 | private $endTime; 58 | private $remoteAddr; 59 | } 60 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/LoggingConfig.php: -------------------------------------------------------------------------------- 1 | targetBucket = $targetBucket; 21 | $this->targetPrefix = $targetPrefix; 22 | } 23 | 24 | /** 25 | * @param $strXml 26 | * @return null 27 | */ 28 | public function parseFromXml($strXml) 29 | { 30 | $xml = simplexml_load_string($strXml); 31 | if (!isset($xml->LoggingEnabled)) return; 32 | foreach ($xml->LoggingEnabled as $status) { 33 | foreach ($status as $key => $value) { 34 | if ($key === 'TargetBucket') { 35 | $this->targetBucket = strval($value); 36 | } elseif ($key === 'TargetPrefix') { 37 | $this->targetPrefix = strval($value); 38 | } 39 | } 40 | break; 41 | } 42 | } 43 | 44 | /** 45 | * Serialize to xml string 46 | * 47 | */ 48 | public function serializeToXml() 49 | { 50 | $xml = new \SimpleXMLElement(''); 51 | if (isset($this->targetBucket) && isset($this->targetPrefix)) { 52 | $loggingEnabled = $xml->addChild('LoggingEnabled'); 53 | $loggingEnabled->addChild('TargetBucket', $this->targetBucket); 54 | $loggingEnabled->addChild('TargetPrefix', $this->targetPrefix); 55 | } 56 | return $xml->asXML(); 57 | } 58 | 59 | /** 60 | * @return string 61 | */ 62 | public function __toString() 63 | { 64 | return $this->serializeToXml(); 65 | } 66 | 67 | /** 68 | * @return string 69 | */ 70 | public function getTargetBucket() 71 | { 72 | return $this->targetBucket; 73 | } 74 | 75 | /** 76 | * @return string 77 | */ 78 | public function getTargetPrefix() 79 | { 80 | return $this->targetPrefix; 81 | } 82 | 83 | private $targetBucket = ""; 84 | private $targetPrefix = ""; 85 | 86 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/ObjectInfo.php: -------------------------------------------------------------------------------- 1 | key = $key; 31 | $this->lastModified = $lastModified; 32 | $this->eTag = $eTag; 33 | $this->type = $type; 34 | $this->size = $size; 35 | $this->storageClass = $storageClass; 36 | } 37 | 38 | /** 39 | * @return string 40 | */ 41 | public function getKey() 42 | { 43 | return $this->key; 44 | } 45 | 46 | /** 47 | * @return string 48 | */ 49 | public function getLastModified() 50 | { 51 | return $this->lastModified; 52 | } 53 | 54 | /** 55 | * @return string 56 | */ 57 | public function getETag() 58 | { 59 | return $this->eTag; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getType() 66 | { 67 | return $this->type; 68 | } 69 | 70 | /** 71 | * php7 && 64bit can use it 72 | * @return int 73 | */ 74 | public function getSize() 75 | { 76 | return (int)$this->size; 77 | } 78 | 79 | 80 | /** 81 | * php5.x or 32bit must use it 82 | * @return string 83 | */ 84 | public function getSizeStr() 85 | { 86 | return $this->size; 87 | } 88 | 89 | /** 90 | * @return string 91 | */ 92 | public function getStorageClass() 93 | { 94 | return $this->storageClass; 95 | } 96 | 97 | private $key = ""; 98 | private $lastModified = ""; 99 | private $eTag = ""; 100 | private $type = ""; 101 | private $size = "0"; 102 | private $storageClass = ""; 103 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/PartInfo.php: -------------------------------------------------------------------------------- 1 | partNumber = $partNumber; 22 | $this->lastModified = $lastModified; 23 | $this->eTag = $eTag; 24 | $this->size = $size; 25 | } 26 | 27 | /** 28 | * @return int 29 | */ 30 | public function getPartNumber() 31 | { 32 | return $this->partNumber; 33 | } 34 | 35 | /** 36 | * @return string 37 | */ 38 | public function getLastModified() 39 | { 40 | return $this->lastModified; 41 | } 42 | 43 | /** 44 | * @return string 45 | */ 46 | public function getETag() 47 | { 48 | return $this->eTag; 49 | } 50 | 51 | /** 52 | * php7 && 64bit can use it 53 | * @return int 54 | */ 55 | public function getSize() 56 | { 57 | return (int)$this->size; 58 | } 59 | 60 | 61 | /** 62 | * php5.x or 32bit must use it 63 | * @return string 64 | */ 65 | public function getSizeStr() 66 | { 67 | return $this->size; 68 | } 69 | 70 | private $partNumber = 0; 71 | private $lastModified = ""; 72 | private $eTag = ""; 73 | private $size = "0"; 74 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/PrefixInfo.php: -------------------------------------------------------------------------------- 1 | prefix = $prefix; 25 | } 26 | 27 | /** 28 | * @return string 29 | */ 30 | public function getPrefix() 31 | { 32 | return $this->prefix; 33 | } 34 | 35 | private $prefix; 36 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/RefererConfig.php: -------------------------------------------------------------------------------- 1 | AllowEmptyReferer)) return; 21 | if (!isset($xml->RefererList)) return; 22 | $this->allowEmptyReferer = 23 | (strval($xml->AllowEmptyReferer) === 'TRUE' || strval($xml->AllowEmptyReferer) === 'true') ? true : false; 24 | 25 | foreach ($xml->RefererList->Referer as $key => $refer) { 26 | $this->refererList[] = strval($refer); 27 | } 28 | } 29 | 30 | 31 | /** 32 | * serialize the RefererConfig object into xml string 33 | * 34 | * @return string 35 | */ 36 | public function serializeToXml() 37 | { 38 | $xml = new \SimpleXMLElement(''); 39 | if ($this->allowEmptyReferer) { 40 | $xml->addChild('AllowEmptyReferer', 'true'); 41 | } else { 42 | $xml->addChild('AllowEmptyReferer', 'false'); 43 | } 44 | $refererList = $xml->addChild('RefererList'); 45 | foreach ($this->refererList as $referer) { 46 | $refererList->addChild('Referer', $referer); 47 | } 48 | return $xml->asXML(); 49 | } 50 | 51 | /** 52 | * @return string 53 | */ 54 | function __toString() 55 | { 56 | return $this->serializeToXml(); 57 | } 58 | 59 | /** 60 | * @param boolean $allowEmptyReferer 61 | */ 62 | public function setAllowEmptyReferer($allowEmptyReferer) 63 | { 64 | $this->allowEmptyReferer = $allowEmptyReferer; 65 | } 66 | 67 | /** 68 | * @param string $referer 69 | */ 70 | public function addReferer($referer) 71 | { 72 | $this->refererList[] = $referer; 73 | } 74 | 75 | /** 76 | * @return boolean 77 | */ 78 | public function isAllowEmptyReferer() 79 | { 80 | return $this->allowEmptyReferer; 81 | } 82 | 83 | /** 84 | * @return array 85 | */ 86 | public function getRefererList() 87 | { 88 | return $this->refererList; 89 | } 90 | 91 | private $allowEmptyReferer = true; 92 | private $refererList = array(); 93 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/RequestPaymentConfig.php: -------------------------------------------------------------------------------- 1 | payer = $payer; 23 | } 24 | 25 | /** 26 | * Parse ServerSideEncryptionConfig from the xml. 27 | * 28 | * @param string $strXml 29 | * @throws OssException 30 | * @return null 31 | */ 32 | public function parseFromXml($strXml) 33 | { 34 | $xml = simplexml_load_string($strXml); 35 | if (isset($xml->Payer)) { 36 | $this->payer = strval($xml->Payer); 37 | } 38 | } 39 | 40 | /** 41 | * Serialize the object into xml string. 42 | * 43 | * @return string 44 | */ 45 | public function serializeToXml() 46 | { 47 | $xml = new \SimpleXMLElement(''); 48 | if (isset($this->payer)) { 49 | $xml->addChild('Payer', $this->payer); 50 | } 51 | return $xml->asXML(); 52 | } 53 | 54 | public function __toString() 55 | { 56 | return $this->serializeToXml(); 57 | } 58 | 59 | /** 60 | * @return string 61 | */ 62 | public function getPayer() 63 | { 64 | return $this->payer; 65 | } 66 | 67 | private $payer = ""; 68 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/RestoreConfig.php: -------------------------------------------------------------------------------- 1 | day = $day; 23 | $this->tier = $tier; 24 | } 25 | 26 | /** 27 | * Parse RestoreConfig from the xml. 28 | * 29 | * @param string $strXml 30 | * @throws OssException 31 | * @return null 32 | */ 33 | public function parseFromXml($strXml) 34 | { 35 | throw new OssException("Not implemented."); 36 | } 37 | 38 | /** 39 | * Serialize the object into xml string. 40 | * 41 | * @return string 42 | */ 43 | public function serializeToXml() 44 | { 45 | $xml = new \SimpleXMLElement(''); 46 | $xml->addChild('Days', strval($this->day)); 47 | if (isset($this->tier)) { 48 | $xml_param = $xml->addChild('JobParameters'); 49 | $xml_param->addChild('Tier', $this->tier); 50 | } 51 | return $xml->asXML(); 52 | } 53 | 54 | public function __toString() 55 | { 56 | return $this->serializeToXml(); 57 | } 58 | 59 | /** 60 | * @return int 61 | */ 62 | public function getDay() 63 | { 64 | return $this->day; 65 | } 66 | 67 | /** 68 | * @return string 69 | */ 70 | public function getTier() 71 | { 72 | return $this->tier; 73 | } 74 | 75 | private $day = 1; 76 | private $tier = 'Standard'; 77 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/ServerSideEncryptionConfig.php: -------------------------------------------------------------------------------- 1 | sseAlgorithm = $sseAlgorithm; 24 | $this->kmsMasterKeyID = $kmsMasterKeyID; 25 | } 26 | 27 | /** 28 | * Parse ServerSideEncryptionConfig from the xml. 29 | * 30 | * @param string $strXml 31 | * @throws OssException 32 | * @return null 33 | */ 34 | public function parseFromXml($strXml) 35 | { 36 | $xml = simplexml_load_string($strXml); 37 | if (!isset($xml->ApplyServerSideEncryptionByDefault)) return; 38 | foreach ($xml->ApplyServerSideEncryptionByDefault as $default) { 39 | foreach ($default as $key => $value) { 40 | if ($key === 'SSEAlgorithm') { 41 | $this->sseAlgorithm = strval($value); 42 | } elseif ($key === 'KMSMasterKeyID') { 43 | $this->kmsMasterKeyID = strval($value); 44 | } 45 | } 46 | break; 47 | } 48 | } 49 | 50 | /** 51 | * Serialize the object into xml string. 52 | * 53 | * @return string 54 | */ 55 | public function serializeToXml() 56 | { 57 | $xml = new \SimpleXMLElement(''); 58 | $default = $xml->addChild('ApplyServerSideEncryptionByDefault'); 59 | if (isset($this->sseAlgorithm)) { 60 | $default->addChild('SSEAlgorithm', $this->sseAlgorithm); 61 | } 62 | if (isset($this->kmsMasterKeyID)) { 63 | $default->addChild('KMSMasterKeyID', $this->kmsMasterKeyID); 64 | } 65 | return $xml->asXML(); 66 | } 67 | 68 | public function __toString() 69 | { 70 | return $this->serializeToXml(); 71 | } 72 | 73 | /** 74 | * @return string 75 | */ 76 | public function getSSEAlgorithm() 77 | { 78 | return $this->sseAlgorithm; 79 | } 80 | 81 | /** 82 | * @return string 83 | */ 84 | public function getKMSMasterKeyID() 85 | { 86 | return $this->kmsMasterKeyID; 87 | } 88 | 89 | private $sseAlgorithm = ""; 90 | private $kmsMasterKeyID = ""; 91 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/StorageCapacityConfig.php: -------------------------------------------------------------------------------- 1 | storageCapacity = $storageCapacity; 23 | } 24 | 25 | /** 26 | * Not implemented 27 | */ 28 | public function parseFromXml($strXml) 29 | { 30 | throw new OssException("Not implemented."); 31 | } 32 | 33 | /** 34 | * Serialize StorageCapacityConfig into xml 35 | * 36 | * @return string 37 | */ 38 | public function serializeToXml() 39 | { 40 | $xml = new \SimpleXMLElement(''); 41 | $xml->addChild('StorageCapacity', strval($this->storageCapacity)); 42 | return $xml->asXML(); 43 | } 44 | 45 | /** 46 | * To string 47 | * 48 | * @return string 49 | */ 50 | function __toString() 51 | { 52 | return $this->serializeToXml(); 53 | } 54 | 55 | /** 56 | * Set storage capacity 57 | * 58 | * @param int $storageCapacity 59 | */ 60 | public function setStorageCapacity($storageCapacity) 61 | { 62 | $this->storageCapacity = $storageCapacity; 63 | } 64 | 65 | /** 66 | * Get storage capacity 67 | * 68 | * @return int 69 | */ 70 | public function getStorageCapacity() 71 | { 72 | return $this->storageCapacity; 73 | } 74 | 75 | private $storageCapacity = 0; 76 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/Tag.php: -------------------------------------------------------------------------------- 1 | key = $key; 20 | $this->value = $value; 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getKey() 27 | { 28 | return $this->key; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getValue() 35 | { 36 | return $this->value; 37 | } 38 | 39 | private $key = ""; 40 | private $value = ""; 41 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/TaggingConfig.php: -------------------------------------------------------------------------------- 1 | tags = array(); 21 | } 22 | 23 | /** 24 | * Get Tag list 25 | * 26 | * @return Tag[] 27 | */ 28 | public function getTags() 29 | { 30 | return $this->tags; 31 | } 32 | 33 | 34 | /** 35 | * Add a new Tag 36 | * 37 | * @param Tag $tag 38 | * @throws OssException 39 | */ 40 | public function addTag($tag) 41 | { 42 | $this->tags[] = $tag; 43 | } 44 | 45 | /** 46 | * Parse TaggingConfig from the xml. 47 | * 48 | * @param string $strXml 49 | * @throws OssException 50 | * @return null 51 | */ 52 | public function parseFromXml($strXml) 53 | { 54 | $xml = simplexml_load_string($strXml); 55 | if (!isset($xml->TagSet) || !isset($xml->TagSet->Tag)) return; 56 | foreach ($xml->TagSet->Tag as $tag) { 57 | $this->addTag(new Tag($tag->Key, $tag->Value)); 58 | } 59 | } 60 | 61 | /** 62 | * Serialize the object into xml string. 63 | * 64 | * @return string 65 | */ 66 | public function serializeToXml() 67 | { 68 | $xml = new \SimpleXMLElement(''); 69 | $xmlTagSet = $xml->addChild('TagSet'); 70 | foreach ($this->tags as $tag) { 71 | $xmlTag = $xmlTagSet->addChild('Tag'); 72 | $xmlTag->addChild('Key', strval($tag->getKey())); 73 | $xmlTag->addChild('Value', strval($tag->getValue())); 74 | } 75 | return $xml->asXML(); 76 | } 77 | 78 | public function __toString() 79 | { 80 | return $this->serializeToXml(); 81 | } 82 | 83 | /** 84 | * Tag list 85 | * 86 | * @var Tag[] 87 | */ 88 | private $tags = array(); 89 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/TransferAccelerationConfig.php: -------------------------------------------------------------------------------- 1 | Enabled)) { 23 | $this->enabled = (strval($xml->Enabled) === 'TRUE' || strval($xml->Enabled) === 'true') ? true : false; 24 | } 25 | } 26 | 27 | /** 28 | * Serialize the object into xml string. 29 | * 30 | * @return string 31 | */ 32 | public function serializeToXml() 33 | { 34 | $xml = new \SimpleXMLElement(''); 35 | if (isset($this->enabled)) { 36 | if($this->enabled === true){ 37 | $xml->addChild('Enabled','true'); 38 | } else { 39 | $xml->addChild('Enabled','false'); 40 | } 41 | } 42 | return $xml->asXML(); 43 | } 44 | 45 | public function __toString() 46 | { 47 | return $this->serializeToXml(); 48 | } 49 | 50 | 51 | /** 52 | * @return bool 53 | */ 54 | public function getEnabled() 55 | { 56 | return $this->enabled; 57 | } 58 | 59 | /** 60 | * @param boolean enabled 61 | */ 62 | public function setEnabled($enabled) 63 | { 64 | $this->enabled = $enabled; 65 | } 66 | 67 | /** 68 | * @var $enabled boolean 69 | */ 70 | private $enabled = false; 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/UploadInfo.php: -------------------------------------------------------------------------------- 1 | key = $key; 24 | $this->uploadId = $uploadId; 25 | $this->initiated = $initiated; 26 | } 27 | 28 | /** 29 | * @return string 30 | */ 31 | public function getKey() 32 | { 33 | return $this->key; 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getUploadId() 40 | { 41 | return $this->uploadId; 42 | } 43 | 44 | /** 45 | * @return string 46 | */ 47 | public function getInitiated() 48 | { 49 | return $this->initiated; 50 | } 51 | 52 | private $key = ""; 53 | private $uploadId = ""; 54 | private $initiated = ""; 55 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/VersioningConfig.php: -------------------------------------------------------------------------------- 1 | status = $status; 22 | } 23 | 24 | /** 25 | * Parse VersioningConfig from the xml. 26 | * 27 | * @param string $strXml 28 | * @throws OssException 29 | * @return null 30 | */ 31 | public function parseFromXml($strXml) 32 | { 33 | $xml = simplexml_load_string($strXml); 34 | if (isset($xml->Status)) { 35 | $this->status = strval($xml->Status); 36 | } 37 | } 38 | 39 | /** 40 | * Serialize the object into xml string. 41 | * 42 | * @return string 43 | */ 44 | public function serializeToXml() 45 | { 46 | $xml = new \SimpleXMLElement(''); 47 | if (isset($this->status)) { 48 | $xml->addChild('Status', $this->status); 49 | } 50 | return $xml->asXML(); 51 | } 52 | 53 | public function __toString() 54 | { 55 | return $this->serializeToXml(); 56 | } 57 | 58 | /** 59 | * @return string 60 | */ 61 | public function getStatus() 62 | { 63 | return $this->status; 64 | } 65 | 66 | private $status = ""; 67 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/WebsiteConfig.php: -------------------------------------------------------------------------------- 1 | indexDocument = $indexDocument; 24 | $this->errorDocument = $errorDocument; 25 | } 26 | 27 | /** 28 | * @param string $strXml 29 | * @return null 30 | */ 31 | public function parseFromXml($strXml) 32 | { 33 | $xml = simplexml_load_string($strXml); 34 | if (isset($xml->IndexDocument) && isset($xml->IndexDocument->Suffix)) { 35 | $this->indexDocument = strval($xml->IndexDocument->Suffix); 36 | } 37 | if (isset($xml->ErrorDocument) && isset($xml->ErrorDocument->Key)) { 38 | $this->errorDocument = strval($xml->ErrorDocument->Key); 39 | } 40 | } 41 | 42 | /** 43 | * Serialize the WebsiteConfig object into xml string. 44 | * 45 | * @return string 46 | * @throws OssException 47 | */ 48 | public function serializeToXml() 49 | { 50 | $xml = new \SimpleXMLElement(''); 51 | $index_document_part = $xml->addChild('IndexDocument'); 52 | $error_document_part = $xml->addChild('ErrorDocument'); 53 | $index_document_part->addChild('Suffix', $this->indexDocument); 54 | $error_document_part->addChild('Key', $this->errorDocument); 55 | return $xml->asXML(); 56 | } 57 | 58 | /** 59 | * @return string 60 | */ 61 | public function getIndexDocument() 62 | { 63 | return $this->indexDocument; 64 | } 65 | 66 | /** 67 | * @return string 68 | */ 69 | public function getErrorDocument() 70 | { 71 | return $this->errorDocument; 72 | } 73 | 74 | private $indexDocument = ""; 75 | private $errorDocument = ""; 76 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/WormConfig.php: -------------------------------------------------------------------------------- 1 | WormId)) { 26 | $this->wormId = strval($xml->WormId); 27 | } 28 | if (isset($xml->State)) { 29 | $this->state = strval($xml->State); 30 | } 31 | if (isset($xml->RetentionPeriodInDays)) { 32 | $this->day = intval($xml->RetentionPeriodInDays); 33 | } 34 | if (isset($xml->CreationDate)) { 35 | $this->creationDate = strval($xml->CreationDate); 36 | } 37 | } 38 | 39 | /** 40 | * Serialize the object into xml string. 41 | * 42 | * @return string 43 | */ 44 | public function serializeToXml() 45 | { 46 | throw new OssException("Not implemented."); 47 | } 48 | 49 | public function __toString() 50 | { 51 | return $this->serializeToXml(); 52 | } 53 | 54 | /** 55 | * @return string 56 | */ 57 | public function getWormId() 58 | { 59 | return $this->wormId; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getState() 66 | { 67 | return $this->state; 68 | } 69 | 70 | /** 71 | * @return int 72 | */ 73 | public function getDay() 74 | { 75 | return $this->day; 76 | } 77 | 78 | /** 79 | * @return string 80 | */ 81 | public function getCreationDate() 82 | { 83 | return $this->creationDate; 84 | } 85 | 86 | private $wormId = ''; 87 | private $state = ''; 88 | private $creationDate = ''; 89 | private $day = 0; 90 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Model/XmlConfig.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 21 | if (empty($content)) { 22 | throw new OssException("body is null"); 23 | } 24 | $xml = simplexml_load_string($content); 25 | if (isset($xml->AccessControlList->Grant)) { 26 | return strval($xml->AccessControlList->Grant); 27 | } else { 28 | throw new OssException("xml format exception"); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/AppendResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->header; 22 | if (isset($header["x-oss-next-append-position"])) { 23 | return intval($header["x-oss-next-append-position"]); 24 | } 25 | throw new OssException("cannot get next-append-position"); 26 | } 27 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/BodyResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body) ? "" : $this->rawResponse->body; 18 | } 19 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/CallbackResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->status; 15 | if ((int)(intval($status) / 100) == 2 && (int)(intval($status)) !== 203) { 16 | return true; 17 | } 18 | return false; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/CopyObjectResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 18 | $xml = simplexml_load_string($body); 19 | $result = array(); 20 | 21 | if (isset($xml->LastModified)) { 22 | $result[] = $xml->LastModified; 23 | } 24 | if (isset($xml->ETag)) { 25 | $result[] = $xml->ETag; 26 | } 27 | 28 | return array_merge($result, $this->rawResponse->header); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/CreateBucketCnameTokenResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $info = new CnameTokenInfo(); 16 | $info->parseFromXml($content); 17 | return $info; 18 | } 19 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/DeleteObjectVersionsResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body); 20 | $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; 21 | return $this->parseDeletedList($xml, $encodingType); 22 | } 23 | 24 | private function parseDeletedList($xml, $encodingType) 25 | { 26 | $retList = array(); 27 | if (isset($xml->Deleted)) { 28 | foreach ($xml->Deleted as $content) { 29 | $key = isset($content->Key) ? strval($content->Key) : ""; 30 | $key = OssUtil::decodeKey($key, $encodingType); 31 | $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; 32 | $deleteMarker = isset($content->DeleteMarker) ? strval($content->DeleteMarker) : ""; 33 | $deleteMarkerVersionId = isset($content->DeleteMarkerVersionId) ? strval($content->DeleteMarkerVersionId) : ""; 34 | $retList[] = new DeletedObjectInfo($key, $versionId, $deleteMarker, $deleteMarkerVersionId); 35 | } 36 | } 37 | return $retList; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/DeleteObjectsResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 18 | $xml = simplexml_load_string($body); 19 | $objects = array(); 20 | 21 | if (isset($xml->Deleted)) { 22 | foreach($xml->Deleted as $deleteKey) 23 | $objects[] = $deleteKey->Key; 24 | } 25 | return $objects; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/ExistResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->status) === 200 ? true : false; 17 | } 18 | 19 | /** 20 | * Check if the response status is OK according to the http status code. 21 | * [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too. 22 | * 23 | * @return bool 24 | */ 25 | protected function isResponseOk() 26 | { 27 | $status = $this->rawResponse->status; 28 | if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { 29 | return true; 30 | } 31 | return false; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketCnameTokenResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $info = new CnameTokenInfo(); 16 | $info->parseFromXml($content); 17 | return $info; 18 | } 19 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketEncryptionResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new ServerSideEncryptionConfig(); 23 | $config->parseFromXml($content); 24 | return $config; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketInfoResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 25 | if (empty($content)) { 26 | throw new OssException("body is null"); 27 | } 28 | $xml = simplexml_load_string($content); 29 | if (isset($xml->Bucket)) { 30 | $info = new BucketInfo(); 31 | $info->parseFromXmlNode($xml->Bucket); 32 | return $info; 33 | } else { 34 | throw new OssException("xml format exception"); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketRequestPaymentResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new RequestPaymentConfig(); 23 | $config->parseFromXml($content); 24 | return $config->getPayer(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketStatResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $stat = new BucketStat(); 23 | $stat->parseFromXml($content); 24 | return $stat; 25 | } 26 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketTagsResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new TaggingConfig(); 23 | $config->parseFromXml($content); 24 | return $config; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketTransferAccelerationResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 18 | $config = new TransferAccelerationConfig(); 19 | $config->parseFromXml($content); 20 | return $config->getEnabled(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketVersioningResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new VersioningConfig(); 23 | $config->parseFromXml($content); 24 | return $config->getStatus(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetBucketWormResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new WormConfig(); 23 | $config->parseFromXml($content); 24 | return $config; 25 | } 26 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetCnameResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $config = new CnameConfig(); 16 | $config->parseFromXml($content); 17 | return $config; 18 | } 19 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetCorsResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $config = new CorsConfig(); 16 | $config->parseFromXml($content); 17 | return $config; 18 | } 19 | 20 | /** 21 | * Check if the response is OK, according to the http status. [200-299]:OK, the Cors config could be got; [404]: not found--no Cors config. 22 | * 23 | * @return bool 24 | */ 25 | protected function isResponseOk() 26 | { 27 | $status = $this->rawResponse->status; 28 | if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { 29 | return true; 30 | } 31 | return false; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetLifecycleResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new LifecycleConfig(); 23 | $config->parseFromXml($content); 24 | return $config; 25 | } 26 | 27 | /** 28 | * Check if the response is OK according to the http status. 29 | * [200-299]: OK, and the LifecycleConfig could be got; [404] The Life cycle config is not found. 30 | * 31 | * @return bool 32 | */ 33 | protected function isResponseOk() 34 | { 35 | $status = $this->rawResponse->status; 36 | if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { 37 | return true; 38 | } 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetLiveChannelHistoryResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $channelList = new GetLiveChannelHistory(); 16 | $channelList->parseFromXml($content); 17 | return $channelList; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetLiveChannelInfoResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $channelList = new GetLiveChannelInfo(); 16 | $channelList->parseFromXml($content); 17 | return $channelList; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetLiveChannelStatusResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 15 | $channelList = new GetLiveChannelStatus(); 16 | $channelList->parseFromXml($content); 17 | return $channelList; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetLocationResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 24 | if (empty($content)) { 25 | throw new OssException("body is null"); 26 | } 27 | $xml = simplexml_load_string($content); 28 | return $xml; 29 | } 30 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetLoggingResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new LoggingConfig(); 23 | $config->parseFromXml($content); 24 | return $config; 25 | } 26 | 27 | /** 28 | * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, 29 | * 404 is also considered a valid response 30 | * 31 | * @return bool 32 | */ 33 | protected function isResponseOk() 34 | { 35 | $status = $this->rawResponse->status; 36 | if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { 37 | return true; 38 | } 39 | return false; 40 | } 41 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetRefererResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $config = new RefererConfig(); 23 | $config->parseFromXml($content); 24 | return $config; 25 | } 26 | 27 | /** 28 | * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, 29 | * 404 is also considered a valid response 30 | * 31 | * @return bool 32 | */ 33 | protected function isResponseOk() 34 | { 35 | $status = $this->rawResponse->status; 36 | if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { 37 | return true; 38 | } 39 | return false; 40 | } 41 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetStorageCapacityResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 24 | if (empty($content)) { 25 | throw new OssException("body is null"); 26 | } 27 | $xml = simplexml_load_string($content); 28 | if (isset($xml->StorageCapacity)) { 29 | return intval($xml->StorageCapacity); 30 | } else { 31 | throw new OssException("xml format exception"); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/GetWebsiteResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 21 | $config = new WebsiteConfig(); 22 | $config->parseFromXml($content); 23 | return $config; 24 | } 25 | 26 | /** 27 | * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, 28 | * 404 is also considered a valid response 29 | * 30 | * @return bool 31 | */ 32 | protected function isResponseOk() 33 | { 34 | $status = $this->rawResponse->status; 35 | if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { 36 | return true; 37 | } 38 | return false; 39 | } 40 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/HeaderResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->header) ? array() : $this->rawResponse->header; 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/InitiateBucketWormResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->header; 22 | if (isset($header["x-oss-worm-id"])) { 23 | return strval($header["x-oss-worm-id"]); 24 | } 25 | throw new OssException("cannot get worm-id"); 26 | } 27 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/InitiateMultipartUploadResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 23 | $xml = simplexml_load_string($content); 24 | if (isset($xml->UploadId)) { 25 | return strval($xml->UploadId); 26 | } 27 | throw new OssException("cannot get UploadId"); 28 | } 29 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/ListBucketsResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 22 | $xml = new \SimpleXMLElement($content); 23 | if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) { 24 | foreach ($xml->Buckets->Bucket as $bucket) { 25 | $bucketInfo = new BucketInfo(); 26 | $bucketInfo->parseFromXmlNode($bucket); 27 | $bucketList[] = $bucketInfo; 28 | } 29 | } 30 | return new BucketListInfo($bucketList); 31 | } 32 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/ListLiveChannelResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 12 | $channelList = new LiveChannelListInfo(); 13 | $channelList->parseFromXml($content); 14 | return $channelList; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/ListMultipartUploadResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 24 | $xml = simplexml_load_string($content); 25 | 26 | $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; 27 | $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : ""; 28 | $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : ""; 29 | $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType); 30 | $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : ""; 31 | $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : ""; 32 | $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType); 33 | $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : ""; 34 | $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; 35 | $delimiter = OssUtil::decodeKey($delimiter, $encodingType); 36 | $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; 37 | $prefix = OssUtil::decodeKey($prefix, $encodingType); 38 | $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0; 39 | $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; 40 | $listUpload = array(); 41 | 42 | if (isset($xml->Upload)) { 43 | foreach ($xml->Upload as $upload) { 44 | $key = isset($upload->Key) ? strval($upload->Key) : ""; 45 | $key = OssUtil::decodeKey($key, $encodingType); 46 | $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : ""; 47 | $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : ""; 48 | $listUpload[] = new UploadInfo($key, $uploadId, $initiated); 49 | } 50 | } 51 | return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker, 52 | $nextKeyMarker, $nextUploadIdMarker, 53 | $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload); 54 | } 55 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/ListPartsResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 23 | $xml = simplexml_load_string($content); 24 | $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : ""; 25 | $key = isset($xml->Key) ? strval($xml->Key) : ""; 26 | $uploadId = isset($xml->UploadId) ? strval($xml->UploadId) : ""; 27 | $nextPartNumberMarker = isset($xml->NextPartNumberMarker) ? intval($xml->NextPartNumberMarker) : ""; 28 | $maxParts = isset($xml->MaxParts) ? intval($xml->MaxParts) : ""; 29 | $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; 30 | $partList = array(); 31 | if (isset($xml->Part)) { 32 | foreach ($xml->Part as $part) { 33 | $partNumber = isset($part->PartNumber) ? intval($part->PartNumber) : ""; 34 | $lastModified = isset($part->LastModified) ? strval($part->LastModified) : ""; 35 | $eTag = isset($part->ETag) ? strval($part->ETag) : ""; 36 | $size = isset($part->Size) ? strval($part->Size) : ""; 37 | $partList[] = new PartInfo($partNumber, $lastModified, $eTag, $size); 38 | } 39 | } 40 | return new ListPartsInfo($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, $partList); 41 | } 42 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/PutLiveChannelResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->body; 12 | $channel = new LiveChannelInfo(); 13 | $channel->parseFromXml($content); 14 | return $channel; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/PutSetDeleteResult.php: -------------------------------------------------------------------------------- 1 | $this->rawResponse->body); 18 | return array_merge($this->rawResponse->header, $body); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/SymlinkResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->header[OssClient::OSS_SYMLINK_TARGET] = rawurldecode($this->rawResponse->header[OssClient::OSS_SYMLINK_TARGET]); 21 | return $this->rawResponse->header; 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/src/OSS/Result/UploadPartResult.php: -------------------------------------------------------------------------------- 1 | rawResponse->header; 22 | if (isset($header["etag"])) { 23 | return $header["etag"]; 24 | } 25 | throw new OssException("cannot get ETag"); 26 | 27 | } 28 | } -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/AclResultTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | 00220120222 17 | user_example 18 | 19 | 20 | public-read 21 | 22 | 23 | BBBB; 24 | 25 | private $invalidXml = << 27 | 28 | 29 | BBBB; 30 | 31 | public function testParseValidXml() 32 | { 33 | $response = new ResponseCore(array(), $this->validXml, 200); 34 | $result = new AclResult($response); 35 | $this->assertEquals("public-read", $result->getData()); 36 | } 37 | 38 | public function testParseNullXml() 39 | { 40 | $response = new ResponseCore(array(), "", 200); 41 | try { 42 | new AclResult($response); 43 | $this->assertTrue(false); 44 | } catch (OssException $e) { 45 | $this->assertEquals('body is null', $e->getMessage()); 46 | } 47 | } 48 | 49 | public function testParseInvalidXml() 50 | { 51 | $response = new ResponseCore(array(), $this->invalidXml, 200); 52 | try { 53 | new AclResult($response); 54 | $this->assertFalse(true); 55 | } catch (OssException $e) { 56 | $this->assertEquals("xml format exception", $e->getMessage()); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/BodyResultTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($result->isOK()); 16 | $this->assertEquals($result->getData(), "hi"); 17 | } 18 | 19 | public function testParseInvalid404() 20 | { 21 | $response = new ResponseCore(array(), null, 200); 22 | $result = new BodyResult($response); 23 | $this->assertTrue($result->isOK()); 24 | $this->assertEquals($result->getData(), ""); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/BucketCnameTest.php: -------------------------------------------------------------------------------- 1 | client = Common::getOssClient(); 17 | $this->bucketName = 'php-sdk-test-bucket-' . strval(rand(0, 10000)); 18 | $this->client->createBucket($this->bucketName); 19 | } 20 | 21 | protected function tearDown(): void 22 | { 23 | $this->client->deleteBucket($this->bucketName); 24 | } 25 | 26 | public function testBucketWithoutCname() 27 | { 28 | $cnameConfig = $this->client->getBucketCname($this->bucketName); 29 | $this->assertEquals(0, count($cnameConfig->getCnames())); 30 | } 31 | 32 | public function testAddCname() 33 | { 34 | $this->client->addBucketCname($this->bucketName, 'www.baidu.com'); 35 | $this->client->addBucketCname($this->bucketName, 'www.qq.com'); 36 | 37 | $ret = $this->client->getBucketCname($this->bucketName); 38 | $this->assertEquals(2, count($ret->getCnames())); 39 | 40 | // add another 2 cnames 41 | $this->client->addBucketCname($this->bucketName, 'www.sina.com.cn'); 42 | $this->client->addBucketCname($this->bucketName, 'www.iqiyi.com'); 43 | 44 | $ret = $this->client->getBucketCname($this->bucketName); 45 | $cnames = $ret->getCnames(); 46 | $cnameList = array(); 47 | 48 | foreach ($cnames as $c) { 49 | $cnameList[] = $c['Domain']; 50 | } 51 | $should = array( 52 | 'www.baidu.com', 53 | 'www.qq.com', 54 | 'www.sina.com.cn', 55 | 'www.iqiyi.com' 56 | ); 57 | $this->assertEquals(4, count($cnames)); 58 | $this->assertEquals(sort($should), sort($cnameList)); 59 | } 60 | 61 | public function testDeleteCname() 62 | { 63 | $this->client->addBucketCname($this->bucketName, 'www.baidu.com'); 64 | $this->client->addBucketCname($this->bucketName, 'www.qq.com'); 65 | 66 | $ret = $this->client->getBucketCname($this->bucketName); 67 | $this->assertEquals(2, count($ret->getCnames())); 68 | 69 | // delete one cname 70 | $this->client->deleteBucketCname($this->bucketName, 'www.baidu.com'); 71 | 72 | $ret = $this->client->getBucketCname($this->bucketName); 73 | $this->assertEquals(1, count($ret->getCnames())); 74 | $cnames = $ret->getCnames(); 75 | $this->assertEquals('www.qq.com', $cnames[0]['Domain']); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/BucketInfoTest.php: -------------------------------------------------------------------------------- 1 | assertNotNull($bucketInfo); 17 | $this->assertEquals('cn-beijing', $bucketInfo->getLocation()); 18 | $this->assertEquals('name', $bucketInfo->getName()); 19 | $this->assertEquals('today', $bucketInfo->getCreateDate()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/CnameConfigTest.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | www.foo.com 16 | enabled 17 | 20150101 18 | 19 | 20 | bar.com 21 | disabled 22 | 20160101 23 | 24 | 25 | BBBB; 26 | 27 | public function testFromXml() 28 | { 29 | $cnameConfig = new CnameConfig(); 30 | $cnameConfig->parseFromXml($this->xml1); 31 | 32 | $cnames = $cnameConfig->getCnames(); 33 | $this->assertEquals(2, count($cnames)); 34 | $this->assertEquals('www.foo.com', $cnames[0]['Domain']); 35 | $this->assertEquals('enabled', $cnames[0]['Status']); 36 | $this->assertEquals('20150101', $cnames[0]['LastModified']); 37 | 38 | $this->assertEquals('bar.com', $cnames[1]['Domain']); 39 | $this->assertEquals('disabled', $cnames[1]['Status']); 40 | $this->assertEquals('20160101', $cnames[1]['LastModified']); 41 | } 42 | 43 | public function testToXml() 44 | { 45 | $cnameConfig = new CnameConfig(); 46 | $cnameConfig->addCname('www.foo.com'); 47 | $cnameConfig->addCname('bar.com'); 48 | 49 | $xml = $cnameConfig->serializeToXml(); 50 | $comp = new CnameConfig(); 51 | $comp->parseFromXml($xml); 52 | 53 | $cnames1 = $cnameConfig->getCnames(); 54 | $cnames2 = $comp->getCnames(); 55 | 56 | $this->assertEquals(count($cnames1), count($cnames2)); 57 | $this->assertEquals(count($cnames1[0]), count($cnames2[0])); 58 | $this->assertEquals(1, count($cnames1[0])); 59 | $this->assertEquals($cnames1[0]['Domain'], $cnames2[0]['Domain']); 60 | } 61 | 62 | public function testCnameNumberLimit() 63 | { 64 | $cnameConfig = new CnameConfig(); 65 | for ($i = 0; $i < CnameConfig::OSS_MAX_RULES; $i += 1) { 66 | $cnameConfig->addCname(strval($i) . '.foo.com'); 67 | } 68 | try { 69 | $cnameConfig->addCname('www.foo.com'); 70 | $this->assertFalse(true); 71 | } catch (OssException $e) { 72 | $this->assertEquals( 73 | $e->getMessage(), 74 | "num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(CnameConfig::OSS_MAX_RULES)); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/CnameTokenInfoTest.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | bucket 15 | www.foo.com 16 | 1234 17 | 20150101 18 | 19 | BBBB; 20 | 21 | public function testFromXml() 22 | { 23 | $info = new CnameTokenInfo(); 24 | $info->parseFromXml($this->xml1); 25 | 26 | $this->assertEquals('bucket', $info->getBucket()); 27 | $this->assertEquals('www.foo.com', $info->getCname()); 28 | $this->assertEquals('1234', $info->getToken()); 29 | $this->assertEquals('20150101', $info->getExpireTime()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/Common.php: -------------------------------------------------------------------------------- 1 | getMessage() . "\n"); 32 | return null; 33 | } 34 | return $ossClient; 35 | } 36 | 37 | public static function getBucketName() 38 | { 39 | return getenv('OSS_BUCKET'); 40 | } 41 | 42 | public static function getRegion() 43 | { 44 | return getenv('OSS_REGION'); 45 | } 46 | 47 | public static function getCallbackUrl() 48 | { 49 | return getenv('OSS_CALLBACK_URL'); 50 | } 51 | 52 | /** 53 | * Tool method, create a bucket 54 | */ 55 | public static function createBucket() 56 | { 57 | $ossClient = self::getOssClient(); 58 | if (is_null($ossClient)) exit(1); 59 | $bucket = self::getBucketName(); 60 | $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ; 61 | try { 62 | $ossClient->createBucket($bucket, $acl); 63 | } catch (OssException $e) { 64 | printf(__FUNCTION__ . ": FAILED\n"); 65 | printf($e->getMessage() . "\n"); 66 | return; 67 | } 68 | print(__FUNCTION__ . ": OK" . "\n"); 69 | } 70 | 71 | /** 72 | * Wait for bucket meta sync 73 | */ 74 | public static function waitMetaSync() 75 | { 76 | if (getenv('TRAVIS')) { 77 | sleep(10); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/CopyObjectResult.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | Fri, 24 Feb 2012 07:18:48 GMT 15 | "5B3C1A2E053D763E1B002CC607C5A0FE" 16 | 17 | BBBB; 18 | 19 | public function testNullResponse() 20 | { 21 | $response = null; 22 | try { 23 | new CopyObjectResult($response); 24 | $this->assertFalse(true); 25 | } catch (OssException $e) { 26 | $this->assertEquals('raw response is null', $e->getMessage()); 27 | } 28 | } 29 | 30 | public function testOkResponse() 31 | { 32 | $header= array(); 33 | $response = new ResponseCore($header, $this->body, 200); 34 | $result = new CopyObjectResult($response); 35 | $data = $result->getData(); 36 | $this->assertTrue($result->isOK()); 37 | $this->assertEquals("Fri, 24 Feb 2012 07:18:48 GMT", $data[0]); 38 | $this->assertEquals("\"5B3C1A2E053D763E1B002CC607C5A0FE\"", $data[1]); 39 | } 40 | 41 | public function testFailResponse() 42 | { 43 | $response = new ResponseCore(array(), "", 404); 44 | try { 45 | new CopyObjectResult($response); 46 | $this->assertFalse(true); 47 | } catch (OssException $e) { 48 | $this->assertFalse(false); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/ExistResultTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($result->isOK()); 17 | $this->assertEquals($result->getData(), true); 18 | } 19 | 20 | public function testParseInvalid404() 21 | { 22 | $response = new ResponseCore(array(), "", 404); 23 | $result = new ExistResult($response); 24 | $this->assertTrue($result->isOK()); 25 | $this->assertEquals($result->getData(), false); 26 | } 27 | 28 | public function testInvalidResponse() 29 | { 30 | $response = new ResponseCore(array(), "", 300); 31 | try { 32 | new ExistResult($response); 33 | $this->assertTrue(false); 34 | } catch (OssException $e) { 35 | $this->assertTrue(true); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | Requester 16 | 17 | BBBB; 18 | 19 | private $validXml2 = << 21 | 22 | BucketOwner 23 | 24 | BBBB; 25 | 26 | private $invalidXml = << 28 | 29 | 30 | BBBB; 31 | 32 | public function testParseValidXml() 33 | { 34 | $response = new ResponseCore(array(), $this->validXml, 200); 35 | $result = new GetBucketRequestPaymentResult($response); 36 | $this->assertTrue($result->isOK()); 37 | $this->assertNotNull($result->getData()); 38 | $this->assertNotNull($result->getRawResponse()); 39 | $payer = $result->getData(); 40 | $this->assertEquals("Requester", $payer); 41 | 42 | $response = new ResponseCore(array(), $this->validXml2, 200); 43 | $result = new GetBucketRequestPaymentResult($response); 44 | $this->assertTrue($result->isOK()); 45 | $this->assertNotNull($result->getData()); 46 | $this->assertNotNull($result->getRawResponse()); 47 | $payer = $result->getData(); 48 | $this->assertEquals("BucketOwner", $payer); 49 | } 50 | 51 | public function testParseNullXml() 52 | { 53 | $response = new ResponseCore(array(), "", 200); 54 | $result = new GetBucketRequestPaymentResult($response); 55 | $payer = $result->getData(); 56 | $this->assertEquals(null, $payer); 57 | } 58 | 59 | public function testParseInvalidXml() 60 | { 61 | $response = new ResponseCore(array(), $this->invalidXml, 200); 62 | $result = new GetBucketRequestPaymentResult($response); 63 | $payer = $result->getData(); 64 | $this->assertEquals(null, $payer); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetBucketTagsResultTest.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | testa 17 | value1-test 18 | 19 | 20 | testb 21 | value2-test 22 | 23 | 24 | 25 | BBBB; 26 | 27 | private $invalidXml = << 29 | 30 | 31 | BBBB; 32 | 33 | private $invalidXml2 = << 35 | 36 | 37 | 38 | 39 | BBBB; 40 | 41 | public function testParseValidXml() 42 | { 43 | $response = new ResponseCore(array(), $this->validXml, 200); 44 | $result = new GetBucketTagsResult($response); 45 | $this->assertTrue($result->isOK()); 46 | $this->assertNotNull($result->getData()); 47 | $this->assertNotNull($result->getRawResponse()); 48 | $config = $result->getData(); 49 | $this->assertEquals(2, count($config->getTags())); 50 | $this->assertEquals("testa", $config->getTags()[0]->getKey()); 51 | $this->assertEquals("value1-test", $config->getTags()[0]->getValue()); 52 | $this->assertEquals("testb", $config->getTags()[1]->getKey()); 53 | $this->assertEquals("value2-test", $config->getTags()[1]->getValue()); 54 | } 55 | 56 | public function testParseNullXml() 57 | { 58 | $response = new ResponseCore(array(), "", 200); 59 | $result = new GetBucketTagsResult($response); 60 | $config = $result->getData(); 61 | $this->assertEquals(0, count($config->getTags())); 62 | 63 | } 64 | 65 | public function testParseInvalidXml() 66 | { 67 | $response = new ResponseCore(array(), $this->invalidXml, 200); 68 | $result = new GetBucketTagsResult($response); 69 | $config = $result->getData(); 70 | $this->assertEquals(0, count($config->getTags())); 71 | 72 | $response = new ResponseCore(array(), $this->invalidXml2, 200); 73 | $result = new GetBucketTagsResult($response); 74 | $config = $result->getData(); 75 | $this->assertEquals(0, count($config->getTags())); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php: -------------------------------------------------------------------------------- 1 | 13 | true 14 | 15 | BBBB; 16 | private $validXml1 = << 18 | false 19 | 20 | BBBB; 21 | 22 | private $invalidXml2 = << 24 | 25 | 26 | BBBB; 27 | 28 | public function testParseValidXml() 29 | { 30 | $response = new ResponseCore(array(), $this->validXml, 200); 31 | $result = new GetBucketTransferAccelerationResult($response); 32 | $this->assertTrue($result->isOK()); 33 | $this->assertNotNull($result->getData()); 34 | $this->assertNotNull($result->getRawResponse()); 35 | $enabled = $result->getData(); 36 | $this->assertEquals(true, $enabled); 37 | } 38 | 39 | public function testParseValidXml1() 40 | { 41 | $response = new ResponseCore(array(), $this->validXml1, 200); 42 | $result = new GetBucketTransferAccelerationResult($response); 43 | $this->assertTrue($result->isOK()); 44 | $this->assertNotNull($result->getData()); 45 | $this->assertNotNull($result->getRawResponse()); 46 | $enabled = $result->getData(); 47 | $this->assertEquals(false, $enabled); 48 | } 49 | 50 | public function testParseInvalidXml2() 51 | { 52 | $response = new ResponseCore(array(), $this->invalidXml2, 200); 53 | $result = new GetBucketTransferAccelerationResult($response); 54 | $this->assertTrue($result->isOK()); 55 | $this->assertNotNull($result->getData()); 56 | $this->assertNotNull($result->getRawResponse()); 57 | $this->assertNotNull($result->getRawResponse()->body); 58 | $enabled = $result->getData(); 59 | $this->assertEquals(false, $enabled); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetCorsResultTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | http://www.b.com 17 | http://www.a.com 18 | http://www.a.com 19 | GET 20 | PUT 21 | POST 22 | x-oss-test 23 | x-oss-test2 24 | x-oss-test2 25 | x-oss-test3 26 | x-oss-test1 27 | x-oss-test1 28 | x-oss-test2 29 | 10 30 | 31 | 32 | http://www.b.com 33 | GET 34 | x-oss-test 35 | x-oss-test1 36 | 110 37 | 38 | 39 | BBBB; 40 | 41 | public function testParseValidXml() 42 | { 43 | $response = new ResponseCore(array(), $this->validXml, 200); 44 | $result = new GetCorsResult($response); 45 | $this->assertTrue($result->isOK()); 46 | $this->assertNotNull($result->getData()); 47 | $this->assertNotNull($result->getRawResponse()); 48 | $corsConfig = $result->getData(); 49 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); 50 | } 51 | 52 | private function cleanXml($xml) 53 | { 54 | return str_replace("\n", "", str_replace("\r", "", $xml)); 55 | } 56 | 57 | public function testInvalidResponse() 58 | { 59 | $response = new ResponseCore(array(), $this->validXml, 300); 60 | try { 61 | $result = new GetCorsResult($response); 62 | $this->assertTrue(false); 63 | } catch (OssException $e) { 64 | $this->assertTrue(true); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetLifecycleResultTest.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | delete obsoleted files 18 | obsoleted/ 19 | Enabled 20 | 3 21 | 22 | 23 | delete temporary files 24 | temporary/ 25 | Enabled 26 | 2022-10-12T00:00:00.000Z 27 | 2022-10-12T00:00:00.000Z 28 | 29 | 30 | BBBB; 31 | 32 | public function testParseValidXml() 33 | { 34 | $response = new ResponseCore(array(), $this->validXml, 200); 35 | $result = new GetLifecycleResult($response); 36 | $this->assertTrue($result->isOK()); 37 | $this->assertNotNull($result->getData()); 38 | $this->assertNotNull($result->getRawResponse()); 39 | $lifecycleConfig = $result->getData(); 40 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($lifecycleConfig->serializeToXml())); 41 | } 42 | 43 | private function cleanXml($xml) 44 | { 45 | return str_replace("\n", "", str_replace("\r", "", $xml)); 46 | } 47 | 48 | public function testInvalidResponse() 49 | { 50 | $response = new ResponseCore(array(), $this->validXml, 300); 51 | try { 52 | $result = new GetLifecycleResult($response); 53 | $this->assertTrue(false); 54 | } catch (OssException $e) { 55 | $this->assertTrue(true); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetLoggingResultTest.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | 17 | TargetBucket 18 | TargetPrefix 19 | 20 | 21 | BBBB; 22 | 23 | public function testParseValidXml() 24 | { 25 | $response = new ResponseCore(array(), $this->validXml, 200); 26 | $result = new GetLoggingResult($response); 27 | $this->assertTrue($result->isOK()); 28 | $this->assertNotNull($result->getData()); 29 | $this->assertNotNull($result->getRawResponse()); 30 | $loggingConfig = $result->getData(); 31 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($loggingConfig->serializeToXml())); 32 | $this->assertEquals("TargetBucket", $loggingConfig->getTargetBucket()); 33 | $this->assertEquals("TargetPrefix", $loggingConfig->getTargetPrefix()); 34 | } 35 | 36 | private function cleanXml($xml) 37 | { 38 | return str_replace("\n", "", str_replace("\r", "", $xml)); 39 | } 40 | 41 | public function testInvalidResponse() 42 | { 43 | $response = new ResponseCore(array(), $this->validXml, 300); 44 | try { 45 | $result = new GetLoggingResult($response); 46 | $this->assertTrue(false); 47 | } catch (OssException $e) { 48 | $this->assertTrue(true); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetRefererResultTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | true 16 | 17 | http://www.aliyun.com 18 | https://www.aliyun.com 19 | http://www.*.com 20 | https://www.?.aliyuncs.com 21 | 22 | 23 | BBBB; 24 | 25 | public function testParseValidXml() 26 | { 27 | $response = new ResponseCore(array(), $this->validXml, 200); 28 | $result = new GetRefererResult($response); 29 | $this->assertTrue($result->isOK()); 30 | $this->assertNotNull($result->getData()); 31 | $this->assertNotNull($result->getRawResponse()); 32 | $refererConfig = $result->getData(); 33 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml())); 34 | } 35 | 36 | private function cleanXml($xml) 37 | { 38 | return str_replace("\n", "", str_replace("\r", "", $xml)); 39 | } 40 | 41 | public function testInvalidResponse() 42 | { 43 | $response = new ResponseCore(array(), $this->validXml, 300); 44 | try { 45 | $result = new GetRefererResult($response); 46 | $this->assertTrue(false); 47 | } catch (OssException $e) { 48 | $this->assertTrue(true); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/GetWebsiteResultTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | index.html 17 | 18 | 19 | errorDocument.html 20 | 21 | 22 | BBBB; 23 | 24 | public function testParseValidXml() 25 | { 26 | $response = new ResponseCore(array(), $this->validXml, 200); 27 | $result = new GetWebsiteResult($response); 28 | $this->assertTrue($result->isOK()); 29 | $this->assertNotNull($result->getData()); 30 | $this->assertNotNull($result->getRawResponse()); 31 | $websiteConfig = $result->getData(); 32 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); 33 | } 34 | 35 | private function cleanXml($xml) 36 | { 37 | return str_replace("\n", "", str_replace("\r", "", $xml)); 38 | } 39 | 40 | public function testInvalidResponse() 41 | { 42 | $response = new ResponseCore(array(), $this->validXml, 300); 43 | try { 44 | $result = new GetWebsiteResult($response); 45 | $this->assertTrue(false); 46 | } catch (OssException $e) { 47 | $this->assertTrue(true); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/HeaderResultTest.php: -------------------------------------------------------------------------------- 1 | 'value'), "", 200); 17 | $result = new HeaderResult($response); 18 | $this->assertTrue($result->isOK()); 19 | $this->assertTrue(is_array($result->getData())); 20 | $data = $result->getData(); 21 | $this->assertEquals($data['key'], 'value'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/HttpTest.php: -------------------------------------------------------------------------------- 1 | assertFalse($res->isOK()); 17 | $this->assertTrue($res->isOK(500)); 18 | } 19 | 20 | public function testGet() 21 | { 22 | $httpCore = new RequestCore("http://www.baidu.com"); 23 | $httpResponse = $httpCore->send_request(); 24 | $this->assertNotNull($httpResponse); 25 | } 26 | 27 | public function testSetProxyAndTimeout() 28 | { 29 | $httpCore = new RequestCore("http://www.baidu.com"); 30 | $httpCore->set_proxy("1.0.2.1:8888"); 31 | $httpCore->connect_timeout = 1; 32 | try { 33 | $httpResponse = $httpCore->send_request(); 34 | $this->assertTrue(false); 35 | } catch (RequestCore_Exception $e) { 36 | $this->assertTrue(true); 37 | } 38 | } 39 | 40 | public function testGetParseTrue() 41 | { 42 | $httpCore = new RequestCore("http://www.baidu.com"); 43 | $httpCore->curlopts = array(CURLOPT_HEADER => true); 44 | $url = $httpCore->send_request(true); 45 | foreach ($httpCore->get_response_header() as $key => $value) { 46 | $this->assertEquals($httpCore->get_response_header($key), $value); 47 | } 48 | $this->assertNotNull($url); 49 | } 50 | 51 | public function testParseResponse() 52 | { 53 | $httpCore = new RequestCore("http://www.baidu.com"); 54 | $response = $httpCore->send_request(); 55 | $parsed = $httpCore->process_response(null, $response); 56 | $this->assertNotNull($parsed); 57 | } 58 | 59 | public function testExceptionGet() 60 | { 61 | $httpCore = null; 62 | $exception = false; 63 | try { 64 | $httpCore = new RequestCore("http://www.notexistsitexx.com"); 65 | $httpCore->set_body(""); 66 | $httpCore->set_method("GET"); 67 | $httpCore->connect_timeout = 10; 68 | $httpCore->timeout = 10; 69 | $res = $httpCore->send_request(); 70 | } catch (RequestCore_Exception $e) { 71 | $exception = true; 72 | } 73 | $this->assertTrue($exception); 74 | } 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/InitiateMultipartUploadResultTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | multipart_upload 16 | multipart.data 17 | 0004B9894A22E5B1888A1E29F8236E2D 18 | 19 | BBBB; 20 | 21 | private $invalidXml = << 23 | 24 | multipart_upload 25 | multipart.data 26 | 27 | BBBB; 28 | 29 | 30 | public function testParseValidXml() 31 | { 32 | $response = new ResponseCore(array(), $this->validXml, 200); 33 | $result = new InitiateMultipartUploadResult($response); 34 | $this->assertEquals("0004B9894A22E5B1888A1E29F8236E2D", $result->getData()); 35 | } 36 | 37 | public function testParseInvalidXml() 38 | { 39 | $response = new ResponseCore(array(), $this->invalidXml, 200); 40 | try { 41 | $result = new InitiateMultipartUploadResult($response); 42 | $this->assertTrue(false); 43 | } catch (OssException $e) { 44 | $this->assertTrue(true); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/ListPartsResultTest.php: -------------------------------------------------------------------------------- 1 | 16 | 17 | multipart_upload 18 | multipart.data 19 | 0004B999EF5A239BB9138C6227D69F95 20 | 5 21 | 1000 22 | false 23 | 24 | 1 25 | 2012-02-23T07:01:34.000Z 26 | "3349DC700140D7F86A078484278075A9" 27 | 6291456 28 | 29 | 30 | 2 31 | 2012-02-23T07:01:12.000Z 32 | "3349DC700140D7F86A078484278075A9" 33 | 6291456 34 | 35 | 36 | 5 37 | 2012-02-23T07:02:03.000Z 38 | "7265F4D211B56873A381D321F586E4A9" 39 | 1024 40 | 41 | 42 | BBBB; 43 | 44 | public function testParseValidXml() 45 | { 46 | $response = new ResponseCore(array(), $this->validXml, 200); 47 | $result = new ListPartsResult($response); 48 | $listPartsInfo = $result->getData(); 49 | $this->assertEquals("multipart_upload", $listPartsInfo->getBucket()); 50 | $this->assertEquals("multipart.data", $listPartsInfo->getKey()); 51 | $this->assertEquals("0004B999EF5A239BB9138C6227D69F95", $listPartsInfo->getUploadId()); 52 | $this->assertEquals(5, $listPartsInfo->getNextPartNumberMarker()); 53 | $this->assertEquals(1000, $listPartsInfo->getMaxParts()); 54 | $this->assertEquals("false", $listPartsInfo->getIsTruncated()); 55 | $this->assertEquals(3, count($listPartsInfo->getListPart())); 56 | $parts = $listPartsInfo->getListPart(); 57 | $this->assertEquals(1, $parts[0]->getPartNumber()); 58 | $this->assertEquals('2012-02-23T07:01:34.000Z', $parts[0]->getLastModified()); 59 | $this->assertEquals('"3349DC700140D7F86A078484278075A9"', $parts[0]->getETag()); 60 | $this->assertEquals(6291456, $parts[0]->getSize()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/LoggingConfigTest.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | TargetBucket 14 | TargetPrefix 15 | 16 | 17 | BBBB; 18 | 19 | private $nullXml = << 21 | 22 | BBBB; 23 | 24 | public function testParseValidXml() 25 | { 26 | $loggingConfig = new LoggingConfig(); 27 | $loggingConfig->parseFromXml($this->validXml); 28 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($loggingConfig))); 29 | } 30 | 31 | public function testConstruct() 32 | { 33 | $loggingConfig = new LoggingConfig('TargetBucket', 'TargetPrefix'); 34 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($loggingConfig->serializeToXml())); 35 | } 36 | 37 | public function testFailedConstruct() 38 | { 39 | $loggingConfig = new LoggingConfig('TargetBucket', null); 40 | $this->assertEquals($this->cleanXml($this->nullXml), $this->cleanXml($loggingConfig->serializeToXml())); 41 | } 42 | 43 | private function cleanXml($xml) 44 | { 45 | return str_replace("\n", "", str_replace("\r", "", $xml)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/MimeTypesTest.php: -------------------------------------------------------------------------------- 1 | assertEquals('application/xml', MimeTypes::getMimetype('file.xml')); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/ObjectAclTest.php: -------------------------------------------------------------------------------- 1 | ossClient; 12 | $bucket = $this->bucket; 13 | 14 | $object = 'test/object-acl'; 15 | $client->deleteObject($bucket, $object); 16 | $client->putObject($bucket, $object, "hello world"); 17 | 18 | $acl = $client->getObjectAcl($bucket, $object); 19 | $this->assertEquals('default', $acl); 20 | 21 | $client->putObjectAcl($bucket, $object, 'public-read'); 22 | $acl = $client->getObjectAcl($bucket, $object); 23 | $this->assertEquals('public-read', $acl); 24 | 25 | $content = $client->getObject($bucket, $object); 26 | $this->assertEquals('hello world', $content); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketCnameTest.php: -------------------------------------------------------------------------------- 1 | bucket . '-cname'; 18 | $client = new OssClient( 19 | getenv('OSS_ACCESS_KEY_ID'), 20 | getenv('OSS_ACCESS_KEY_SECRET'), 21 | "oss-ap-southeast-2.aliyuncs.com", false); 22 | 23 | $client->createBucket($bucketName); 24 | 25 | try { 26 | $info1 = $client->createBucketCnameToken($bucketName, "www.example.com"); 27 | $this->assertEquals("www.example.com", $info1->getCname()); 28 | $this->assertEquals($bucketName, $info1->getBucket()); 29 | } catch (OssException $e) { 30 | $this->assertTrue(false); 31 | } 32 | 33 | try { 34 | $info2 = $client->getBucketCnameToken($bucketName, "www.example.com"); 35 | $this->assertEquals("www.example.com", $info2->getCname()); 36 | $this->assertEquals($bucketName, $info2->getBucket()); 37 | } catch (OssException $e) { 38 | $this->assertTrue(false); 39 | } 40 | 41 | try { 42 | $result = $client->addBucketCname($bucketName, "www.example.com"); 43 | } catch (OssException $e) { 44 | $this->assertEquals('NeedVerifyDomainOwnership', $e->getErrorCode()); 45 | } 46 | 47 | try { 48 | $config = $client->getBucketCname($bucketName); 49 | } catch (OssException $e) { 50 | $this->assertTrue(false); 51 | } 52 | 53 | try { 54 | $result = $client->deleteBucketCname($bucketName, "www.example.com"); 55 | } catch (OssException $e) { 56 | $this->assertTrue(false); 57 | } 58 | 59 | $client->deleteBucket($bucketName); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketEncryptionTest.php: -------------------------------------------------------------------------------- 1 | ossClient->putBucketEncryption($this->bucket, $config); 18 | } catch (OssException $e) { 19 | var_dump($e->getMessage()); 20 | $this->assertTrue(false); 21 | } 22 | try { 23 | Common::waitMetaSync(); 24 | $config2 = $this->ossClient->getBucketEncryption($this->bucket); 25 | $this->assertEquals($config->serializeToXml(), $config2->serializeToXml()); 26 | $this->assertEquals("AES256", $config2->getSSEAlgorithm()); 27 | $this->assertEquals(null, $config2->getKMSMasterKeyID()); 28 | } catch (OssException $e) { 29 | $this->assertTrue(false); 30 | } 31 | 32 | $config = new ServerSideEncryptionConfig("KMS", "kms-id"); 33 | try { 34 | $this->ossClient->putBucketEncryption($this->bucket, $config); 35 | } catch (OssException $e) { 36 | var_dump($e->getMessage()); 37 | $this->assertTrue(false); 38 | } 39 | try { 40 | Common::waitMetaSync(); 41 | $config2 = $this->ossClient->getBucketEncryption($this->bucket); 42 | $this->assertEquals($config->serializeToXml(), $config2->serializeToXml()); 43 | $this->assertEquals("KMS", $config2->getSSEAlgorithm()); 44 | $this->assertEquals("kms-id", $config2->getKMSMasterKeyID()); 45 | } catch (OssException $e) { 46 | $this->assertTrue(false); 47 | } 48 | 49 | try { 50 | Common::waitMetaSync(); 51 | $this->ossClient->deleteBucketEncryption($this->bucket); 52 | } catch (OssException $e) { 53 | $this->assertTrue(false); 54 | } 55 | try { 56 | Common::waitMetaSync(); 57 | $config2 = $this->ossClient->getBucketEncryption($this->bucket); 58 | $this->assertTrue(false); 59 | } catch (OssException $e) { 60 | $this->assertEquals("NoSuchServerSideEncryptionRule", $e->getErrorCode()); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketInfoTest.php: -------------------------------------------------------------------------------- 1 | ossClient->getBucketInfo($this->bucket); 14 | $this->assertEquals($this->bucket, $info->getName()); 15 | $this->assertEquals("Standard", $info->getStorageClass()); 16 | } catch (OssException $e) { 17 | $this->assertTrue(false); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketLifecycleTest.php: -------------------------------------------------------------------------------- 1 | addRule($lifecycleRule); 22 | $actions = array(); 23 | $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z'); 24 | $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); 25 | $lifecycleConfig->addRule($lifecycleRule); 26 | 27 | try { 28 | $this->ossClient->putBucketLifecycle($this->bucket, $lifecycleConfig); 29 | } catch (OssException $e) { 30 | $this->assertTrue(false); 31 | } 32 | 33 | try { 34 | Common::waitMetaSync(); 35 | $lifecycleConfig2 = $this->ossClient->getBucketLifecycle($this->bucket); 36 | $this->assertEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig2->serializeToXml()); 37 | } catch (OssException $e) { 38 | $this->assertTrue(false); 39 | } 40 | 41 | try { 42 | Common::waitMetaSync(); 43 | $this->ossClient->deleteBucketLifecycle($this->bucket); 44 | } catch (OssException $e) { 45 | $this->assertTrue(false); 46 | } 47 | 48 | try { 49 | Common::waitMetaSync(); 50 | $lifecycleConfig3 = $this->ossClient->getBucketLifecycle($this->bucket); 51 | $this->assertNotEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig3->serializeToXml()); 52 | } catch (OssException $e) { 53 | $this->assertTrue(false); 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketLoggingTest.php: -------------------------------------------------------------------------------- 1 | bucket, 'prefix'); 16 | try { 17 | $this->ossClient->putBucketLogging($this->bucket, $this->bucket, 'prefix'); 18 | } catch (OssException $e) { 19 | var_dump($e->getMessage()); 20 | $this->assertTrue(false); 21 | } 22 | try { 23 | Common::waitMetaSync(); 24 | $loggingConfig2 = $this->ossClient->getBucketLogging($this->bucket); 25 | $this->assertEquals($loggingConfig->serializeToXml(), $loggingConfig2->serializeToXml()); 26 | } catch (OssException $e) { 27 | $this->assertTrue(false); 28 | } 29 | try { 30 | Common::waitMetaSync(); 31 | $this->ossClient->deleteBucketLogging($this->bucket); 32 | } catch (OssException $e) { 33 | $this->assertTrue(false); 34 | } 35 | try { 36 | Common::waitMetaSync(); 37 | $loggingConfig3 = $this->ossClient->getBucketLogging($this->bucket); 38 | $this->assertNotEquals($loggingConfig->serializeToXml(), $loggingConfig3->serializeToXml()); 39 | } catch (OssException $e) { 40 | $this->assertTrue(false); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketPolicyTest.php: -------------------------------------------------------------------------------- 1 | ossClient->deleteBucketPolicy($this->bucket); 31 | $policy = $this->ossClient->getBucketPolicy($this->bucket); 32 | $this->assertTrue(false); 33 | } catch (OssException $e) { 34 | $this->assertTrue(true); 35 | $this->assertEquals("NoSuchBucketPolicy", $e->getErrorCode()); 36 | } 37 | 38 | try { 39 | $this->ossClient->putBucketPolicy($this->bucket, $policy_str); 40 | $policy = $this->ossClient->getBucketPolicy($this->bucket); 41 | $this->assertEquals($policy_str, $policy); 42 | $this->ossClient->deleteBucketPolicy($this->bucket); 43 | } catch (OssException $e) { 44 | $this->assertTrue(false); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketRefererTest.php: -------------------------------------------------------------------------------- 1 | addReferer('http://www.aliyun.com'); 18 | 19 | try { 20 | $this->ossClient->putBucketReferer($this->bucket, $refererConfig); 21 | } catch (OssException $e) { 22 | var_dump($e->getMessage()); 23 | $this->assertTrue(false); 24 | } 25 | try { 26 | Common::waitMetaSync(); 27 | $refererConfig2 = $this->ossClient->getBucketReferer($this->bucket); 28 | $this->assertEquals($refererConfig->serializeToXml(), $refererConfig2->serializeToXml()); 29 | } catch (OssException $e) { 30 | $this->assertTrue(false); 31 | } 32 | try { 33 | Common::waitMetaSync(); 34 | $nullRefererConfig = new RefererConfig(); 35 | $nullRefererConfig->setAllowEmptyReferer(false); 36 | $this->ossClient->putBucketReferer($this->bucket, $nullRefererConfig); 37 | } catch (OssException $e) { 38 | $this->assertTrue(false); 39 | } 40 | try { 41 | Common::waitMetaSync(); 42 | $refererConfig3 = $this->ossClient->getBucketLogging($this->bucket); 43 | $this->assertNotEquals($refererConfig->serializeToXml(), $refererConfig3->serializeToXml()); 44 | } catch (OssException $e) { 45 | $this->assertTrue(false); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php: -------------------------------------------------------------------------------- 1 | ossClient->getBucketRequestPayment($this->bucket); 18 | $this->assertEquals("BucketOwner", $payer); 19 | } catch (OssException $e) { 20 | $this->assertTrue(false); 21 | } 22 | 23 | try { 24 | $this->ossClient->putBucketRequestPayment($this->bucket, "Requester"); 25 | } catch (OssException $e) { 26 | var_dump($e->getMessage()); 27 | $this->assertTrue(false); 28 | } 29 | try { 30 | Common::waitMetaSync(); 31 | $payer = $this->ossClient->getBucketRequestPayment($this->bucket); 32 | $this->assertEquals("Requester", $payer); 33 | } catch (OssException $e) { 34 | $this->assertTrue(false); 35 | } 36 | 37 | try { 38 | $this->ossClient->putBucketRequestPayment($this->bucket, "BucketOwner"); 39 | } catch (OssException $e) { 40 | var_dump($e->getMessage()); 41 | $this->assertTrue(false); 42 | } 43 | try { 44 | Common::waitMetaSync(); 45 | $payer = $this->ossClient->getBucketRequestPayment($this->bucket); 46 | $this->assertEquals("BucketOwner", $payer); 47 | } catch (OssException $e) { 48 | $this->assertTrue(false); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketStatTestTest.php: -------------------------------------------------------------------------------- 1 | ossClient->putObject($this->bucket, "name-1.txt", $content); 15 | $this->ossClient->putObject($this->bucket, "name-2.txt", $content); 16 | $this->ossClient->putObject($this->bucket, "name-3.txt", $content); 17 | 18 | $object = "multipart-test.txt"; 19 | $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); 20 | 21 | Common::waitMetaSync(); 22 | Common::waitMetaSync(); 23 | Common::waitMetaSync(); 24 | $stat = $this->ossClient->getBucketStat($this->bucket); 25 | $this->assertEquals(3, $stat->getObjectCount()); 26 | $this->assertEquals(15, $stat->getStorage()); 27 | $this->assertEquals(1, $stat->getMultipartUploadCount()); 28 | 29 | } catch (OssException $e) { 30 | $this->assertTrue(false); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php: -------------------------------------------------------------------------------- 1 | ossClient->getBucketStorageCapacity($this->bucket); 14 | $this->assertEquals($storageCapacity, -1); 15 | } catch (OssException $e) { 16 | $this->assertTrue(false); 17 | } 18 | 19 | try { 20 | $this->ossClient->putBucketStorageCapacity($this->bucket, 1000); 21 | } catch (OssException $e) { 22 | $this->assertTrue(false); 23 | } 24 | 25 | try { 26 | Common::waitMetaSync(); 27 | $storageCapacity = $this->ossClient->getBucketStorageCapacity($this->bucket); 28 | $this->assertEquals($storageCapacity, 1000); 29 | } catch (OssException $e) { 30 | $this->assertTrue(false); 31 | } 32 | 33 | try { 34 | $this->ossClient->putBucketStorageCapacity($this->bucket, 0); 35 | 36 | Common::waitMetaSync(); 37 | 38 | $storageCapacity = $this->ossClient->getBucketStorageCapacity($this->bucket); 39 | $this->assertEquals($storageCapacity, 0); 40 | 41 | $this->ossClient->putObject($this->bucket, 'test-storage-capacity','test-content'); 42 | $this->assertTrue(false); 43 | } catch (OssException $e) { 44 | $this->assertEquals('Bucket storage exceed max storage capacity.',$e->getErrorMessage()); 45 | } 46 | 47 | try { 48 | $this->ossClient->putBucketStorageCapacity($this->bucket, -2); 49 | $this->assertTrue(false); 50 | } catch (OssException $e) { 51 | $this->assertEquals(400, $e->getHTTPStatus()); 52 | $this->assertEquals('InvalidArgument', $e->getErrorCode()); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php: -------------------------------------------------------------------------------- 1 | ossClient->getBucketTransferAcceleration($this->bucket); 17 | $this->assertTrue(false); 18 | } catch (OssException $e) { 19 | $this->assertEquals("NoSuchTransferAccelerationConfiguration", $e->getErrorCode()); 20 | } 21 | 22 | try { 23 | $this->ossClient->putBucketTransferAcceleration($this->bucket, true); 24 | Common::waitMetaSync(); 25 | $status = $this->ossClient->getBucketTransferAcceleration($this->bucket); 26 | $this->assertEquals(true, $status); 27 | } catch (OssException $e) { 28 | $this->assertTrue(false); 29 | } 30 | 31 | try { 32 | $this->ossClient->putBucketTransferAcceleration($this->bucket, false); 33 | Common::waitMetaSync(); 34 | $status = $this->ossClient->getBucketTransferAcceleration($this->bucket); 35 | $this->assertEquals(false, $status); 36 | } catch (OssException $e) { 37 | $this->assertTrue(false); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketVersioningTest.php: -------------------------------------------------------------------------------- 1 | ossClient->getBucketVersioning($this->bucket); 17 | $this->assertEquals(null, $status); 18 | } catch (OssException $e) { 19 | $this->assertTrue(false); 20 | } 21 | 22 | try { 23 | $this->ossClient->putBucketVersioning($this->bucket, "Enabled"); 24 | Common::waitMetaSync(); 25 | $status = $this->ossClient->getBucketVersioning($this->bucket); 26 | $this->assertEquals("Enabled", $status); 27 | } catch (OssException $e) { 28 | $this->assertTrue(false); 29 | } 30 | 31 | try { 32 | $this->ossClient->putBucketVersioning($this->bucket, "Suspended"); 33 | Common::waitMetaSync(); 34 | $status = $this->ossClient->getBucketVersioning($this->bucket); 35 | $this->assertEquals("Suspended", $status); 36 | } catch (OssException $e) { 37 | $this->assertTrue(false); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketWebsiteTest.php: -------------------------------------------------------------------------------- 1 | ossClient->putBucketWebsite($this->bucket, $websiteConfig); 20 | } catch (OssException $e) { 21 | var_dump($e->getMessage()); 22 | $this->assertTrue(false); 23 | } 24 | 25 | try { 26 | Common::waitMetaSync(); 27 | $websiteConfig2 = $this->ossClient->getBucketWebsite($this->bucket); 28 | $this->assertEquals($websiteConfig->serializeToXml(), $websiteConfig2->serializeToXml()); 29 | } catch (OssException $e) { 30 | $this->assertTrue(false); 31 | } 32 | try { 33 | Common::waitMetaSync(); 34 | $this->ossClient->deleteBucketWebsite($this->bucket); 35 | } catch (OssException $e) { 36 | $this->assertTrue(false); 37 | } 38 | try { 39 | Common::waitMetaSync(); 40 | $websiteConfig3 = $this->ossClient->getBucketLogging($this->bucket); 41 | $this->assertNotEquals($websiteConfig->serializeToXml(), $websiteConfig3->serializeToXml()); 42 | } catch (OssException $e) { 43 | $this->assertTrue(false); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssClientBucketWormTest.php: -------------------------------------------------------------------------------- 1 | ossClient->initiateBucketWorm($this->bucket, 30); 16 | $config = $this->ossClient->getBucketWorm($this->bucket); 17 | $this->assertEquals($wormId, $config->getWormId()); 18 | $this->assertEquals("InProgress", $config->getState()); 19 | $this->assertEquals(30, $config->getDay()); 20 | $this->ossClient->abortBucketWorm($this->bucket); 21 | 22 | $wormId = $this->ossClient->initiateBucketWorm($this->bucket, 60); 23 | $this->ossClient->completeBucketWorm($this->bucket, $wormId); 24 | $config = $this->ossClient->getBucketWorm($this->bucket); 25 | 26 | $this->ossClient->ExtendBucketWorm($this->bucket, $wormId, 120); 27 | $config = $this->ossClient->getBucketWorm($this->bucket); 28 | $this->assertEquals($wormId, $config->getWormId()); 29 | $this->assertEquals("Locked", $config->getState()); 30 | $this->assertEquals(120, $config->getDay()); 31 | 32 | } catch (OssException $e) { 33 | $this->assertTrue(false); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/OssExceptionTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(false); 14 | } catch (OssException $e) { 15 | $this->assertNotNull($e); 16 | $this->assertEquals($e->getMessage(), "ERR"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/PutSetDeleteResultTest.php: -------------------------------------------------------------------------------- 1 | assertFalse(true); 18 | } catch (OssException $e) { 19 | $this->assertEquals('raw response is null', $e->getMessage()); 20 | } 21 | } 22 | 23 | public function testOkResponse() 24 | { 25 | $header= array( 26 | 'x-oss-request-id' => '582AA51E004C4550BD27E0E4', 27 | 'etag' => '595FA1EA77945233921DF12427F9C7CE', 28 | 'content-md5' => 'WV+h6neUUjOSHfEkJ/nHzg==', 29 | 'info' => array( 30 | 'http_code' => '200', 31 | 'method' => 'PUT' 32 | ), 33 | ); 34 | $response = new ResponseCore($header, "this is a mock body, just for test", 200); 35 | $result = new PutSetDeleteResult($response); 36 | $data = $result->getData(); 37 | $this->assertTrue($result->isOK()); 38 | $this->assertEquals("this is a mock body, just for test", $data['body']); 39 | $this->assertEquals('582AA51E004C4550BD27E0E4', $data['x-oss-request-id']); 40 | $this->assertEquals('595FA1EA77945233921DF12427F9C7CE', $data['etag']); 41 | $this->assertEquals('WV+h6neUUjOSHfEkJ/nHzg==', $data['content-md5']); 42 | $this->assertEquals('200', $data['info']['http_code']); 43 | $this->assertEquals('PUT', $data['info']['method']); 44 | } 45 | 46 | public function testFailResponse() 47 | { 48 | $response = new ResponseCore(array(), "", 301); 49 | try { 50 | new PutSetDeleteResult($response); 51 | $this->assertFalse(true); 52 | } catch (OssException $e) { 53 | $this->assertFalse(false); 54 | } 55 | } 56 | 57 | protected function setUp(): void 58 | { 59 | 60 | } 61 | 62 | protected function tearDown(): void 63 | { 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/RefererConfigTest.php: -------------------------------------------------------------------------------- 1 | 13 | 14 | true 15 | 16 | http://www.aliyun.com 17 | https://www.aliyun.com 18 | http://www.*.com 19 | https://www.?.aliyuncs.com 20 | 21 | 22 | BBBB; 23 | 24 | private $validXml2 = << 26 | 27 | true 28 | 29 | http://www.aliyun.com 30 | 31 | 32 | BBBB; 33 | 34 | public function testParseValidXml() 35 | { 36 | $refererConfig = new RefererConfig(); 37 | $refererConfig->parseFromXml($this->validXml); 38 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml())); 39 | } 40 | 41 | public function testParseValidXml2() 42 | { 43 | $refererConfig = new RefererConfig(); 44 | $refererConfig->parseFromXml($this->validXml2); 45 | $this->assertEquals(true, $refererConfig->isAllowEmptyReferer()); 46 | $this->assertEquals(1, count($refererConfig->getRefererList())); 47 | $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml(strval($refererConfig))); 48 | } 49 | 50 | private function cleanXml($xml) 51 | { 52 | return str_replace("\n", "", str_replace("\r", "", $xml)); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/StorageCapacityConfigTest.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 10 14 | 15 | BBBB; 16 | 17 | private $validXml_20 = << 19 | 20 | 20 21 | 22 | BBBB; 23 | 24 | public function testConstruct() 25 | { 26 | $config = new StorageCapacityConfig(10); 27 | $this->assertEquals($config->getStorageCapacity(), 10); 28 | $this->assertEquals($this->cleanXml($this->validXml_10), $this->cleanXml($config->serializeToXml())); 29 | } 30 | 31 | public function testSetStorageCapacity() 32 | { 33 | $config = new StorageCapacityConfig(2); 34 | $config->setStorageCapacity(20); 35 | $this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->serializeToXml())); 36 | $this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->__toString())); 37 | } 38 | 39 | public function testParseFromXml() 40 | { 41 | try { 42 | $config = new StorageCapacityConfig(10); 43 | $config->parseFromXml('invaide xml'); 44 | $this->assertTrue(false); 45 | } catch (OssException $e) { 46 | $this->assertTrue(true); 47 | if (strpos($e, "Not implemented.") == false) 48 | { 49 | $this->assertTrue(false); 50 | } 51 | } 52 | } 53 | 54 | private function cleanXml($xml) 55 | { 56 | return str_replace("\n", "", str_replace("\r", "", $xml)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/StorageCapacityTest.php: -------------------------------------------------------------------------------- 1 | 14 | 15 | 1 16 | 17 | BBBB; 18 | 19 | private $validXml = << 21 | 22 | 1 23 | 24 | BBBB; 25 | 26 | public function testParseInValidXml() 27 | { 28 | $response = new ResponseCore(array(), $this->inValidXml, 300); 29 | try { 30 | new GetStorageCapacityResult($response); 31 | $this->assertTrue(false); 32 | } catch (OssException $e) { 33 | $this->assertTrue(true); 34 | } 35 | } 36 | 37 | public function testParseEmptyXml() 38 | { 39 | $response = new ResponseCore(array(), "", 300); 40 | try { 41 | new GetStorageCapacityResult($response); 42 | $this->assertTrue(false); 43 | } catch (OssException $e) { 44 | $this->assertTrue(true); 45 | } 46 | } 47 | 48 | public function testParseValidXml() 49 | { 50 | $response = new ResponseCore(array(), $this->validXml, 200); 51 | $result = new GetStorageCapacityResult($response); 52 | $this->assertEquals($result->getData(), 1); 53 | } 54 | 55 | public function testSerializeToXml() 56 | { 57 | $xml = "\n1\n"; 58 | 59 | $storageCapacityConfig = new StorageCapacityConfig(1); 60 | $content = $storageCapacityConfig->serializeToXml(); 61 | $this->assertEquals($content, $xml); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/TestOssClientBase.php: -------------------------------------------------------------------------------- 1 | bucket = Common::getBucketName() .'-'. time(); 24 | $this->ossClient = Common::getOssClient(); 25 | $this->ossClient->createBucket($this->bucket); 26 | Common::waitMetaSync(); 27 | } 28 | 29 | protected function tearDown(): void 30 | { 31 | if (!$this->ossClient->doesBucketExist($this->bucket)) { 32 | return; 33 | } 34 | 35 | $objects = $this->ossClient->listObjects( 36 | $this->bucket, array('max-keys' => 1000, 'delimiter' => ''))->getObjectList(); 37 | $keys = array(); 38 | foreach ($objects as $obj) { 39 | $keys[] = $obj->getKey(); 40 | } 41 | if (count($keys) > 0) { 42 | $this->ossClient->deleteObjects($this->bucket, $keys); 43 | } 44 | $uploads = $this->ossClient->listMultipartUploads($this->bucket)->getUploads(); 45 | foreach ($uploads as $up) { 46 | $this->ossClient->abortMultipartUpload($this->bucket, $up->getKey(), $up->getUploadId()); 47 | } 48 | 49 | $this->ossClient->deleteBucket($this->bucket); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/TransferAccelerationConfigTest.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | true 14 | 15 | BBBB; 16 | private $validXml1 = << 18 | 19 | false 20 | 21 | BBBB; 22 | 23 | private $invalidXml1 = << 25 | 26 | 27 | BBBB; 28 | 29 | public function testParseValidXml() 30 | { 31 | $transferConfig = new TransferAccelerationConfig(); 32 | $transferConfig->parseFromXml($this->validXml); 33 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($transferConfig))); 34 | $this->assertEquals(true,$transferConfig->getEnabled()); 35 | } 36 | 37 | public function testValidXml1() 38 | { 39 | $transferConfig = new TransferAccelerationConfig(); 40 | $transferConfig->parseFromXml($this->validXml1); 41 | $this->assertEquals($this->cleanXml($this->validXml1), $this->cleanXml(strval($transferConfig))); 42 | $this->assertEquals(false,$transferConfig->getEnabled()); 43 | } 44 | 45 | public function testInvalidXml1() 46 | { 47 | $transferConfig = new TransferAccelerationConfig(); 48 | $transferConfig->parseFromXml($this->invalidXml1); 49 | $this->assertEquals(false,$transferConfig->getEnabled()); 50 | } 51 | 52 | private function cleanXml($xml) 53 | { 54 | return str_replace("\n", "", str_replace("\r", "", $xml)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/UploadPartResultTest.php: -------------------------------------------------------------------------------- 1 | '7265F4D211B56873A381D321F586E4A9'); 13 | private $invalidHeader = array(); 14 | 15 | public function testParseValidHeader() 16 | { 17 | $response = new ResponseCore($this->validHeader, "", 200); 18 | $result = new UploadPartResult($response); 19 | $eTag = $result->getData(); 20 | $this->assertEquals('7265F4D211B56873A381D321F586E4A9', $eTag); 21 | } 22 | 23 | public function testParseInvalidHeader() 24 | { 25 | $response = new ResponseCore($this->invalidHeader, "", 200); 26 | try { 27 | new UploadPartResult($response); 28 | $this->assertTrue(false); 29 | } catch (OssException $e) { 30 | $this->assertEquals('cannot get ETag', $e->getMessage()); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Upload/SDK/aliyun-oss-php-sdk-2.6.0/tests/OSS/Tests/WebsiteConfigTest.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | index.html 15 | 16 | 17 | errorDocument.html 18 | 19 | 20 | BBBB; 21 | 22 | private $nullXml = << 24 | BBBB; 25 | private $nullXml2 = << 27 | BBBB; 28 | 29 | public function testParseValidXml() 30 | { 31 | $websiteConfig = new WebsiteConfig("index"); 32 | $websiteConfig->parseFromXml($this->validXml); 33 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); 34 | } 35 | 36 | public function testParsenullXml() 37 | { 38 | $websiteConfig = new WebsiteConfig(); 39 | $websiteConfig->parseFromXml($this->nullXml); 40 | $this->assertTrue($this->cleanXml($this->nullXml) === $this->cleanXml($websiteConfig->serializeToXml()) || 41 | $this->cleanXml($this->nullXml2) === $this->cleanXml($websiteConfig->serializeToXml())); 42 | } 43 | 44 | public function testWebsiteConstruct() 45 | { 46 | $websiteConfig = new WebsiteConfig("index.html", "errorDocument.html"); 47 | $this->assertEquals('index.html', $websiteConfig->getIndexDocument()); 48 | $this->assertEquals('errorDocument.html', $websiteConfig->getErrorDocument()); 49 | $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); 50 | } 51 | 52 | private function cleanXml($xml) 53 | { 54 | return str_replace("\n", "", str_replace("\r", "", $xml)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Upload/Static/magnifying_glass.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponycool/typecho-plugins/6d6e34a71f96a3665ac97e15c6b8671eb0cf17d7/Upload/Static/magnifying_glass.ico -------------------------------------------------------------------------------- /Upload/Static/nopic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ponycool/typecho-plugins/6d6e34a71f96a3665ac97e15c6b8671eb0cf17d7/Upload/Static/nopic.jpg -------------------------------------------------------------------------------- /scripts/copy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | DIR_NAME=$0 4 | if [ "${DIR_NAME:0:1}" = "/" ]; then 5 | CURR_DIR=$(dirname "$DIR_NAME") 6 | else 7 | CURR_DIR="$(pwd)"/"$(dirname "$DIR_NAME")" 8 | fi 9 | . "$CURR_DIR"/message.sh 10 | 11 | TARGET_PATH=$CURR_DIR/../ 12 | SOURCE_PATH=$CURR_DIR/../../blog/usr/plugins/ 13 | declare -a PLUGINS 14 | PLUGINS[0]="Ads" 15 | PLUGINS[1]="Cors" 16 | PLUGINS[2]="GetRealIP" 17 | PLUGINS[3]="Mourn" 18 | PLUGINS[4]="PageViews" 19 | PLUGINS[5]="RunTime" 20 | PLUGINS[6]="TagsList" 21 | PLUGINS[7]="Upload" 22 | 23 | info "开始同步......" 24 | 25 | if [ ! -d "$SOURCE_PATH" ]; then 26 | error "源目录不存在" 27 | fi 28 | 29 | for i in ${!PLUGINS[@]}; do 30 | if [ ! -d "$SOURCE_PATH${PLUGINS[$i]}" ]; then 31 | error "插件目录${PLUGINS[$i]}不存在" 32 | fi 33 | 34 | # 开始同步插件 35 | cp -a "$SOURCE_PATH${PLUGINS[$i]}" $TARGET_PATH 36 | if [ "$?" != 0 ]; then 37 | error "插件${PLUGINS[$i]}同步失败" 38 | else 39 | success "插件${PLUGINS[$i]}同步成功" 40 | fi 41 | done 42 | 43 | # 同步结果 44 | if [ "$?" != 0 ]; then 45 | error "插件同步失败" 46 | else 47 | success "所有同步完成" 48 | fi 49 | -------------------------------------------------------------------------------- /scripts/message.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 提示信息 4 | function info() { 5 | echo -e "\033[32m提示信息:$1\033[0m" 6 | } 7 | 8 | # 成功信息 9 | function success() { 10 | echo -e "\033[36m成功信息:$1\033[0m" 11 | } 12 | 13 | # 错误信息 14 | function error() { 15 | echo -e "\033[31m错误信息:$1\033[0m" 16 | exit 17 | } 18 | --------------------------------------------------------------------------------